Skip to content

Commit

Permalink
CR-13084-hide-cluster-resources (#657)
Browse files Browse the repository at this point in the history
* patch `internal: true` to cluster-resources appset
* bumped version to 0.1.19
  • Loading branch information
ATGardner authored Dec 18, 2022
1 parent 30f734a commit 7dfbc67
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=v0.1.18
VERSION=v0.1.19

OUT_DIR=dist
YEAR?=$(shell date +"%Y")
Expand Down
30 changes: 30 additions & 0 deletions cmd/commands/runtime_install.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import (
apcmd "github.com/argoproj-labs/argocd-autopilot/cmd/commands"
"github.com/argoproj-labs/argocd-autopilot/pkg/application"
"github.com/argoproj-labs/argocd-autopilot/pkg/fs"
"github.com/argoproj-labs/argocd-autopilot/pkg/git"
apgit "github.com/argoproj-labs/argocd-autopilot/pkg/git"
"github.com/argoproj-labs/argocd-autopilot/pkg/kube"
apstore "github.com/argoproj-labs/argocd-autopilot/pkg/store"
Expand Down Expand Up @@ -693,6 +694,11 @@ func runRuntimeInstall(ctx context.Context, opts *RuntimeInstallOptions) error {
return util.DecorateErrorWithDocsLink(fmt.Errorf("failed to bootstrap repository: %w", err))
}

err = patchClusterResourcesAppSet(ctx, opts.InsCloneOpts)
if err != nil {
return util.DecorateErrorWithDocsLink(fmt.Errorf("failed to patch cluster-resources ApplicationSet: %w", err))
}

err = oc.PrepareOpenshiftCluster(ctx, &oc.OpenshiftOptions{
KubeFactory: opts.KubeFactory,
RuntimeName: opts.RuntimeName,
Expand Down Expand Up @@ -2146,3 +2152,27 @@ func getRuntimeDef(runtimeDef, version string) string {
}
return strings.Replace(runtimeDef, "stable", version, 1)
}

func patchClusterResourcesAppSet(ctx context.Context, cloneOpts *git.CloneOptions) error {
r, fs, err := cloneOpts.GetRepo(ctx)
if err != nil {
return err
}

appSet := &argocdv1alpha1.ApplicationSet{}
name := store.Get().ClusterResourcesPath
if err := fs.ReadYamls(name, appSet); err != nil {
return err
}

if appSet.ObjectMeta.Labels == nil {
appSet.ObjectMeta.Labels = make(map[string]string)
}

appSet.ObjectMeta.Labels[store.Get().LabelKeyCFInternal] = "true"
if err = fs.WriteYamls(name, appSet); err != nil {
return err
}

return apu.PushWithMessage(ctx, r, "patch cluster-resources ApplicationSet")
}
4 changes: 2 additions & 2 deletions docs/releases/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ cf version

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

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

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

# move the binary to your $PATH
mv ./cf-darwin-amd64 /usr/local/bin/cf
Expand Down
2 changes: 2 additions & 0 deletions pkg/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ type Store struct {
MinKubeVersion string
MaxKubeVersion string
MasterIngressName string
ClusterResourcesPath string
InClusterPath string
SccName string
CFInternalGitSources []string
Expand Down Expand Up @@ -265,6 +266,7 @@ func init() {
s.MinKubeVersion = "v1.21.0"
s.MaxKubeVersion = "v1.25.0"
s.MasterIngressName = "-master"
s.ClusterResourcesPath = "/bootstrap/cluster-resources.yaml"
s.InClusterPath = "/bootstrap/cluster-resources/in-cluster"
s.SccName = "cf-scc"
s.CFInternalGitSources = []string{s.MarketplaceGitSourceName}
Expand Down
6 changes: 1 addition & 5 deletions pkg/util/aputil/aputil.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,12 @@ func AddCloneFlags(cmd *cobra.Command, o *CloneFlagsOptions) *git.CloneOptions {
return opts
}

func PushWithMessage(ctx context.Context, r git.Repository, msg string, progress ...io.Writer) error {
func PushWithMessage(ctx context.Context, r git.Repository, msg string) error {
var (
err error
prog io.Writer
)

if len(progress) > 0 {
prog = progress[0]
}

for try := 0; try < pushRetries; try++ {
_, err = r.Persist(ctx, &git.PushOptions{
AddGlobPattern: ".",
Expand Down

0 comments on commit 7dfbc67

Please sign in to comment.