Skip to content

Commit

Permalink
release command
Browse files Browse the repository at this point in the history
Allows you to trivially bulk tag module installations for an app on the command line.  Ideally pluggable into cd pipelines as needed.
  • Loading branch information
michaeljguarino committed Jul 2, 2023
1 parent f2bfa20 commit 9aa4c06
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 16 deletions.
29 changes: 27 additions & 2 deletions cmd/plural/repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,20 @@ func (p *Plural) reposCommands() []cli.Command {
{
Name: "unlock",
Usage: "unlocks installations in a repo that have breaking changes",
ArgsUsage: "REPO",
Action: latestVersion(p.handleUnlockRepo),
ArgsUsage: "APP",
Action: latestVersion(requireArgs(p.handleUnlockRepo, []string{"APP"})),
},
{
Name: "release",
Usage: "tags the installations in the current cluster with the given release channels",
ArgsUsage: "APP",
Flags: []cli.Flag{
cli.StringSliceFlag{
Name: "tag",
Usage: "tag name for a given release channel, eg stable, warm, dev, prod",
},
},
Action: latestVersion(requireArgs(p.handleRelease, []string{"APP"})),
},
{
Name: "reinstall",
Expand Down Expand Up @@ -63,6 +75,19 @@ func (p *Plural) reposCommands() []cli.Command {
}
}

func (p *Plural) handleRelease(c *cli.Context) error {
p.InitPluralClient()
app := c.Args().First()
tags := c.StringSlice("tag")
err := p.Release(c.Args().First(), c.StringSlice("tag"))
if err != nil {
return api.GetErrorResponse(err, "Release")
}

utils.Success("Published release for %s to channels [%s]\n", app, strings.Join(tags, ", "))
return nil
}

func (p *Plural) handleUnlockRepo(c *cli.Context) error {
p.InitPluralClient()
err := p.UnlockRepository(c.Args().First())
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ require (
github.com/olekukonko/tablewriter v0.0.5
github.com/packethost/packngo v0.29.0
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8
github.com/pluralsh/gqlclient v1.3.17
github.com/pluralsh/gqlclient v1.3.18
github.com/pluralsh/plural-operator v0.5.3
github.com/pluralsh/polly v0.1.1
github.com/rodaine/hclencoder v0.0.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,8 @@ github.com/pluralsh/controller-reconcile-helper v0.0.4 h1:1o+7qYSyoeqKFjx+WgQTxD
github.com/pluralsh/controller-reconcile-helper v0.0.4/go.mod h1:AfY0gtteD6veBjmB6jiRx/aR4yevEf6K0M13/pGan/s=
github.com/pluralsh/gqlclient v1.3.17 h1:hD/rG+lhxP3kN1UUXrzZd2uN7P76MvNTEJEzYOpERXo=
github.com/pluralsh/gqlclient v1.3.17/go.mod h1:z1qHnvPeqIN/a+5OzFs40e6HI6tDxzh1+yJuEpvqGy4=
github.com/pluralsh/gqlclient v1.3.18 h1:SthOBnlEgXh1bAKQXrZDNZRekaw3zDku4I4xgVsumDE=
github.com/pluralsh/gqlclient v1.3.18/go.mod h1:z1qHnvPeqIN/a+5OzFs40e6HI6tDxzh1+yJuEpvqGy4=
github.com/pluralsh/oauth v0.9.2 h1:tM9hBK4tCnJUeCOgX0ctxBBCS3hiCDPoxkJLODtedmQ=
github.com/pluralsh/oauth v0.9.2/go.mod h1:aTUw/75rzcsbvW+/TLvWtHVDXFIdtFrDtUncOq9vHyM=
github.com/pluralsh/plural-operator v0.5.3 h1:GaPL3LgimfzKZNHt7zXzqYZpb0hgyW9noHYnkA+rqNs=
Expand Down
1 change: 1 addition & 0 deletions pkg/api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ type Client interface {
Cluster(id string) (*Cluster, error)
CreateUpgrade(queue, repository string, attrs gqlclient.UpgradeAttributes) error
TransferOwnership(name, email string) error
Release(name string, tags []string) error
Chat(history []*ChatMessage) (*ChatMessage, error)
}

Expand Down
6 changes: 5 additions & 1 deletion pkg/api/repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,12 @@ func (client *client) ListRepositories(query string) ([]*Repository, error) {
return res, err
}

func (client *client) Scaffolds(in *ScaffoldInputs) ([]*ScaffoldFile, error) {
func (client *client) Release(name string, tags []string) error {
_, err := client.pluralClient.Release(context.Background(), name, tags)
return err
}

func (client *client) Scaffolds(in *ScaffoldInputs) ([]*ScaffoldFile, error) {
scaffolds, err := client.pluralClient.Scaffolds(context.Background(), in.Application, in.Publisher, gqlclient.Category(strings.ToUpper(in.Category)), &in.Ingress, &in.Postgres)
if err != nil {
return nil, err
Expand Down
25 changes: 19 additions & 6 deletions pkg/test/mocks/Client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions pkg/test/mocks/Kube.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9aa4c06

Please sign in to comment.