Skip to content

Commit

Permalink
refactor: add versioned requests for machinery based requests (#335)
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon committed Apr 10, 2024
1 parent 269759d commit 3fd31de
Show file tree
Hide file tree
Showing 20 changed files with 83 additions and 39 deletions.
5 changes: 4 additions & 1 deletion cmd/deploytarget.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package cmd
import (
"context"
"fmt"
"strconv"

"github.com/spf13/cobra"
"github.com/uselagoon/lagoon-cli/internal/lagoon"
"github.com/uselagoon/lagoon-cli/internal/lagoon/client"
Expand All @@ -11,7 +13,6 @@ import (
l "github.com/uselagoon/machinery/api/lagoon"
lclient "github.com/uselagoon/machinery/api/lagoon/client"
s "github.com/uselagoon/machinery/api/schema"
"strconv"
)

var addDeployTargetCmd = &cobra.Command{
Expand Down Expand Up @@ -353,6 +354,7 @@ var addDeployTargetToOrganizationCmd = &cobra.Command{
lc := lclient.New(
lagoonCLIConfig.Lagoons[current].GraphQL,
lagoonCLIVersion,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)

Expand Down Expand Up @@ -410,6 +412,7 @@ var RemoveDeployTargetFromOrganizationCmd = &cobra.Command{
lc := lclient.New(
lagoonCLIConfig.Lagoons[current].GraphQL,
lagoonCLIVersion,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)

Expand Down
2 changes: 2 additions & 0 deletions cmd/deploytargetconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"context"
"fmt"

l "github.com/uselagoon/machinery/api/lagoon"
lclient "github.com/uselagoon/machinery/api/lagoon/client"
s "github.com/uselagoon/machinery/api/schema"
Expand Down Expand Up @@ -61,6 +62,7 @@ var addDeployTargetConfigCmd = &cobra.Command{
lc := lclient.New(
lagoonCLIConfig.Lagoons[current].GraphQL,
lagoonCLIVersion,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)
project, err := l.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc)
Expand Down
4 changes: 3 additions & 1 deletion cmd/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package cmd
import (
"context"
"fmt"
s "github.com/uselagoon/machinery/api/schema"
"os"
"strings"

s "github.com/uselagoon/machinery/api/schema"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/uselagoon/lagoon-cli/internal/lagoon"
Expand Down Expand Up @@ -104,6 +105,7 @@ var updateEnvironmentCmd = &cobra.Command{
lc := lclient.New(
lagoonCLIConfig.Lagoons[current].GraphQL,
lagoonCLIVersion,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)
project, err := l.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc)
Expand Down
3 changes: 3 additions & 0 deletions cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ var getProjectCmd = &cobra.Command{
lc := lclient.New(
lagoonCLIConfig.Lagoons[current].GraphQL,
lagoonCLIVersion,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)

Expand Down Expand Up @@ -148,6 +149,7 @@ This returns information about a deployment, the logs of this build can also be
lc := lclient.New(
lagoonCLIConfig.Lagoons[current].GraphQL,
lagoonCLIVersion,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)
deployment, err := l.GetDeploymentByName(context.TODO(), cmdProjectName, cmdProjectEnvironment, buildName, showLogs, lc)
Expand Down Expand Up @@ -279,6 +281,7 @@ var getOrganizationCmd = &cobra.Command{
lc := lclient.New(
lagoonCLIConfig.Lagoons[current].GraphQL,
lagoonCLIVersion,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)
organization, err := l.GetOrganizationByName(context.TODO(), organizationName, lc)
Expand Down
1 change: 1 addition & 0 deletions cmd/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ var addGroupToOrganizationCmd = &cobra.Command{
lc := lclient.New(
lagoonCLIConfig.Lagoons[current].GraphQL,
lagoonCLIVersion,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)

Expand Down
10 changes: 10 additions & 0 deletions cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ var listEnvironmentsCmd = &cobra.Command{
lc := lclient.New(
lagoonCLIConfig.Lagoons[current].GraphQL,
lagoonCLIVersion,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)
environments, err := l.GetEnvironmentsByProjectName(context.TODO(), cmdProjectName, lc)
Expand Down Expand Up @@ -395,6 +396,7 @@ Without a group name, this query may time out in large Lagoon installs.`,
lc := lclient.New(
lagoonCLIConfig.Lagoons[current].GraphQL,
lagoonCLIVersion,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)
data := []output.Data{}
Expand Down Expand Up @@ -461,6 +463,7 @@ This query can take a long time to run if there are a lot of users.`,
lc := lclient.New(
lagoonCLIConfig.Lagoons[current].GraphQL,
lagoonCLIVersion,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)
allUsers, err := l.AllUsers(context.TODO(), ls.AllUsersFilter{
Expand Down Expand Up @@ -513,6 +516,7 @@ var listUsersGroupsCmd = &cobra.Command{
lc := lclient.New(
lagoonCLIConfig.Lagoons[current].GraphQL,
lagoonCLIVersion,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)
allUsers, err := l.GetUserByEmail(context.TODO(), emailAddress, lc)
Expand Down Expand Up @@ -607,6 +611,7 @@ var listProjectGroupsCmd = &cobra.Command{
lc := lclient.New(
lagoonCLIConfig.Lagoons[current].GraphQL,
lagoonCLIVersion,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)
projectGroups, err := l.GetProjectGroups(context.TODO(), cmdProjectName, lc)
Expand Down Expand Up @@ -671,6 +676,7 @@ var listOrganizationProjectsCmd = &cobra.Command{
lc := lclient.New(
lagoonCLIConfig.Lagoons[current].GraphQL,
lagoonCLIVersion,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)

Expand Down Expand Up @@ -724,6 +730,7 @@ var listOrganizationGroupsCmd = &cobra.Command{
lc := lclient.New(
lagoonCLIConfig.Lagoons[current].GraphQL,
lagoonCLIVersion,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)

Expand Down Expand Up @@ -784,6 +791,7 @@ var listOrganizationDeployTargetsCmd = &cobra.Command{
lc := lclient.New(
lagoonCLIConfig.Lagoons[current].GraphQL,
lagoonCLIVersion,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)
deployTargets, err := l.ListDeployTargetsByOrganizationNameOrID(context.TODO(), nullStrCheck(organizationName), nullUintCheck(organizationID), lc)
Expand Down Expand Up @@ -839,6 +847,7 @@ var ListOrganizationUsersCmd = &cobra.Command{
lc := lclient.New(
lagoonCLIConfig.Lagoons[current].GraphQL,
lagoonCLIVersion,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)
organization, err := l.GetOrganizationByName(context.Background(), organizationName, lc)
Expand Down Expand Up @@ -884,6 +893,7 @@ var listOrganizationsCmd = &cobra.Command{
lc := lclient.New(
lagoonCLIConfig.Lagoons[current].GraphQL,
lagoonCLIVersion,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)

Expand Down
3 changes: 3 additions & 0 deletions cmd/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ func loginToken() error {
if err = writeLagoonConfig(&lagoonCLIConfig, filepath.Join(configFilePath, configName+configExtension)); err != nil {
return fmt.Errorf("couldn't write config: %v", err)
}
if err = versionCheck(lagoonCLIConfig.Current); err != nil {
return fmt.Errorf("couldn't check version: %v", err)
}

return nil
}
Expand Down
3 changes: 3 additions & 0 deletions cmd/notificationsemail.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"encoding/json"
"fmt"

"github.com/spf13/cobra"
"github.com/uselagoon/lagoon-cli/internal/lagoon"
"github.com/uselagoon/lagoon-cli/internal/lagoon/client"
Expand Down Expand Up @@ -52,6 +53,7 @@ It does not configure a project to send notifications to email though, you need
lc := lclient.New(
lagoonCLIConfig.Lagoons[current].GraphQL,
lagoonCLIVersion,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)

Expand Down Expand Up @@ -163,6 +165,7 @@ var listProjectEmailsCmd = &cobra.Command{
lc := lclient.New(
lagoonCLIConfig.Lagoons[current].GraphQL,
lagoonCLIVersion,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)

Expand Down
3 changes: 3 additions & 0 deletions cmd/notificationsrocketchat.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"encoding/json"
"fmt"

l "github.com/uselagoon/machinery/api/lagoon"
lclient "github.com/uselagoon/machinery/api/lagoon/client"
s "github.com/uselagoon/machinery/api/schema"
Expand Down Expand Up @@ -57,6 +58,7 @@ It does not configure a project to send notifications to RocketChat though, you
lc := lclient.New(
lagoonCLIConfig.Lagoons[current].GraphQL,
lagoonCLIVersion,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)

Expand Down Expand Up @@ -171,6 +173,7 @@ var listProjectRocketChatsCmd = &cobra.Command{
lc := lclient.New(
lagoonCLIConfig.Lagoons[current].GraphQL,
lagoonCLIVersion,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)

Expand Down
3 changes: 3 additions & 0 deletions cmd/notificationsslack.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"encoding/json"
"fmt"

l "github.com/uselagoon/machinery/api/lagoon"
lclient "github.com/uselagoon/machinery/api/lagoon/client"
s "github.com/uselagoon/machinery/api/schema"
Expand Down Expand Up @@ -57,6 +58,7 @@ It does not configure a project to send notifications to Slack though, you need
lc := lclient.New(
lagoonCLIConfig.Lagoons[current].GraphQL,
lagoonCLIVersion,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)

Expand Down Expand Up @@ -171,6 +173,7 @@ var listProjectSlacksCmd = &cobra.Command{
lc := lclient.New(
lagoonCLIConfig.Lagoons[current].GraphQL,
lagoonCLIVersion,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)

Expand Down
3 changes: 3 additions & 0 deletions cmd/notificationsteams.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"encoding/json"
"fmt"

l "github.com/uselagoon/machinery/api/lagoon"
lclient "github.com/uselagoon/machinery/api/lagoon/client"
s "github.com/uselagoon/machinery/api/schema"
Expand Down Expand Up @@ -53,6 +54,7 @@ It does not configure a project to send notifications to Microsoft Teams though,
lc := lclient.New(
lagoonCLIConfig.Lagoons[current].GraphQL,
lagoonCLIVersion,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)

Expand Down Expand Up @@ -164,6 +166,7 @@ var listProjectMicrosoftTeamsCmd = &cobra.Command{
lc := lclient.New(
lagoonCLIConfig.Lagoons[current].GraphQL,
lagoonCLIVersion,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)

Expand Down
3 changes: 3 additions & 0 deletions cmd/notificationswebhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"encoding/json"
"fmt"

l "github.com/uselagoon/machinery/api/lagoon"
lclient "github.com/uselagoon/machinery/api/lagoon/client"
s "github.com/uselagoon/machinery/api/schema"
Expand Down Expand Up @@ -53,6 +54,7 @@ It does not configure a project to send notifications to webhook though, you nee
lc := lclient.New(
lagoonCLIConfig.Lagoons[current].GraphQL,
lagoonCLIVersion,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)

Expand Down Expand Up @@ -164,6 +166,7 @@ var listProjectWebhooksCmd = &cobra.Command{
lc := lclient.New(
lagoonCLIConfig.Lagoons[current].GraphQL,
lagoonCLIVersion,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)

Expand Down
4 changes: 4 additions & 0 deletions cmd/organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"context"
"fmt"

"github.com/spf13/cobra"
"github.com/uselagoon/lagoon-cli/pkg/output"
l "github.com/uselagoon/machinery/api/lagoon"
Expand Down Expand Up @@ -63,6 +64,7 @@ var addOrgCmd = &cobra.Command{
lc := lclient.New(
lagoonCLIConfig.Lagoons[current].GraphQL,
lagoonCLIVersion,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)

Expand Down Expand Up @@ -116,6 +118,7 @@ var deleteOrgCmd = &cobra.Command{
lc := lclient.New(
lagoonCLIConfig.Lagoons[current].GraphQL,
lagoonCLIVersion,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)

Expand Down Expand Up @@ -189,6 +192,7 @@ var updateOrganizationCmd = &cobra.Command{
lc := lclient.New(
lagoonCLIConfig.Lagoons[current].GraphQL,
lagoonCLIVersion,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)

Expand Down
10 changes: 8 additions & 2 deletions cmd/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import (
"context"
"encoding/json"
"fmt"
"os"
"strconv"

l "github.com/uselagoon/machinery/api/lagoon"
lclient "github.com/uselagoon/machinery/api/lagoon/client"
s "github.com/uselagoon/machinery/api/schema"
"os"
"strconv"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
Expand Down Expand Up @@ -163,6 +164,7 @@ var listProjectByMetadata = &cobra.Command{
lc := lclient.New(
lagoonCLIConfig.Lagoons[current].GraphQL,
lagoonCLIVersion,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)
projects, err := l.GetProjectsByMetadata(context.TODO(), key, value, lc)
Expand Down Expand Up @@ -282,6 +284,7 @@ var updateProjectMetadata = &cobra.Command{
lc := lclient.New(
lagoonCLIConfig.Lagoons[current].GraphQL,
lagoonCLIVersion,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)
project, err := l.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc)
Expand Down Expand Up @@ -337,6 +340,7 @@ var deleteProjectMetadataByKey = &cobra.Command{
lc := lclient.New(
lagoonCLIConfig.Lagoons[current].GraphQL,
lagoonCLIVersion,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)
project, err := l.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc)
Expand Down Expand Up @@ -487,6 +491,7 @@ var addProjectToOrganizationCmd = &cobra.Command{
lc := lclient.New(
lagoonCLIConfig.Lagoons[current].GraphQL,
lagoonCLIVersion,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)

Expand Down Expand Up @@ -561,6 +566,7 @@ var RemoveProjectFromOrganizationCmd = &cobra.Command{
lc := lclient.New(
lagoonCLIConfig.Lagoons[current].GraphQL,
lagoonCLIVersion,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)

Expand Down
Loading

0 comments on commit 3fd31de

Please sign in to comment.