From f5b467e262806e3c257da0b1150651ae28cf2c5e Mon Sep 17 00:00:00 2001 From: Chris Goodwin <40746380+CGoodwin90@users.noreply.github.com> Date: Mon, 30 Oct 2023 13:36:14 +1100 Subject: [PATCH 1/6] Change: Updates the output from an `Error` to `Stderr` when listing variables where none are set (#298) --- cmd/list.go | 14 +++++++------- pkg/output/main.go | 4 ++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/cmd/list.go b/cmd/list.go index efbcbbad..f71c71b3 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -290,13 +290,6 @@ var listVariablesCmd = &cobra.Command{ } data = append(data, env) } - if len(data) == 0 { - if cmdProjectEnvironment != "" { - return fmt.Errorf("There are no variables for environment '%s' in project '%s'", cmdProjectEnvironment, cmdProjectName) - } else { - return fmt.Errorf("There are no variables for project '%s'", cmdProjectName) - } - } header := []string{ "ID", "Project", @@ -309,6 +302,13 @@ var listVariablesCmd = &cobra.Command{ if reveal { header = append(header, "Value") } + if len(data) == 0 { + if cmdProjectEnvironment != "" { + outputOptions.Error = fmt.Sprintf("There are no variables for environment '%s' in project '%s'", cmdProjectEnvironment, cmdProjectName) + } else { + outputOptions.Error = fmt.Sprintf("There are no variables for project '%s'\n", cmdProjectName) + } + } output.RenderOutput(output.Table{ Header: header, Data: data, diff --git a/pkg/output/main.go b/pkg/output/main.go index 756bd69c..05ff549e 100644 --- a/pkg/output/main.go +++ b/pkg/output/main.go @@ -26,6 +26,7 @@ type Options struct { JSON bool Pretty bool Debug bool + Error string } // Result . @@ -125,6 +126,9 @@ func RenderOutput(data Table, opts Options) { RenderJSON(returnedData, opts) } else { // otherwise render a table + if opts.Error != "" { + os.Stderr.WriteString(opts.Error) + } table := tablewriter.NewWriter(os.Stdout) opts.Header = !opts.Header if opts.Header { From 5ce8a2a223b31f3be37832e6aa254ecfd68641ea Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Mon, 30 Oct 2023 13:49:19 +1100 Subject: [PATCH 2/6] fix: if value of variable is empty, dont replace it with - (#299) --- cmd/list.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/list.go b/cmd/list.go index f71c71b3..6c2a23ef 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -286,7 +286,7 @@ var listVariablesCmd = &cobra.Command{ env = append(env, returnNonEmptyString(fmt.Sprintf("%v", envvar.Scope))) env = append(env, returnNonEmptyString(fmt.Sprintf("%v", envvar.Name))) if reveal { - env = append(env, returnNonEmptyString(fmt.Sprintf("%v", envvar.Value))) + env = append(env, fmt.Sprintf("%v", envvar.Value)) } data = append(data, env) } From f1a8c0d2de6f784e8309c012017920dc7160abca Mon Sep 17 00:00:00 2001 From: Chris Goodwin <40746380+CGoodwin90@users.noreply.github.com> Date: Mon, 4 Dec 2023 16:17:21 +1100 Subject: [PATCH 3/6] Fix: Updated various commands to utilize machinery (#300) --- cmd/deploytargetconfig.go | 23 ++- cmd/project.go | 30 ++-- cmd/tasks.go | 20 +-- go.mod | 4 +- go.sum | 5 + .../_lgraphql/addDeployTargetConfig.graphql | 61 -------- .../_lgraphql/projectsByMetadata.graphql | 27 ---- .../removeProjectMetadataByKey.graphql | 16 -- .../_lgraphql/switchActiveStandby.graphql | 15 -- .../lagoon/client/_lgraphql/taskByID.graphql | 18 --- .../_lgraphql/updateProjectMetadata.graphql | 20 --- internal/lagoon/client/lgraphql/lgraphql.go | 148 +----------------- internal/lagoon/client/mutation.go | 73 --------- internal/lagoon/client/query.go | 41 ----- internal/lagoon/deploytargetconfig.go | 7 - internal/lagoon/projects.go | 21 --- internal/lagoon/tasks.go | 27 ---- 17 files changed, 54 insertions(+), 502 deletions(-) delete mode 100644 internal/lagoon/client/_lgraphql/addDeployTargetConfig.graphql delete mode 100644 internal/lagoon/client/_lgraphql/projectsByMetadata.graphql delete mode 100644 internal/lagoon/client/_lgraphql/removeProjectMetadataByKey.graphql delete mode 100644 internal/lagoon/client/_lgraphql/switchActiveStandby.graphql delete mode 100644 internal/lagoon/client/_lgraphql/taskByID.graphql delete mode 100644 internal/lagoon/client/_lgraphql/updateProjectMetadata.graphql delete mode 100644 internal/lagoon/tasks.go diff --git a/cmd/deploytargetconfig.go b/cmd/deploytargetconfig.go index d9fd24f8..ad0dfcf8 100644 --- a/cmd/deploytargetconfig.go +++ b/cmd/deploytargetconfig.go @@ -3,6 +3,9 @@ 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" "github.com/spf13/cobra" "github.com/uselagoon/lagoon-cli/internal/lagoon" @@ -41,6 +44,12 @@ var addDeployTargetConfigCmd = &cobra.Command{ return err } + if cmdProjectName == "" { + return fmt.Errorf("Missing arguments: project is a required flag") + } + if deploytarget == 0 { + return fmt.Errorf("Missing arguments: deploytarget id is a required flag") + } if pullrequests == "" { return fmt.Errorf("Missing arguments: pullrequests is a required flag") } @@ -48,31 +57,31 @@ var addDeployTargetConfigCmd = &cobra.Command{ return fmt.Errorf("Missing arguments: branches is a required flag") } current := lagoonCLIConfig.Current - lc := client.New( + token := lagoonCLIConfig.Lagoons[current].Token + lc := lclient.New( lagoonCLIConfig.Lagoons[current].GraphQL, - lagoonCLIConfig.Lagoons[current].Token, - lagoonCLIConfig.Lagoons[current].Version, lagoonCLIVersion, + &token, debug) - project, err := lagoon.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) + project, err := l.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) if err != nil { return err } - addDeployTargetConfig := &schema.AddDeployTargetConfigInput{ + addDeployTargetConfig := &s.AddDeployTargetConfigInput{ Project: uint(project.ID), Weight: weight, } if branches != "" { addDeployTargetConfig.Branches = branches } - if branches != "" { + if pullrequests != "" { addDeployTargetConfig.Pullrequests = pullrequests } if deploytarget != 0 { addDeployTargetConfig.DeployTarget = deploytarget } if yesNo(fmt.Sprintf("You are attempting to add a deploytarget configuration to project '%s', are you sure?", cmdProjectName)) { - deployTargetConfig, err := lagoon.AddDeployTargetConfiguration(context.TODO(), addDeployTargetConfig, lc) + deployTargetConfig, err := l.AddDeployTargetConfiguration(context.TODO(), addDeployTargetConfig, lc) if err != nil { return err } diff --git a/cmd/project.go b/cmd/project.go index 272e56bf..25863c1e 100644 --- a/cmd/project.go +++ b/cmd/project.go @@ -4,6 +4,8 @@ import ( "context" "encoding/json" "fmt" + l "github.com/uselagoon/machinery/api/lagoon" + lclient "github.com/uselagoon/machinery/api/lagoon/client" "os" "github.com/spf13/cobra" @@ -155,13 +157,13 @@ var listProjectByMetadata = &cobra.Command{ return fmt.Errorf("Missing arguments: key is not defined") } current := lagoonCLIConfig.Current - lc := client.New( + token := lagoonCLIConfig.Lagoons[current].Token + lc := lclient.New( lagoonCLIConfig.Lagoons[current].GraphQL, - lagoonCLIConfig.Lagoons[current].Token, - lagoonCLIConfig.Lagoons[current].Version, lagoonCLIVersion, + &token, debug) - projects, err := lagoon.GetProjectsByMetadata(context.TODO(), key, value, lc) + projects, err := l.GetProjectsByMetadata(context.TODO(), key, value, lc) if err != nil { return err } @@ -275,17 +277,17 @@ var updateProjectMetadata = &cobra.Command{ } if yesNo(fmt.Sprintf("You are attempting to update key '%s' for project '%s' metadata, are you sure?", key, cmdProjectName)) { current := lagoonCLIConfig.Current - lc := client.New( + token := lagoonCLIConfig.Lagoons[current].Token + lc := lclient.New( lagoonCLIConfig.Lagoons[current].GraphQL, - lagoonCLIConfig.Lagoons[current].Token, - lagoonCLIConfig.Lagoons[current].Version, lagoonCLIVersion, + &token, debug) - project, err := lagoon.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) + project, err := l.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) if err != nil { return err } - projectResult, err := lagoon.UpdateProjectMetadata(context.TODO(), int(project.ID), key, value, lc) + projectResult, err := l.UpdateProjectMetadata(context.TODO(), int(project.ID), key, value, lc) if err != nil { return err } @@ -330,17 +332,17 @@ var deleteProjectMetadataByKey = &cobra.Command{ } if yesNo(fmt.Sprintf("You are attempting to delete key '%s' from project '%s' metadata, are you sure?", key, cmdProjectName)) { current := lagoonCLIConfig.Current - lc := client.New( + token := lagoonCLIConfig.Lagoons[current].Token + lc := lclient.New( lagoonCLIConfig.Lagoons[current].GraphQL, - lagoonCLIConfig.Lagoons[current].Token, - lagoonCLIConfig.Lagoons[current].Version, lagoonCLIVersion, + &token, debug) - project, err := lagoon.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) + project, err := l.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) if err != nil { return err } - projectResult, err := lagoon.RemoveProjectMetadataByKey(context.TODO(), int(project.ID), key, lc) + projectResult, err := l.RemoveProjectMetadataByKey(context.TODO(), int(project.ID), key, lc) if err != nil { return err } diff --git a/cmd/tasks.go b/cmd/tasks.go index 3050c95a..a927f91b 100644 --- a/cmd/tasks.go +++ b/cmd/tasks.go @@ -7,10 +7,10 @@ import ( "errors" "fmt" "github.com/spf13/cobra" - "github.com/uselagoon/lagoon-cli/internal/lagoon" - "github.com/uselagoon/lagoon-cli/internal/lagoon/client" "github.com/uselagoon/lagoon-cli/pkg/api" "github.com/uselagoon/lagoon-cli/pkg/output" + l "github.com/uselagoon/machinery/api/lagoon" + lclient "github.com/uselagoon/machinery/api/lagoon/client" "io/ioutil" "os" ) @@ -41,13 +41,13 @@ var getTaskByID = &cobra.Command{ return fmt.Errorf("Missing arguments: ID is not defined") } current := lagoonCLIConfig.Current - lc := client.New( + token := lagoonCLIConfig.Lagoons[current].Token + lc := lclient.New( lagoonCLIConfig.Lagoons[current].GraphQL, - lagoonCLIConfig.Lagoons[current].Token, - lagoonCLIConfig.Lagoons[current].Version, lagoonCLIVersion, + &token, debug) - result, err := lagoon.TaskByID(context.TODO(), taskID, lc) + result, err := l.TaskByID(context.TODO(), taskID, lc) if err != nil { return err } @@ -100,13 +100,13 @@ If the task fails or fails to update, contact your Lagoon administrator for assi } if yesNo(fmt.Sprintf("You are attempting to run the active/standby switch for project '%s', are you sure?", cmdProjectName)) { current := lagoonCLIConfig.Current - lc := client.New( + token := lagoonCLIConfig.Lagoons[current].Token + lc := lclient.New( lagoonCLIConfig.Lagoons[current].GraphQL, - lagoonCLIConfig.Lagoons[current].Token, - lagoonCLIConfig.Lagoons[current].Version, lagoonCLIVersion, + &token, debug) - result, err := lagoon.ActiveStandbySwitch(context.TODO(), cmdProjectName, lc) + result, err := l.ActiveStandbySwitch(context.TODO(), cmdProjectName, lc) if err != nil { return err } diff --git a/go.mod b/go.mod index 4ec1069e..2d25de43 100644 --- a/go.mod +++ b/go.mod @@ -30,7 +30,7 @@ require ( github.com/guregu/null v4.0.0+incompatible // workaround for https://github.com/manifoldco/promptui/issues/98 github.com/nicksnyder/go-i18n v1.10.1 // indirect - github.com/uselagoon/machinery v0.0.11 + github.com/uselagoon/machinery v0.0.13 golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3 // indirect golang.org/x/sys v0.0.0-20220412211240-33da011f77ad // indirect gopkg.in/alecthomas/kingpin.v3-unstable v3.0.0-20191105091915-95d230a53780 // indirect @@ -41,4 +41,4 @@ replace github.com/olekukonko/tablewriter => github.com/shreddedbacon/tablewrite // replace github.com/machinebox/graphql => ../../shreddedbacon/graphql -// replace github.com/olekukonko/tablewriter => ../../shreddedbacon/tablewriter \ No newline at end of file +// replace github.com/olekukonko/tablewriter => ../../shreddedbacon/tablewriter diff --git a/go.sum b/go.sum index fe18d60a..ce748682 100644 --- a/go.sum +++ b/go.sum @@ -27,6 +27,7 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/go-bindata/go-bindata v3.1.2+incompatible h1:5vjJMVhowQdPzjE1LdxyFF7YFTXg5IgGVW4gBr5IbvE= github.com/go-bindata/go-bindata v3.1.2+incompatible/go.mod h1:xK8Dsgwmeed+BBsSy2XTopBn/8uK2HWuGSnA11C3Joo= +github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/golang/lint v0.0.0-20181026193005-c67002cb31c3 h1:I4BOK3PBMjhWfQM2zPJKK7lOBGsrsvOB7kBELP33hiE= github.com/golang/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= @@ -107,6 +108,10 @@ github.com/tsenart/deadcode v0.0.0-20160724212837-210d2dc333e9/go.mod h1:q+QjxYv github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/uselagoon/machinery v0.0.11 h1:s6EhyU/pj1+C4FdS0EqmR6C0dLsoeCd9n+5xHL1YDag= github.com/uselagoon/machinery v0.0.11/go.mod h1:IXLxlkahEAEgpCmu9Xa/Wmjo6ja4Aoq7tf8G7VrileE= +github.com/uselagoon/machinery v0.0.12 h1:TJnA+FrL1uEhRTjJ6dExiL4G7SOQ+hUfGuWDmbW2HBA= +github.com/uselagoon/machinery v0.0.12/go.mod h1:h/qeMWQR4Qqu33x+8AulNDeolEwvb/G+aIsn/jyUtwk= +github.com/uselagoon/machinery v0.0.13 h1:ZCLBNWJmDr3wikaHs3pWhQ1j8MprhIqRuChgSqmLyZc= +github.com/uselagoon/machinery v0.0.13/go.mod h1:h/qeMWQR4Qqu33x+8AulNDeolEwvb/G+aIsn/jyUtwk= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= diff --git a/internal/lagoon/client/_lgraphql/addDeployTargetConfig.graphql b/internal/lagoon/client/_lgraphql/addDeployTargetConfig.graphql deleted file mode 100644 index b2ae21dd..00000000 --- a/internal/lagoon/client/_lgraphql/addDeployTargetConfig.graphql +++ /dev/null @@ -1,61 +0,0 @@ -{{ if apiVerGreaterThanOrEqual . "2.10.0" }} -mutation ( - $project: Int! - $weight: Int - $branches: String! - $pullrequests: String! - $deployTarget: Int! - $deployTargetProjectPattern: String -){ - addDeployTargetConfig(input:{ - deployTarget: $deployTarget - weight: $weight - branches: $branches - pullrequests: $pullrequests - project: $project - deployTargetProjectPattern: $deployTargetProjectPattern - }){ - id - deployTarget{ - id - name - friendlyName - cloudProvider - cloudRegion - } - branches - pullrequests - weight - } -} -{{ else }} -mutation ( - $project: Int! - $weight: Int - $branches: String - $pullrequests: String - $deployTarget: Int! - $deployTargetProjectPattern: String -){ - addDeployTargetConfig(input:{ - deployTarget: $deployTarget - weight: $weight - branches: $branches - pullrequests: $pullrequests - project: $project - deployTargetProjectPattern: $deployTargetProjectPattern - }){ - id - deployTarget{ - id - name - friendlyName - cloudProvider - cloudRegion - } - branches - pullrequests - weight - } -} -{{ end }} \ No newline at end of file diff --git a/internal/lagoon/client/_lgraphql/projectsByMetadata.graphql b/internal/lagoon/client/_lgraphql/projectsByMetadata.graphql deleted file mode 100644 index f72b3120..00000000 --- a/internal/lagoon/client/_lgraphql/projectsByMetadata.graphql +++ /dev/null @@ -1,27 +0,0 @@ -{{ if apiVerGreaterThanOrEqual . "1.6.0" }} -query ( - $key: String! - $value: String){ - projectsByMetadata( - metadata: { - key: $key - value: $value - } - ){ - id - name - autoIdle - branches - pullrequests - metadata - productionEnvironment - openshiftProjectPattern - developmentEnvironmentsLimit - gitUrl - autoIdle - openshift{ - id - } - } -} -{{ end }} \ No newline at end of file diff --git a/internal/lagoon/client/_lgraphql/removeProjectMetadataByKey.graphql b/internal/lagoon/client/_lgraphql/removeProjectMetadataByKey.graphql deleted file mode 100644 index b9226177..00000000 --- a/internal/lagoon/client/_lgraphql/removeProjectMetadataByKey.graphql +++ /dev/null @@ -1,16 +0,0 @@ -{{ if apiVerGreaterThanOrEqual . "1.6.0" }} -mutation ( - $id: Int! - $key: String!){ - removeProjectMetadataByKey( - input:{ - id: $id - key: $key - } - ){ - id - name - metadata - } -} -{{ end }} \ No newline at end of file diff --git a/internal/lagoon/client/_lgraphql/switchActiveStandby.graphql b/internal/lagoon/client/_lgraphql/switchActiveStandby.graphql deleted file mode 100644 index 4b2586cb..00000000 --- a/internal/lagoon/client/_lgraphql/switchActiveStandby.graphql +++ /dev/null @@ -1,15 +0,0 @@ -{{ if apiVerGreaterThanOrEqual . "1.9.0" }} -mutation ( - $project: String! - ) { - switchActiveStandby( - input: { - project:{ - name: $project - } - } - ) { - id - } -} -{{ end }} \ No newline at end of file diff --git a/internal/lagoon/client/_lgraphql/taskByID.graphql b/internal/lagoon/client/_lgraphql/taskByID.graphql deleted file mode 100644 index 8f836ec0..00000000 --- a/internal/lagoon/client/_lgraphql/taskByID.graphql +++ /dev/null @@ -1,18 +0,0 @@ -{{ if apiVerGreaterThanOrEqual . "1.9.0" }} -query ( - $id: Int! - ){ - taskById(id: $id){ - id - name - command - status - started - completed - created - logs - remoteId - service - } -} -{{ end }} \ No newline at end of file diff --git a/internal/lagoon/client/_lgraphql/updateProjectMetadata.graphql b/internal/lagoon/client/_lgraphql/updateProjectMetadata.graphql deleted file mode 100644 index 1a190c48..00000000 --- a/internal/lagoon/client/_lgraphql/updateProjectMetadata.graphql +++ /dev/null @@ -1,20 +0,0 @@ -{{ if apiVerGreaterThanOrEqual . "1.6.0" }} -mutation ( - $id: Int! - $key: String! - $value: String){ - updateProjectMetadata( - input:{ - id: $id - patch: { - key: $key - value: $value - } - } - ){ - id - name - metadata - } -} -{{ end }} \ No newline at end of file diff --git a/internal/lagoon/client/lgraphql/lgraphql.go b/internal/lagoon/client/lgraphql/lgraphql.go index 15b4f101..f246b0f1 100644 --- a/internal/lagoon/client/lgraphql/lgraphql.go +++ b/internal/lagoon/client/lgraphql/lgraphql.go @@ -1,7 +1,6 @@ // Code generated for package lgraphql by go-bindata DO NOT EDIT. (@generated) // sources: // _lgraphql/addDeployTarget.graphql -// _lgraphql/addDeployTargetConfig.graphql // _lgraphql/addEnvVariable.graphql // _lgraphql/addGroup.graphql // _lgraphql/addGroupsToProject.graphql @@ -27,14 +26,9 @@ // _lgraphql/minimalProjectByName.graphql // _lgraphql/projectByName.graphql // _lgraphql/projectByNameMetadata.graphql -// _lgraphql/projectsByMetadata.graphql -// _lgraphql/removeProjectMetadataByKey.graphql // _lgraphql/sshEndpointsByProject.graphql -// _lgraphql/switchActiveStandby.graphql -// _lgraphql/taskByID.graphql // _lgraphql/updateDeployTarget.graphql // _lgraphql/updateDeployTargetConfig.graphql -// _lgraphql/updateProjectMetadata.graphql // _lgraphql/variables/addOrUpdateEnvVariableByName.graphql // _lgraphql/variables/deleteEnvVariableByName.graphql // _lgraphql/variables/getEnvVariablesByProjectEnvironmentName.graphql @@ -161,26 +155,6 @@ func _lgraphqlAdddeploytargetGraphql() (*asset, error) { return a, nil } -var __lgraphqlAdddeploytargetconfigGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x92\x31\x4f\xfb\x30\x10\xc5\xf7\x7c\x8a\xfb\x57\xff\xa1\x5d\xaa\xc2\x98\x15\x10\x62\x81\x08\x2a\x76\x13\x5f\x12\x23\xf7\x9c\x5e\x6c\x50\x15\xf9\xbb\xa3\xd6\x4d\x52\xa7\x29\x13\x63\x3d\xbe\x7b\xb9\xcb\xef\xe9\xb5\x2d\xa8\x02\x44\xad\xde\x91\x1f\x19\x85\x45\x5e\x57\x82\x5e\xf8\x61\xeb\x84\x86\x25\xcc\x6e\x97\x37\xab\xe5\x6a\x06\xde\x27\x1b\x67\x85\x55\x86\x60\x9e\x00\x00\xfc\xaf\xd9\x7c\x62\x6e\x53\x78\x22\xfb\x2f\x48\xdf\xa8\xca\x2a\x28\x41\xf8\x60\x41\x79\x85\x4d\x0a\x6f\x96\x15\x95\x47\x5f\xed\xb4\x66\xdc\x3a\x6c\xec\x78\x24\xb1\xd6\x66\xb7\x16\x5c\x62\xb4\xfa\x54\xcf\xc2\xe5\x4c\x58\x8b\x4c\xdd\x82\x64\xd1\x1e\xac\x42\xca\xfb\x13\xf3\x9d\xa1\x42\x95\x73\x45\xb5\xb3\x69\x70\xec\x5f\x7c\x27\x5a\xdf\x7b\x3a\x9c\x23\x57\xaf\x0f\x54\x3d\x60\x3f\x8b\xd1\x22\xd2\xc1\xd3\x25\xd7\x65\x38\xf9\x57\x63\xca\x5f\x22\x38\x7c\xef\x17\x03\x9d\x92\x93\x2b\x07\xc3\xc8\xb4\x7f\x24\x36\x18\x09\x05\x2b\x24\xa9\x77\xcf\xe3\x41\xae\x8d\x93\x19\x9b\x2f\x25\x91\xcf\x27\xaf\x58\x2a\x43\xbd\xee\xcf\x72\x9b\x0c\x6b\x94\x7a\x40\x4a\x7c\xd2\xb6\x80\xba\xc1\xbf\x6a\xe0\xe5\x02\x5e\xfb\x77\xed\xdf\x85\xfe\x91\x04\xef\x7f\x02\x00\x00\xff\xff\x06\x39\x95\x1a\x2d\x05\x00\x00") - -func _lgraphqlAdddeploytargetconfigGraphqlBytes() ([]byte, error) { - return bindataRead( - __lgraphqlAdddeploytargetconfigGraphql, - "_lgraphql/addDeployTargetConfig.graphql", - ) -} - -func _lgraphqlAdddeploytargetconfigGraphql() (*asset, error) { - bytes, err := _lgraphqlAdddeploytargetconfigGraphqlBytes() - if err != nil { - return nil, err - } - - info := bindataFileInfo{name: "_lgraphql/addDeployTargetConfig.graphql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} - return a, nil -} - var __lgraphqlAddenvvariableGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x5c\x8e\xb1\xca\xc3\x20\x14\x46\xf7\x3c\xc5\xf7\xc3\x3f\x24\x90\x27\x70\xef\x90\x39\xa5\xfb\x6d\x95\x22\x24\x37\x21\xbd\x06\x42\xe9\xbb\x17\xbd\xda\x4a\x07\x97\x73\xd4\xef\xcc\x41\x48\xfc\xc2\x68\x1b\xe0\x5f\x8e\xd5\x19\x9c\x78\xbf\xd0\xe6\xe9\x3a\xb9\xf3\xb1\xba\xbf\xbe\xa8\xc1\x1a\x0c\x2c\x0a\x1e\xb7\xe5\xe7\xf2\x18\x89\x4a\xa6\xd9\x19\x8c\xb2\x79\xbe\x2b\xd9\x69\x0a\x5f\xd4\xe1\xd9\x00\x00\x59\x5b\x7d\xd0\x7a\x5e\x83\x98\xec\x00\xcd\x49\xd3\x7d\x85\x62\x46\xee\x29\x38\xc7\x68\x54\x81\x1a\x91\x5a\x0a\xca\x15\x5a\x93\xd8\xab\xfb\xcc\x79\x5b\x3d\x54\xd9\xc4\xf3\x0e\x00\x00\xff\xff\x1d\x4f\x13\xd7\x24\x01\x00\x00") func _lgraphqlAddenvvariableGraphqlBytes() ([]byte, error) { @@ -681,46 +655,6 @@ func _lgraphqlProjectbynamemetadataGraphql() (*asset, error) { return a, nil } -var __lgraphqlProjectsbymetadataGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x74\x90\x4d\x4b\xc4\x30\x10\x86\xef\xfd\x15\xe3\xe2\xc1\xbd\x14\xbd\x78\xd8\xa3\xb0\x88\xa0\xb8\xe0\xc7\x7d\x6c\x66\xb7\xd1\x34\x69\x27\x93\x42\x09\xf9\xef\xd2\x76\x4d\x2b\xe2\x9c\x86\x67\xe6\x7d\xe7\x23\x46\xd0\x47\xc0\x56\xbf\x13\xdf\x33\xa1\x10\xbf\xd6\x68\x9f\x79\xdf\x05\x34\x50\xc2\xe6\xa6\xbc\x2d\xaf\x37\x90\x52\xd1\x05\xe2\x01\xae\x0a\x00\x80\xcb\x2f\x1a\x76\xf0\x22\xac\xed\xe9\x62\x26\x3d\x9a\x40\x3f\x6c\x1b\x27\xd8\xb2\xfb\xa4\x4a\xfc\xdd\xf0\x44\x82\x0a\x05\x67\xf9\x18\xcd\x99\xec\x20\x66\x36\xc6\xe4\x3c\xfa\xff\xa2\x67\xf7\x79\x4a\xae\xa4\x29\xdb\x2e\x06\x5a\xe5\xd4\x62\xb3\x34\x62\x10\xf7\xa0\xcc\x02\x3e\x18\x6d\x55\x93\xcf\xa0\x0d\xc6\x30\x75\x81\xbc\xf8\x3f\x3b\x2e\x5d\xec\x54\xa8\x44\x3b\xbb\xb7\xbd\x66\x67\x1b\xb2\x92\xab\xae\x25\xeb\x6b\x7d\x94\xc3\x7c\xf7\x01\x45\x88\x6d\xae\x2b\xea\xc9\xb8\x76\xd4\xac\xe4\xfe\x51\x37\x7a\x31\x39\x69\x79\x63\xf3\xff\xe6\x79\xc8\xfa\x6d\xab\xbb\xe7\x9f\xa4\x22\x15\x31\x02\x59\x05\x29\x7d\x07\x00\x00\xff\xff\x88\xf4\xc3\xb2\xe6\x01\x00\x00") - -func _lgraphqlProjectsbymetadataGraphqlBytes() ([]byte, error) { - return bindataRead( - __lgraphqlProjectsbymetadataGraphql, - "_lgraphql/projectsByMetadata.graphql", - ) -} - -func _lgraphqlProjectsbymetadataGraphql() (*asset, error) { - bytes, err := _lgraphqlProjectsbymetadataGraphqlBytes() - if err != nil { - return nil, err - } - - info := bindataFileInfo{name: "_lgraphql/projectsByMetadata.graphql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} - return a, nil -} - -var __lgraphqlRemoveprojectmetadatabykeyGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x54\x8d\x31\x0b\xc2\x30\x10\x85\xf7\xfc\x8a\x6b\x71\xb0\x4b\xd1\xc5\x21\xa3\x20\x22\x22\x0a\x8a\xfb\x61\x4e\x8d\x9a\xb4\x1e\x57\xa1\x84\xfc\x77\x69\x2a\x55\x6f\xba\xf7\xc1\xfb\x5e\x08\x60\xcf\x80\xb5\x3d\x12\x2f\x99\x50\x88\x0f\x57\xf4\x5b\x5e\x3c\x1b\x7c\x40\x09\xf9\xb4\x9c\x95\x93\x1c\x62\x54\xae\x11\x14\x5b\x79\x18\x2b\x00\x80\x91\x35\x1a\x56\x5e\xb2\x3e\xdd\xa9\xd5\xb0\x17\xb6\xfe\x92\x15\x21\x31\x26\x57\xbd\x68\xc7\xd5\x8d\x4e\xb2\x21\x41\x83\x82\xf3\x76\x4d\x6d\x6f\xe8\xce\xfa\xba\x11\x1d\x86\x9c\x98\xd1\x9d\xfd\x8f\x25\x7d\x37\x32\xd0\x98\xbe\xe2\x5b\xfd\x69\x78\x74\x34\x04\xf7\x59\x56\x7d\x2b\xaa\x10\x80\xbc\x81\x18\xdf\x01\x00\x00\xff\xff\x82\x2b\x13\x86\xfe\x00\x00\x00") - -func _lgraphqlRemoveprojectmetadatabykeyGraphqlBytes() ([]byte, error) { - return bindataRead( - __lgraphqlRemoveprojectmetadatabykeyGraphql, - "_lgraphql/removeProjectMetadataByKey.graphql", - ) -} - -func _lgraphqlRemoveprojectmetadatabykeyGraphql() (*asset, error) { - bytes, err := _lgraphqlRemoveprojectmetadatabykeyGraphqlBytes() - if err != nil { - return nil, err - } - - info := bindataFileInfo{name: "_lgraphql/removeProjectMetadataByKey.graphql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} - return a, nil -} - var __lgraphqlSshendpointsbyprojectGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x2a\x2c\x4d\x2d\xaa\x54\xd0\x50\xc9\x4b\xcc\x4d\xb5\x52\x08\x2e\x29\xca\xcc\x4b\x57\xd4\x54\xa8\xe6\x52\x50\x28\x28\xca\xcf\x4a\x4d\x2e\x71\xaa\xf4\x4b\xcc\x4d\xd5\x80\x28\x00\xab\x83\x48\x2b\x28\x64\xa6\x80\x29\x90\x10\x98\x91\x9a\x57\x96\x59\x94\x9f\x97\x9b\x9a\x57\x52\x0c\x55\x02\x57\x84\xa4\x4c\x41\x21\xbf\x20\x35\xaf\x38\x23\x33\xad\x24\x00\x62\x85\x1f\x16\x29\x98\x7e\x24\x13\x14\x14\x8a\x8b\x33\x3c\xf2\x8b\x4b\x90\xf9\x01\xf9\x45\x30\x7e\x2d\x17\x8c\xac\xe5\xaa\xe5\x02\x04\x00\x00\xff\xff\x54\x7c\x7d\xf6\xda\x00\x00\x00") func _lgraphqlSshendpointsbyprojectGraphqlBytes() ([]byte, error) { @@ -741,46 +675,6 @@ func _lgraphqlSshendpointsbyprojectGraphql() (*asset, error) { return a, nil } -var __lgraphqlSwitchactivestandbyGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x3c\x8c\xb1\x8f\x82\x50\x0c\x87\xf7\xfe\x15\xbf\x23\x37\x1c\x0b\xb9\x1b\x8f\xcd\xc1\x38\x3a\x60\xdc\x2b\x54\xa9\x91\x82\xcf\xa2\x31\x2f\xef\x7f\x37\x18\xb0\x43\x93\x7e\xe9\xf7\xc5\x08\x3d\x82\x07\xdd\x4b\xd8\x04\x61\x97\xb0\x6b\xd9\xb6\x61\x7d\x1d\xf9\x82\x02\xd9\x5f\xf1\x5f\xfc\x66\x48\x89\xba\xd1\xd9\xb5\x37\xfc\x10\xf0\x3d\x84\xfe\x2c\xb5\x97\xa8\x3c\xa8\x9d\xbe\x08\xc8\x11\x09\xb8\x3d\xd4\xeb\x76\x55\xbb\xde\xa5\x72\xb6\xe6\xf0\x9c\x04\x40\x6d\x18\xbd\x7c\xff\x4c\xb3\x04\x96\x1b\x30\xee\xa4\xfc\x94\x67\x9c\x68\xd9\xf9\xac\x6a\x43\x13\x48\x14\x23\xc4\x1a\xa4\xf4\x0a\x00\x00\xff\xff\xf9\xe3\xea\x42\xc6\x00\x00\x00") - -func _lgraphqlSwitchactivestandbyGraphqlBytes() ([]byte, error) { - return bindataRead( - __lgraphqlSwitchactivestandbyGraphql, - "_lgraphql/switchActiveStandby.graphql", - ) -} - -func _lgraphqlSwitchactivestandbyGraphql() (*asset, error) { - bytes, err := _lgraphqlSwitchactivestandbyGraphqlBytes() - if err != nil { - return nil, err - } - - info := bindataFileInfo{name: "_lgraphql/switchActiveStandby.graphql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} - return a, nil -} - -var __lgraphqlTaskbyidGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x3c\x8e\x31\x0f\x82\x30\x10\x85\xf7\xfe\x8a\x27\x61\xc0\x85\xe8\xa8\xa3\x89\x31\x4c\x2e\xc6\xfd\x42\x4f\x6d\xa4\x05\x8e\x62\x42\x9a\xfe\x77\x43\x11\xa7\xfb\xee\xdd\xcb\x97\x0b\x01\xe6\x01\xea\xcc\x9d\xe5\x22\x4c\x9e\xe5\xf6\x22\x77\x95\x73\x3f\x52\x83\x12\xd9\xbe\x3c\x94\xbb\x0c\x31\xaa\x7e\x64\x99\x50\x28\x20\x37\xfa\x88\xca\xf9\x8d\x02\xb6\x41\x01\x9e\x86\xf7\x69\xaa\x74\x31\x1f\x72\xa3\x53\x08\x18\x9d\x86\x23\xcb\x09\xea\xd6\x5a\x72\x4b\x38\x78\xf2\xe3\xb0\xa2\x78\xd6\x6b\xa5\x6b\xf8\xbf\xa5\x97\x16\x6e\xda\xe7\x52\x17\xb6\xad\xe7\xea\xa7\x61\xf9\x98\x7a\xd6\x47\x15\x55\x08\x60\xa7\x11\xe3\x37\x00\x00\xff\xff\xb1\xdc\x9e\x8c\xd8\x00\x00\x00") - -func _lgraphqlTaskbyidGraphqlBytes() ([]byte, error) { - return bindataRead( - __lgraphqlTaskbyidGraphql, - "_lgraphql/taskByID.graphql", - ) -} - -func _lgraphqlTaskbyidGraphql() (*asset, error) { - bytes, err := _lgraphqlTaskbyidGraphqlBytes() - if err != nil { - return nil, err - } - - info := bindataFileInfo{name: "_lgraphql/taskByID.graphql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} - return a, nil -} - var __lgraphqlUpdatedeploytargetGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x6c\x91\x41\x6e\xea\x30\x10\x86\xf7\x73\x8a\x79\x12\x0b\x90\x38\x41\xb6\xaf\x8b\xd2\x05\xa0\xd2\x1e\xc0\xc5\x43\xb0\x9a\x78\x22\x67\x52\x09\x55\xdc\xbd\x0a\x24\xb1\x27\xce\x2a\xf1\xff\x8f\xa5\xf1\xf7\xd5\x9d\x18\x71\xec\x71\x0d\x88\x2b\x67\x0b\xdc\x79\xf9\xd7\xff\x7b\x53\x53\x81\x27\x09\xce\x97\xdb\x3e\x38\xb3\x6f\xb9\xa2\xcf\x50\xa9\x58\xf8\x9b\xbc\x4a\x02\x77\x42\xe1\x68\x44\x28\xe8\xa6\x6d\xaf\xaf\xdc\xca\x3c\x3b\x72\xd0\x59\xcd\xde\x09\xf7\xc7\xff\xec\x2f\xae\x2c\xf0\xed\x74\xd8\x3f\xaa\xaf\xce\x55\x76\x57\x9b\x52\x2f\x77\x09\x8e\xbc\xad\x6e\xfb\x6c\xeb\x8a\x3b\x7b\x0c\xfc\xe3\x2c\x85\xbc\x79\xa7\xd2\xf1\xb4\xe4\x06\x7f\x01\x11\xb1\x6b\xac\x11\x7a\xa1\xa6\xe2\xdb\x87\x09\x25\x49\x31\x64\x87\x86\x7c\x7b\x75\x17\x59\x3b\xdf\x74\x52\x0c\x17\x10\x7b\x74\x2b\x67\x87\x53\x63\xe4\x7c\x8d\x25\xe2\x93\xe6\x03\xea\x76\x0a\x53\xa2\x09\xde\x38\x30\xb0\x7d\x32\x9e\xd2\x19\x5f\xcd\x3b\x5e\x9e\x60\x8f\xd8\x55\xf5\x64\x3e\xd2\x8f\x55\xca\x37\x81\x1d\x07\x72\x37\x99\xae\x38\xac\xb5\x28\x4b\x09\x06\xad\x48\x2b\x9b\x8d\x8d\xbe\x52\x7b\xc3\xc4\xfd\xf1\xbd\x6f\x12\x25\x10\xe1\x0f\xbf\xe7\x40\x46\x68\x2c\x52\xae\x91\x3f\x28\x7e\xa0\x90\xc1\x9c\x12\x2c\xbc\x01\xb2\x85\x21\xc7\x01\x0b\x32\x61\x19\x31\x8c\xcf\xbb\xc3\x5f\x00\x00\x00\xff\xff\x7f\xe0\xea\x58\xb0\x03\x00\x00") func _lgraphqlUpdatedeploytargetGraphqlBytes() ([]byte, error) { @@ -821,26 +715,6 @@ func _lgraphqlUpdatedeploytargetconfigGraphql() (*asset, error) { return a, nil } -var __lgraphqlUpdateprojectmetadataGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x64\x8e\xb1\x6e\xc2\x30\x10\x86\x77\x3f\xc5\x35\xea\xd0\x2c\x51\xbb\x74\xf0\x5e\x55\x1d\x2a\x90\x40\xec\xa7\xf8\x20\x86\xc4\x31\xd6\x19\x09\x59\x7e\x77\xe4\x38\x10\x2c\x6e\xf2\x7d\xe7\xbb\xff\x0b\x01\xf4\x1e\xd0\xea\x1d\xb9\x5f\x47\xc8\xe4\xb6\x1d\x9a\x95\xfb\x39\x7b\xec\xa1\x81\xea\xab\xf9\x6e\x3e\x2b\x88\x51\x0c\x9e\x91\xf5\x68\xe0\x43\x00\x00\xbc\x6b\x25\xe1\xcf\xf0\x5b\xee\x4e\x74\x95\xb0\x61\xa7\xcd\x61\x26\x17\xec\x3d\xdd\x59\x1d\x26\xe8\xad\x42\xa6\xb5\x1b\x8f\xd4\xf2\x3f\x31\x2a\x64\xcc\xf7\x52\x69\x63\x3d\xcb\xf0\xe8\x27\xa6\x64\xca\x2a\x98\x45\x6e\x3b\x09\xe5\xc7\x54\x93\x45\x72\x79\x99\xcc\x36\xd9\xaa\x98\x46\x51\xbe\xea\xe5\xec\x53\xac\xc1\x61\x59\x1b\x66\x73\x91\xb7\xa2\x08\x01\xc8\x28\x88\xf1\x16\x00\x00\xff\xff\xa5\x4e\x06\xe0\x51\x01\x00\x00") - -func _lgraphqlUpdateprojectmetadataGraphqlBytes() ([]byte, error) { - return bindataRead( - __lgraphqlUpdateprojectmetadataGraphql, - "_lgraphql/updateProjectMetadata.graphql", - ) -} - -func _lgraphqlUpdateprojectmetadataGraphql() (*asset, error) { - bytes, err := _lgraphqlUpdateprojectmetadataGraphqlBytes() - if err != nil { - return nil, err - } - - info := bindataFileInfo{name: "_lgraphql/updateProjectMetadata.graphql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} - return a, nil -} - var __lgraphqlVariablesAddorupdateenvvariablebynameGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xca\x2d\x2d\x49\x2c\xc9\xcc\xcf\x53\xd0\xe0\x52\x50\x50\xc9\xcc\x2b\x28\x2d\xb1\x52\x70\xcd\x2b\x0b\x4b\x2c\xca\x4c\x4c\xca\x49\x75\xaa\xf4\x4b\xcc\x4d\xf5\x04\x89\x2b\x72\x69\x2a\x54\x73\x29\x28\x28\x28\x24\xa6\xa4\xf8\x17\x85\x16\xa4\x24\x96\xa4\x62\x28\xd5\x80\x9a\x01\x31\x0b\xa6\x03\x04\x32\x53\xe0\xcc\xbc\xc4\xdc\x54\x38\xa7\x2c\x31\xa7\x14\xc1\x2b\x4e\xce\x2f\x80\xf0\x6a\xb9\x6a\xb9\x00\x01\x00\x00\xff\xff\x2e\x2c\x3b\xed\x9f\x00\x00\x00") func _lgraphqlVariablesAddorupdateenvvariablebynameGraphqlBytes() ([]byte, error) { @@ -1494,7 +1368,6 @@ func AssetNames() []string { // _bindata is a table, holding each asset generator, mapped to its name. var _bindata = map[string]func() (*asset, error){ "_lgraphql/addDeployTarget.graphql": _lgraphqlAdddeploytargetGraphql, - "_lgraphql/addDeployTargetConfig.graphql": _lgraphqlAdddeploytargetconfigGraphql, "_lgraphql/addEnvVariable.graphql": _lgraphqlAddenvvariableGraphql, "_lgraphql/addGroup.graphql": _lgraphqlAddgroupGraphql, "_lgraphql/addGroupsToProject.graphql": _lgraphqlAddgroupstoprojectGraphql, @@ -1520,14 +1393,9 @@ var _bindata = map[string]func() (*asset, error){ "_lgraphql/minimalProjectByName.graphql": _lgraphqlMinimalprojectbynameGraphql, "_lgraphql/projectByName.graphql": _lgraphqlProjectbynameGraphql, "_lgraphql/projectByNameMetadata.graphql": _lgraphqlProjectbynamemetadataGraphql, - "_lgraphql/projectsByMetadata.graphql": _lgraphqlProjectsbymetadataGraphql, - "_lgraphql/removeProjectMetadataByKey.graphql": _lgraphqlRemoveprojectmetadatabykeyGraphql, "_lgraphql/sshEndpointsByProject.graphql": _lgraphqlSshendpointsbyprojectGraphql, - "_lgraphql/switchActiveStandby.graphql": _lgraphqlSwitchactivestandbyGraphql, - "_lgraphql/taskByID.graphql": _lgraphqlTaskbyidGraphql, "_lgraphql/updateDeployTarget.graphql": _lgraphqlUpdatedeploytargetGraphql, "_lgraphql/updateDeployTargetConfig.graphql": _lgraphqlUpdatedeploytargetconfigGraphql, - "_lgraphql/updateProjectMetadata.graphql": _lgraphqlUpdateprojectmetadataGraphql, "_lgraphql/variables/addOrUpdateEnvVariableByName.graphql": _lgraphqlVariablesAddorupdateenvvariablebynameGraphql, "_lgraphql/variables/deleteEnvVariableByName.graphql": _lgraphqlVariablesDeleteenvvariablebynameGraphql, "_lgraphql/variables/getEnvVariablesByProjectEnvironmentName.graphql": _lgraphqlVariablesGetenvvariablesbyprojectenvironmentnameGraphql, @@ -1603,7 +1471,6 @@ type bintree struct { var _bintree = &bintree{nil, map[string]*bintree{ "_lgraphql": &bintree{nil, map[string]*bintree{ "addDeployTarget.graphql": &bintree{_lgraphqlAdddeploytargetGraphql, map[string]*bintree{}}, - "addDeployTargetConfig.graphql": &bintree{_lgraphqlAdddeploytargetconfigGraphql, map[string]*bintree{}}, "addEnvVariable.graphql": &bintree{_lgraphqlAddenvvariableGraphql, map[string]*bintree{}}, "addGroup.graphql": &bintree{_lgraphqlAddgroupGraphql, map[string]*bintree{}}, "addGroupsToProject.graphql": &bintree{_lgraphqlAddgroupstoprojectGraphql, map[string]*bintree{}}, @@ -1656,16 +1523,11 @@ var _bintree = &bintree{nil, map[string]*bintree{ "updateNotificationSlack.graphql": &bintree{_lgraphqlNotificationsUpdatenotificationslackGraphql, map[string]*bintree{}}, "updateNotificationWebhook.graphql": &bintree{_lgraphqlNotificationsUpdatenotificationwebhookGraphql, map[string]*bintree{}}, }}, - "projectByName.graphql": &bintree{_lgraphqlProjectbynameGraphql, map[string]*bintree{}}, - "projectByNameMetadata.graphql": &bintree{_lgraphqlProjectbynamemetadataGraphql, map[string]*bintree{}}, - "projectsByMetadata.graphql": &bintree{_lgraphqlProjectsbymetadataGraphql, map[string]*bintree{}}, - "removeProjectMetadataByKey.graphql": &bintree{_lgraphqlRemoveprojectmetadatabykeyGraphql, map[string]*bintree{}}, - "sshEndpointsByProject.graphql": &bintree{_lgraphqlSshendpointsbyprojectGraphql, map[string]*bintree{}}, - "switchActiveStandby.graphql": &bintree{_lgraphqlSwitchactivestandbyGraphql, map[string]*bintree{}}, - "taskByID.graphql": &bintree{_lgraphqlTaskbyidGraphql, map[string]*bintree{}}, - "updateDeployTarget.graphql": &bintree{_lgraphqlUpdatedeploytargetGraphql, map[string]*bintree{}}, - "updateDeployTargetConfig.graphql": &bintree{_lgraphqlUpdatedeploytargetconfigGraphql, map[string]*bintree{}}, - "updateProjectMetadata.graphql": &bintree{_lgraphqlUpdateprojectmetadataGraphql, map[string]*bintree{}}, + "projectByName.graphql": &bintree{_lgraphqlProjectbynameGraphql, map[string]*bintree{}}, + "projectByNameMetadata.graphql": &bintree{_lgraphqlProjectbynamemetadataGraphql, map[string]*bintree{}}, + "sshEndpointsByProject.graphql": &bintree{_lgraphqlSshendpointsbyprojectGraphql, map[string]*bintree{}}, + "updateDeployTarget.graphql": &bintree{_lgraphqlUpdatedeploytargetGraphql, map[string]*bintree{}}, + "updateDeployTargetConfig.graphql": &bintree{_lgraphqlUpdatedeploytargetconfigGraphql, map[string]*bintree{}}, "variables": &bintree{nil, map[string]*bintree{ "addOrUpdateEnvVariableByName.graphql": &bintree{_lgraphqlVariablesAddorupdateenvvariablebynameGraphql, map[string]*bintree{}}, "deleteEnvVariableByName.graphql": &bintree{_lgraphqlVariablesDeleteenvvariablebynameGraphql, map[string]*bintree{}}, diff --git a/internal/lagoon/client/mutation.go b/internal/lagoon/client/mutation.go index 1dba8f61..a4917238 100644 --- a/internal/lagoon/client/mutation.go +++ b/internal/lagoon/client/mutation.go @@ -208,65 +208,6 @@ func (c *Client) DeployEnvironmentBranch(ctx context.Context, return c.client.Run(ctx, req, &out) } -// RunActiveStandbySwitch deploys a branch. -func (c *Client) RunActiveStandbySwitch(ctx context.Context, - project string, out *schema.Task) error { - req, err := c.newVersionedRequest("_lgraphql/switchActiveStandby.graphql", map[string]interface{}{ - "project": project, - }) - if err != nil { - return err - } - - // return c.client.Run(ctx, req, &out) - return c.client.Run(ctx, req, &struct { - Response *schema.Task `json:"switchActiveStandby"` - }{ - Response: out, - }) -} - -// UpdateProjectMetadata updates a projects metadata. -func (c *Client) UpdateProjectMetadata( - ctx context.Context, id int, key string, value string, projects *schema.ProjectMetadata) error { - - req, err := c.newVersionedRequest("_lgraphql/updateProjectMetadata.graphql", - map[string]interface{}{ - "id": id, - "key": key, - "value": value, - }) - if err != nil { - return err - } - - return c.client.Run(ctx, req, &struct { - Response *schema.ProjectMetadata `json:"updateProjectMetadata"` - }{ - Response: projects, - }) -} - -// RemoveProjectMetadataByKey removes metadata from a project for given key. -func (c *Client) RemoveProjectMetadataByKey( - ctx context.Context, id int, key string, projects *schema.ProjectMetadata) error { - - req, err := c.newVersionedRequest("_lgraphql/removeProjectMetadataByKey.graphql", - map[string]interface{}{ - "id": id, - "key": key, - }) - if err != nil { - return err - } - - return c.client.Run(ctx, req, &struct { - Response *schema.ProjectMetadata `json:"removeProjectMetadataByKey"` - }{ - Response: projects, - }) -} - // AddRestore adds a restore. func (c *Client) AddRestore( ctx context.Context, backupID string, out *schema.Restore) error { @@ -284,20 +225,6 @@ func (c *Client) AddRestore( }) } -// AddDeployTargetConfiguration adds a deploytarget configuration to a project. -func (c *Client) AddDeployTargetConfiguration(ctx context.Context, - in *schema.AddDeployTargetConfigInput, out *schema.DeployTargetConfig) error { - req, err := c.newVersionedRequest("_lgraphql/addDeployTargetConfig.graphql", in) - if err != nil { - return err - } - return c.client.Run(ctx, req, &struct { - Response *schema.DeployTargetConfig `json:"addDeployTargetConfig"` - }{ - Response: out, - }) -} - // UpdateDeployTargetConfiguration adds a deploytarget configuration to a project. func (c *Client) UpdateDeployTargetConfiguration(ctx context.Context, in *schema.UpdateDeployTargetConfigInput, out *schema.DeployTargetConfig) error { diff --git a/internal/lagoon/client/query.go b/internal/lagoon/client/query.go index b46ed451..2957d21c 100644 --- a/internal/lagoon/client/query.go +++ b/internal/lagoon/client/query.go @@ -118,26 +118,6 @@ func (c *Client) LagoonSchema( }) } -// GetTaskByID queries the Lagoon API for a task by its ID, and -// unmarshals the response. -func (c *Client) GetTaskByID( - ctx context.Context, id int, task *schema.Task) error { - - req, err := c.newVersionedRequest("_lgraphql/taskByID.graphql", - map[string]interface{}{ - "id": id, - }) - if err != nil { - return err - } - - return c.client.Run(ctx, req, &struct { - Response *schema.Task `json:"taskById"` - }{ - Response: task, - }) -} - // MinimalProjectByName queries the Lagoon API for a project by its name, and // unmarshals the response into project. func (c *Client) MinimalProjectByName( @@ -178,27 +158,6 @@ func (c *Client) ProjectByNameMetadata( }) } -// ProjectsByMetadata queries the Lagoon API for a project by its name, and -// unmarshals the response into project. -func (c *Client) ProjectsByMetadata( - ctx context.Context, key string, value string, projects *[]schema.ProjectMetadata) error { - - req, err := c.newVersionedRequest("_lgraphql/projectsByMetadata.graphql", - map[string]interface{}{ - "key": key, - "value": value, - }) - if err != nil { - return err - } - - return c.client.Run(ctx, req, &struct { - Response *[]schema.ProjectMetadata `json:"projectsByMetadata"` - }{ - Response: projects, - }) -} - // DeployTargetConfigsByProjectID queries the Lagoon API for a projects deploytarget configs by its id, and // unmarshals the response into deploytargetconfigs. func (c *Client) DeployTargetConfigsByProjectID( diff --git a/internal/lagoon/deploytargetconfig.go b/internal/lagoon/deploytargetconfig.go index 29b2b629..35c5ddf5 100644 --- a/internal/lagoon/deploytargetconfig.go +++ b/internal/lagoon/deploytargetconfig.go @@ -11,7 +11,6 @@ import ( // DeployTargetConfigs interface contains methods for getting info on deploytarget configs. type DeployTargetConfigs interface { DeployTargetConfigsByProjectID(ctx context.Context, project int, deployTargets *[]schema.DeployTargetConfig) error - AddDeployTargetConfiguration(ctx context.Context, in *schema.AddDeployTargetConfigInput, deployTargets *schema.DeployTargetConfig) error UpdateDeployTargetConfiguration(ctx context.Context, in *schema.UpdateDeployTargetConfigInput, deployTargets *schema.DeployTargetConfig) error DeleteDeployTargetConfiguration(ctx context.Context, id int, project int, deployTargets *schema.DeleteDeployTargetConfig) error } @@ -22,12 +21,6 @@ func GetDeployTargetConfigs(ctx context.Context, project int, dtc DeployTargetCo return &deployTargets, dtc.DeployTargetConfigsByProjectID(ctx, project, &deployTargets) } -// AddDeployTargetConfiguration adds a deploytarget config to a specific project. -func AddDeployTargetConfiguration(ctx context.Context, in *schema.AddDeployTargetConfigInput, dtc DeployTargetConfigs) (*schema.DeployTargetConfig, error) { - deployTarget := schema.DeployTargetConfig{} - return &deployTarget, dtc.AddDeployTargetConfiguration(ctx, in, &deployTarget) -} - // UpdateDeployTargetConfiguration adds a deploytarget config to a specific project. func UpdateDeployTargetConfiguration(ctx context.Context, in *schema.UpdateDeployTargetConfigInput, dtc DeployTargetConfigs) (*schema.DeployTargetConfig, error) { deployTarget := schema.DeployTargetConfig{} diff --git a/internal/lagoon/projects.go b/internal/lagoon/projects.go index 276b7038..b236ca5f 100644 --- a/internal/lagoon/projects.go +++ b/internal/lagoon/projects.go @@ -12,9 +12,6 @@ import ( type Projects interface { MinimalProjectByName(ctx context.Context, name string, project *schema.Project) error ProjectByNameMetadata(ctx context.Context, name string, project *schema.ProjectMetadata) error - ProjectsByMetadata(ctx context.Context, key string, value string, project *[]schema.ProjectMetadata) error - UpdateProjectMetadata(ctx context.Context, id int, key string, value string, project *schema.ProjectMetadata) error - RemoveProjectMetadataByKey(ctx context.Context, id int, key string, project *schema.ProjectMetadata) error SSHEndpointsByProject(ctx context.Context, name string, project *schema.Project) error } @@ -24,30 +21,12 @@ func GetMinimalProjectByName(ctx context.Context, name string, p Projects) (*sch return &project, p.MinimalProjectByName(ctx, name, &project) } -// GetProjectsByMetadata gets info of projects in lagoon that have matching metadata. -func GetProjectsByMetadata(ctx context.Context, key string, value string, p Projects) (*[]schema.ProjectMetadata, error) { - project := []schema.ProjectMetadata{} - return &project, p.ProjectsByMetadata(ctx, key, value, &project) -} - // GetProjectMetadata gets the metadata key:values for a lagoon project. func GetProjectMetadata(ctx context.Context, name string, p Projects) (*schema.ProjectMetadata, error) { project := schema.ProjectMetadata{} return &project, p.ProjectByNameMetadata(ctx, name, &project) } -// UpdateProjectMetadata updates a project with provided metadata. -func UpdateProjectMetadata(ctx context.Context, id int, key string, value string, p Projects) (*schema.ProjectMetadata, error) { - project := schema.ProjectMetadata{} - return &project, p.UpdateProjectMetadata(ctx, id, key, value, &project) -} - -// RemoveProjectMetadataByKey remove metadata from a project by key. -func RemoveProjectMetadataByKey(ctx context.Context, id int, key string, p Projects) (*schema.ProjectMetadata, error) { - project := schema.ProjectMetadata{} - return &project, p.RemoveProjectMetadataByKey(ctx, id, key, &project) -} - // GetSSHEndpointsByProject gets info of projects in lagoon that have matching metadata. func GetSSHEndpointsByProject(ctx context.Context, name string, p Projects) (*schema.Project, error) { project := schema.Project{} diff --git a/internal/lagoon/tasks.go b/internal/lagoon/tasks.go deleted file mode 100644 index cce1a113..00000000 --- a/internal/lagoon/tasks.go +++ /dev/null @@ -1,27 +0,0 @@ -// Package lagoon implements high-level functions for interacting with the -// Lagoon API. -package lagoon - -import ( - "context" - - "github.com/uselagoon/lagoon-cli/internal/schema" -) - -// Tasks interface contains methods for running tasks in projects and environments in lagoon. -type Tasks interface { - RunActiveStandbySwitch(ctx context.Context, project string, result *schema.Task) error - GetTaskByID(ctx context.Context, id int, result *schema.Task) error -} - -// ActiveStandbySwitch runs the activestandby switch. -func ActiveStandbySwitch(ctx context.Context, project string, t Tasks) (*schema.Task, error) { - result := schema.Task{} - return &result, t.RunActiveStandbySwitch(ctx, project, &result) -} - -// TaskByID returns a task by the associated id -func TaskByID(ctx context.Context, id int, t Tasks) (*schema.Task, error) { - result := schema.Task{} - return &result, t.GetTaskByID(ctx, id, &result) -} From 9274b3f57040bc443ece92d6bc63d14220e1cf0e Mon Sep 17 00:00:00 2001 From: Chris Goodwin <40746380+CGoodwin90@users.noreply.github.com> Date: Tue, 5 Dec 2023 12:54:58 +1100 Subject: [PATCH 4/6] Change: Refactored `get project` command, adds `deploymentsDisabled` & updated to use `bools` instead of `int bools` (#297) --- cmd/get.go | 90 ++++++++++++++++++++++++++++++++++++++++++------------ go.mod | 2 +- 2 files changed, 72 insertions(+), 20 deletions(-) diff --git a/cmd/get.go b/cmd/get.go index 193aef2c..1a603ecd 100644 --- a/cmd/get.go +++ b/cmd/get.go @@ -1,14 +1,18 @@ package cmd import ( + "context" "encoding/json" "fmt" - "os" - "github.com/spf13/cobra" "github.com/spf13/pflag" "github.com/uselagoon/lagoon-cli/pkg/api" "github.com/uselagoon/lagoon-cli/pkg/output" + "os" + "strconv" + + l "github.com/uselagoon/machinery/api/lagoon" + lclient "github.com/uselagoon/machinery/api/lagoon/client" ) // GetFlags . @@ -44,30 +48,78 @@ var getProjectCmd = &cobra.Command{ Use: "project", Aliases: []string{"p"}, Short: "Get details about a project", - Run: func(cmd *cobra.Command, args []string) { - getProjectFlags := parseGetFlags(*cmd.Flags()) - if getProjectFlags.Project == "" { + PreRunE: func(_ *cobra.Command, _ []string) error { + return validateTokenE(lagoonCLIConfig.Current) + }, + RunE: func(cmd *cobra.Command, args []string) error { + debug, err := cmd.Flags().GetBool("debug") + if err != nil { + return err + } + if cmdProjectName == "" { fmt.Println("Missing arguments: Project name is not defined") - cmd.Help() - os.Exit(1) + return nil } - returnedJSON, err := pClient.GetProjectInfo(getProjectFlags.Project) + current := lagoonCLIConfig.Current + token := lagoonCLIConfig.Lagoons[current].Token + lc := lclient.New( + lagoonCLIConfig.Lagoons[current].GraphQL, + lagoonCLIVersion, + &token, + debug) + + project, err := l.GetProjectByName(context.TODO(), cmdProjectName, lc) if err != nil { - output.RenderError(err.Error(), outputOptions) - os.Exit(1) + return err } - var dataMain output.Table - err = json.Unmarshal([]byte(returnedJSON), &dataMain) - if err != nil { - output.RenderError(err.Error(), outputOptions) - os.Exit(1) + + if project == nil { + output.RenderInfo(fmt.Sprintf("No details for project '%s'", cmdProjectName), outputOptions) + return nil } - if len(dataMain.Data) == 0 { - output.RenderInfo(fmt.Sprintf("No details for project '%s'", getProjectFlags.Project), outputOptions) - os.Exit(0) + + DevEnvironments := 0 + productionRoute := "none" + deploymentsDisabled, err := strconv.ParseBool(strconv.Itoa(int(project.DeploymentsDisabled))) + handleError(err) + autoIdle, err := strconv.ParseBool(strconv.Itoa(int(project.AutoIdle))) + handleError(err) + factsUI, err := strconv.ParseBool(strconv.Itoa(int(project.FactsUI))) + handleError(err) + problemsUI, err := strconv.ParseBool(strconv.Itoa(int(project.ProblemsUI))) + handleError(err) + for _, environment := range project.Environments { + if environment.EnvironmentType == "development" { + DevEnvironments++ + } + if environment.EnvironmentType == "production" { + productionRoute = environment.Route + } } - output.RenderOutput(dataMain, outputOptions) + data := []output.Data{} + data = append(data, []string{ + returnNonEmptyString(fmt.Sprintf("%d", project.ID)), + returnNonEmptyString(fmt.Sprintf("%v", project.Name)), + returnNonEmptyString(fmt.Sprintf("%v", project.GitURL)), + returnNonEmptyString(fmt.Sprintf("%v", project.Branches)), + returnNonEmptyString(fmt.Sprintf("%v", project.PullRequests)), + returnNonEmptyString(fmt.Sprintf("%v", productionRoute)), + returnNonEmptyString(fmt.Sprintf("%v/%v", DevEnvironments, project.DevelopmentEnvironmentsLimit)), + returnNonEmptyString(fmt.Sprintf("%v", project.DevelopmentEnvironmentsLimit)), + returnNonEmptyString(fmt.Sprintf("%v", project.ProductionEnvironment)), + returnNonEmptyString(fmt.Sprintf("%v", project.RouterPattern)), + returnNonEmptyString(fmt.Sprintf("%v", autoIdle)), + returnNonEmptyString(fmt.Sprintf("%v", factsUI)), + returnNonEmptyString(fmt.Sprintf("%v", problemsUI)), + returnNonEmptyString(fmt.Sprintf("%v", deploymentsDisabled)), + }) + dataMain := output.Table{ + Header: []string{"ID", "ProjectName", "GitURL", "Branches", "PullRequests", "ProductionRoute", "DevEnvironments", "DevEnvLimit", "ProductionEnv", "RouterPattern", "AutoIdle", "FactsUI", "ProblemsUI", "DeploymentsDisabled"}, + Data: data, + } + output.RenderOutput(dataMain, outputOptions) + return nil }, } diff --git a/go.mod b/go.mod index 2d25de43..3bcebbdb 100644 --- a/go.mod +++ b/go.mod @@ -39,6 +39,6 @@ require ( // use this version for fixes to formatting of end header replace github.com/olekukonko/tablewriter => github.com/shreddedbacon/tablewriter v0.0.2-0.20200114082015-d810c4a558bf -// replace github.com/machinebox/graphql => ../../shreddedbacon/graphql +//replace github.com/uselagoon/machinery => ../machinery // replace github.com/olekukonko/tablewriter => ../../shreddedbacon/tablewriter From fb8a37ab6386748463400306eca65a63137a34b1 Mon Sep 17 00:00:00 2001 From: Chris Goodwin <40746380+CGoodwin90@users.noreply.github.com> Date: Tue, 5 Dec 2023 13:58:31 +1100 Subject: [PATCH 5/6] Feature: List Project Groups functionality (#288) Co-authored-by: Ben Jackson --- cmd/list.go | 56 +++++++++++++++++++ docs/commands/lagoon.md | 2 +- docs/commands/lagoon_list.md | 5 +- docs/commands/lagoon_list_backups.md | 2 +- docs/commands/lagoon_list_deployments.md | 2 +- .../lagoon_list_deploytarget-configs.md | 2 +- docs/commands/lagoon_list_deploytargets.md | 2 +- docs/commands/lagoon_list_environments.md | 2 +- docs/commands/lagoon_list_group-projects.md | 2 +- docs/commands/lagoon_list_groups.md | 2 +- docs/commands/lagoon_list_invokable-tasks.md | 2 +- docs/commands/lagoon_list_notification.md | 2 +- docs/commands/lagoon_list_project-groups.md | 39 +++++++++++++ .../lagoon_list_projects-by-metadata.md | 2 +- docs/commands/lagoon_list_projects.md | 2 +- docs/commands/lagoon_list_tasks.md | 2 +- docs/commands/lagoon_list_users.md | 2 +- docs/commands/lagoon_list_variables.md | 2 +- internal/lagoon/client/lgraphql/lgraphql.go | 12 ++-- 19 files changed, 120 insertions(+), 22 deletions(-) create mode 100644 docs/commands/lagoon_list_project-groups.md diff --git a/cmd/list.go b/cmd/list.go index 6c2a23ef..d77f7188 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "os" + "strconv" "github.com/spf13/cobra" "github.com/spf13/pflag" @@ -436,11 +437,66 @@ var listNotificationCmd = &cobra.Command{ }, } +var listProjectGroupsCmd = &cobra.Command{ + Use: "project-groups", + Aliases: []string{"pg"}, + Short: "List groups in a project (alias: pg)", + PreRunE: func(_ *cobra.Command, _ []string) error { + return validateTokenE(lagoonCLIConfig.Current) + }, + RunE: func(cmd *cobra.Command, args []string) error { + debug, err := cmd.Flags().GetBool("debug") + if err != nil { + return err + } + if cmdProjectName == "" { + fmt.Println("Missing arguments: Project is not defined") + cmd.Help() + os.Exit(1) + } + + current := lagoonCLIConfig.Current + token := lagoonCLIConfig.Lagoons[current].Token + lc := lclient.New( + lagoonCLIConfig.Lagoons[current].GraphQL, + lagoonCLIVersion, + &token, + debug) + projectGroups, err := l.GetProjectGroups(context.TODO(), cmdProjectName, lc) + handleError(err) + + if len(projectGroups.Groups) == 0 { + output.RenderInfo(fmt.Sprintf("There are no projects in group '%s'", groupName), outputOptions) + os.Exit(0) + } + + data := []output.Data{} + for _, group := range projectGroups.Groups { + var organization = "null" + if group.Organization != 0 { + organization = strconv.Itoa(group.Organization) + } + data = append(data, []string{ + returnNonEmptyString(fmt.Sprintf("%v", group.ID)), + returnNonEmptyString(fmt.Sprintf("%v", group.Name)), + returnNonEmptyString(fmt.Sprintf("%v", organization)), + }) + } + dataMain := output.Table{ + Header: []string{"Group ID", "Group Name", "Organization"}, + Data: data, + } + output.RenderOutput(dataMain, outputOptions) + return nil + }, +} + func init() { listCmd.AddCommand(listDeployTargetsCmd) listCmd.AddCommand(listDeploymentsCmd) listCmd.AddCommand(listGroupsCmd) listCmd.AddCommand(listGroupProjectsCmd) + listCmd.AddCommand(listProjectGroupsCmd) listCmd.AddCommand(listEnvironmentsCmd) listCmd.AddCommand(listProjectsCmd) listCmd.AddCommand(listNotificationCmd) diff --git a/docs/commands/lagoon.md b/docs/commands/lagoon.md index 6cfb47c0..7ab9ad66 100644 --- a/docs/commands/lagoon.md +++ b/docs/commands/lagoon.md @@ -39,7 +39,7 @@ lagoon [flags] * [lagoon get](lagoon_get.md) - Get info on a resource * [lagoon import](lagoon_import.md) - Import a config from a yaml file * [lagoon kibana](lagoon_kibana.md) - Launch the kibana interface -* [lagoon list](lagoon_list.md) - List projects, deployments, variables or notifications +* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications * [lagoon login](lagoon_login.md) - Log into a Lagoon instance * [lagoon retrieve](lagoon_retrieve.md) - Trigger a retrieval operation on backups * [lagoon run](lagoon_run.md) - Run a task against an environment diff --git a/docs/commands/lagoon_list.md b/docs/commands/lagoon_list.md index 2b48e078..31bdd6ed 100644 --- a/docs/commands/lagoon_list.md +++ b/docs/commands/lagoon_list.md @@ -1,10 +1,10 @@ ## lagoon list -List projects, deployments, variables or notifications +List projects, environments, deployments, variables or notifications ### Synopsis -List projects, deployments, variables or notifications +List projects, environments, deployments, variables or notifications ### Options @@ -42,6 +42,7 @@ List projects, deployments, variables or notifications * [lagoon list groups](lagoon_list_groups.md) - List groups you have access to (alias: g) * [lagoon list invokable-tasks](lagoon_list_invokable-tasks.md) - Print a list of invokable tasks * [lagoon list notification](lagoon_list_notification.md) - List all notifications or notifications on projects +* [lagoon list project-groups](lagoon_list_project-groups.md) - List groups in a project (alias: pg) * [lagoon list projects](lagoon_list_projects.md) - List all projects you have access to (alias: p) * [lagoon list projects-by-metadata](lagoon_list_projects-by-metadata.md) - List projects by a given metadata key or key:value * [lagoon list tasks](lagoon_list_tasks.md) - List tasks for an environment (alias: t) diff --git a/docs/commands/lagoon_list_backups.md b/docs/commands/lagoon_list_backups.md index 962e9c92..6a209b04 100644 --- a/docs/commands/lagoon_list_backups.md +++ b/docs/commands/lagoon_list_backups.md @@ -35,5 +35,5 @@ lagoon list backups [flags] ### SEE ALSO -* [lagoon list](lagoon_list.md) - List projects, deployments, variables or notifications +* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications diff --git a/docs/commands/lagoon_list_deployments.md b/docs/commands/lagoon_list_deployments.md index 6175372a..25a09aff 100644 --- a/docs/commands/lagoon_list_deployments.md +++ b/docs/commands/lagoon_list_deployments.md @@ -35,5 +35,5 @@ lagoon list deployments [flags] ### SEE ALSO -* [lagoon list](lagoon_list.md) - List projects, deployments, variables or notifications +* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications diff --git a/docs/commands/lagoon_list_deploytarget-configs.md b/docs/commands/lagoon_list_deploytarget-configs.md index d3806da4..723d714e 100644 --- a/docs/commands/lagoon_list_deploytarget-configs.md +++ b/docs/commands/lagoon_list_deploytarget-configs.md @@ -35,5 +35,5 @@ lagoon list deploytarget-configs [flags] ### SEE ALSO -* [lagoon list](lagoon_list.md) - List projects, deployments, variables or notifications +* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications diff --git a/docs/commands/lagoon_list_deploytargets.md b/docs/commands/lagoon_list_deploytargets.md index eb899903..3791e812 100644 --- a/docs/commands/lagoon_list_deploytargets.md +++ b/docs/commands/lagoon_list_deploytargets.md @@ -35,5 +35,5 @@ lagoon list deploytargets [flags] ### SEE ALSO -* [lagoon list](lagoon_list.md) - List projects, deployments, variables or notifications +* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications diff --git a/docs/commands/lagoon_list_environments.md b/docs/commands/lagoon_list_environments.md index 504151f2..5186199d 100644 --- a/docs/commands/lagoon_list_environments.md +++ b/docs/commands/lagoon_list_environments.md @@ -35,5 +35,5 @@ lagoon list environments [flags] ### SEE ALSO -* [lagoon list](lagoon_list.md) - List projects, deployments, variables or notifications +* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications diff --git a/docs/commands/lagoon_list_group-projects.md b/docs/commands/lagoon_list_group-projects.md index a1213b98..803d32db 100644 --- a/docs/commands/lagoon_list_group-projects.md +++ b/docs/commands/lagoon_list_group-projects.md @@ -36,5 +36,5 @@ lagoon list group-projects [flags] ### SEE ALSO -* [lagoon list](lagoon_list.md) - List projects, deployments, variables or notifications +* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications diff --git a/docs/commands/lagoon_list_groups.md b/docs/commands/lagoon_list_groups.md index 40f5cf53..cad64322 100644 --- a/docs/commands/lagoon_list_groups.md +++ b/docs/commands/lagoon_list_groups.md @@ -35,5 +35,5 @@ lagoon list groups [flags] ### SEE ALSO -* [lagoon list](lagoon_list.md) - List projects, deployments, variables or notifications +* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications diff --git a/docs/commands/lagoon_list_invokable-tasks.md b/docs/commands/lagoon_list_invokable-tasks.md index 0c27bef6..77e92550 100644 --- a/docs/commands/lagoon_list_invokable-tasks.md +++ b/docs/commands/lagoon_list_invokable-tasks.md @@ -35,5 +35,5 @@ lagoon list invokable-tasks [flags] ### SEE ALSO -* [lagoon list](lagoon_list.md) - List projects, deployments, variables or notifications +* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications diff --git a/docs/commands/lagoon_list_notification.md b/docs/commands/lagoon_list_notification.md index 5b4f86b5..f89a4300 100644 --- a/docs/commands/lagoon_list_notification.md +++ b/docs/commands/lagoon_list_notification.md @@ -31,7 +31,7 @@ List all notifications or notifications on projects ### SEE ALSO -* [lagoon list](lagoon_list.md) - List projects, deployments, variables or notifications +* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications * [lagoon list notification email](lagoon_list_notification_email.md) - List all email notification details (alias: e) * [lagoon list notification microsoftteams](lagoon_list_notification_microsoftteams.md) - List all Microsoft Teams notification details (alias: m) * [lagoon list notification project-email](lagoon_list_notification_project-email.md) - List email details about a project (alias: pe) diff --git a/docs/commands/lagoon_list_project-groups.md b/docs/commands/lagoon_list_project-groups.md new file mode 100644 index 00000000..9bfb2d13 --- /dev/null +++ b/docs/commands/lagoon_list_project-groups.md @@ -0,0 +1,39 @@ +## lagoon list project-groups + +List groups in a project (alias: pg) + +### Synopsis + +List groups in a project (alias: pg) + +``` +lagoon list project-groups [flags] +``` + +### Options + +``` + -h, --help help for project-groups +``` + +### Options inherited from parent commands + +``` + --config-file string Path to the config file to use (must be *.yml or *.yaml) + --debug Enable debugging output (if supported) + -e, --environment string Specify an environment to use + --force Force yes on prompts (if supported) + -l, --lagoon string The Lagoon instance to interact with + --no-header No header on table (if supported) + --output-csv Output as CSV (if supported) + --output-json Output as JSON (if supported) + --pretty Make JSON pretty (if supported) + -p, --project string Specify a project to use + --skip-update-check Skip checking for updates + -i, --ssh-key string Specify path to a specific SSH key to use for lagoon authentication +``` + +### SEE ALSO + +* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications + diff --git a/docs/commands/lagoon_list_projects-by-metadata.md b/docs/commands/lagoon_list_projects-by-metadata.md index ca245d5e..981142ac 100644 --- a/docs/commands/lagoon_list_projects-by-metadata.md +++ b/docs/commands/lagoon_list_projects-by-metadata.md @@ -38,5 +38,5 @@ lagoon list projects-by-metadata [flags] ### SEE ALSO -* [lagoon list](lagoon_list.md) - List projects, deployments, variables or notifications +* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications diff --git a/docs/commands/lagoon_list_projects.md b/docs/commands/lagoon_list_projects.md index 7b9fa690..ba3b8559 100644 --- a/docs/commands/lagoon_list_projects.md +++ b/docs/commands/lagoon_list_projects.md @@ -35,5 +35,5 @@ lagoon list projects [flags] ### SEE ALSO -* [lagoon list](lagoon_list.md) - List projects, deployments, variables or notifications +* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications diff --git a/docs/commands/lagoon_list_tasks.md b/docs/commands/lagoon_list_tasks.md index 6d3aac8c..11e2fe80 100644 --- a/docs/commands/lagoon_list_tasks.md +++ b/docs/commands/lagoon_list_tasks.md @@ -35,5 +35,5 @@ lagoon list tasks [flags] ### SEE ALSO -* [lagoon list](lagoon_list.md) - List projects, deployments, variables or notifications +* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications diff --git a/docs/commands/lagoon_list_users.md b/docs/commands/lagoon_list_users.md index 7a22d8d7..7988ae11 100644 --- a/docs/commands/lagoon_list_users.md +++ b/docs/commands/lagoon_list_users.md @@ -36,5 +36,5 @@ lagoon list users [flags] ### SEE ALSO -* [lagoon list](lagoon_list.md) - List projects, deployments, variables or notifications +* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications diff --git a/docs/commands/lagoon_list_variables.md b/docs/commands/lagoon_list_variables.md index a4c01425..59f6eed4 100644 --- a/docs/commands/lagoon_list_variables.md +++ b/docs/commands/lagoon_list_variables.md @@ -36,5 +36,5 @@ lagoon list variables [flags] ### SEE ALSO -* [lagoon list](lagoon_list.md) - List projects, deployments, variables or notifications +* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications diff --git a/internal/lagoon/client/lgraphql/lgraphql.go b/internal/lagoon/client/lgraphql/lgraphql.go index f246b0f1..5c965f9e 100644 --- a/internal/lagoon/client/lgraphql/lgraphql.go +++ b/internal/lagoon/client/lgraphql/lgraphql.go @@ -1432,11 +1432,13 @@ var _bindata = map[string]func() (*asset, error){ // directory embedded in the file by go-bindata. // For example if you run go-bindata on data/... and data contains the // following hierarchy: -// data/ -// foo.txt -// img/ -// a.png -// b.png +// +// data/ +// foo.txt +// img/ +// a.png +// b.png +// // then AssetDir("data") would return []string{"foo.txt", "img"} // AssetDir("data/img") would return []string{"a.png", "b.png"} // AssetDir("foo.txt") and AssetDir("notexist") would return an error From eeb83b5b54f8d56bbf342e604e6b18fdab25d28e Mon Sep 17 00:00:00 2001 From: Chris Goodwin <40746380+CGoodwin90@users.noreply.github.com> Date: Tue, 5 Dec 2023 15:03:03 +1100 Subject: [PATCH 6/6] Fix: Fixes & refactors `user-sshkey` commands (#303) --- cmd/users.go | 159 ++++++++++++++++----- docs/commands/lagoon_delete_user-sshkey.md | 4 +- docs/commands/lagoon_get_user-sshkeys.md | 1 - pkg/lagoon/users/main.go | 2 - pkg/lagoon/users/users.go | 70 --------- 5 files changed, 128 insertions(+), 108 deletions(-) diff --git a/cmd/users.go b/cmd/users.go index 1178213b..72b306e2 100644 --- a/cmd/users.go +++ b/cmd/users.go @@ -1,11 +1,16 @@ package cmd import ( + "context" "encoding/json" "errors" "fmt" + l "github.com/uselagoon/machinery/api/lagoon" + lclient "github.com/uselagoon/machinery/api/lagoon/client" + s "github.com/uselagoon/machinery/api/schema" "io/ioutil" "os" + "strconv" "strings" "github.com/spf13/cobra" @@ -147,22 +152,36 @@ var deleteSSHKeyCmd = &cobra.Command{ Use: "user-sshkey", Aliases: []string{"u"}, Short: "Delete an SSH key from Lagoon", - Run: func(cmd *cobra.Command, args []string) { - if sshKeyName == "" { - fmt.Println("Missing arguments: SSH key name is not defined") - cmd.Help() - os.Exit(1) + PreRunE: func(_ *cobra.Command, _ []string) error { + return validateTokenE(cmdLagoon) + }, + RunE: func(cmd *cobra.Command, args []string) error { + debug, err := cmd.Flags().GetBool("debug") + sshKeyID, err := cmd.Flags().GetUint("id") + if err != nil { + return err } - var customReqResult []byte - var err error - if yesNo(fmt.Sprintf("You are attempting to delete SSH key named '%s', are you sure?", sshKeyName)) { - customReqResult, err = uClient.DeleteSSHKey(sshKeyName) + if sshKeyID == 0 { + fmt.Println("Missing arguments: SSH key ID is not defined") + return nil + } + current := lagoonCLIConfig.Current + token := lagoonCLIConfig.Lagoons[current].Token + lc := lclient.New( + lagoonCLIConfig.Lagoons[current].GraphQL, + lagoonCLIVersion, + &token, + debug) + + if yesNo(fmt.Sprintf("You are attempting to delete SSH key ID:'%d', are you sure?", sshKeyID)) { + _, err := l.RemoveSSHKey(context.TODO(), sshKeyID, lc) handleError(err) resultData := output.Result{ - Result: string(customReqResult), + Result: "success", } output.RenderResult(resultData, outputOptions) } + return nil }, } @@ -226,23 +245,55 @@ var getUserKeysCmd = &cobra.Command{ Aliases: []string{"us"}, Short: "Get a user's SSH keys", Long: `Get a user's SSH keys. This will only work for users that are part of a group`, - Run: func(cmd *cobra.Command, args []string) { + PreRunE: func(_ *cobra.Command, _ []string) error { + return validateTokenE(cmdLagoon) + }, + RunE: func(cmd *cobra.Command, args []string) error { + debug, err := cmd.Flags().GetBool("debug") + if err != nil { + return err + } + userEmail, err := cmd.Flags().GetString("email") + if err != nil { + return err + } if userEmail == "" { fmt.Println("Missing arguments: Email address is not defined") - cmd.Help() - os.Exit(1) + return nil } - returnedJSON, err := uClient.ListUserSSHKeys(groupName, strings.ToLower(userEmail), false) - handleError(err) - var dataMain output.Table - err = json.Unmarshal([]byte(returnedJSON), &dataMain) + + current := lagoonCLIConfig.Current + token := lagoonCLIConfig.Lagoons[current].Token + lc := lclient.New( + lagoonCLIConfig.Lagoons[current].GraphQL, + lagoonCLIVersion, + &token, + debug) + userKeys, err := l.GetUserSSHKeysByEmail(context.TODO(), userEmail, lc) handleError(err) - if len(dataMain.Data) == 0 { + if len(userKeys.SSHKeys) == 0 { output.RenderInfo(fmt.Sprintf("No SSH keys for user '%s'", strings.ToLower(userEmail)), outputOptions) - os.Exit(0) + return nil } - output.RenderOutput(dataMain, outputOptions) + data := []output.Data{} + for _, userkey := range userKeys.SSHKeys { + data = append(data, []string{ + strconv.Itoa(int(userkey.ID)), + userKeys.Email, + userkey.Name, + string(userkey.KeyType), + userkey.KeyValue, + }) + } + + dataMain := output.Table{ + Header: []string{"ID", "Email", "Name", "Type", "Value"}, + Data: data, + } + + output.RenderOutput(dataMain, outputOptions) + return nil }, } @@ -252,18 +303,61 @@ var getAllUserKeysCmd = &cobra.Command{ Aliases: []string{"aus"}, Short: "Get all user SSH keys", Long: `Get all user SSH keys. This will only work for users that are part of a group`, - Run: func(cmd *cobra.Command, args []string) { - returnedJSON, err := uClient.ListUserSSHKeys(groupName, strings.ToLower(userEmail), true) - handleError(err) - var dataMain output.Table - err = json.Unmarshal([]byte(returnedJSON), &dataMain) + PreRunE: func(_ *cobra.Command, _ []string) error { + return validateTokenE(cmdLagoon) + }, + RunE: func(cmd *cobra.Command, args []string) error { + debug, err := cmd.Flags().GetBool("debug") + if err != nil { + return err + } + groupName, err := cmd.Flags().GetString("name") + if err != nil { + return err + } + + current := lagoonCLIConfig.Current + token := lagoonCLIConfig.Lagoons[current].Token + lc := lclient.New( + lagoonCLIConfig.Lagoons[current].GraphQL, + lagoonCLIVersion, + &token, + debug) + groupMembers, err := l.ListAllGroupMembersWithKeys(context.TODO(), groupName, lc) handleError(err) - if len(dataMain.Data) == 0 { - output.RenderInfo("No SSH keys for any users", outputOptions) - os.Exit(0) + + var userGroups []s.AddSSHKeyInput + for _, group := range *groupMembers { + for _, member := range group.Members { + for _, key := range member.User.SSHKeys { + userGroups = append(userGroups, s.AddSSHKeyInput{SSHKey: key, UserEmail: member.User.Email}) + } + } } - output.RenderOutput(dataMain, outputOptions) + var data []output.Data + for _, userData := range userGroups { + keyID := strconv.Itoa(int(userData.SSHKey.ID)) + userEmail := returnNonEmptyString(strings.Replace(userData.UserEmail, " ", "_", -1)) + keyName := returnNonEmptyString(strings.Replace(userData.SSHKey.Name, " ", "_", -1)) + keyValue := returnNonEmptyString(strings.Replace(userData.SSHKey.KeyValue, " ", "_", -1)) + keyType := returnNonEmptyString(strings.Replace(string(userData.SSHKey.KeyType), " ", "_", -1)) + data = append(data, []string{ + keyID, + userEmail, + keyName, + keyType, + keyValue, + }) + } + + dataMain := output.Table{ + Header: []string{"ID", "Email", "Name", "Type", "Value"}, + Data: data, + } + + output.RenderOutput(dataMain, outputOptions) + return nil }, } @@ -281,12 +375,11 @@ func init() { addUserSSHKeyCmd.Flags().StringVarP(&pubKeyFile, "pubkey", "K", "", "Specify path to the public key to add") addUserSSHKeyCmd.Flags().StringVarP(&pubKeyValue, "keyvalue", "V", "", "Value of the public key to add (ssh-ed25519 AAA..)") deleteUserCmd.Flags().StringVarP(&userEmail, "email", "E", "", "Email address of the user") - deleteSSHKeyCmd.Flags().StringVarP(&sshKeyName, "keyname", "N", "", "Name of the SSH key") + deleteSSHKeyCmd.Flags().Uint("id", 0, "ID of the SSH key") updateUserCmd.Flags().StringVarP(&userFirstName, "firstName", "F", "", "New first name of the user") updateUserCmd.Flags().StringVarP(&userLastName, "lastName", "L", "", "New last name of the user") updateUserCmd.Flags().StringVarP(&userEmail, "email", "E", "", "New email address of the user") updateUserCmd.Flags().StringVarP(¤tUserEmail, "current-email", "C", "", "Current email address of the user") - getUserKeysCmd.Flags().StringVarP(&userEmail, "email", "E", "", "New email address of the user") - getUserKeysCmd.Flags().StringVarP(&groupName, "name", "N", "", "Name of the group to check users in (if not specified, will default to all groups)") - getAllUserKeysCmd.Flags().StringVarP(&groupName, "name", "N", "", "Name of the group to list users in (if not specified, will default to all groups)") + getUserKeysCmd.Flags().StringP("email", "E", "", "New email address of the user") + getAllUserKeysCmd.Flags().StringP("name", "N", "", "Name of the group to list users in (if not specified, will default to all groups)") } diff --git a/docs/commands/lagoon_delete_user-sshkey.md b/docs/commands/lagoon_delete_user-sshkey.md index cb7184e9..3c08eaaf 100644 --- a/docs/commands/lagoon_delete_user-sshkey.md +++ b/docs/commands/lagoon_delete_user-sshkey.md @@ -13,8 +13,8 @@ lagoon delete user-sshkey [flags] ### Options ``` - -h, --help help for user-sshkey - -N, --keyname string Name of the SSH key + -h, --help help for user-sshkey + --id uint ID of the SSH key ``` ### Options inherited from parent commands diff --git a/docs/commands/lagoon_get_user-sshkeys.md b/docs/commands/lagoon_get_user-sshkeys.md index dd396691..c38f2c3a 100644 --- a/docs/commands/lagoon_get_user-sshkeys.md +++ b/docs/commands/lagoon_get_user-sshkeys.md @@ -15,7 +15,6 @@ lagoon get user-sshkeys [flags] ``` -E, --email string New email address of the user -h, --help help for user-sshkeys - -N, --name string Name of the group to check users in (if not specified, will default to all groups) ``` ### Options inherited from parent commands diff --git a/pkg/lagoon/users/main.go b/pkg/lagoon/users/main.go index 4afa8fb6..39d40039 100644 --- a/pkg/lagoon/users/main.go +++ b/pkg/lagoon/users/main.go @@ -23,10 +23,8 @@ type Client interface { ListUsers(string) ([]byte, error) AddUser(api.User) ([]byte, error) AddSSHKeyToUser(api.User, api.SSHKey) ([]byte, error) - DeleteSSHKey(string) ([]byte, error) DeleteUser(api.User) ([]byte, error) ModifyUser(api.User, api.User) ([]byte, error) - ListUserSSHKeys(string, string, bool) ([]byte, error) ListGroups(string) ([]byte, error) ListGroupProjects(string, bool) ([]byte, error) } diff --git a/pkg/lagoon/users/users.go b/pkg/lagoon/users/users.go index c4c15897..1cf3ea5a 100644 --- a/pkg/lagoon/users/users.go +++ b/pkg/lagoon/users/users.go @@ -61,24 +61,6 @@ func (u *Users) AddSSHKeyToUser(user api.User, sshKey api.SSHKey) ([]byte, error return returnResult, nil } -// DeleteSSHKey function -func (u *Users) DeleteSSHKey(keyName string) ([]byte, error) { - customReq := api.CustomRequest{ - Query: `mutation deleteSshKey ($keyname: String!) { - deleteSshKey(input:{name: $keyname}) - }`, - Variables: map[string]interface{}{ - "keyname": keyName, - }, - MappedResult: "deleteSshKey", - } - returnResult, err := u.api.Request(customReq) - if err != nil { - return []byte(""), err - } - return returnResult, nil -} - // DeleteUser function func (u *Users) DeleteUser(user api.User) ([]byte, error) { customReq := api.CustomRequest{ @@ -212,58 +194,6 @@ func processUserList(listUsers []byte) ([]byte, error) { return json.Marshal(dataMain) } -// ListUserSSHKeys function -func (u *Users) ListUserSSHKeys(groupName string, email string, allUsers bool) ([]byte, error) { - //@TODO: once individual user interaction comes in, this will need to be adjusted - customReq := api.CustomRequest{ - Query: `query allGroups ($name: String) { - allGroups (name: $name) { - name - id - members{ - user{ - id - email - firstName - lastName - sshKeys{ - name - keyType - keyValue - } - } - role - } - } - }`, - Variables: map[string]interface{}{ - "name": groupName, - }, - MappedResult: "allGroups", - } - listUsers, err := u.api.Request(customReq) - if err != nil { - return []byte(""), err - } - returnedKeys, err := processReturnedUserKeysList(listUsers) - if err != nil { - return []byte(""), err - } - var returnResult []byte - if allUsers { - returnResult, err = processAllUserKeysList(returnedKeys) - if err != nil { - return []byte(""), err - } - } else { - returnResult, err = processUserKeysList(returnedKeys, email) - if err != nil { - return []byte(""), err - } - } - return returnResult, nil -} - func processReturnedUserKeysList(listUsers []byte) ([]ExtendedSSHKey, error) { var groupMembers GroupMembers userDataStep1 := []ExtendedSSHKey{}