diff --git a/cmd/application_redeploy.go b/cmd/application_redeploy.go index d998b355..72f107ea 100644 --- a/cmd/application_redeploy.go +++ b/cmd/application_redeploy.go @@ -49,7 +49,7 @@ var applicationRedeployCmd = &cobra.Command{ panic("unreachable") // staticcheck false positive: https://staticcheck.io/docs/checks#SA5011 } - msg, err := utils.RedeployService(client, envId, application.Id, utils.ApplicationType, watchFlag) + msg, err := utils.RedeployService(client, envId, application.Id, application.Name, utils.ApplicationType, watchFlag) if err != nil { utils.PrintlnError(err) diff --git a/cmd/application_update.go b/cmd/application_update.go index 2212c6e5..2f144d66 100644 --- a/cmd/application_update.go +++ b/cmd/application_update.go @@ -65,7 +65,7 @@ var applicationUpdateCmd = &cobra.Command{ Name: &application.Name, Description: application.Description.Get(), GitRepository: &qovery.ApplicationGitRepositoryRequest{ - Url: *application.GitRepository.Url, + Url: application.GitRepository.Url, Branch: application.GitRepository.Branch, RootPath: application.GitRepository.RootPath, }, diff --git a/cmd/container_redeploy.go b/cmd/container_redeploy.go index d11aad6a..aff88cb9 100644 --- a/cmd/container_redeploy.go +++ b/cmd/container_redeploy.go @@ -49,7 +49,7 @@ var containerRedeployCmd = &cobra.Command{ panic("unreachable") // staticcheck false positive: https://staticcheck.io/docs/checks#SA5011 } - msg, err := utils.RedeployService(client, envId, container.Id, utils.ContainerType, watchFlag) + msg, err := utils.RedeployService(client, envId, container.Id, container.Name, utils.ContainerType, watchFlag) if err != nil { utils.PrintlnError(err) diff --git a/cmd/cronjob_redeploy.go b/cmd/cronjob_redeploy.go index 0a271f5f..3d5b46c9 100644 --- a/cmd/cronjob_redeploy.go +++ b/cmd/cronjob_redeploy.go @@ -48,7 +48,7 @@ var cronjobRedeployCmd = &cobra.Command{ panic("unreachable") // staticcheck false positive: https://staticcheck.io/docs/checks#SA5011 } - msg, err := utils.RedeployService(client, envId, cronjob.CronJobResponse.Id, utils.JobType, watchFlag) + msg, err := utils.RedeployService(client, envId, cronjob.CronJobResponse.Id, cronjob.CronJobResponse.Name, utils.JobType, watchFlag) if err != nil { utils.PrintlnError(err) diff --git a/cmd/database_redeploy.go b/cmd/database_redeploy.go index ddb31159..dda664cc 100644 --- a/cmd/database_redeploy.go +++ b/cmd/database_redeploy.go @@ -49,7 +49,7 @@ var databaseRedeployCmd = &cobra.Command{ panic("unreachable") // staticcheck false positive: https://staticcheck.io/docs/checks#SA5011 } - msg, err := utils.RedeployService(client, envId, database.Id, utils.DatabaseType, watchFlag) + msg, err := utils.RedeployService(client, envId, database.Id, database.Name, utils.DatabaseType, watchFlag) if err != nil { utils.PrintlnError(err) diff --git a/cmd/helm_redeploy.go b/cmd/helm_redeploy.go index 05446b56..a5ea3de0 100644 --- a/cmd/helm_redeploy.go +++ b/cmd/helm_redeploy.go @@ -49,7 +49,7 @@ var helmRedeployCmd = &cobra.Command{ panic("unreachable") // staticcheck false positive: https://staticcheck.io/docs/checks#SA5011 } - msg, err := utils.RedeployService(client, envId, helm.Id, utils.HelmType, watchFlag) + msg, err := utils.RedeployService(client, envId, helm.Id, helm.Name, utils.HelmType, watchFlag) if err != nil { utils.PrintlnError(err) diff --git a/cmd/helm_update.go b/cmd/helm_update.go index 1d5daab1..7607b7e8 100644 --- a/cmd/helm_update.go +++ b/cmd/helm_update.go @@ -120,14 +120,10 @@ func GetHelmSource(helm *qovery.HelmResponse, chartName string, chartVersion str updatedBranch = &charGitCommitBranch } - if gitRepository.Url == nil { - return nil, fmt.Errorf("Invalid Helm git repository source") - } - return &qovery.HelmRequestAllOfSource{ HelmRequestAllOfSourceOneOf: &qovery.HelmRequestAllOfSourceOneOf{ GitRepository: &qovery.HelmGitRepositoryRequest{ - Url: *gitRepository.Url, + Url: gitRepository.Url, Branch: updatedBranch, RootPath: gitRepository.RootPath, GitTokenId: gitRepository.GitTokenId, @@ -175,15 +171,11 @@ func GetHelmValuesOverride(helm *qovery.HelmResponse, valuesOverrideCommitBranch updatedBranch = &valuesOverrideCommitBranch } - if git.GitRepository.Url == nil { - return nil, fmt.Errorf("Invalid Helm git repository source") - } - updatedFile := qovery.HelmRequestAllOfValuesOverrideFile{} updatedFile.SetGit(qovery.HelmRequestAllOfValuesOverrideFileGit{ Paths: git.Paths, GitRepository: qovery.ApplicationGitRepositoryRequest{ - Url: *git.GitRepository.Url, + Url: git.GitRepository.Url, Branch: updatedBranch, GitTokenId: git.GitRepository.GitTokenId, RootPath: git.GitRepository.RootPath, diff --git a/cmd/lifecycle_redeploy.go b/cmd/lifecycle_redeploy.go index 82d59f10..5db8e447 100644 --- a/cmd/lifecycle_redeploy.go +++ b/cmd/lifecycle_redeploy.go @@ -48,7 +48,7 @@ var lifecycleRedeployCmd = &cobra.Command{ panic("unreachable") // staticcheck false positive: https://staticcheck.io/docs/checks#SA5011 } - msg, err := utils.RedeployService(client, envId, lifecycle.LifecycleJobResponse.Id, utils.JobType, watchFlag) + msg, err := utils.RedeployService(client, envId, lifecycle.LifecycleJobResponse.Id, lifecycle.LifecycleJobResponse.Name, utils.JobType, watchFlag) if err != nil { utils.PrintlnError(err) diff --git a/go.mod b/go.mod index 9573a1cd..df2b961a 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/pkg/errors v0.9.1 github.com/posthog/posthog-go v0.0.0-20221221115252-24dfed35d71a github.com/pterm/pterm v0.12.55 - github.com/qovery/qovery-client-go v0.0.0-20240117104703-29bf4ea6d3b0 + github.com/qovery/qovery-client-go v0.0.0-20240201142745-3115f6b80050 github.com/sirupsen/logrus v1.9.0 github.com/spf13/cobra v1.6.1 github.com/spf13/pflag v1.0.5 diff --git a/go.sum b/go.sum index 4c01401a..b198709f 100644 --- a/go.sum +++ b/go.sum @@ -204,6 +204,8 @@ github.com/qovery/qovery-client-go v0.0.0-20240108095100-718858da5460 h1:NTLkMvI github.com/qovery/qovery-client-go v0.0.0-20240108095100-718858da5460/go.mod h1:5QD7sC1Z6XCCYd31c4XKVwGdEOjvtgG0NDcaVDoWb+o= github.com/qovery/qovery-client-go v0.0.0-20240117104703-29bf4ea6d3b0 h1:RwDgJbYuAxjq7GJ2kxvf4ORq9g0l/ZWv5xHjMlOzNmU= github.com/qovery/qovery-client-go v0.0.0-20240117104703-29bf4ea6d3b0/go.mod h1:5QD7sC1Z6XCCYd31c4XKVwGdEOjvtgG0NDcaVDoWb+o= +github.com/qovery/qovery-client-go v0.0.0-20240201142745-3115f6b80050 h1:BnUMqurlKYBHZgHexSmIxR+OiAtZ3RzAqpg0Ylueflw= +github.com/qovery/qovery-client-go v0.0.0-20240201142745-3115f6b80050/go.mod h1:5QD7sC1Z6XCCYd31c4XKVwGdEOjvtgG0NDcaVDoWb+o= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis= github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= diff --git a/pkg/version.go b/pkg/version.go index f85b0e58..c0c4262f 100644 --- a/pkg/version.go +++ b/pkg/version.go @@ -11,7 +11,7 @@ import ( ) func GetCurrentVersion() string { - return "0.82.1" // ci-version-check + return "0.82.2" // ci-version-check } func GetLatestOnlineVersionUrl() (string, error) { diff --git a/utils/qovery.go b/utils/qovery.go index 9d25aef4..7d4a7451 100644 --- a/utils/qovery.go +++ b/utils/qovery.go @@ -2116,7 +2116,7 @@ func DeployService(client *qovery.APIClient, envId string, serviceId string, ser return DeployService(client, envId, serviceId, serviceType, request, watchFlag) } -func RedeployService(client *qovery.APIClient, envId string, serviceId string, serviceType ServiceType, watchFlag bool) (string, error) { +func RedeployService(client *qovery.APIClient, envId string, serviceId string, serviceName string, serviceType ServiceType, watchFlag bool) (string, error) { statuses, _, err := client.EnvironmentMainCallsAPI.GetEnvironmentStatuses(context.Background(), envId).Execute() if err != nil { @@ -2128,7 +2128,24 @@ func RedeployService(client *qovery.APIClient, envId string, serviceId string, s case ApplicationType: for _, application := range statuses.GetApplications() { if application.Id == serviceId && IsTerminalState(application.State) { - _, _, err := client.ApplicationActionsAPI.DeployApplication(context.Background(), serviceId).Execute() + apps, _, error := client.ApplicationsAPI.ListApplication(context.Background(), envId).Execute() + if error != nil { + PrintlnError(err) + os.Exit(1) + panic("unreachable") // staticcheck false positive: https://staticcheck.io/docs/checks#SA5011 + } + + app := FindByApplicationName(apps.GetResults(), serviceName); + if app == nil { + PrintlnError(fmt.Errorf("application %s not found", serviceName)) + PrintlnInfo("You can list all applications with: qovery application list") + os.Exit(1) + panic("unreachable") // staticcheck false positive: https://staticcheck.io/docs/checks#SA5011 + } + + deployRequest := qovery.DeployRequest{ GitCommitId: *app.GitRepository.DeployedCommitId} + + _, _, err := client.ApplicationActionsAPI.DeployApplication(context.Background(), serviceId).DeployRequest(deployRequest).Execute() if err != nil { return "", err } @@ -2158,7 +2175,9 @@ func RedeployService(client *qovery.APIClient, envId string, serviceId string, s case ContainerType: for _, container := range statuses.GetContainers() { if container.Id == serviceId && IsTerminalState(container.State) { - _, _, err := client.ContainerActionsAPI.DeployContainer(context.Background(), serviceId).Execute() + containerDeployRequest := qovery.ContainerDeployRequest{} + + _, _, err := client.ContainerActionsAPI.DeployContainer(context.Background(), serviceId).ContainerDeployRequest(containerDeployRequest) .Execute() if err != nil { return "", err } @@ -2173,7 +2192,9 @@ func RedeployService(client *qovery.APIClient, envId string, serviceId string, s case JobType: for _, job := range statuses.GetJobs() { if job.Id == serviceId && IsTerminalState(job.State) { - _, _, err := client.JobActionsAPI.DeployJob(context.Background(), serviceId).Execute() + deployRequest := qovery.JobDeployRequest{} + + _, _, err := client.JobActionsAPI.DeployJob(context.Background(), serviceId).JobDeployRequest(deployRequest).Execute() if err != nil { return "", err } @@ -2188,7 +2209,9 @@ func RedeployService(client *qovery.APIClient, envId string, serviceId string, s case HelmType: for _, helm := range statuses.GetHelms() { if helm.Id == serviceId && IsTerminalState(helm.State) { - _, _, err := client.HelmActionsAPI.DeployHelm(context.Background(), serviceId).Execute() + deployRequest := qovery.HelmDeployRequest{} + + _, _, err := client.HelmActionsAPI.DeployHelm(context.Background(), serviceId).HelmDeployRequest(deployRequest).Execute() if err != nil { return "", err } @@ -2208,7 +2231,7 @@ func RedeployService(client *qovery.APIClient, envId string, serviceId string, s // sleep here to avoid too many requests time.Sleep(5 * time.Second) - return RedeployService(client, envId, serviceId, serviceType, watchFlag) + return RedeployService(client, envId, serviceId, serviceName, serviceType, watchFlag) } func StopService(client *qovery.APIClient, envId string, serviceIds string, serviceType ServiceType, watchFlag bool) (string, error) { @@ -2445,7 +2468,7 @@ func ToJobRequest(job qovery.JobResponse) qovery.JobRequest { if docker != nil { sourceDockerGitRepository := qovery.ApplicationGitRepositoryRequest{ - Url: *docker.GitRepository.Url, + Url: docker.GitRepository.Url, Branch: docker.GitRepository.Branch, RootPath: docker.GitRepository.RootPath, }