Skip to content

Commit

Permalink
fix broken references and update v1beta1 references
Browse files Browse the repository at this point in the history
Signed-off-by: Jaideep Rao <jaideep.r97@gmail.com>
  • Loading branch information
jaideepr97 committed Sep 27, 2023
1 parent 43417be commit 7c12e38
Show file tree
Hide file tree
Showing 69 changed files with 543 additions and 2,418 deletions.
228 changes: 0 additions & 228 deletions api/v1alpha1/argocd_conversion.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion api/v1beta1/argocd_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func Test_ArgoCD_ApplicationInstanceLabelKey(t *testing.T) {
cr.Spec.ApplicationInstanceLabelKey = "my.corp/instance"
assert.Equal(t, cr.ApplicationInstanceLabelKey(), "my.corp/instance")
cr = &ArgoCD{}
assert.Equal(t, cr.ApplicationInstanceLabelKey(), common.ArgoCDDefaultApplicationInstanceLabelKey)
assert.Equal(t, cr.ApplicationInstanceLabelKey(), common.AppK8sKeyInstance)
}

func Test_ResourceTrackingMethodToString(t *testing.T) {
Expand Down
3 changes: 0 additions & 3 deletions common/names.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ const (
// ArgoCDTLSCertsConfigMapName is the upstream hard-coded TLS certificate data ConfigMap name.
ArgoCDTLSCertsConfigMapName = "argocd-tls-certs-cm"

// ArgoCDRedisServerTLSSecretName is the name of the TLS secret for the redis-server
ArgoCDRedisServerTLSSecretName = "argocd-operator-redis-tls"

// ArgoCDRepoServerTLSSecretName is the name of the TLS secret for the repo-server
ArgoCDRepoServerTLSSecretName = "argocd-repo-server-tls"

Expand Down
4 changes: 2 additions & 2 deletions controllers/argocd/appcontroller/appcontroller.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package appcontroller

import (
"github.com/argoproj-labs/argocd-operator/api/v1alpha1"
"github.com/argoproj-labs/argocd-operator/api/v1beta1"
"github.com/go-logr/logr"
"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand All @@ -10,7 +10,7 @@ import (
type AppControllerReconciler struct {
Client *client.Client
Scheme *runtime.Scheme
Instance *v1alpha1.ArgoCD
Instance *v1beta1.ArgoCD
ClusterScoped bool
Logger logr.Logger
ManagedNamespaces map[string]string
Expand Down
17 changes: 9 additions & 8 deletions controllers/argocd/applicationset.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"k8s.io/apimachinery/pkg/util/intstr"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"

"github.com/argoproj-labs/argocd-operator/api/v1beta1"
argoproj "github.com/argoproj-labs/argocd-operator/api/v1beta1"
"github.com/argoproj-labs/argocd-operator/common"
"github.com/argoproj-labs/argocd-operator/pkg/mutation/openshift"
Expand All @@ -39,7 +40,7 @@ const (
)

// getArgoApplicationSetCommand will return the command for the ArgoCD ApplicationSet component.
func getArgoApplicationSetCommand(cr *argoproj.ArgoCD) []string {
func getArgoApplicationSetCommand(cr *v1beta1.ArgoCD) []string {
cmd := make([]string, 0)

cmd = append(cmd, "entrypoint.sh")
Expand Down Expand Up @@ -68,7 +69,7 @@ func getArgoApplicationSetCommand(cr *argoproj.ArgoCD) []string {
return cmd
}

func (r *ArgoCDReconciler) reconcileApplicationSetController(cr *argoprojv1a1.ArgoCD) error {
func (r *ArgoCDReconciler) reconcileApplicationSetController(cr *v1beta1.ArgoCD) error {

log.Info("reconciling applicationset serviceaccounts")
sa, err := r.reconcileApplicationSetServiceAccount(cr)
Expand Down Expand Up @@ -101,7 +102,7 @@ func (r *ArgoCDReconciler) reconcileApplicationSetController(cr *argoprojv1a1.Ar
}

// reconcileApplicationControllerDeployment will ensure the Deployment resource is present for the ArgoCD Application Controller component.
func (r *ArgoCDReconciler) reconcileApplicationSetDeployment(cr *argoprojv1a1.ArgoCD, sa *corev1.ServiceAccount) error {
func (r *ArgoCDReconciler) reconcileApplicationSetDeployment(cr *v1beta1.ArgoCD, sa *corev1.ServiceAccount) error {
deploy := newDeploymentWithSuffix("applicationset-controller", "controller", cr)

setAppSetLabels(&deploy.ObjectMeta)
Expand Down Expand Up @@ -157,7 +158,7 @@ func (r *ArgoCDReconciler) reconcileApplicationSetDeployment(cr *argoprojv1a1.Ar
addSCMGitlabVolumeMount := false
if scmRootCAConfigMapName := getSCMRootCAConfigMapName(cr); scmRootCAConfigMapName != "" {
cm := newConfigMapWithName(scmRootCAConfigMapName, cr)
if argoutil.IsObjectFound(r.Client, cr.Namespace, cr.Spec.ApplicationSet.SCMRootCAConfigMap, cm) {
if util.IsObjectFound(r.Client, cr.Namespace, cr.Spec.ApplicationSet.SCMRootCAConfigMap, cm) {
addSCMGitlabVolumeMount = true
podSpec.Volumes = append(podSpec.Volumes, corev1.Volume{
Name: "appset-gitlab-scm-tls-cert",
Expand Down Expand Up @@ -288,7 +289,7 @@ func applicationSetContainer(cr *argoproj.ArgoCD, addSCMGitlabVolumeMount bool)
return container
}

func (r *ArgoCDReconciler) reconcileApplicationSetServiceAccount(cr *argoprojv1a1.ArgoCD) (*corev1.ServiceAccount, error) {
func (r *ArgoCDReconciler) reconcileApplicationSetServiceAccount(cr *v1beta1.ArgoCD) (*corev1.ServiceAccount, error) {

sa := newServiceAccountWithName("applicationset-controller", cr)
setAppSetLabels(&sa.ObjectMeta)
Expand Down Expand Up @@ -317,7 +318,7 @@ func (r *ArgoCDReconciler) reconcileApplicationSetServiceAccount(cr *argoprojv1a
return sa, err
}

func (r *ArgoCDReconciler) reconcileApplicationSetRole(cr *argoprojv1a1.ArgoCD) (*v1.Role, error) {
func (r *ArgoCDReconciler) reconcileApplicationSetRole(cr *v1beta1.ArgoCD) (*v1.Role, error) {

policyRules := []v1.PolicyRule{

Expand Down Expand Up @@ -419,7 +420,7 @@ func (r *ArgoCDReconciler) reconcileApplicationSetRole(cr *argoprojv1a1.ArgoCD)
return role, r.Client.Update(context.TODO(), role)
}

func (r *ArgoCDReconciler) reconcileApplicationSetRoleBinding(cr *argoprojv1a1.ArgoCD, role *v1.Role, sa *corev1.ServiceAccount) error {
func (r *ArgoCDReconciler) reconcileApplicationSetRoleBinding(cr *v1beta1.ArgoCD, role *v1.Role, sa *corev1.ServiceAccount) error {

name := "applicationset-controller"

Expand Down Expand Up @@ -510,7 +511,7 @@ func setAppSetLabels(obj *metav1.ObjectMeta) {
}

// reconcileApplicationSetService will ensure that the Service is present for the ApplicationSet webhook and metrics component.
func (r *ArgoCDReconciler) reconcileApplicationSetService(cr *argoprojv1a1.ArgoCD) error {
func (r *ArgoCDReconciler) reconcileApplicationSetService(cr *v1beta1.ArgoCD) error {
log.Info("reconciling applicationset service")

svc := newServiceWithSuffix(common.ApplicationSetServiceNameSuffix, common.ApplicationSetServiceNameSuffix, cr)
Expand Down
4 changes: 2 additions & 2 deletions controllers/argocd/applicationset/applicationset.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package applicationset

import (
"github.com/argoproj-labs/argocd-operator/api/v1alpha1"
"github.com/argoproj-labs/argocd-operator/api/v1beta1"
"github.com/go-logr/logr"
"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand All @@ -10,7 +10,7 @@ import (
type ApplicationSetReconciler struct {
Client *client.Client
Scheme *runtime.Scheme
Instance *v1alpha1.ArgoCD
Instance *v1beta1.ArgoCD
Logger logr.Logger
}

Expand Down
32 changes: 16 additions & 16 deletions controllers/argocd/applicationset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
logf "sigs.k8s.io/controller-runtime/pkg/log"

argoproj "github.com/argoproj-labs/argocd-operator/api/v1beta1"
"github.com/argoproj-labs/argocd-operator/api/v1beta1"
"github.com/argoproj-labs/argocd-operator/common"
"github.com/argoproj-labs/argocd-operator/pkg/util"
)
Expand Down Expand Up @@ -75,7 +75,7 @@ func applicationSetDefaultVolumes() []corev1.Volume {
func TestReconcileApplicationSet_CreateDeployments(t *testing.T) {
logf.SetLogger(ZapLogger(true))
a := makeTestArgoCD()
a.Spec.ApplicationSet = &argoproj.ArgoCDApplicationSet{}
a.Spec.ApplicationSet = &v1beta1.ArgoCDApplicationSet{}

r := makeTestReconciler(t, a)

Expand All @@ -96,7 +96,7 @@ func TestReconcileApplicationSet_CreateDeployments(t *testing.T) {
checkExpectedDeploymentValues(t, r, deployment, &sa, a)
}

func checkExpectedDeploymentValues(t *testing.T, r *ReconcileArgoCD, deployment *appsv1.Deployment, sa *corev1.ServiceAccount, a *argoproj.ArgoCD) {
func checkExpectedDeploymentValues(t *testing.T, r *ArgoCDReconciler, deployment *appsv1.Deployment, sa *corev1.ServiceAccount, a *v1beta1.ArgoCD) {
assert.Equal(t, deployment.Spec.Template.Spec.ServiceAccountName, sa.ObjectMeta.Name)
appsetAssertExpectedLabels(t, &deployment.ObjectMeta)

Expand Down Expand Up @@ -151,7 +151,7 @@ func checkExpectedDeploymentValues(t *testing.T, r *ReconcileArgoCD, deployment
},
}

if a.Spec.ApplicationSet.SCMRootCAConfigMap != "" && argoutil.IsObjectFound(r.Client, a.Namespace, common.ArgoCDAppSetGitlabSCMTLSCertsConfigMapName, a) {
if a.Spec.ApplicationSet.SCMRootCAConfigMap != "" && util.IsObjectFound(r.Client, a.Namespace, common.ArgoCDAppSetGitlabSCMTLSCertsConfigMapName, a) {
volumes = append(volumes, corev1.Volume{
Name: "appset-gitlab-scm-tls-cert",
VolumeSource: corev1.VolumeSource{
Expand Down Expand Up @@ -186,7 +186,7 @@ func TestReconcileApplicationSetProxyConfiguration(t *testing.T) {
setProxyEnvVars(t)

a := makeTestArgoCD()
a.Spec.ApplicationSet = &argoproj.ArgoCDApplicationSet{}
a.Spec.ApplicationSet = &v1beta1.ArgoCDApplicationSet{}

r := makeTestReconciler(t, a)

Expand Down Expand Up @@ -238,7 +238,7 @@ func TestReconcileApplicationSet_UpdateExistingDeployments(t *testing.T) {
logf.SetLogger(ZapLogger(true))
a := makeTestArgoCD()

a.Spec.ApplicationSet = &argoproj.ArgoCDApplicationSet{}
a.Spec.ApplicationSet = &v1beta1.ArgoCDApplicationSet{}

existingDeployment := &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -319,41 +319,41 @@ func TestReconcileApplicationSet_Deployments_SpecOverride(t *testing.T) {

tests := []struct {
name string
appSetField *argoproj.ArgoCDApplicationSet
appSetField *v1beta1.ArgoCDApplicationSet
envVars map[string]string
expectedContainerImage string
}{
{
name: "unspecified fields should use default",
appSetField: &v1alpha1.ArgoCDApplicationSet{},
appSetField: &v1beta1.ArgoCDApplicationSet{},
expectedContainerImage: util.CombineImageTag(common.ArgoCDDefaultArgoImage, common.ArgoCDDefaultArgoVersion),
},
{
name: "ensure that sha hashes are formatted correctly",
appSetField: &argoproj.ArgoCDApplicationSet{
appSetField: &v1beta1.ArgoCDApplicationSet{
Image: "custom-image",
Version: "sha256:b835999eb5cf75d01a2678cd971095926d9c2566c9ffe746d04b83a6a0a2849f",
},
expectedContainerImage: "custom-image@sha256:b835999eb5cf75d01a2678cd971095926d9c2566c9ffe746d04b83a6a0a2849f",
},
{
name: "custom image should properly substitute",
appSetField: &argoproj.ArgoCDApplicationSet{
appSetField: &v1beta1.ArgoCDApplicationSet{
Image: "custom-image",
Version: "custom-version",
},
expectedContainerImage: "custom-image:custom-version",
},
{
name: "verify env var substitution overrides default",
appSetField: &v1alpha1.ArgoCDApplicationSet{},
appSetField: &v1beta1.ArgoCDApplicationSet{},
envVars: map[string]string{common.ArgoCDImageEnvVar: "custom-env-image"},
expectedContainerImage: "custom-env-image",
},

{
name: "env var should not override spec fields",
appSetField: &argoproj.ArgoCDApplicationSet{
appSetField: &v1beta1.ArgoCDApplicationSet{
Image: "custom-image",
Version: "custom-version",
},
Expand All @@ -362,10 +362,10 @@ func TestReconcileApplicationSet_Deployments_SpecOverride(t *testing.T) {
},
{
name: "ensure scm tls cert mount is present",
appSetField: &argoproj.ArgoCDApplicationSet{
appSetField: &v1beta1.ArgoCDApplicationSet{
SCMRootCAConfigMap: "test-scm-tls-mount",
},
envVars: map[string]string{common.ArgoCDImageEnvName: "custom-env-image"},
envVars: map[string]string{common.ArgoCDImageEnvVar: "custom-env-image"},
expectedContainerImage: "custom-env-image",
},
}
Expand Down Expand Up @@ -524,7 +524,7 @@ func TestReconcileApplicationSet_Service(t *testing.T) {

func TestArgoCDApplicationSetCommand(t *testing.T) {
a := makeTestArgoCD()
a.Spec.ApplicationSet = &argoproj.ArgoCDApplicationSet{}
a.Spec.ApplicationSet = &v1beta1.ArgoCDApplicationSet{}
r := makeTestReconciler(t, a)

baseCommand := []string{
Expand Down Expand Up @@ -611,7 +611,7 @@ func TestArgoCDApplicationSetCommand(t *testing.T) {

func TestArgoCDApplicationSetEnv(t *testing.T) {
a := makeTestArgoCD()
a.Spec.ApplicationSet = &argoproj.ArgoCDApplicationSet{}
a.Spec.ApplicationSet = &v1beta1.ArgoCDApplicationSet{}
r := makeTestReconciler(t, a)

defaultEnv := []corev1.EnvVar{
Expand Down
12 changes: 3 additions & 9 deletions controllers/argocd/argocd_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"fmt"
"time"

"github.com/argoproj-labs/argocd-operator/api/v1alpha1"
"github.com/argoproj-labs/argocd-operator/api/v1beta1"
"github.com/argoproj-labs/argocd-operator/common"
"github.com/argoproj-labs/argocd-operator/controllers/argocd/appcontroller"
"github.com/argoproj-labs/argocd-operator/controllers/argocd/applicationset"
Expand All @@ -36,9 +36,6 @@ import (
"github.com/go-logr/logr"
"github.com/prometheus/client_golang/prometheus"

argoproj "github.com/argoproj-labs/argocd-operator/api/v1beta1"

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"

Expand All @@ -54,7 +51,7 @@ var _ reconcile.Reconciler = &ArgoCDReconciler{}
type ArgoCDReconciler struct {
client.Client
Scheme *runtime.Scheme
Instance *v1alpha1.ArgoCD
Instance *v1beta1.ArgoCD
ClusterScoped bool
Logger logr.Logger

Expand Down Expand Up @@ -114,10 +111,7 @@ func (r *ArgoCDReconciler) Reconcile(ctx context.Context, request ctrl.Request)
ReconcileTime.WithLabelValues(request.Namespace).Observe(time.Since(reconcileStartTS).Seconds())
}()

reqLogger := logr.FromContext(ctx, "namespace", request.Namespace, "name", request.Name)
reqLogger.Info("Reconciling ArgoCD")

argocd := &v1alpha1.ArgoCD{}
argocd := &v1beta1.ArgoCD{}
err := r.Client.Get(ctx, request.NamespacedName, argocd)
if err != nil {
if errors.IsNotFound(err) {
Expand Down
14 changes: 7 additions & 7 deletions controllers/argocd/argocd_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

argoproj "github.com/argoproj-labs/argocd-operator/api/v1beta1"
"github.com/argoproj-labs/argocd-operator/api/v1beta1"
"github.com/argoproj-labs/argocd-operator/common"
"github.com/argoproj-labs/argocd-operator/pkg/cluster"
"github.com/argoproj-labs/argocd-operator/pkg/util"
Expand All @@ -43,19 +43,19 @@ import (
var _ reconcile.Reconciler = &ArgoCDReconciler{}

func deletedAt(now time.Time) argoCDOpt {
return func(a *argov1alpha1.ArgoCD) {
return func(a *v1beta1.ArgoCD) {
wrapped := metav1.NewTime(now)
a.ObjectMeta.DeletionTimestamp = &wrapped
}
}

func addFinalizer(finalizer string) argoCDOpt {
return func(a *argov1alpha1.ArgoCD) {
return func(a *v1beta1.ArgoCD) {
a.Finalizers = append(a.Finalizers, finalizer)
}
}

func clusterResources(argocd *argov1alpha1.ArgoCD) []runtime.Object {
func clusterResources(argocd *v1beta1.ArgoCD) []runtime.Object {
return []runtime.Object{
newClusterRole(common.ArgoCDApplicationControllerComponent, []v1.PolicyRule{}, argocd),
newClusterRole(common.ArgoCDServerComponent, []v1.PolicyRule{}, argocd),
Expand Down Expand Up @@ -288,10 +288,10 @@ func TestSetResourceManagedNamespaces(t *testing.T) {
}),
)

instanceOne := makeTestArgoCD(func(ac *argov1alpha1.ArgoCD) {
instanceOne := makeTestArgoCD(func(ac *v1beta1.ArgoCD) {
ac.Namespace = "instance-1"
})
instanceTwo := makeTestArgoCD(func(ac *argov1alpha1.ArgoCD) {
instanceTwo := makeTestArgoCD(func(ac *v1beta1.ArgoCD) {
ac.Namespace = "instance-2"
})

Expand Down Expand Up @@ -345,7 +345,7 @@ func TestSetAppManagedNamespaces(t *testing.T) {
}),
)

instance := makeTestArgoCD(func(ac *argov1alpha1.ArgoCD) {
instance := makeTestArgoCD(func(ac *v1beta1.ArgoCD) {
ac.Namespace = "instance-1"
ac.Spec.SourceNamespaces = []string{"test-ns-1", "test-ns-2", "test-ns-3"}
})
Expand Down
4 changes: 2 additions & 2 deletions controllers/argocd/argocdcommon/argohelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package argocdcommon
import (
"os"

"github.com/argoproj-labs/argocd-operator/api/v1alpha1"
"github.com/argoproj-labs/argocd-operator/api/v1beta1"
"github.com/argoproj-labs/argocd-operator/common"
"github.com/argoproj-labs/argocd-operator/pkg/util"
)

func GetArgoContainerImage(cr *v1alpha1.ArgoCD) string {
func GetArgoContainerImage(cr *v1beta1.ArgoCD) string {
defaultTag, defaultImg := false, false
img := cr.Spec.Image
if img == "" {
Expand Down
8 changes: 4 additions & 4 deletions controllers/argocd/argocdcommon/testing.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package argocdcommon

import (
"github.com/argoproj-labs/argocd-operator/api/v1alpha1"
"github.com/argoproj-labs/argocd-operator/api/v1beta1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand All @@ -28,10 +28,10 @@ func MakeTestServiceAccount() *corev1.ServiceAccount {
}
}

type argoCDOpt func(*v1alpha1.ArgoCD)
type argoCDOpt func(*v1beta1.ArgoCD)

func MakeTestArgoCD(opts ...argoCDOpt) *v1alpha1.ArgoCD {
a := &v1alpha1.ArgoCD{
func MakeTestArgoCD(opts ...argoCDOpt) *v1beta1.ArgoCD {
a := &v1beta1.ArgoCD{
ObjectMeta: metav1.ObjectMeta{
Name: TestArgoCDName,
Namespace: TestNamespace,
Expand Down
Loading

0 comments on commit 7c12e38

Please sign in to comment.