Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions cmd/deployment/metadata.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package deployment

import (
"context"
"encoding/json"
"fmt"
"strings"

"github.com/go-git/go-git/v5"
errors "github.com/pkg/errors"
"github.com/urfave/cli/v2"
"github.com/urfave/cli/v3"
)

type Metadata struct {
Expand All @@ -22,7 +23,7 @@ type Deployment struct {
Msg string `json:"msg"`
}

func DeploymentMetadata(c *cli.Context) error {
func DeploymentMetadata(ctx context.Context, c *cli.Command) error {
repo, err := git.PlainOpenWithOptions(".", &git.PlainOpenOptions{DetectDotGit: true})
if err != nil {
return errors.Wrap(err, "unable to open git repository")
Expand Down Expand Up @@ -65,7 +66,7 @@ func DeploymentMetadata(c *cli.Context) error {
json, _ := json.Marshal(md)

// Write string to stdout
fmt.Fprintf(c.App.Writer, "%s", json)
fmt.Fprintf(c.Writer, "%s", json)

return nil
}
14 changes: 7 additions & 7 deletions cmd/elastic-cloud/delete-stale.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/elastic/go-elasticsearch/v9/esapi"
"github.com/manifoldco/promptui"
errors "github.com/pkg/errors"
"github.com/urfave/cli/v2"
"github.com/urfave/cli/v3"
lagoon_client "github.com/uselagoon/machinery/api/lagoon/client"
"github.com/uselagoon/machinery/api/schema"
)
Expand All @@ -38,7 +38,7 @@ type Aliases struct {
Aliases map[string]AliasAttr `json:"aliases"`
}

func DeleteStaleIndices(c *cli.Context) error {
func DeleteStaleIndices(ctx context.Context, c *cli.Command) error {
force := c.Bool("force")
apiKey := c.String("deployment-api-key")
cloudId := c.String("deployment-id")
Expand Down Expand Up @@ -108,12 +108,12 @@ func DeleteStaleIndices(c *cli.Context) error {
if len(aliasList[k].Aliases) > 0 {
if !outputDeleteList {
for aliasName := range aliasList[k].Aliases {
fmt.Fprintf(c.App.Writer, "The index %s is %d days old but will not be deleted because it has an associated alias %s\n", k, diffInDays, aliasName)
fmt.Fprintf(c.Writer, "The index %s is %d days old but will not be deleted because it has an associated alias %s\n", k, diffInDays, aliasName)
}
}
} else {
if !outputDeleteList {
fmt.Fprintf(c.App.Writer, "The index %s is %d days old and will be marked for deletion\n", k, diffInDays)
fmt.Fprintf(c.Writer, "The index %s is %d days old and will be marked for deletion\n", k, diffInDays)
}
deleteList = append(deleteList, k)
}
Expand All @@ -128,15 +128,15 @@ func DeleteStaleIndices(c *cli.Context) error {
fmt.Printf("%+s", string(json))
}
if force {
fmt.Fprint(c.App.Writer, "Deleting indices marked for deletion.")
fmt.Fprint(c.Writer, "Deleting indices marked for deletion.")
statusCode, err := deleteIndices(client, deleteList, i)
if err != nil {
return errors.Wrap(err, "error deleting indices")
} else {
if statusCode == 200 {
fmt.Fprintf(c.App.Writer, "Deletion request failed. Status code %d", statusCode)
fmt.Fprintf(c.Writer, "Deletion request failed. Status code %d", statusCode)
} else {
fmt.Fprintf(c.App.Writer, "%+v indices successfully deleted.", i)
fmt.Fprintf(c.Writer, "%+v indices successfully deleted.", i)
}
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions cmd/elastic-cloud/unassigned-shards.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
elasticsearch "github.com/elastic/go-elasticsearch/v9"
"github.com/elastic/go-elasticsearch/v9/esapi"
errors "github.com/pkg/errors"
"github.com/urfave/cli/v2"
"github.com/urfave/cli/v3"
)

type Shard struct {
Expand All @@ -19,7 +19,7 @@ type Shard struct {

type Shards []Shard

func ListUnassignedShards(c *cli.Context) error {
func ListUnassignedShards(ctx context.Context, c *cli.Command) error {
apiKey := c.String("deployment-api-key")
cloudId := c.String("deployment-id")
client, err := elasticsearch.NewClient(elasticsearch.Config{APIKey: apiKey, CloudID: cloudId})
Expand Down
8 changes: 4 additions & 4 deletions cmd/kms/decrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (
"github.com/aws/aws-sdk-go-v2/service/kms"
"github.com/dpc-sdp/bay-cli/internal/helpers"
errors "github.com/pkg/errors"
"github.com/urfave/cli/v2"
"github.com/urfave/cli/v3"
)

func Decrypt(c *cli.Context) error {
inputContents, err := io.ReadAll(c.App.Reader)
func Decrypt(ctx context.Context, c *cli.Command) error {
inputContents, err := io.ReadAll(c.Reader)
if err != nil {
return errors.Wrap(err, "unable to read input")
}
Expand All @@ -39,6 +39,6 @@ func Decrypt(c *cli.Context) error {
return errors.Wrap(err, "error decrypting payload")
}

io.WriteString(c.App.Writer, string(out.Plaintext))
io.WriteString(c.Writer, string(out.Plaintext))
return nil
}
10 changes: 5 additions & 5 deletions cmd/kms/encrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import (
"github.com/aws/aws-sdk-go-v2/service/kms"
"github.com/dpc-sdp/bay-cli/internal/helpers"
errors "github.com/pkg/errors"
"github.com/urfave/cli/v2"
"github.com/urfave/cli/v3"
)

func Encrypt(c *cli.Context) error {
logger := log.New(c.App.ErrWriter, "", log.LstdFlags)
func Encrypt(ctx context.Context, c *cli.Command) error {
logger := log.New(c.ErrWriter, "", log.LstdFlags)

inputContents, err := io.ReadAll(c.App.Reader)
inputContents, err := io.ReadAll(c.Reader)
if err != nil {
return errors.Wrap(err, "unable to read input")
}
Expand Down Expand Up @@ -51,6 +51,6 @@ func Encrypt(c *cli.Context) error {
return errors.Wrap(err, "error encrypting payload with key")
}

io.WriteString(c.App.Writer, b64.StdEncoding.EncodeToString(out.CiphertextBlob))
io.WriteString(c.Writer, b64.StdEncoding.EncodeToString(out.CiphertextBlob))
return nil
}
15 changes: 8 additions & 7 deletions cmd/project-map/by-backend.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package project_map

import (
"context"
"encoding/json"
"fmt"
"io"
"strings"

"github.com/alexeyco/simpletable"
"github.com/urfave/cli/v2"
"github.com/urfave/cli/v3"
"github.com/uselagoon/machinery/api/schema"

"github.com/dpc-sdp/bay-cli/internal/helpers"
Expand All @@ -22,7 +23,7 @@ type ByBackendResponseItem struct {
FrontEnds []string `json:"frontends"`
}

func ByBackend(c *cli.Context) error {
func ByBackend(ctx context.Context, c *cli.Command) error {
client, err := helpers.NewLagoonClient(nil)
if err != nil {
return err
Expand All @@ -34,7 +35,7 @@ func ByBackend(c *cli.Context) error {
args := make([]string, 0)
if all {
projects := make([]schema.ProjectMetadata, 0)
err = client.ProjectsByMetadata(c.Context, "type", "tide", &projects)
err = client.ProjectsByMetadata(ctx, "type", "tide", &projects)
if err != nil {
return err
}
Expand All @@ -50,13 +51,13 @@ func ByBackend(c *cli.Context) error {

for _, v := range args {
project := &schema.ProjectMetadata{}
err := client.ProjectByNameMetadata(c.Context, v, project)
err := client.ProjectByNameMetadata(ctx, v, project)
if err != nil {
return err
}

projects := make([]schema.ProjectMetadata, 0)
err = client.ProjectsByMetadata(c.Context, "backend-project", v, &projects)
err = client.ProjectsByMetadata(ctx, "backend-project", v, &projects)
if err != nil {
return err
}
Expand All @@ -75,7 +76,7 @@ func ByBackend(c *cli.Context) error {

if c.String("output") == "json" {
a, _ := json.Marshal(output)
io.WriteString(c.App.Writer, string(a))
io.WriteString(c.Writer, string(a))
} else {
table := simpletable.New()

Expand All @@ -94,7 +95,7 @@ func ByBackend(c *cli.Context) error {
table.Body.Cells = append(table.Body.Cells, r)
}
table.SetStyle(simpletable.StyleCompactLite)
io.WriteString(c.App.Writer, table.String())
io.WriteString(c.Writer, table.String())
}

return nil
Expand Down
15 changes: 8 additions & 7 deletions cmd/project-map/by-frontend.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package project_map

import (
"context"
"encoding/json"
"fmt"
"github.com/alexeyco/simpletable"
"github.com/urfave/cli/v2"
"github.com/urfave/cli/v3"
"github.com/uselagoon/machinery/api/schema"
"io"

Expand All @@ -15,7 +16,7 @@ type ByFrontendResponse struct {
Items map[string]string `json:"items"`
}

func ByFrontend(c *cli.Context) error {
func ByFrontend(ctx context.Context, c *cli.Command) error {
client, err := helpers.NewLagoonClient(nil)
if err != nil {
return err
Expand All @@ -30,7 +31,7 @@ func ByFrontend(c *cli.Context) error {
if all {
// @todo once all frontends are on ripple 2, remove the obsolete check.
rippleProjects := make([]schema.ProjectMetadata, 0)
err = client.ProjectsByMetadata(c.Context, "type", "ripple", &rippleProjects)
err = client.ProjectsByMetadata(ctx, "type", "ripple", &rippleProjects)
if err != nil {
return err
}
Expand All @@ -39,7 +40,7 @@ func ByFrontend(c *cli.Context) error {
}

ripple2Projects := make([]schema.ProjectMetadata, 0)
err = client.ProjectsByMetadata(c.Context, "type", "ripple2", &ripple2Projects)
err = client.ProjectsByMetadata(ctx, "type", "ripple2", &ripple2Projects)
if err != nil {
return err
}
Expand All @@ -57,7 +58,7 @@ func ByFrontend(c *cli.Context) error {
for _, v := range args {
project := &schema.ProjectMetadata{}

err := client.ProjectByNameMetadata(c.Context, v, project)
err := client.ProjectByNameMetadata(ctx, v, project)
if err != nil {
return err
}
Expand All @@ -70,7 +71,7 @@ func ByFrontend(c *cli.Context) error {

if c.String("output") == "json" {
a, _ := json.Marshal(output)
io.WriteString(c.App.Writer, string(a))
io.WriteString(c.Writer, string(a))
} else {
table := simpletable.New()

Expand All @@ -89,7 +90,7 @@ func ByFrontend(c *cli.Context) error {
table.Body.Cells = append(table.Body.Cells, r)
}
table.SetStyle(simpletable.StyleCompactLite)
io.WriteString(c.App.Writer, table.String())
io.WriteString(c.Writer, table.String())
}

return nil
Expand Down
5 changes: 1 addition & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/go-git/go-git/v5 v5.16.2
github.com/manifoldco/promptui v0.9.0
github.com/pkg/errors v0.9.1
github.com/urfave/cli/v2 v2.27.7
github.com/urfave/cli/v3 v3.3.8
github.com/uselagoon/machinery v0.0.34
golang.org/x/crypto v0.39.0
gopkg.in/yaml.v3 v3.0.1
Expand All @@ -36,7 +36,6 @@ require (
github.com/aws/smithy-go v1.22.4 // indirect
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect
github.com/cloudflare/circl v1.6.1 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect
github.com/cyphar/filepath-securejoin v0.4.1 // indirect
github.com/elastic/elastic-transport-go/v8 v8.7.0 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
Expand All @@ -55,11 +54,9 @@ require (
github.com/onsi/gomega v1.36.1 // indirect
github.com/pjbgf/sha1cd v0.3.2 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
github.com/skeema/knownhosts v1.3.1 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/otel v1.35.0 // indirect
go.opentelemetry.io/otel/metric v1.35.0 // indirect
Expand Down
10 changes: 2 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 h1:q763qf9huN11kDQavWs
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/cloudflare/circl v1.6.1 h1:zqIqSPIndyBh1bjLVVDHMPpVKqp8Su/V+6MeDzzQBQ0=
github.com/cloudflare/circl v1.6.1/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs=
github.com/cpuguy83/go-md2man/v2 v2.0.7 h1:zbFlGlXEAKlwXpmvle3d8Oe3YnkKIK4xSRTd3sHPnBo=
github.com/cpuguy83/go-md2man/v2 v2.0.7/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
github.com/cyphar/filepath-securejoin v0.4.1 h1:JyxxyPEaktOD+GAnqIqTf9A8tHyAG22rowi7HkoSU1s=
github.com/cyphar/filepath-securejoin v0.4.1/go.mod h1:Sdj7gXlvMcPZsbhwhQ33GguGLDGQL7h7bg04C/+u9jI=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -121,8 +119,6 @@ github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
Expand All @@ -133,14 +129,12 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/urfave/cli/v2 v2.27.7 h1:bH59vdhbjLv3LAvIu6gd0usJHgoTTPhCFib8qqOwXYU=
github.com/urfave/cli/v2 v2.27.7/go.mod h1:CyNAG/xg+iAOg0N4MPGZqVmv2rCoP267496AOXUZjA4=
github.com/urfave/cli/v3 v3.3.8 h1:BzolUExliMdet9NlJ/u4m5vHSotJ3PzEqSAZ1oPMa/E=
github.com/urfave/cli/v3 v3.3.8/go.mod h1:FJSKtM/9AiiTOJL4fJ6TbMUkxBXn7GO9guZqoZtpYpo=
github.com/uselagoon/machinery v0.0.34 h1:5DsvXEyMeXmzQhjt11YH7+kZJueabovrwKTv0x7jQV8=
github.com/uselagoon/machinery v0.0.34/go.mod h1:G0ujppuNR0BrtAnlmH8xDb9TDfayb4A36aeo0DYg7fQ=
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw=
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4=
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
go.opentelemetry.io/otel v1.35.0 h1:xKWKPxrxB6OtMCbmMY021CqC45J+3Onta9MqjhnusiQ=
Expand Down
4 changes: 2 additions & 2 deletions internal/helpers/cli.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package helpers

import "github.com/urfave/cli/v2"
import "github.com/urfave/cli/v3"

func GetAllArgs(c *cli.Context) []string {
func GetAllArgs(c *cli.Command) []string {
args := make([]string, 0)
i := 0
l := c.Args().Len()
Expand Down
Loading