Skip to content

Commit

Permalink
Fixed additional commands
Browse files Browse the repository at this point in the history
  • Loading branch information
CGoodwin90 committed Oct 31, 2023
1 parent 67c59a8 commit 8395256
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
17 changes: 10 additions & 7 deletions cmd/deploytargetconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -48,31 +51,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
}
Expand Down
20 changes: 10 additions & 10 deletions cmd/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 8395256

Please sign in to comment.