Skip to content

Commit

Permalink
chore: remove short import references for machinery
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon committed Jun 16, 2024
1 parent 82f897e commit 050a394
Show file tree
Hide file tree
Showing 20 changed files with 305 additions and 299 deletions.
23 changes: 12 additions & 11 deletions cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package cmd
import (
"context"
"fmt"
lclient "github.com/uselagoon/machinery/api/lagoon/client"
"strconv"

lclient "github.com/uselagoon/machinery/api/lagoon/client"

"github.com/spf13/cobra"
l "github.com/uselagoon/machinery/api/lagoon"
ls "github.com/uselagoon/machinery/api/schema"
"github.com/uselagoon/machinery/api/lagoon"
"github.com/uselagoon/machinery/api/schema"
)

var deployCmd = &cobra.Command{
Expand Down Expand Up @@ -66,7 +67,7 @@ use 'lagoon deploy latest' instead`,
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)
depBranch := &ls.DeployEnvironmentBranchInput{
depBranch := &schema.DeployEnvironmentBranchInput{
Branch: branch,
Project: cmdProjectName,
ReturnData: returnData,
Expand All @@ -75,7 +76,7 @@ use 'lagoon deploy latest' instead`,
if branchRef != "" {
depBranch.BranchRef = branchRef
}
result, err := l.DeployBranch(context.TODO(), depBranch, lc)
result, err := lagoon.DeployBranch(context.TODO(), depBranch, lc)
if err != nil {
return err
}
Expand Down Expand Up @@ -132,7 +133,7 @@ var deployPromoteCmd = &cobra.Command{
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)
result, err := l.DeployPromote(context.TODO(), &ls.DeployEnvironmentPromoteInput{
result, err := lagoon.DeployPromote(context.TODO(), &schema.DeployEnvironmentPromoteInput{
SourceEnvironment: sourceEnvironment,
DestinationEnvironment: destinationEnvironment,
Project: cmdProjectName,
Expand Down Expand Up @@ -187,10 +188,10 @@ This environment should already exist in lagoon. It is analogous with the 'Deplo
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)
result, err := l.DeployLatest(context.TODO(), &ls.DeployEnvironmentLatestInput{
Environment: ls.EnvironmentInput{
result, err := lagoon.DeployLatest(context.TODO(), &schema.DeployEnvironmentLatestInput{
Environment: schema.EnvironmentInput{
Name: cmdProjectEnvironment,
Project: ls.ProjectInput{
Project: schema.ProjectInput{
Name: cmdProjectName,
},
},
Expand Down Expand Up @@ -271,8 +272,8 @@ This pullrequest may not already exist as an environment in lagoon.`,
&token,
debug)

result, err := l.DeployPullRequest(context.TODO(), &ls.DeployEnvironmentPullrequestInput{
Project: ls.ProjectInput{
result, err := lagoon.DeployPullRequest(context.TODO(), &schema.DeployEnvironmentPullrequestInput{
Project: schema.ProjectInput{
Name: cmdProjectName,
},
Title: prTitle,
Expand Down
30 changes: 15 additions & 15 deletions cmd/deploytarget.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (

"github.com/spf13/cobra"
"github.com/uselagoon/lagoon-cli/pkg/output"
l "github.com/uselagoon/machinery/api/lagoon"
"github.com/uselagoon/machinery/api/lagoon"
lclient "github.com/uselagoon/machinery/api/lagoon/client"
ls "github.com/uselagoon/machinery/api/schema"
"github.com/uselagoon/machinery/api/schema"
)

var addDeployTargetCmd = &cobra.Command{
Expand Down Expand Up @@ -66,7 +66,7 @@ var addDeployTargetCmd = &cobra.Command{
return err
}

addDeployTarget := &ls.AddDeployTargetInput{
addDeployTarget := &schema.AddDeployTargetInput{
Name: name,
FriendlyName: friendlyName,
CloudProvider: cloudProvider,
Expand Down Expand Up @@ -99,7 +99,7 @@ var addDeployTargetCmd = &cobra.Command{
debug)

if yesNo(fmt.Sprintf("You are attempting to add '%s' DeployTarget, are you sure?", addDeployTarget.Name)) {
addDeployTargetResponse, err := l.AddDeployTarget(context.TODO(), addDeployTarget, lc)
addDeployTargetResponse, err := lagoon.AddDeployTarget(context.TODO(), addDeployTarget, lc)
if err != nil {
return err
}
Expand Down Expand Up @@ -216,8 +216,8 @@ var updateDeployTargetCmd = &cobra.Command{
&lagoonToken,
debug)

updateDeployTarget := &ls.UpdateDeployTargetInput{
AddDeployTargetInput: ls.AddDeployTargetInput{
updateDeployTarget := &schema.UpdateDeployTargetInput{
AddDeployTargetInput: schema.AddDeployTargetInput{
ID: id,
Token: token,
FriendlyName: friendlyName,
Expand All @@ -231,7 +231,7 @@ var updateDeployTargetCmd = &cobra.Command{
BuildImage: buildImage,
}
if yesNo(fmt.Sprintf("You are attempting to update '%d' DeployTarget, are you sure?", updateDeployTarget.ID)) {
updateDeployTargetResponse, err := l.UpdateDeployTarget(context.TODO(), updateDeployTarget, lc)
updateDeployTargetResponse, err := lagoon.UpdateDeployTarget(context.TODO(), updateDeployTarget, lc)
if err != nil {
return err
}
Expand Down Expand Up @@ -307,11 +307,11 @@ var deleteDeployTargetCmd = &cobra.Command{
&token,
debug)

deleteDeployTarget := &ls.DeleteDeployTargetInput{
deleteDeployTarget := &schema.DeleteDeployTargetInput{
Name: name,
}
if yesNo(fmt.Sprintf("You are attempting to delete DeployTarget '%s', are you sure?", deleteDeployTarget.Name)) {
deleteDeployTargetResponse, err := l.DeleteDeployTarget(context.TODO(), deleteDeployTarget, lc)
deleteDeployTargetResponse, err := lagoon.DeleteDeployTarget(context.TODO(), deleteDeployTarget, lc)
if err != nil {
return err
}
Expand Down Expand Up @@ -358,20 +358,20 @@ var addDeployTargetToOrganizationCmd = &cobra.Command{
&token,
debug)

organization, err := l.GetOrganizationByName(context.TODO(), organizationName, lc)
organization, err := lagoon.GetOrganizationByName(context.TODO(), organizationName, lc)
if err != nil {
return err
}
if organization.Name == "" {
return fmt.Errorf("error querying organization by name")
}

deployTargetInput := ls.AddDeployTargetToOrganizationInput{
deployTargetInput := schema.AddDeployTargetToOrganizationInput{
DeployTarget: deploytarget,
Organization: organization.ID,
}

deployTargetResponse, err := l.AddDeployTargetToOrganization(context.TODO(), &deployTargetInput, lc)
deployTargetResponse, err := lagoon.AddDeployTargetToOrganization(context.TODO(), &deployTargetInput, lc)
if err != nil {
return err
}
Expand Down Expand Up @@ -422,21 +422,21 @@ var removeDeployTargetFromOrganizationCmd = &cobra.Command{
&token,
debug)

organization, err := l.GetOrganizationByName(context.TODO(), organizationName, lc)
organization, err := lagoon.GetOrganizationByName(context.TODO(), organizationName, lc)
if err != nil {
return err
}
if organization.Name == "" {
return fmt.Errorf("error querying organization by name")
}

deployTargetInput := ls.RemoveDeployTargetFromOrganizationInput{
deployTargetInput := schema.RemoveDeployTargetFromOrganizationInput{
DeployTarget: deploytarget,
Organization: organization.ID,
}

if yesNo(fmt.Sprintf("You are attempting to remove deploy target '%d' from organization '%s', are you sure?", deploytarget, organization.Name)) {
_, err := l.RemoveDeployTargetFromOrganization(context.TODO(), &deployTargetInput, lc)
_, err := lagoon.RemoveDeployTargetFromOrganization(context.TODO(), &deployTargetInput, lc)
if err != nil {
return err
}
Expand Down
25 changes: 13 additions & 12 deletions cmd/deploytargetconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import (
"context"
"fmt"

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

"github.com/uselagoon/machinery/api/lagoon"
lclient "github.com/uselagoon/machinery/api/lagoon/client"
"github.com/uselagoon/machinery/api/schema"

"github.com/spf13/cobra"
"github.com/uselagoon/lagoon-cli/pkg/output"
)
Expand Down Expand Up @@ -56,11 +57,11 @@ var addDeployTargetConfigCmd = &cobra.Command{
&token,
debug)

project, err := l.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc)
project, err := lagoon.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc)
if err != nil {
return err
}
addDeployTargetConfig := &ls.AddDeployTargetConfigInput{
addDeployTargetConfig := &schema.AddDeployTargetConfigInput{
Project: project.ID,
Weight: weight,
}
Expand All @@ -74,7 +75,7 @@ var addDeployTargetConfigCmd = &cobra.Command{
addDeployTargetConfig.DeployTarget = deploytarget
}
if yesNo(fmt.Sprintf("You are attempting to add a deploytarget configuration to project '%s', are you sure?", cmdProjectName)) {
deployTargetConfig, err := l.AddDeployTargetConfiguration(context.TODO(), addDeployTargetConfig, lc)
deployTargetConfig, err := lagoon.AddDeployTargetConfiguration(context.TODO(), addDeployTargetConfig, lc)
if err != nil {
return err
}
Expand Down Expand Up @@ -153,7 +154,7 @@ var updateDeployTargetConfigCmd = &cobra.Command{
&token,
debug)

updateDeployTargetConfig := &ls.UpdateDeployTargetConfigInput{
updateDeployTargetConfig := &schema.UpdateDeployTargetConfigInput{
ID: id,
Weight: weight,
}
Expand All @@ -168,7 +169,7 @@ var updateDeployTargetConfigCmd = &cobra.Command{
}

if yesNo(fmt.Sprintf("You are attempting to update a deploytarget configuration with id '%d', are you sure?", id)) {
deployTargetConfig, err := l.UpdateDeployTargetConfiguration(context.TODO(), updateDeployTargetConfig, lc)
deployTargetConfig, err := lagoon.UpdateDeployTargetConfiguration(context.TODO(), updateDeployTargetConfig, lc)
if err != nil {
return err
}
Expand Down Expand Up @@ -231,7 +232,7 @@ var deleteDeployTargetConfigCmd = &cobra.Command{
&token,
debug)

project, err := l.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc)
project, err := lagoon.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc)
if err != nil {
return err
}
Expand All @@ -242,7 +243,7 @@ var deleteDeployTargetConfigCmd = &cobra.Command{
}

if yesNo(fmt.Sprintf("You are attempting to delete deploytarget configuration with id '%d' from project '%s', are you sure?", id, cmdProjectName)) {
result, err := l.DeleteDeployTargetConfiguration(context.TODO(), int(id), int(project.ID), lc)
result, err := lagoon.DeleteDeployTargetConfiguration(context.TODO(), int(id), int(project.ID), lc)
if err != nil {
return err
}
Expand Down Expand Up @@ -279,7 +280,7 @@ var listDeployTargetConfigsCmd = &cobra.Command{
&token,
debug)

project, err := l.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc)
project, err := lagoon.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc)
if err != nil {
return err
}
Expand All @@ -288,7 +289,7 @@ var listDeployTargetConfigsCmd = &cobra.Command{
output.RenderError(outputOptions.Error, outputOptions)
return nil
}
deployTargetConfigs, err := l.GetDeployTargetConfigs(context.TODO(), int(project.ID), lc)
deployTargetConfigs, err := lagoon.GetDeployTargetConfigs(context.TODO(), int(project.ID), lc)
if err != nil {
return err
}
Expand Down
31 changes: 16 additions & 15 deletions cmd/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package cmd
import (
"context"
"fmt"
ls "github.com/uselagoon/machinery/api/schema"
"strings"

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

"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/uselagoon/lagoon-cli/pkg/output"
l "github.com/uselagoon/machinery/api/lagoon"
"github.com/uselagoon/machinery/api/lagoon"
lclient "github.com/uselagoon/machinery/api/lagoon/client"
)

Expand Down Expand Up @@ -42,7 +43,7 @@ var deleteEnvCmd = &cobra.Command{
&token,
debug)
if yesNo(fmt.Sprintf("You are attempting to delete environment '%s' from project '%s', are you sure?", cmdProjectEnvironment, cmdProjectName)) {
environment, err := l.DeleteEnvironment(context.TODO(), cmdProjectEnvironment, cmdProjectName, true, lc)
environment, err := lagoon.DeleteEnvironment(context.TODO(), cmdProjectEnvironment, cmdProjectName, true, lc)
if err != nil {
return err
}
Expand Down Expand Up @@ -118,22 +119,22 @@ var updateEnvironmentCmd = &cobra.Command{
lagoonCLIConfig.Lagoons[current].Version,
&token,
debug)
project, err := l.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc)
project, err := lagoon.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc)
if project.Name == "" {
err = fmt.Errorf("project not found")
}
if err != nil {
return err
}
environment, err := l.GetEnvironmentByName(context.TODO(), cmdProjectEnvironment, project.ID, lc)
environment, err := lagoon.GetEnvironmentByName(context.TODO(), cmdProjectEnvironment, project.ID, lc)
if environment.Name == "" {
err = fmt.Errorf("environment not found")
}
if err != nil {
return err
}

environmentFlags := ls.UpdateEnvironmentPatchInput{
environmentFlags := schema.UpdateEnvironmentPatchInput{
DeployBaseRef: nullStrCheck(deployBaseRef),
DeployHeadRef: nullStrCheck(deployHeadRef),
OpenshiftProjectName: nullStrCheck(namespace),
Expand All @@ -146,21 +147,21 @@ var updateEnvironmentCmd = &cobra.Command{
environmentFlags.AutoIdle = &environmentAutoIdle
}
if environmentType != "" {
envType := ls.EnvType(strings.ToUpper(environmentType))
if validationErr := ls.ValidateType(envType); validationErr != nil {
envType := schema.EnvType(strings.ToUpper(environmentType))
if validationErr := schema.ValidateType(envType); validationErr != nil {
handleError(validationErr)
}
environmentFlags.EnvironmentType = &envType
}
if deployT != "" {
deployType := ls.DeployType(strings.ToUpper(deployT))
if validationErr := ls.ValidateType(deployType); validationErr != nil {
deployType := schema.DeployType(strings.ToUpper(deployT))
if validationErr := schema.ValidateType(deployType); validationErr != nil {
handleError(validationErr)
}
environmentFlags.DeployType = &deployType
}

result, err := l.UpdateEnvironment(context.TODO(), environment.ID, environmentFlags, lc)
result, err := lagoon.UpdateEnvironment(context.TODO(), environment.ID, environmentFlags, lc)
if err != nil {
return err
}
Expand Down Expand Up @@ -207,11 +208,11 @@ var listBackupsCmd = &cobra.Command{
&token,
debug)

project, err := l.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc)
project, err := lagoon.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc)
if err != nil {
return err
}
backupsResult, err := l.GetBackupsForEnvironmentByName(context.TODO(), cmdProjectEnvironment, project.ID, lc)
backupsResult, err := lagoon.GetBackupsForEnvironmentByName(context.TODO(), cmdProjectEnvironment, project.ID, lc)
if err != nil {
return err
}
Expand Down Expand Up @@ -277,11 +278,11 @@ This returns a direct URL to the backup, this is a signed download link with a l
&token,
debug)

project, err := l.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc)
project, err := lagoon.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc)
if err != nil {
return err
}
backupsResult, err := l.GetBackupsForEnvironmentByName(context.TODO(), cmdProjectEnvironment, project.ID, lc)
backupsResult, err := lagoon.GetBackupsForEnvironmentByName(context.TODO(), cmdProjectEnvironment, project.ID, lc)
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit 050a394

Please sign in to comment.