diff --git a/cmd/gitops/update/cmd.go b/cmd/gitops/update/cmd.go index cb3c0d43880..09401706e2c 100644 --- a/cmd/gitops/update/cmd.go +++ b/cmd/gitops/update/cmd.go @@ -12,9 +12,9 @@ func UpdateCommand(endpoint *string, client *resty.Client) *cobra.Command { Use: "update", Short: "Update a Weave GitOps resource", Example: ` -# Update an installed profile to a certain version -gitops update profile --name --version --config-repo --cluster --namespace -`, + # Update a profile that is installed on a cluster + gitops update profile --name=podinfo --cluster=prod --config-repo=ssh://git@github.com/owner/config-repo.git --version=1.0.0 + `, } cmd.AddCommand(profiles.UpdateCommand()) diff --git a/cmd/gitops/update/profiles/profiles.go b/cmd/gitops/update/profiles/profiles.go index bdad4c02005..d7bd1a63117 100644 --- a/cmd/gitops/update/profiles/profiles.go +++ b/cmd/gitops/update/profiles/profiles.go @@ -24,16 +24,16 @@ import ( var opts profiles.UpdateOptions -// UpdateCommand provides support for updating an installed profile's version. +// UpdateCommand provides support for updating a profile that is installed on a cluster. func UpdateCommand() *cobra.Command { cmd := &cobra.Command{ Use: "profile", - Short: "Update a profile to a different version", + Short: "Update a profile installation", SilenceUsage: true, SilenceErrors: true, Example: ` - # Update an installed profile to a different version - gitops update profile --name=podinfo --cluster=prod --version=1.0.0 --config-repo=ssh://git@github.com/owner/config-repo.git --namespace=test-namespace + # Update a profile that is installed on a cluster + gitops update profile --name=podinfo --cluster=prod --config-repo=ssh://git@github.com/owner/config-repo.git --version=1.0.0 `, RunE: updateProfileCmdRunE(), } diff --git a/pkg/helm/releases_test.go b/pkg/helm/releases_test.go index c9884f01ff6..1e4c3212fd0 100644 --- a/pkg/helm/releases_test.go +++ b/pkg/helm/releases_test.go @@ -75,8 +75,8 @@ var _ = Describe("AppendHelmReleaseToString", func() { ) }) - When("the file does not exist", func() { - It("creates one with the new helm release", func() { + When("the given string is empty", func() { + It("appends a helm release to it", func() { s, err := helm.AppendHelmReleaseToString("", newRelease) Expect(err).NotTo(HaveOccurred()) r, err := yaml.Marshal(newRelease) diff --git a/test/acceptance/test/profiles_test.go b/test/acceptance/test/profiles_test.go index a4100eb02c6..aa216a33960 100644 --- a/test/acceptance/test/profiles_test.go +++ b/test/acceptance/test/profiles_test.go @@ -131,21 +131,27 @@ Namespace: %s`, clusterName, namespace))) }, "120s", "1s").Should(Equal(http.StatusOK)) By("Updating the version of the installed profile") - stdOut, stdErr = runCommandAndReturnStringOutput(fmt.Sprintf("%s update profile --name %s --version 6.0.0 --namespace %s --cluster %s --config-repo %s --auto-merge", gitopsBinaryPath, profileName, namespace, clusterName, appRepoRemoteURL)) - Expect(stdErr).To(BeEmpty()) + time.Sleep(4 * time.Minute) + Eventually(func() string { + stdOut, stdErr = runCommandAndReturnStringOutput(fmt.Sprintf("%s update profile --name %s --version 6.0.0 --namespace %s --cluster %s --config-repo %s --auto-merge", gitopsBinaryPath, profileName, namespace, clusterName, appRepoRemoteURL)) + return stdErr + }, "120s", "5s").Should(BeEmpty()) + Expect(stdOut).To(ContainSubstring( - fmt.Sprintf(`Updating 1 profile: - - Name: podinfo - Version: 6.0.0 - Cluster: %s - Namespace: %s`, clusterName, namespace))) + fmt.Sprintf( + `Updating profile: + +Name: podinfo +Version: 6.0.0 +Cluster: %s +Namespace: %s`, clusterName, namespace))) By("Verifying that the profile installed in the cluster's namespace was updated to the correct version") - Eventually(func() int { - resp, statusCode, err = kubernetesDoRequest(namespace, clusterName+"-"+profileName, "9898", "/healthz", clientSet) - return statusCode - }, "120s", "1s").Should(Equal(http.StatusOK)) + Eventually(func() string { + stdOut, stdErr = runCommandAndReturnStringOutput(fmt.Sprintf("kubectl get pods -n %s --selector=app.kubernetes.io/name=%s-%s -o jsonpath='{.items[*].spec.containers[*].image}'", namespace, clusterName, profileName)) + Expect(stdErr).Should(BeEmpty()) + return stdOut + }, "240s", "5s").Should(ContainSubstring("ghcr.io/stefanprodan/podinfo:6.0.0")) }) It("@skipOnNightly profiles are installed into a different namespace", func() {