Skip to content

Commit

Permalink
Add sync marking to cli (#435)
Browse files Browse the repository at this point in the history
This will allow our api to know if a deploy ran successfully for a specific repo
  • Loading branch information
michaeljguarino authored Aug 24, 2023
1 parent b79724d commit 3c165e4
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 3 deletions.
4 changes: 4 additions & 0 deletions cmd/plural/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ func (p *Plural) deploy(c *cli.Context) error {
if err := scaffold.Notes(installation); err != nil {
return err
}

if err := p.Client.MarkSynced(repo); err != nil {
utils.Warn("failed to mark %s as synced, this is not a critical error but might drift state in our api, you can run `plural repos synced %s` to mark it manually", repo, repo)
}
}

utils.Highlight("\n==> Commit and push your changes to record your deployment\n\n")
Expand Down
10 changes: 10 additions & 0 deletions cmd/plural/repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ func (p *Plural) reposCommands() []cli.Command {
Usage: "eliminates your current plural installation set, to change cloud provider or eject from plural",
Action: latestVersion(p.handleResetInstallations),
},
{
Name: "synced",
Usage: "marks installations in this repo as being synced",
Action: p.handleMarkSynced,
},
{
Name: "uninstall",
Usage: "uninstall an app from the plural api",
Expand Down Expand Up @@ -162,6 +167,11 @@ func (p *Plural) handleReinstall(c *cli.Context) error {
return nil
}

func (p *Plural) handleMarkSynced(c *cli.Context) error {
p.InitPluralClient()
return p.MarkSynced(c.Args().Get(0))
}

func (p *Plural) handleResetInstallations(c *cli.Context) error {
p.InitPluralClient()
conf := config.Read()
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.9.0
github.com/pluralsh/gqlclient v1.10.0
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 @@ -932,6 +932,8 @@ github.com/pluralsh/gqlclient v1.8.0 h1:0KCgfjmeOXYmlExXRsxyvdkb7WEL03vu4g17u8fL
github.com/pluralsh/gqlclient v1.8.0/go.mod h1:qSXKUlio1F2DRPy8el4oFYsmpKbkUYspgPB87T4it5I=
github.com/pluralsh/gqlclient v1.9.0 h1:ERQovQEs1/IFcYQLi7S4SmWcMo0Fl4sz/UTmpcyMgoc=
github.com/pluralsh/gqlclient v1.9.0/go.mod h1:qSXKUlio1F2DRPy8el4oFYsmpKbkUYspgPB87T4it5I=
github.com/pluralsh/gqlclient v1.10.0 h1:ccYB+A0JbPYkEeVzdfajd29l65N6x/buSKPMMxM8OIA=
github.com/pluralsh/gqlclient v1.10.0/go.mod h1:qSXKUlio1F2DRPy8el4oFYsmpKbkUYspgPB87T4it5I=
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 @@ -96,6 +96,7 @@ type Client interface {
CreateTrust(issuer, trust string) error
DeleteTrust(id string) error
OidcToken(provider gqlclient.ExternalOidcProvider, token, email string) (string, error)
MarkSynced(repo string) error
}

type client struct {
Expand Down
5 changes: 5 additions & 0 deletions pkg/api/installations.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ func (client *client) ResetInstallations() (int, error) {
return int(*resp.ResetInstallations), err
}

func (client *client) MarkSynced(repo string) error {
_, err := client.pluralClient.MarkSynced(client.ctx, repo)
return err
}

func convertRedirectUris(uris []string) []*string {
res := make([]*string, len(uris))
for i := range uris {
Expand Down
16 changes: 15 additions & 1 deletion pkg/test/mocks/Client.go

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

2 changes: 1 addition & 1 deletion 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 3c165e4

Please sign in to comment.