-
Notifications
You must be signed in to change notification settings - Fork 24
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
base: main
Are you sure you want to change the base?
Conversation
panic("unreachable") // staticcheck false positive: https://staticcheck.io/docs/checks#SA5011 | ||
} | ||
|
||
utils.Println("Environment is cloned!") |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
variable typo:
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) |
There was a problem hiding this comment.
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:
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 |
There was a problem hiding this comment.
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
if changeAutoDeploy { | ||
req.AutoDeploy = *qovery.NewNullableBool(&applicationAutoDeploy) | ||
} |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
[...]
)
First part of ticket "Create Preview environments via CLI"
Split CMD and functions for: