Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

refacto to split cmd and functions #379

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

baalooos
Copy link

First part of ticket "Create Preview environments via CLI"

Split CMD and functions for:

  • application update
  • environment clone
  • environment update

panic("unreachable") // staticcheck false positive: https://staticcheck.io/docs/checks#SA5011
}

utils.Println("Environment is cloned!")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can remove this Println to keep only the one you added here:

os.Exit(1)
panic("unreachable") // staticcheck false positive: https://staticcheck.io/docs/checks#SA5011
}
var newEnvId = environment.EnvironmentClone(client, organizationName, projectName, environmentName, newEnvironmentName, clusterName, environmentType, applyDeploymentRule, orgId, envId)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

variable typo:

Suggested change
var newEnvId = environment.EnvironmentClone(client, organizationName, projectName, environmentName, newEnvironmentName, clusterName, environmentType, applyDeploymentRule, orgId, envId)
var newEnvironment = environment.EnvironmentClone(client, organizationName, projectName, environmentName, newEnvironmentName, clusterName, environmentType, applyDeploymentRule, orgId, envId)


utils.Println("Environment is cloned!")
utils.Println("your new environment ID is: " + newEnvId.Id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can improve the message, e.g:

Suggested change
utils.Println("your new environment ID is: " + newEnvId.Id)
utils.Println(fmt.Sprintf("Your environment has been cloned [id: %s, name: %s]", newEnv.Id, newEnv.name))

if cmd.Flags().Changed("auto-deploy") {
req.AutoDeploy = *qovery.NewNullableBool(&applicationAutoDeploy)
changeAutoDeploy = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iiuc you should target &applicationAutoDeploy instead of setting to true.
The condition cmd.Flags().Changed("auto-deploy") means that the flag has been set (it can be true or false).
Also, you should use a nullable variable type to be able to keep the current behavior, see https://github.com/Qovery/qovery-cli/pull/379/files#diff-347ce49b39961c56097bf8e9b5eee84236e37636a3615f43ab6197e9293bba7eR70

Comment on lines +70 to +72
if changeAutoDeploy {
req.AutoDeploy = *qovery.NewNullableBool(&applicationAutoDeploy)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here the changeAutoDeploy function parameter should be a nullable boolean (autodeploy *bool), to set the req.AutoDeploy only if this is not null, e.g

if autodeploy != nil {
   [...]
}

"github.com/qovery/qovery-client-go"
)

func EnvironmentDeploy(client *qovery.APIClient, organizationName string, projectName string, environmentName string, newEnvironmentName string, clusterName string, environmentType string, applyDeploymentRule bool, envId string, servicesJson string, applicationNames string, containerNames string, lifecycleNames string, cronjobNames string, helmNames string, skipPausedServicesFlag bool, watchFlag bool) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should auto-reformat to add line breaks for each param (more readable):

func EnvironmentDeploy(
  client *qovery.APIClient,
  organizationName string
  [...]
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants