Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions cli/cmd/argocd.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ func AddArgoCDCmd(parentCmd *cobra.Command, opts *GlobalOptions) {

When --deploy-dc-config is set, Codesphere-managed resources are applied after
the chart install/upgrade:
- AppProjects (always)
- Helm OCI registry secret (always, requires OMS_REGISTRY_PASSWORD)
- Local cluster secret (only if --dc-id is provided)
- Git repo credentials (only if OMS_GIT_PASSWORD env var is set)
Expand All @@ -118,7 +117,7 @@ func AddArgoCDCmd(parentCmd *cobra.Command, opts *GlobalOptions) {
argocd.cmd.Flags().StringVar(&argocd.Opts.DatacenterId, "dc-id", "", "Codesphere Datacenter ID (optional, registers local cluster in ArgoCD)")
argocd.cmd.Flags().StringVar(&argocd.Opts.RegistryURL, "registry-url", "ghcr.io/codesphere-cloud/charts", "OCI registry URL for the Helm chart repository")
argocd.cmd.Flags().StringVarP(&argocd.Opts.Version, "version", "v", "", "Version of the ArgoCD helm chart to install")
argocd.cmd.Flags().BoolVar(&argocd.Opts.FullInstall, "deploy-dc-config", false, "Apply Codesphere-managed resources (AppProjects, Repo Creds, ...) after installing the chart")
argocd.cmd.Flags().BoolVar(&argocd.Opts.FullInstall, "deploy-dc-config", false, "Apply Codesphere-managed resources (Repo Creds, ...) after installing the chart")
argocd.cmd.Flags().StringArrayVarP(&argocd.Opts.ValueFiles, "values", "f", nil, "Specify values in a YAML file (can be specified multiple times)")
argocd.cmd.Flags().BoolVar(&argocd.Opts.ForceConflicts, "force-conflicts", false, "Force field ownership conflicts during upgrade (sets server-side apply ForceConflicts)")
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)")
Expand Down
3 changes: 1 addition & 2 deletions docs/oms_beta_install_argocd.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Install or upgrade the ArgoCD helm release.

When --deploy-dc-config is set, Codesphere-managed resources are applied after
the chart install/upgrade:
- AppProjects (always)
- Helm OCI registry secret (always, requires OMS_REGISTRY_PASSWORD)
- Local cluster secret (only if --dc-id is provided)
- Git repo credentials (only if OMS_GIT_PASSWORD env var is set)
Expand Down Expand Up @@ -45,7 +44,7 @@ $ oms beta install argocd --deploy-dc-config --dc-id 0

```
--dc-id string Codesphere Datacenter ID (optional, registers local cluster in ArgoCD)
--deploy-dc-config Apply Codesphere-managed resources (AppProjects, Repo Creds, ...) after installing the chart
--deploy-dc-config Apply Codesphere-managed resources (Repo Creds, ...) after installing the chart
--force-conflicts Force field ownership conflicts during upgrade (sets server-side apply ForceConflicts)
-h, --help help for argocd
--registry-url string OCI registry URL for the Helm chart repository (default "ghcr.io/codesphere-cloud/charts")
Expand Down
31 changes: 1 addition & 30 deletions internal/installer/argocd/argocd_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"log"

k8s "github.com/codesphere-cloud/oms/internal/util"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/kubernetes"
)

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

type argoCDResources struct {
clientset kubernetes.Interface
dynClient dynamic.Interface

DatacenterId string
OciPassword string
OciRegistryURL string
GitPassword string
}

func NewArgoCDResources(clientset kubernetes.Interface, dynClient dynamic.Interface, dataCenterId string, ociPassword string, ociRegistryURL string, gitPassword string) (ArgoCDResources, error) {
func NewArgoCDResources(clientset kubernetes.Interface, dataCenterId string, ociPassword string, ociRegistryURL string, gitPassword string) (ArgoCDResources, error) {
return &argoCDResources{
clientset: clientset,
dynClient: dynClient,
DatacenterId: dataCenterId,
OciPassword: ociPassword,
OciRegistryURL: ociRegistryURL,
GitPassword: gitPassword,
}, nil
}

//go:embed manifests/app-projects.yaml
var appProjectsYAML []byte

//go:embed manifests/cluster-local.yaml.tpl
var localClusterTpl []byte

Expand All @@ -54,10 +48,6 @@ var helmRegistryTpl []byte
var gitRepoTpl []byte

func (a *argoCDResources) ApplyAll(ctx context.Context) error {
if err := a.applyAppProjects(ctx); err != nil {
return fmt.Errorf("applying app projects: %w", err)
}

if a.DatacenterId != "" {
if err := a.applyLocalCluster(ctx); err != nil {
return fmt.Errorf("applying local cluster secret: %w", err)
Expand All @@ -81,25 +71,6 @@ func (a *argoCDResources) ApplyAll(ctx context.Context) error {
return nil
}

func (a *argoCDResources) applyAppProjects(ctx context.Context) error {
log.Println("Applying AppProjects... ")
objects, err := k8s.DecodeMultiDocYAML(appProjectsYAML)
if err != nil {
return fmt.Errorf("decoding app projects yaml: %w", err)
}

for _, obj := range objects {
gvr, err := k8s.GvrForUnstructured(obj)
if err != nil {
return err
}
if err := k8s.ApplyUnstructured(ctx, a.dynClient, gvr, obj); err != nil {
return fmt.Errorf("applying app project %q: %w", obj.GetName(), err)
}
}
return nil
}

func (a *argoCDResources) applyLocalCluster(ctx context.Context) error {
log.Println("Applying local cluster secret... ")
rendered, err := k8s.RenderTemplate(localClusterTpl, map[string]string{
Expand Down
8 changes: 4 additions & 4 deletions internal/installer/argocd/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ func NewInstaller(cfg InstallerConfig) (*Installer, error) {
return nil, fmt.Errorf("init helm client failed: %w", err)
}

clientset, dynClient, err := k8s.NewClientsFromRESTConfig(cfg.RESTConfig)
clientset, _, err := k8s.NewClientsFromRESTConfig(cfg.RESTConfig)
if err != nil {
return nil, fmt.Errorf("creating kubernetes clients: %w", err)
}
resources, err := NewArgoCDResources(clientset, dynClient, cfg.DatacenterId, cfg.OciPassword, cfg.OciRegistryURL, cfg.GitPassword)
resources, err := NewArgoCDResources(clientset, cfg.DatacenterId, cfg.OciPassword, cfg.OciRegistryURL, cfg.GitPassword)
if err != nil {
return nil, fmt.Errorf("init argocd resources client failed: %w", err)
}
Expand All @@ -70,11 +70,11 @@ func NewInstaller(cfg InstallerConfig) (*Installer, error) {
if err != nil {
return nil, fmt.Errorf("init helm client failed: %w", err)
}
clientset, dynClient, err := k8s.NewClients()
clientset, _, err := k8s.NewClients()
if err != nil {
return nil, fmt.Errorf("creating kubernetes clients: %w", err)
}
resources, err := NewArgoCDResources(clientset, dynClient, cfg.DatacenterId, cfg.OciPassword, cfg.OciRegistryURL, cfg.GitPassword)
resources, err := NewArgoCDResources(clientset, cfg.DatacenterId, cfg.OciPassword, cfg.OciRegistryURL, cfg.GitPassword)
if err != nil {
return nil, fmt.Errorf("init argocd resources client failed: %w", err)
}
Expand Down
74 changes: 0 additions & 74 deletions internal/installer/argocd/manifests/app-projects.yaml

This file was deleted.

1 change: 0 additions & 1 deletion internal/util/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ func VaultGVR() schema.GroupVersionResource {
// gvrMappings maps Kubernetes Kind names to their plural resource names.
// New kinds used in embedded templates need a corresponding entry here.
var gvrMappings = map[string]string{
"AppProject": "appprojects",
"Vault": "vaults",
"ServiceAccount": "serviceaccounts",
"Role": "roles",
Expand Down
12 changes: 0 additions & 12 deletions internal/util/k8s_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,18 +133,6 @@ var _ = Describe("DenderTemplate", func() {
})

var _ = Describe("GvrForUnstructured", func() {
It("returns the correct GVR for AppProject", func() {
obj := &unstructured.Unstructured{}
obj.SetAPIVersion("argoproj.io/v1alpha1")
obj.SetKind("AppProject")

gvr, err := util.GvrForUnstructured(obj)
Expect(err).ToNot(HaveOccurred())
Expect(gvr.Group).To(Equal("argoproj.io"))
Expect(gvr.Version).To(Equal("v1alpha1"))
Expect(gvr.Resource).To(Equal("appprojects"))
})

It("returns the correct GVR for Vault", func() {
obj := &unstructured.Unstructured{}
obj.SetAPIVersion("vault.banzaicloud.com/v1alpha1")
Expand Down
Loading