From b2913a8cc7e168fb5e2ca5d9f62a1633700adf52 Mon Sep 17 00:00:00 2001 From: Dex Date: Fri, 1 Mar 2019 10:09:50 -0600 Subject: [PATCH] remove devtool releaser stuff --- pkg/cli/devtoolreleaser/cmd.go | 65 ------------------- pkg/cli/devtoolreleaser/releaser.go | 91 --------------------------- pkg/lifecycle/render/github/render.go | 1 - 3 files changed, 157 deletions(-) delete mode 100644 pkg/cli/devtoolreleaser/cmd.go delete mode 100644 pkg/cli/devtoolreleaser/releaser.go diff --git a/pkg/cli/devtoolreleaser/cmd.go b/pkg/cli/devtoolreleaser/cmd.go deleted file mode 100644 index a6f04a923..000000000 --- a/pkg/cli/devtoolreleaser/cmd.go +++ /dev/null @@ -1,65 +0,0 @@ -package devtoolreleaser - -import ( - "context" - "os" - "strings" - - "github.com/mitchellh/cli" - "github.com/pkg/errors" - "github.com/replicatedhq/ship/pkg/fs" - "github.com/replicatedhq/ship/pkg/logger" - "github.com/spf13/cobra" - "github.com/spf13/viper" -) - -func Cmd() *cobra.Command { - vip := viper.New() - cmd := &cobra.Command{ - Use: "devtool-releaser", - Short: "API client for creating ship releases", - Long: ` - -`, - RunE: func(cmd *cobra.Command, args []string) error { - - releaser := &Releaser{ - viper: vip, - logger: logger.New(vip, fs.NewBaseFilesystem()), - ui: &cli.ColoredUi{ - OutputColor: cli.UiColorNone, - ErrorColor: cli.UiColorRed, - WarnColor: cli.UiColorYellow, - InfoColor: cli.UiColorGreen, - Ui: &cli.BasicUi{ - Reader: os.Stdin, - Writer: os.Stdout, - ErrorWriter: os.Stderr, - }, - }, - } - - err := releaser.Release(context.Background()) - - if err != nil { - return errors.Wrap(err, "promote release") - } - - return nil - }, - } - - cmd.Flags().String("vendor-token", "", "Token to use to communicate with https://g.replicated.com") - cmd.Flags().String("graphql-api-address", "https://g.replicated.com/graphql", "upstream g. address") - cmd.Flags().String("spec-file", "", "spec file to promote") - cmd.Flags().String("channel-id", "", "channel id to promote") - cmd.Flags().String("semver", "", "semver of the release") - cmd.Flags().String("release-notes", "", "release notes") - cmd.Flags().String("log-level", "off", "log level") - - vip.BindPFlags(cmd.Flags()) - vip.BindPFlags(cmd.PersistentFlags()) - vip.AutomaticEnv() - vip.SetEnvKeyReplacer(strings.NewReplacer("-", "_")) - return cmd -} diff --git a/pkg/cli/devtoolreleaser/releaser.go b/pkg/cli/devtoolreleaser/releaser.go deleted file mode 100644 index a92b220bb..000000000 --- a/pkg/cli/devtoolreleaser/releaser.go +++ /dev/null @@ -1,91 +0,0 @@ -package devtoolreleaser - -import ( - "context" - "fmt" - "io/ioutil" - "net/url" - - "github.com/go-kit/kit/log" - "github.com/mitchellh/cli" - "github.com/pkg/errors" - "github.com/replicatedhq/ship/pkg/e2e" - "github.com/spf13/viper" -) - -type Releaser struct { - viper *viper.Viper - logger log.Logger - ui cli.Ui -} - -func (r *Releaser) getParams() (token, specContents, semver, channelID, gqlAddr string, err error) { - token = r.viper.GetString("vendor-token") - if token == "" { - err = errors.New("param vendor-token is required") - return - } - - specFile := r.viper.GetString("spec-file") - if specFile == "" { - err = errors.New("param spec-file is required") - return - } - - specBytes, err := ioutil.ReadFile(specFile) - if err != nil { - err = errors.Wrapf(err, "read file %s", specFile) - return - } - specContents = string(specBytes) - - semver = r.viper.GetString("semver") - if semver == "" { - err = errors.New("param semver is required") - return - } - - channelID = r.viper.GetString("channel-id") - if channelID == "" { - err = errors.New("param channel-id is required") - return - } - - gqlAddr = r.viper.GetString("graphql-api-address") - return -} - -func (r *Releaser) Release( - ctx context.Context, -) error { - - token, specContents, semver, channelID, gqlAddr, err := r.getParams() - if err != nil { - return errors.Wrap(err, "load params") - } - - gqlServer, err := url.Parse(gqlAddr) - if err != nil { - return errors.Wrapf(err, "parse graphql-api-address URL \"%s\"", gqlAddr) - } - client := &e2e.GraphQLClient{ - GQLServer: gqlServer, - Token: token, - Logger: r.logger, - } - - data, err := client.PromoteRelease( - string(specContents), - channelID, - semver, - r.viper.GetString("release-notes"), - ) - - r.ui.Info(fmt.Sprintf("received data %+v", data)) - - if err != nil { - return errors.Wrapf(err, "promote release") - } - - return nil -} diff --git a/pkg/lifecycle/render/github/render.go b/pkg/lifecycle/render/github/render.go index 9e4fc6210..8bb0e6eb4 100644 --- a/pkg/lifecycle/render/github/render.go +++ b/pkg/lifecycle/render/github/render.go @@ -22,7 +22,6 @@ import ( "github.com/replicatedhq/ship/pkg/state" "github.com/replicatedhq/ship/pkg/templates" "github.com/replicatedhq/ship/pkg/util" - "github.com/spf13/afero" "github.com/spf13/viper" )