Skip to content

Commit 244892a

Browse files
authored
CR-13084-hide-cluster-resources-upgrade (#658)
* try to patch cluster-resource appset on upgrade * bumped version to 0.1.20
1 parent 7dfbc67 commit 244892a

File tree

5 files changed

+27
-16
lines changed

5 files changed

+27
-16
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION=v0.1.19
1+
VERSION=v0.1.20
22

33
OUT_DIR=dist
44
YEAR?=$(shell date +"%Y")

cmd/commands/common.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ import (
3434
"github.com/codefresh-io/cli-v2/pkg/runtime"
3535
"github.com/codefresh-io/cli-v2/pkg/store"
3636
"github.com/codefresh-io/cli-v2/pkg/util"
37+
apu "github.com/codefresh-io/cli-v2/pkg/util/aputil"
3738

39+
"github.com/argoproj-labs/argocd-autopilot/pkg/fs"
40+
"github.com/argoproj-labs/argocd-autopilot/pkg/git"
3841
apgit "github.com/argoproj-labs/argocd-autopilot/pkg/git"
3942
aputil "github.com/argoproj-labs/argocd-autopilot/pkg/util"
4043
platmodel "github.com/codefresh-io/go-sdk/pkg/codefresh/model"
@@ -790,3 +793,16 @@ func getRuntime(ctx context.Context, runtimeName string) (*platmodel.Runtime, er
790793

791794
return rt, nil
792795
}
796+
797+
func patchRuntimeRepo(ctx context.Context, cloneOpts *git.CloneOptions, msg string, f func(fs fs.FS) error) error {
798+
r, fs, err := cloneOpts.GetRepo(ctx)
799+
if err != nil {
800+
return err
801+
}
802+
803+
if err = f(fs); err != nil {
804+
return err
805+
}
806+
807+
return apu.PushWithMessage(ctx, r, msg)
808+
}

cmd/commands/runtime.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,11 @@ func runRuntimeUpgrade(ctx context.Context, opts *RuntimeUpgradeOptions) error {
909909
return fmt.Errorf("failed to upgrade runtime: %w", err)
910910
}
911911

912+
err = patchClusterResourcesAppSet(fs)
913+
if err != nil {
914+
log.G(ctx).Warnf("failed to patch cluster-resources ApplicationSet: %w", err)
915+
}
916+
912917
log.G(ctx).Info("Pushing new runtime definition")
913918
err = apu.PushWithMessage(ctx, r, fmt.Sprintf("Upgraded to %s", newRt.Spec.Version))
914919
handleCliStep(reporter.UpgradeStepPushRuntimeDefinition, "Pushing new runtime definition", err, false, false)

cmd/commands/runtime_install.go

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ import (
4747
apcmd "github.com/argoproj-labs/argocd-autopilot/cmd/commands"
4848
"github.com/argoproj-labs/argocd-autopilot/pkg/application"
4949
"github.com/argoproj-labs/argocd-autopilot/pkg/fs"
50-
"github.com/argoproj-labs/argocd-autopilot/pkg/git"
5150
apgit "github.com/argoproj-labs/argocd-autopilot/pkg/git"
5251
"github.com/argoproj-labs/argocd-autopilot/pkg/kube"
5352
apstore "github.com/argoproj-labs/argocd-autopilot/pkg/store"
@@ -694,7 +693,7 @@ func runRuntimeInstall(ctx context.Context, opts *RuntimeInstallOptions) error {
694693
return util.DecorateErrorWithDocsLink(fmt.Errorf("failed to bootstrap repository: %w", err))
695694
}
696695

697-
err = patchClusterResourcesAppSet(ctx, opts.InsCloneOpts)
696+
err = patchRuntimeRepo(ctx, opts.InsCloneOpts, "patch cluster-resources ApplicationSet", patchClusterResourcesAppSet)
698697
if err != nil {
699698
return util.DecorateErrorWithDocsLink(fmt.Errorf("failed to patch cluster-resources ApplicationSet: %w", err))
700699
}
@@ -2153,12 +2152,7 @@ func getRuntimeDef(runtimeDef, version string) string {
21532152
return strings.Replace(runtimeDef, "stable", version, 1)
21542153
}
21552154

2156-
func patchClusterResourcesAppSet(ctx context.Context, cloneOpts *git.CloneOptions) error {
2157-
r, fs, err := cloneOpts.GetRepo(ctx)
2158-
if err != nil {
2159-
return err
2160-
}
2161-
2155+
func patchClusterResourcesAppSet(fs fs.FS) error {
21622156
appSet := &argocdv1alpha1.ApplicationSet{}
21632157
name := store.Get().ClusterResourcesPath
21642158
if err := fs.ReadYamls(name, appSet); err != nil {
@@ -2170,9 +2164,5 @@ func patchClusterResourcesAppSet(ctx context.Context, cloneOpts *git.CloneOption
21702164
}
21712165

21722166
appSet.ObjectMeta.Labels[store.Get().LabelKeyCFInternal] = "true"
2173-
if err = fs.WriteYamls(name, appSet); err != nil {
2174-
return err
2175-
}
2176-
2177-
return apu.PushWithMessage(ctx, r, "patch cluster-resources ApplicationSet")
2167+
return fs.WriteYamls(name, appSet)
21782168
}

docs/releases/release_notes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ cf version
2323

2424
```bash
2525
# download and extract the binary
26-
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.19/cf-linux-amd64.tar.gz | tar zx
26+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.20/cf-linux-amd64.tar.gz | tar zx
2727

2828
# move the binary to your $PATH
2929
mv ./cf-linux-amd64 /usr/local/bin/cf
@@ -36,7 +36,7 @@ cf version
3636

3737
```bash
3838
# download and extract the binary
39-
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.19/cf-darwin-amd64.tar.gz | tar zx
39+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.20/cf-darwin-amd64.tar.gz | tar zx
4040

4141
# move the binary to your $PATH
4242
mv ./cf-darwin-amd64 /usr/local/bin/cf

0 commit comments

Comments
 (0)