Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: add versioned requests for machinery based requests #335

Merged
merged 1 commit into from
Apr 10, 2024
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
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
Loading