This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Turbolift recipe to update helm template versions | |
# | |
# prerequisites: | |
# 1. https://github.com/Skyscanner/turbolift#installation | |
# 2. https://github.com/mikefarah/yq#install | |
# | |
# assumptions: | |
# 1. you have all buddy pipeline definitions under `/.buddy` directory of each repo and they all have `.yaml` or `.yml` extension | |
# 2. you define the helm chart version in an action of type `HELM` which has a list of `execute_commands`, and the version is passed in like `--version $version`. In other words, there's an action that looks like: | |
# - action: Render k8s manifest from Helm chart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"encoding/csv" | |
"errors" | |
"fmt" | |
"io" | |
"log" | |
"os" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// dataStore retrieves data | |
type dataStore interface { | |
getData(context.Context, filter) ([]item, error) | |
} | |
// fileStorage uploads the data to file storage | |
type fileStorage interface { | |
upload(context.Context, []byte) error | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// fileStorage uploads the data to file storage | |
type fileStorage interface { | |
upload(context.Context, []byte) error | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// fileStorage uploads the data to file storage | |
type fileStorage interface { | |
upload(context.Context, io.Reader) error | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// run is the main logic of the service | |
func (s service) run(ctx context.Context, f filter) error { | |
pr, pw := io.Pipe() | |
r, err := s.ds.getData(ctx, f) | |
if err != nil { | |
return fmt.Errorf("querying: %v", err) | |
} | |
go writeRowsToCSV(r, pw) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func main() { | |
f, err := os.Create("cpu.prof") | |
if err != nil { | |
log.Fatal(err) | |
} | |
pprof.StartCPUProfile(f) | |
defer pprof.StopCPUProfile() | |
// the rest of the logic | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func main() { | |
f, err := os.Create("cpu.prof") | |
if err != nil { | |
log.Fatal(err) | |
} | |
pprof.StartCPUProfile(f) | |
defer pprof.StopCPUProfile() | |
// the rest of the logic | |
} |