Skip to content

Commit 57c7ebf

Browse files
committed
chore(argocd) remove unused projects
1 parent a49fc87 commit 57c7ebf

6 files changed

Lines changed: 6 additions & 123 deletions

File tree

cli/cmd/argocd.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ func AddArgoCDCmd(parentCmd *cobra.Command, opts *GlobalOptions) {
9696
9797
When --deploy-dc-config is set, Codesphere-managed resources are applied after
9898
the chart install/upgrade:
99-
- AppProjects (always)
10099
- Helm OCI registry secret (always, requires OMS_REGISTRY_PASSWORD)
101100
- Local cluster secret (only if --dc-id is provided)
102101
- Git repo credentials (only if OMS_GIT_PASSWORD env var is set)
@@ -118,7 +117,7 @@ func AddArgoCDCmd(parentCmd *cobra.Command, opts *GlobalOptions) {
118117
argocd.cmd.Flags().StringVar(&argocd.Opts.DatacenterId, "dc-id", "", "Codesphere Datacenter ID (optional, registers local cluster in ArgoCD)")
119118
argocd.cmd.Flags().StringVar(&argocd.Opts.RegistryURL, "registry-url", "ghcr.io/codesphere-cloud/charts", "OCI registry URL for the Helm chart repository")
120119
argocd.cmd.Flags().StringVarP(&argocd.Opts.Version, "version", "v", "", "Version of the ArgoCD helm chart to install")
121-
argocd.cmd.Flags().BoolVar(&argocd.Opts.FullInstall, "deploy-dc-config", false, "Apply Codesphere-managed resources (AppProjects, Repo Creds, ...) after installing the chart")
120+
argocd.cmd.Flags().BoolVar(&argocd.Opts.FullInstall, "deploy-dc-config", false, "Apply Codesphere-managed resources (Repo Creds, ...) after installing the chart")
122121
argocd.cmd.Flags().StringArrayVarP(&argocd.Opts.ValueFiles, "values", "f", nil, "Specify values in a YAML file (can be specified multiple times)")
123122
argocd.cmd.Flags().BoolVar(&argocd.Opts.ForceConflicts, "force-conflicts", false, "Force field ownership conflicts during upgrade (sets server-side apply ForceConflicts)")
124123
argocd.cmd.Flags().StringVar(&argocd.Opts.RepoURL, "repo", "", "Helm chart repository URL; supports HTTP (default: https://argoproj.github.io/argo-helm) and OCI (e.g. oci://ghcr.io/argoproj/argo-helm)")

internal/installer/argocd/argocd_resources.go

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"log"
1212

1313
k8s "github.com/codesphere-cloud/oms/internal/util"
14-
"k8s.io/client-go/dynamic"
1514
"k8s.io/client-go/kubernetes"
1615
)
1716

@@ -22,28 +21,23 @@ type ArgoCDResources interface {
2221

2322
type argoCDResources struct {
2423
clientset kubernetes.Interface
25-
dynClient dynamic.Interface
2624

2725
DatacenterId string
2826
OciPassword string
2927
OciRegistryURL string
3028
GitPassword string
3129
}
3230

33-
func NewArgoCDResources(clientset kubernetes.Interface, dynClient dynamic.Interface, dataCenterId string, ociPassword string, ociRegistryURL string, gitPassword string) (ArgoCDResources, error) {
31+
func NewArgoCDResources(clientset kubernetes.Interface, dataCenterId string, ociPassword string, ociRegistryURL string, gitPassword string) (ArgoCDResources, error) {
3432
return &argoCDResources{
3533
clientset: clientset,
36-
dynClient: dynClient,
3734
DatacenterId: dataCenterId,
3835
OciPassword: ociPassword,
3936
OciRegistryURL: ociRegistryURL,
4037
GitPassword: gitPassword,
4138
}, nil
4239
}
4340

44-
//go:embed manifests/app-projects.yaml
45-
var appProjectsYAML []byte
46-
4741
//go:embed manifests/cluster-local.yaml.tpl
4842
var localClusterTpl []byte
4943

@@ -54,10 +48,6 @@ var helmRegistryTpl []byte
5448
var gitRepoTpl []byte
5549

5650
func (a *argoCDResources) ApplyAll(ctx context.Context) error {
57-
if err := a.applyAppProjects(ctx); err != nil {
58-
return fmt.Errorf("applying app projects: %w", err)
59-
}
60-
6151
if a.DatacenterId != "" {
6252
if err := a.applyLocalCluster(ctx); err != nil {
6353
return fmt.Errorf("applying local cluster secret: %w", err)
@@ -81,25 +71,6 @@ func (a *argoCDResources) ApplyAll(ctx context.Context) error {
8171
return nil
8272
}
8373

84-
func (a *argoCDResources) applyAppProjects(ctx context.Context) error {
85-
log.Println("Applying AppProjects... ")
86-
objects, err := k8s.DecodeMultiDocYAML(appProjectsYAML)
87-
if err != nil {
88-
return fmt.Errorf("decoding app projects yaml: %w", err)
89-
}
90-
91-
for _, obj := range objects {
92-
gvr, err := k8s.GvrForUnstructured(obj)
93-
if err != nil {
94-
return err
95-
}
96-
if err := k8s.ApplyUnstructured(ctx, a.dynClient, gvr, obj); err != nil {
97-
return fmt.Errorf("applying app project %q: %w", obj.GetName(), err)
98-
}
99-
}
100-
return nil
101-
}
102-
10374
func (a *argoCDResources) applyLocalCluster(ctx context.Context) error {
10475
log.Println("Applying local cluster secret... ")
10576
rendered, err := k8s.RenderTemplate(localClusterTpl, map[string]string{

internal/installer/argocd/installer.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ func NewInstaller(cfg InstallerConfig) (*Installer, error) {
5252
return nil, fmt.Errorf("init helm client failed: %w", err)
5353
}
5454

55-
clientset, dynClient, err := k8s.NewClientsFromRESTConfig(cfg.RESTConfig)
55+
clientset, _, err := k8s.NewClientsFromRESTConfig(cfg.RESTConfig)
5656
if err != nil {
5757
return nil, fmt.Errorf("creating kubernetes clients: %w", err)
5858
}
59-
resources, err := NewArgoCDResources(clientset, dynClient, cfg.DatacenterId, cfg.OciPassword, cfg.OciRegistryURL, cfg.GitPassword)
59+
resources, err := NewArgoCDResources(clientset, cfg.DatacenterId, cfg.OciPassword, cfg.OciRegistryURL, cfg.GitPassword)
6060
if err != nil {
6161
return nil, fmt.Errorf("init argocd resources client failed: %w", err)
6262
}
@@ -70,11 +70,11 @@ func NewInstaller(cfg InstallerConfig) (*Installer, error) {
7070
if err != nil {
7171
return nil, fmt.Errorf("init helm client failed: %w", err)
7272
}
73-
clientset, dynClient, err := k8s.NewClients()
73+
clientset, _, err := k8s.NewClients()
7474
if err != nil {
7575
return nil, fmt.Errorf("creating kubernetes clients: %w", err)
7676
}
77-
resources, err := NewArgoCDResources(clientset, dynClient, cfg.DatacenterId, cfg.OciPassword, cfg.OciRegistryURL, cfg.GitPassword)
77+
resources, err := NewArgoCDResources(clientset, cfg.DatacenterId, cfg.OciPassword, cfg.OciRegistryURL, cfg.GitPassword)
7878
if err != nil {
7979
return nil, fmt.Errorf("init argocd resources client failed: %w", err)
8080
}

internal/installer/argocd/manifests/app-projects.yaml

Lines changed: 0 additions & 74 deletions
This file was deleted.

internal/util/k8s.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ func VaultGVR() schema.GroupVersionResource {
6666
// gvrMappings maps Kubernetes Kind names to their plural resource names.
6767
// New kinds used in embedded templates need a corresponding entry here.
6868
var gvrMappings = map[string]string{
69-
"AppProject": "appprojects",
7069
"Vault": "vaults",
7170
"ServiceAccount": "serviceaccounts",
7271
"Role": "roles",

internal/util/k8s_test.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,6 @@ var _ = Describe("DenderTemplate", func() {
133133
})
134134

135135
var _ = Describe("GvrForUnstructured", func() {
136-
It("returns the correct GVR for AppProject", func() {
137-
obj := &unstructured.Unstructured{}
138-
obj.SetAPIVersion("argoproj.io/v1alpha1")
139-
obj.SetKind("AppProject")
140-
141-
gvr, err := util.GvrForUnstructured(obj)
142-
Expect(err).ToNot(HaveOccurred())
143-
Expect(gvr.Group).To(Equal("argoproj.io"))
144-
Expect(gvr.Version).To(Equal("v1alpha1"))
145-
Expect(gvr.Resource).To(Equal("appprojects"))
146-
})
147-
148136
It("returns the correct GVR for Vault", func() {
149137
obj := &unstructured.Unstructured{}
150138
obj.SetAPIVersion("vault.banzaicloud.com/v1alpha1")

0 commit comments

Comments
 (0)