cd: kill the argo naming — binaries, packages, identifiers

Every command is cd-*: cd, cd-server, cd-repo-server,
cd-application-controller, cd-applicationset-controller, cd-cmp-server,
cd-commit-server, cd-dex, cd-git-ask-pass, cd-k8s-auth, cd-notification.
util/argo is util/cd; util/notification/argocd is util/notification/cd.

Preserved deliberately: github.com/argoproj/argocd-example-apps is an
EXTERNAL repo used as an e2e fixture, and notifications-engine + pkg/v2 are
real dependencies. Renaming a URL we do not own would break the tests.

Two bugs I made and caught, both from a careless sed:
- s/argo/cd/g turned 'argocd' into 'cdcd' in two directory names
- renaming the package declaration left every call site saying argo.X

go build ./... exit 0.

Co-authored-by: Hanzo Dev <[email protected]>
This commit is contained in:
2026-07-28 16:00:25 -07:00
co-authored by Hanzo Dev
parent a30bce2e1b
commit 84ee9fa0ce
903 changed files with 4085 additions and 4085 deletions
@@ -57,16 +57,16 @@ import (
"github.com/hanzoai/deploy/util/settings"
argov1alpha1 "github.com/hanzoai/deploy/pkg/apis/application/v1alpha1"
argoutil "github.com/hanzoai/deploy/util/argo"
"github.com/hanzoai/deploy/util/argo/normalizers"
argoutil "github.com/hanzoai/deploy/util/cd"
"github.com/hanzoai/deploy/util/cd/normalizers"
"github.com/hanzoai/deploy/pkg/apis/application"
)
const (
// Rather than importing the whole argocd-notifications controller, just copying the const here
// https://github.com/argoproj-labs/argocd-notifications/blob/33d345fa838829bb50fca5c08523aba380d2c12b/pkg/controller/subscriptions.go#L12
// https://github.com/argoproj-labs/argocd-notifications/blob/33d345fa838829bb50fca5c08523aba380d2c12b/pkg/controller/state.go#L17
// Rather than importing the whole cd-notifications controller, just copying the const here
// https://github.com/argoproj-labs/cd-notifications/blob/33d345fa838829bb50fca5c08523aba380d2c12b/pkg/controller/subscriptions.go#L12
// https://github.com/argoproj-labs/cd-notifications/blob/33d345fa838829bb50fca5c08523aba380d2c12b/pkg/controller/state.go#L17
NotifiedAnnotationKey = "notified.notifications.argoproj.io"
ReconcileRequeueOnValidationError = time.Minute * 3
ReverseDeletionOrder = "Reverse"
@@ -51,9 +51,9 @@ func getDefaultTestClientSet(obj ...runtime.Object) *kubefake.Clientset {
argoCDSecret := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: argocommon.ArgoCDSecretName,
Namespace: "argocd",
Namespace: "cd",
Labels: map[string]string{
"app.kubernetes.io/part-of": "argocd",
"app.kubernetes.io/part-of": "cd",
},
},
Data: map[string][]byte{
@@ -65,9 +65,9 @@ func getDefaultTestClientSet(obj ...runtime.Object) *kubefake.Clientset {
emptyArgoCDConfigMap := &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: argocommon.ArgoCDConfigMapName,
Namespace: "argocd",
Namespace: "cd",
Labels: map[string]string{
"app.kubernetes.io/part-of": "argocd",
"app.kubernetes.io/part-of": "cd",
},
},
Data: map[string]string{},
@@ -524,7 +524,7 @@ func TestCreateOrUpdateInCluster(t *testing.T) {
},
},
{
name: "Ensure that argocd notifications state and refresh annotation is preserved from an existing app",
name: "Ensure that cd notifications state and refresh annotation is preserved from an existing app",
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
@@ -1144,7 +1144,7 @@ func TestCreateOrUpdateInCluster(t *testing.T) {
},
},
{
name: "Ensure that argocd pre-delete and post-delete finalizers are preserved from an existing app",
name: "Ensure that cd pre-delete and post-delete finalizers are preserved from an existing app",
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
@@ -1712,10 +1712,10 @@ func TestRemoveFinalizerOnInvalidDestination_FinalizerTypes(t *testing.T) {
kubeclientset := kubefake.NewClientset(objects...)
metrics := appsetmetrics.NewFakeAppsetMetrics()
settingsMgr := settings.NewSettingsManager(t.Context(), kubeclientset, "argocd")
settingsMgr := settings.NewSettingsManager(t.Context(), kubeclientset, "cd")
// Initialize the settings manager to ensure cluster cache is ready
_ = settingsMgr.ResyncInformers()
argodb := db.NewDB("argocd", settingsMgr, kubeclientset)
argodb := db.NewDB("cd", settingsMgr, kubeclientset)
clusterInformer, err := settings.NewClusterInformer(kubeclientset, "namespace")
require.NoError(t, err)
@@ -1857,7 +1857,7 @@ func TestRemoveFinalizerOnInvalidDestination_DestinationTypes(t *testing.T) {
secret := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "my-secret",
Namespace: "argocd",
Namespace: "cd",
Labels: map[string]string{
argocommon.LabelKeySecretType: argocommon.LabelValueSecretTypeCluster,
},
@@ -1878,12 +1878,12 @@ func TestRemoveFinalizerOnInvalidDestination_DestinationTypes(t *testing.T) {
kubeclientset := getDefaultTestClientSet(secret)
metrics := appsetmetrics.NewFakeAppsetMetrics()
settingsMgr := settings.NewSettingsManager(t.Context(), kubeclientset, "argocd")
settingsMgr := settings.NewSettingsManager(t.Context(), kubeclientset, "cd")
// Initialize the settings manager to ensure cluster cache is ready
_ = settingsMgr.ResyncInformers()
argodb := db.NewDB("argocd", settingsMgr, kubeclientset)
argodb := db.NewDB("cd", settingsMgr, kubeclientset)
clusterInformer, err := settings.NewClusterInformer(kubeclientset, "argocd")
clusterInformer, err := settings.NewClusterInformer(kubeclientset, "cd")
require.NoError(t, err)
defer startAndSyncInformer(t, clusterInformer)()
@@ -2425,7 +2425,7 @@ func TestRequeueGeneratorFails(t *testing.T) {
appSet := v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Generators: []v1alpha1.ApplicationSetGenerator{{
@@ -2459,7 +2459,7 @@ func TestRequeueGeneratorFails(t *testing.T) {
req := ctrl.Request{
NamespacedName: types.NamespacedName{
Namespace: "argocd",
Namespace: "cd",
Name: "name",
},
}
@@ -2628,7 +2628,7 @@ func TestValidateGeneratedApplications(t *testing.T) {
secret := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "my-secret",
Namespace: "argocd",
Namespace: "cd",
Labels: map[string]string{
argocommon.LabelKeySecretType: argocommon.LabelValueSecretTypeCluster,
},
@@ -2642,7 +2642,7 @@ func TestValidateGeneratedApplications(t *testing.T) {
kubeclientset := getDefaultTestClientSet(secret)
argodb := db.NewDB("argocd", settings.NewSettingsManager(t.Context(), kubeclientset, "argocd"), kubeclientset)
argodb := db.NewDB("cd", settings.NewSettingsManager(t.Context(), kubeclientset, "cd"), kubeclientset)
r := ApplicationSetReconciler{
Client: client,
@@ -2670,12 +2670,12 @@ func TestReconcilerValidationProjectErrorBehaviour(t *testing.T) {
require.NoError(t, err)
project := v1alpha1.AppProject{
ObjectMeta: metav1.ObjectMeta{Name: "good-project", Namespace: "argocd"},
ObjectMeta: metav1.ObjectMeta{Name: "good-project", Namespace: "cd"},
}
appSet := v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
GoTemplate: true,
@@ -2693,7 +2693,7 @@ func TestReconcilerValidationProjectErrorBehaviour(t *testing.T) {
Template: v1alpha1.ApplicationSetTemplate{
ApplicationSetTemplateMeta: v1alpha1.ApplicationSetTemplateMeta{
Name: "{{.project}}",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSpec{
Source: &v1alpha1.ApplicationSource{RepoURL: "https://github.com/argoproj/argocd-example-apps", Path: "guestbook"},
@@ -2709,9 +2709,9 @@ func TestReconcilerValidationProjectErrorBehaviour(t *testing.T) {
client := fake.NewClientBuilder().WithScheme(scheme).WithObjects(&appSet, &project).WithStatusSubresource(&appSet).WithIndex(&v1alpha1.Application{}, ".metadata.controller", appControllerIndexer).Build()
metrics := appsetmetrics.NewFakeAppsetMetrics()
argodb := db.NewDB("argocd", settings.NewSettingsManager(t.Context(), kubeclientset, "argocd"), kubeclientset)
argodb := db.NewDB("cd", settings.NewSettingsManager(t.Context(), kubeclientset, "cd"), kubeclientset)
clusterInformer, err := settings.NewClusterInformer(kubeclientset, "argocd")
clusterInformer, err := settings.NewClusterInformer(kubeclientset, "cd")
require.NoError(t, err)
r := ApplicationSetReconciler{
@@ -2725,14 +2725,14 @@ func TestReconcilerValidationProjectErrorBehaviour(t *testing.T) {
ArgoDB: argodb,
KubeClientset: kubeclientset,
Policy: v1alpha1.ApplicationsSyncPolicySync,
ArgoCDNamespace: "argocd",
ArgoCDNamespace: "cd",
Metrics: metrics,
ClusterInformer: clusterInformer,
}
req := ctrl.Request{
NamespacedName: types.NamespacedName{
Namespace: "argocd",
Namespace: "cd",
Name: "name",
},
}
@@ -2745,12 +2745,12 @@ func TestReconcilerValidationProjectErrorBehaviour(t *testing.T) {
var app v1alpha1.Application
// make sure good app got created
err = r.Get(t.Context(), crtclient.ObjectKey{Namespace: "argocd", Name: "good-project"}, &app)
err = r.Get(t.Context(), crtclient.ObjectKey{Namespace: "cd", Name: "good-project"}, &app)
require.NoError(t, err)
assert.Equal(t, "good-project", app.Name)
// make sure bad app was not created
err = r.Get(t.Context(), crtclient.ObjectKey{Namespace: "argocd", Name: "bad-project"}, &app)
err = r.Get(t.Context(), crtclient.ObjectKey{Namespace: "cd", Name: "bad-project"}, &app)
require.Error(t, err)
}
@@ -2775,7 +2775,7 @@ func TestSetApplicationSetStatusCondition(t *testing.T) {
appset: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Generators: []v1alpha1.ApplicationSetGenerator{
@@ -2815,7 +2815,7 @@ func TestSetApplicationSetStatusCondition(t *testing.T) {
appset: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Generators: []v1alpha1.ApplicationSetGenerator{
@@ -2851,7 +2851,7 @@ func TestSetApplicationSetStatusCondition(t *testing.T) {
appset: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Generators: []v1alpha1.ApplicationSetGenerator{
@@ -2891,7 +2891,7 @@ func TestSetApplicationSetStatusCondition(t *testing.T) {
appset: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Generators: []v1alpha1.ApplicationSetGenerator{
@@ -2934,7 +2934,7 @@ func TestSetApplicationSetStatusCondition(t *testing.T) {
appset: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Generators: []v1alpha1.ApplicationSetGenerator{
@@ -2977,7 +2977,7 @@ func TestSetApplicationSetStatusCondition(t *testing.T) {
appset: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Generators: []v1alpha1.ApplicationSetGenerator{
@@ -3045,7 +3045,7 @@ func TestSetApplicationSetStatusCondition(t *testing.T) {
appset: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Generators: []v1alpha1.ApplicationSetGenerator{
@@ -3105,7 +3105,7 @@ func TestSetApplicationSetStatusCondition(t *testing.T) {
appset: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Generators: []v1alpha1.ApplicationSetGenerator{
@@ -3160,7 +3160,7 @@ func TestSetApplicationSetStatusCondition(t *testing.T) {
appset: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Generators: []v1alpha1.ApplicationSetGenerator{
@@ -3219,7 +3219,7 @@ func TestSetApplicationSetStatusCondition(t *testing.T) {
t.Run(c.name, func(t *testing.T) {
client := fake.NewClientBuilder().WithScheme(scheme).WithObjects(&c.appset).WithIndex(&v1alpha1.Application{}, ".metadata.controller", appControllerIndexer).WithStatusSubresource(&c.appset).Build()
metrics := appsetmetrics.NewFakeAppsetMetrics()
argodb := db.NewDB("argocd", settings.NewSettingsManager(t.Context(), kubeclientset, "argocd"), kubeclientset)
argodb := db.NewDB("cd", settings.NewSettingsManager(t.Context(), kubeclientset, "cd"), kubeclientset)
r := ApplicationSetReconciler{
Client: client,
@@ -3251,13 +3251,13 @@ func applicationsUpdateSyncPolicyTest(t *testing.T, applicationsSyncPolicy v1alp
require.NoError(t, err)
defaultProject := v1alpha1.AppProject{
ObjectMeta: metav1.ObjectMeta{Name: "default", Namespace: "argocd"},
ObjectMeta: metav1.ObjectMeta{Name: "default", Namespace: "cd"},
Spec: v1alpha1.AppProjectSpec{SourceRepos: []string{"*"}, Destinations: []v1alpha1.ApplicationDestination{{Namespace: "*", Server: "https://good-cluster"}}},
}
appSet := v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Generators: []v1alpha1.ApplicationSetGenerator{
@@ -3275,7 +3275,7 @@ func applicationsUpdateSyncPolicyTest(t *testing.T, applicationsSyncPolicy v1alp
Template: v1alpha1.ApplicationSetTemplate{
ApplicationSetTemplateMeta: v1alpha1.ApplicationSetTemplateMeta{
Name: "{{cluster}}",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSpec{
Source: &v1alpha1.ApplicationSource{RepoURL: "https://github.com/argoproj/argocd-example-apps", Path: "guestbook"},
@@ -3289,7 +3289,7 @@ func applicationsUpdateSyncPolicyTest(t *testing.T, applicationsSyncPolicy v1alp
secret := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "my-cluster",
Namespace: "argocd",
Namespace: "cd",
Labels: map[string]string{
argocommon.LabelKeySecretType: argocommon.LabelValueSecretTypeCluster,
},
@@ -3308,8 +3308,8 @@ func applicationsUpdateSyncPolicyTest(t *testing.T, applicationsSyncPolicy v1alp
client := fake.NewClientBuilder().WithScheme(scheme).WithObjects(&appSet, &defaultProject, secret).WithStatusSubresource(&appSet).WithIndex(&v1alpha1.Application{}, ".metadata.controller", appControllerIndexer).Build()
metrics := appsetmetrics.NewFakeAppsetMetrics()
argodb := db.NewDB("argocd", settings.NewSettingsManager(t.Context(), kubeclientset, "argocd"), kubeclientset)
clusterInformer, err := settings.NewClusterInformer(kubeclientset, "argocd")
argodb := db.NewDB("cd", settings.NewSettingsManager(t.Context(), kubeclientset, "cd"), kubeclientset)
clusterInformer, err := settings.NewClusterInformer(kubeclientset, "cd")
require.NoError(t, err)
defer startAndSyncInformer(t, clusterInformer)()
@@ -3323,7 +3323,7 @@ func applicationsUpdateSyncPolicyTest(t *testing.T, applicationsSyncPolicy v1alp
"List": generators.NewListGenerator(),
},
ArgoDB: argodb,
ArgoCDNamespace: "argocd",
ArgoCDNamespace: "cd",
KubeClientset: kubeclientset,
Policy: v1alpha1.ApplicationsSyncPolicySync,
EnablePolicyOverride: allowPolicyOverride,
@@ -3333,7 +3333,7 @@ func applicationsUpdateSyncPolicyTest(t *testing.T, applicationsSyncPolicy v1alp
req := ctrl.Request{
NamespacedName: types.NamespacedName{
Namespace: "argocd",
Namespace: "cd",
Name: "name",
},
}
@@ -3346,13 +3346,13 @@ func applicationsUpdateSyncPolicyTest(t *testing.T, applicationsSyncPolicy v1alp
var app v1alpha1.Application
// make sure good app got created
err = r.Get(t.Context(), crtclient.ObjectKey{Namespace: "argocd", Name: "good-cluster"}, &app)
err = r.Get(t.Context(), crtclient.ObjectKey{Namespace: "cd", Name: "good-cluster"}, &app)
require.NoError(t, err)
assert.Equal(t, "good-cluster", app.Name)
// Update resource
var retrievedApplicationSet v1alpha1.ApplicationSet
err = r.Get(t.Context(), crtclient.ObjectKey{Namespace: "argocd", Name: "name"}, &retrievedApplicationSet)
err = r.Get(t.Context(), crtclient.ObjectKey{Namespace: "cd", Name: "name"}, &retrievedApplicationSet)
require.NoError(t, err)
retrievedApplicationSet.Spec.Template.Annotations = map[string]string{"annotation-key": "annotation-value"}
@@ -3368,7 +3368,7 @@ func applicationsUpdateSyncPolicyTest(t *testing.T, applicationsSyncPolicy v1alp
resUpdate, err := r.Reconcile(t.Context(), req)
require.NoError(t, err)
err = r.Get(t.Context(), crtclient.ObjectKey{Namespace: "argocd", Name: "good-cluster"}, &app)
err = r.Get(t.Context(), crtclient.ObjectKey{Namespace: "cd", Name: "good-cluster"}, &app)
require.NoError(t, err)
assert.Equal(t, time.Duration(0), resUpdate.RequeueAfter)
assert.Equal(t, "good-cluster", app.Name)
@@ -3424,14 +3424,14 @@ func TestReconcilePopulatesResourcesStatusOnFirstRun(t *testing.T) {
require.NoError(t, err)
defaultProject := v1alpha1.AppProject{
ObjectMeta: metav1.ObjectMeta{Name: "default", Namespace: "argocd"},
ObjectMeta: metav1.ObjectMeta{Name: "default", Namespace: "cd"},
Spec: v1alpha1.AppProjectSpec{SourceRepos: []string{"*"}, Destinations: []v1alpha1.ApplicationDestination{{Namespace: "*", Server: "https://good-cluster"}}},
}
applicationsSyncPolicy := v1alpha1.ApplicationsSyncPolicySync
appSet := v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Generators: []v1alpha1.ApplicationSetGenerator{
@@ -3449,7 +3449,7 @@ func TestReconcilePopulatesResourcesStatusOnFirstRun(t *testing.T) {
Template: v1alpha1.ApplicationSetTemplate{
ApplicationSetTemplateMeta: v1alpha1.ApplicationSetTemplateMeta{
Name: "{{cluster}}",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSpec{
Source: &v1alpha1.ApplicationSource{RepoURL: "https://github.com/argoproj/argocd-example-apps", Path: "guestbook"},
@@ -3463,7 +3463,7 @@ func TestReconcilePopulatesResourcesStatusOnFirstRun(t *testing.T) {
secret := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "my-cluster",
Namespace: "argocd",
Namespace: "cd",
Labels: map[string]string{
argocommon.LabelKeySecretType: argocommon.LabelValueSecretTypeCluster,
},
@@ -3484,8 +3484,8 @@ func TestReconcilePopulatesResourcesStatusOnFirstRun(t *testing.T) {
Build()
metrics := appsetmetrics.NewFakeAppsetMetrics()
argodb := db.NewDB("argocd", settings.NewSettingsManager(t.Context(), kubeclientset, "argocd"), kubeclientset)
clusterInformer, err := settings.NewClusterInformer(kubeclientset, "argocd")
argodb := db.NewDB("cd", settings.NewSettingsManager(t.Context(), kubeclientset, "cd"), kubeclientset)
clusterInformer, err := settings.NewClusterInformer(kubeclientset, "cd")
require.NoError(t, err)
defer startAndSyncInformer(t, clusterInformer)()
@@ -3497,7 +3497,7 @@ func TestReconcilePopulatesResourcesStatusOnFirstRun(t *testing.T) {
Recorder: record.NewFakeRecorder(1),
Generators: map[string]generators.Generator{"List": generators.NewListGenerator()},
ArgoDB: argodb,
ArgoCDNamespace: "argocd",
ArgoCDNamespace: "cd",
KubeClientset: kubeclientset,
Policy: v1alpha1.ApplicationsSyncPolicySync,
Metrics: metrics,
@@ -3505,14 +3505,14 @@ func TestReconcilePopulatesResourcesStatusOnFirstRun(t *testing.T) {
}
req := ctrl.Request{
NamespacedName: types.NamespacedName{Namespace: "argocd", Name: "name"},
NamespacedName: types.NamespacedName{Namespace: "cd", Name: "name"},
}
_, err = r.Reconcile(t.Context(), req)
require.NoError(t, err)
var retrievedAppSet v1alpha1.ApplicationSet
err = r.Get(t.Context(), crtclient.ObjectKey{Namespace: "argocd", Name: "name"}, &retrievedAppSet)
err = r.Get(t.Context(), crtclient.ObjectKey{Namespace: "cd", Name: "name"}, &retrievedAppSet)
require.NoError(t, err)
assert.Len(t, retrievedAppSet.Status.Resources, 1, "status.resources should have 1 item after first reconcile")
@@ -3539,13 +3539,13 @@ func applicationsDeleteSyncPolicyTest(t *testing.T, applicationsSyncPolicy v1alp
require.NoError(t, err)
defaultProject := v1alpha1.AppProject{
ObjectMeta: metav1.ObjectMeta{Name: "default", Namespace: "argocd"},
ObjectMeta: metav1.ObjectMeta{Name: "default", Namespace: "cd"},
Spec: v1alpha1.AppProjectSpec{SourceRepos: []string{"*"}, Destinations: []v1alpha1.ApplicationDestination{{Namespace: "*", Server: "https://good-cluster"}}},
}
appSet := v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Generators: []v1alpha1.ApplicationSetGenerator{
@@ -3563,7 +3563,7 @@ func applicationsDeleteSyncPolicyTest(t *testing.T, applicationsSyncPolicy v1alp
Template: v1alpha1.ApplicationSetTemplate{
ApplicationSetTemplateMeta: v1alpha1.ApplicationSetTemplateMeta{
Name: "{{cluster}}",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSpec{
Source: &v1alpha1.ApplicationSource{RepoURL: "https://github.com/argoproj/argocd-example-apps", Path: "guestbook"},
@@ -3577,7 +3577,7 @@ func applicationsDeleteSyncPolicyTest(t *testing.T, applicationsSyncPolicy v1alp
secret := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "my-cluster",
Namespace: "argocd",
Namespace: "cd",
Labels: map[string]string{
argocommon.LabelKeySecretType: argocommon.LabelValueSecretTypeCluster,
},
@@ -3596,9 +3596,9 @@ func applicationsDeleteSyncPolicyTest(t *testing.T, applicationsSyncPolicy v1alp
client := fake.NewClientBuilder().WithScheme(scheme).WithObjects(&appSet, &defaultProject, secret).WithStatusSubresource(&appSet).WithIndex(&v1alpha1.Application{}, ".metadata.controller", appControllerIndexer).Build()
metrics := appsetmetrics.NewFakeAppsetMetrics()
argodb := db.NewDB("argocd", settings.NewSettingsManager(t.Context(), kubeclientset, "argocd"), kubeclientset)
argodb := db.NewDB("cd", settings.NewSettingsManager(t.Context(), kubeclientset, "cd"), kubeclientset)
clusterInformer, err := settings.NewClusterInformer(kubeclientset, "argocd")
clusterInformer, err := settings.NewClusterInformer(kubeclientset, "cd")
require.NoError(t, err)
defer startAndSyncInformer(t, clusterInformer)()
@@ -3612,7 +3612,7 @@ func applicationsDeleteSyncPolicyTest(t *testing.T, applicationsSyncPolicy v1alp
"List": generators.NewListGenerator(),
},
ArgoDB: argodb,
ArgoCDNamespace: "argocd",
ArgoCDNamespace: "cd",
KubeClientset: kubeclientset,
Policy: v1alpha1.ApplicationsSyncPolicySync,
EnablePolicyOverride: allowPolicyOverride,
@@ -3622,7 +3622,7 @@ func applicationsDeleteSyncPolicyTest(t *testing.T, applicationsSyncPolicy v1alp
req := ctrl.Request{
NamespacedName: types.NamespacedName{
Namespace: "argocd",
Namespace: "cd",
Name: "name",
},
}
@@ -3635,13 +3635,13 @@ func applicationsDeleteSyncPolicyTest(t *testing.T, applicationsSyncPolicy v1alp
var app v1alpha1.Application
// make sure good app got created
err = r.Get(t.Context(), crtclient.ObjectKey{Namespace: "argocd", Name: "good-cluster"}, &app)
err = r.Get(t.Context(), crtclient.ObjectKey{Namespace: "cd", Name: "good-cluster"}, &app)
require.NoError(t, err)
assert.Equal(t, "good-cluster", app.Name)
// Update resource
var retrievedApplicationSet v1alpha1.ApplicationSet
err = r.Get(t.Context(), crtclient.ObjectKey{Namespace: "argocd", Name: "name"}, &retrievedApplicationSet)
err = r.Get(t.Context(), crtclient.ObjectKey{Namespace: "cd", Name: "name"}, &retrievedApplicationSet)
require.NoError(t, err)
retrievedApplicationSet.Spec.Generators = []v1alpha1.ApplicationSetGenerator{
{
@@ -3714,7 +3714,7 @@ func TestPolicies(t *testing.T) {
require.NoError(t, err)
defaultProject := v1alpha1.AppProject{
ObjectMeta: metav1.ObjectMeta{Name: "default", Namespace: "argocd"},
ObjectMeta: metav1.ObjectMeta{Name: "default", Namespace: "cd"},
Spec: v1alpha1.AppProjectSpec{SourceRepos: []string{"*"}, Destinations: []v1alpha1.ApplicationDestination{{Namespace: "*", Server: "https://kubernetes.default.svc"}}},
}
@@ -3758,7 +3758,7 @@ func TestPolicies(t *testing.T) {
appSet := v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
GoTemplate: true,
@@ -3776,7 +3776,7 @@ func TestPolicies(t *testing.T) {
Template: v1alpha1.ApplicationSetTemplate{
ApplicationSetTemplateMeta: v1alpha1.ApplicationSetTemplateMeta{
Name: "{{.name}}",
Namespace: "argocd",
Namespace: "cd",
Annotations: map[string]string{
"key": "value",
},
@@ -3793,9 +3793,9 @@ func TestPolicies(t *testing.T) {
client := fake.NewClientBuilder().WithScheme(scheme).WithObjects(&appSet, &defaultProject).WithStatusSubresource(&appSet).WithIndex(&v1alpha1.Application{}, ".metadata.controller", appControllerIndexer).Build()
metrics := appsetmetrics.NewFakeAppsetMetrics()
argodb := db.NewDB("argocd", settings.NewSettingsManager(t.Context(), kubeclientset, "argocd"), kubeclientset)
argodb := db.NewDB("cd", settings.NewSettingsManager(t.Context(), kubeclientset, "cd"), kubeclientset)
clusterInformer, err := settings.NewClusterInformer(kubeclientset, "argocd")
clusterInformer, err := settings.NewClusterInformer(kubeclientset, "cd")
require.NoError(t, err)
defer startAndSyncInformer(t, clusterInformer)()
@@ -3809,7 +3809,7 @@ func TestPolicies(t *testing.T) {
"List": generators.NewListGenerator(),
},
ArgoDB: argodb,
ArgoCDNamespace: "argocd",
ArgoCDNamespace: "cd",
KubeClientset: kubeclientset,
Policy: policy,
ClusterInformer: clusterInformer,
@@ -3818,7 +3818,7 @@ func TestPolicies(t *testing.T) {
req := ctrl.Request{
NamespacedName: types.NamespacedName{
Namespace: "argocd",
Namespace: "cd",
Name: "name",
},
}
@@ -3829,7 +3829,7 @@ func TestPolicies(t *testing.T) {
assert.Equal(t, time.Duration(0), res.RequeueAfter)
var app v1alpha1.Application
err = r.Get(ctx, crtclient.ObjectKey{Namespace: "argocd", Name: "my-app"}, &app)
err = r.Get(ctx, crtclient.ObjectKey{Namespace: "cd", Name: "my-app"}, &app)
require.NoError(t, err)
assert.Equal(t, "value", app.Annotations["key"])
@@ -3842,7 +3842,7 @@ func TestPolicies(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, time.Duration(0), res.RequeueAfter)
err = r.Get(ctx, crtclient.ObjectKey{Namespace: "argocd", Name: "my-app"}, &app)
err = r.Get(ctx, crtclient.ObjectKey{Namespace: "cd", Name: "my-app"}, &app)
require.NoError(t, err)
if c.allowedUpdate {
@@ -3852,7 +3852,7 @@ func TestPolicies(t *testing.T) {
}
// Check if the Application is deleted
err = r.Get(ctx, crtclient.ObjectKey{Namespace: "argocd", Name: "name"}, &appSet)
err = r.Get(ctx, crtclient.ObjectKey{Namespace: "cd", Name: "name"}, &appSet)
require.NoError(t, err)
appSet.Spec.Generators[0] = v1alpha1.ApplicationSetGenerator{
List: &v1alpha1.ListGenerator{
@@ -3866,7 +3866,7 @@ func TestPolicies(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, time.Duration(0), res.RequeueAfter)
err = r.Get(ctx, crtclient.ObjectKey{Namespace: "argocd", Name: "my-app"}, &app)
err = r.Get(ctx, crtclient.ObjectKey{Namespace: "cd", Name: "my-app"}, &app)
require.NoError(t, err)
if c.allowedDelete {
assert.NotNil(t, app.DeletionTimestamp)
@@ -3895,7 +3895,7 @@ func TestSetApplicationSetApplicationStatus(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Generators: []v1alpha1.ApplicationSetGenerator{
@@ -3928,7 +3928,7 @@ func TestSetApplicationSetApplicationStatus(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Generators: []v1alpha1.ApplicationSetGenerator{
@@ -3971,7 +3971,7 @@ func TestSetApplicationSetApplicationStatus(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Generators: []v1alpha1.ApplicationSetGenerator{
@@ -4001,7 +4001,7 @@ func TestSetApplicationSetApplicationStatus(t *testing.T) {
client := fake.NewClientBuilder().WithScheme(scheme).WithObjects(&cc.appSet).WithStatusSubresource(&cc.appSet).Build()
metrics := appsetmetrics.NewFakeAppsetMetrics()
argodb := db.NewDB("argocd", settings.NewSettingsManager(t.Context(), kubeclientset, "argocd"), kubeclientset)
argodb := db.NewDB("cd", settings.NewSettingsManager(t.Context(), kubeclientset, "cd"), kubeclientset)
r := ApplicationSetReconciler{
Client: client,
@@ -4041,7 +4041,7 @@ func TestUpdateResourceStatus(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Status: v1alpha1.ApplicationSetStatus{
Resources: []v1alpha1.ResourceStatus{},
@@ -4055,7 +4055,7 @@ func TestUpdateResourceStatus(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Status: v1alpha1.ApplicationSetStatus{
ApplicationStatus: []v1alpha1.ApplicationSetApplicationStatus{},
@@ -4091,7 +4091,7 @@ func TestUpdateResourceStatus(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Status: v1alpha1.ApplicationSetStatus{
Resources: []v1alpha1.ResourceStatus{
@@ -4135,7 +4135,7 @@ func TestUpdateResourceStatus(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Status: v1alpha1.ApplicationSetStatus{
Resources: []v1alpha1.ResourceStatus{
@@ -4180,7 +4180,7 @@ func TestUpdateResourceStatus(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Status: v1alpha1.ApplicationSetStatus{
Resources: []v1alpha1.ResourceStatus{
@@ -4203,7 +4203,7 @@ func TestUpdateResourceStatus(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Status: v1alpha1.ApplicationSetStatus{
Resources: []v1alpha1.ResourceStatus{
@@ -4272,7 +4272,7 @@ func TestUpdateResourceStatus(t *testing.T) {
client := fake.NewClientBuilder().WithScheme(scheme).WithStatusSubresource(&cc.appSet).WithObjects(&cc.appSet).Build()
metrics := appsetmetrics.NewFakeAppsetMetrics()
argodb := db.NewDB("argocd", settings.NewSettingsManager(t.Context(), kubeclientset, "argocd"), kubeclientset)
argodb := db.NewDB("cd", settings.NewSettingsManager(t.Context(), kubeclientset, "cd"), kubeclientset)
r := ApplicationSetReconciler{
Client: client,
@@ -4346,7 +4346,7 @@ func TestResourceStatusAreOrdered(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Status: v1alpha1.ApplicationSetStatus{
Resources: []v1alpha1.ResourceStatus{},
@@ -4362,7 +4362,7 @@ func TestResourceStatusAreOrdered(t *testing.T) {
client := fake.NewClientBuilder().WithScheme(scheme).WithStatusSubresource(&cc.appSet).WithObjects(&cc.appSet).Build()
metrics := appsetmetrics.NewFakeAppsetMetrics()
argodb := db.NewDB("argocd", settings.NewSettingsManager(t.Context(), kubeclientset, "argocd"), kubeclientset)
argodb := db.NewDB("cd", settings.NewSettingsManager(t.Context(), kubeclientset, "cd"), kubeclientset)
r := ApplicationSetReconciler{
Client: client,
@@ -5138,7 +5138,7 @@ func TestReconcileAddsFinalizer_WhenDeletionOrderReverse(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "test-appset",
Namespace: "argocd",
Namespace: "cd",
// No finalizers initially
},
Spec: v1alpha1.ApplicationSetSpec{
@@ -5170,7 +5170,7 @@ func TestReconcileAddsFinalizer_WhenDeletionOrderReverse(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "test-appset",
Namespace: "argocd",
Namespace: "cd",
Finalizers: []string{
v1alpha1.ResourcesFinalizerName,
},
@@ -5204,7 +5204,7 @@ func TestReconcileAddsFinalizer_WhenDeletionOrderReverse(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "test-appset",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -5235,7 +5235,7 @@ func TestReconcileAddsFinalizer_WhenDeletionOrderReverse(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "test-appset",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -5265,7 +5265,7 @@ func TestReconcileAddsFinalizer_WhenDeletionOrderReverse(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "test-appset",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -5300,7 +5300,7 @@ func TestReconcileAddsFinalizer_WhenDeletionOrderReverse(t *testing.T) {
WithIndex(&v1alpha1.Application{}, ".metadata.controller", appControllerIndexer).
Build()
metrics := appsetmetrics.NewFakeAppsetMetrics()
argodb := db.NewDB("argocd", settings.NewSettingsManager(t.Context(), kubeclientset, "argocd"), kubeclientset)
argodb := db.NewDB("cd", settings.NewSettingsManager(t.Context(), kubeclientset, "cd"), kubeclientset)
r := ApplicationSetReconciler{
Client: client,
@@ -5356,7 +5356,7 @@ func TestReconcileProgressiveSyncDisabled(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "test-appset",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Generators: []v1alpha1.ApplicationSetGenerator{},
@@ -5381,7 +5381,7 @@ func TestReconcileProgressiveSyncDisabled(t *testing.T) {
client := fake.NewClientBuilder().WithScheme(scheme).WithObjects(&cc.appSet).WithStatusSubresource(&cc.appSet).WithIndex(&v1alpha1.Application{}, ".metadata.controller", appControllerIndexer).Build()
metrics := appsetmetrics.NewFakeAppsetMetrics()
argodb := db.NewDB("argocd", settings.NewSettingsManager(t.Context(), kubeclientset, "argocd"), kubeclientset)
argodb := db.NewDB("cd", settings.NewSettingsManager(t.Context(), kubeclientset, "cd"), kubeclientset)
r := ApplicationSetReconciler{
Client: client,
@@ -49,7 +49,7 @@ func TestClusterEventHandler(t *testing.T) {
items: []argov1alpha1.ApplicationSet{},
secret: corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Namespace: "argocd",
Namespace: "cd",
Name: "my-secret",
Labels: map[string]string{
argocommon.LabelKeySecretType: argocommon.LabelValueSecretTypeCluster,
@@ -64,7 +64,7 @@ func TestClusterEventHandler(t *testing.T) {
{
ObjectMeta: metav1.ObjectMeta{
Name: "my-app-set",
Namespace: "argocd",
Namespace: "cd",
},
Spec: argov1alpha1.ApplicationSetSpec{
Generators: []argov1alpha1.ApplicationSetGenerator{
@@ -77,7 +77,7 @@ func TestClusterEventHandler(t *testing.T) {
},
secret: corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Namespace: "argocd",
Namespace: "cd",
Name: "my-secret",
Labels: map[string]string{
argocommon.LabelKeySecretType: argocommon.LabelValueSecretTypeCluster,
@@ -85,7 +85,7 @@ func TestClusterEventHandler(t *testing.T) {
},
},
expectedRequests: []reconcile.Request{{
NamespacedName: types.NamespacedName{Namespace: "argocd", Name: "my-app-set"},
NamespacedName: types.NamespacedName{Namespace: "cd", Name: "my-app-set"},
}},
},
{
@@ -94,7 +94,7 @@ func TestClusterEventHandler(t *testing.T) {
{
ObjectMeta: metav1.ObjectMeta{
Name: "my-app-set",
Namespace: "argocd",
Namespace: "cd",
},
Spec: argov1alpha1.ApplicationSetSpec{
Generators: []argov1alpha1.ApplicationSetGenerator{
@@ -107,7 +107,7 @@ func TestClusterEventHandler(t *testing.T) {
{
ObjectMeta: metav1.ObjectMeta{
Name: "my-app-set2",
Namespace: "argocd",
Namespace: "cd",
},
Spec: argov1alpha1.ApplicationSetSpec{
Generators: []argov1alpha1.ApplicationSetGenerator{
@@ -120,7 +120,7 @@ func TestClusterEventHandler(t *testing.T) {
},
secret: corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Namespace: "argocd",
Namespace: "cd",
Name: "my-secret",
Labels: map[string]string{
argocommon.LabelKeySecretType: argocommon.LabelValueSecretTypeCluster,
@@ -128,8 +128,8 @@ func TestClusterEventHandler(t *testing.T) {
},
},
expectedRequests: []reconcile.Request{
{NamespacedName: types.NamespacedName{Namespace: "argocd", Name: "my-app-set"}},
{NamespacedName: types.NamespacedName{Namespace: "argocd", Name: "my-app-set2"}},
{NamespacedName: types.NamespacedName{Namespace: "cd", Name: "my-app-set"}},
{NamespacedName: types.NamespacedName{Namespace: "cd", Name: "my-app-set2"}},
},
},
{
@@ -138,7 +138,7 @@ func TestClusterEventHandler(t *testing.T) {
{
ObjectMeta: metav1.ObjectMeta{
Name: "my-app-set",
Namespace: "argocd",
Namespace: "cd",
},
Spec: argov1alpha1.ApplicationSetSpec{
Generators: []argov1alpha1.ApplicationSetGenerator{
@@ -151,7 +151,7 @@ func TestClusterEventHandler(t *testing.T) {
{
ObjectMeta: metav1.ObjectMeta{
Name: "app-set-non-cluster",
Namespace: "argocd",
Namespace: "cd",
},
Spec: argov1alpha1.ApplicationSetSpec{
Generators: []argov1alpha1.ApplicationSetGenerator{
@@ -164,7 +164,7 @@ func TestClusterEventHandler(t *testing.T) {
},
secret: corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Namespace: "argocd",
Namespace: "cd",
Name: "my-secret",
Labels: map[string]string{
argocommon.LabelKeySecretType: argocommon.LabelValueSecretTypeCluster,
@@ -172,7 +172,7 @@ func TestClusterEventHandler(t *testing.T) {
},
},
expectedRequests: []reconcile.Request{
{NamespacedName: types.NamespacedName{Namespace: "argocd", Name: "my-app-set"}},
{NamespacedName: types.NamespacedName{Namespace: "cd", Name: "my-app-set"}},
},
},
{
@@ -194,7 +194,7 @@ func TestClusterEventHandler(t *testing.T) {
},
secret: corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Namespace: "argocd",
Namespace: "cd",
Name: "my-secret",
Labels: map[string]string{
argocommon.LabelKeySecretType: argocommon.LabelValueSecretTypeCluster,
@@ -222,8 +222,8 @@ func TestClusterEventHandler(t *testing.T) {
},
secret: corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Namespace: "argocd",
Name: "my-non-argocd-secret",
Namespace: "cd",
Name: "my-non-cd-secret",
},
},
expectedRequests: []reconcile.Request{},
@@ -234,7 +234,7 @@ func TestClusterEventHandler(t *testing.T) {
{
ObjectMeta: metav1.ObjectMeta{
Name: "my-app-set",
Namespace: "argocd",
Namespace: "cd",
},
Spec: argov1alpha1.ApplicationSetSpec{
Generators: []argov1alpha1.ApplicationSetGenerator{
@@ -253,7 +253,7 @@ func TestClusterEventHandler(t *testing.T) {
},
secret: corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Namespace: "argocd",
Namespace: "cd",
Name: "my-secret",
Labels: map[string]string{
argocommon.LabelKeySecretType: argocommon.LabelValueSecretTypeCluster,
@@ -261,7 +261,7 @@ func TestClusterEventHandler(t *testing.T) {
},
},
expectedRequests: []reconcile.Request{{
NamespacedName: types.NamespacedName{Namespace: "argocd", Name: "my-app-set"},
NamespacedName: types.NamespacedName{Namespace: "cd", Name: "my-app-set"},
}},
},
{
@@ -270,7 +270,7 @@ func TestClusterEventHandler(t *testing.T) {
{
ObjectMeta: metav1.ObjectMeta{
Name: "my-app-set",
Namespace: "argocd",
Namespace: "cd",
},
Spec: argov1alpha1.ApplicationSetSpec{
Generators: []argov1alpha1.ApplicationSetGenerator{
@@ -289,7 +289,7 @@ func TestClusterEventHandler(t *testing.T) {
},
secret: corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Namespace: "argocd",
Namespace: "cd",
Name: "my-secret",
Labels: map[string]string{
argocommon.LabelKeySecretType: argocommon.LabelValueSecretTypeCluster,
@@ -304,7 +304,7 @@ func TestClusterEventHandler(t *testing.T) {
{
ObjectMeta: metav1.ObjectMeta{
Name: "my-app-set",
Namespace: "argocd",
Namespace: "cd",
},
Spec: argov1alpha1.ApplicationSetSpec{
Generators: []argov1alpha1.ApplicationSetGenerator{
@@ -320,7 +320,7 @@ func TestClusterEventHandler(t *testing.T) {
"clusters": {
"selector": {
"matchLabels": {
"argocd.argoproj.io/secret-type": "cluster"
"cd.argoproj.io/secret-type": "cluster"
}
}
}
@@ -339,7 +339,7 @@ func TestClusterEventHandler(t *testing.T) {
},
secret: corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Namespace: "argocd",
Namespace: "cd",
Name: "my-secret",
Labels: map[string]string{
argocommon.LabelKeySecretType: argocommon.LabelValueSecretTypeCluster,
@@ -347,7 +347,7 @@ func TestClusterEventHandler(t *testing.T) {
},
},
expectedRequests: []reconcile.Request{{
NamespacedName: types.NamespacedName{Namespace: "argocd", Name: "my-app-set"},
NamespacedName: types.NamespacedName{Namespace: "cd", Name: "my-app-set"},
}},
},
{
@@ -356,7 +356,7 @@ func TestClusterEventHandler(t *testing.T) {
{
ObjectMeta: metav1.ObjectMeta{
Name: "my-app-set",
Namespace: "argocd",
Namespace: "cd",
},
Spec: argov1alpha1.ApplicationSetSpec{
Generators: []argov1alpha1.ApplicationSetGenerator{
@@ -390,7 +390,7 @@ func TestClusterEventHandler(t *testing.T) {
},
secret: corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Namespace: "argocd",
Namespace: "cd",
Name: "my-secret",
Labels: map[string]string{
argocommon.LabelKeySecretType: argocommon.LabelValueSecretTypeCluster,
@@ -405,7 +405,7 @@ func TestClusterEventHandler(t *testing.T) {
{
ObjectMeta: metav1.ObjectMeta{
Name: "my-app-set",
Namespace: "argocd",
Namespace: "cd",
},
Spec: argov1alpha1.ApplicationSetSpec{
Generators: []argov1alpha1.ApplicationSetGenerator{
@@ -424,7 +424,7 @@ func TestClusterEventHandler(t *testing.T) {
},
secret: corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Namespace: "argocd",
Namespace: "cd",
Name: "my-secret",
Labels: map[string]string{
argocommon.LabelKeySecretType: argocommon.LabelValueSecretTypeCluster,
@@ -432,7 +432,7 @@ func TestClusterEventHandler(t *testing.T) {
},
},
expectedRequests: []reconcile.Request{{
NamespacedName: types.NamespacedName{Namespace: "argocd", Name: "my-app-set"},
NamespacedName: types.NamespacedName{Namespace: "cd", Name: "my-app-set"},
}},
},
{
@@ -441,7 +441,7 @@ func TestClusterEventHandler(t *testing.T) {
{
ObjectMeta: metav1.ObjectMeta{
Name: "my-app-set",
Namespace: "argocd",
Namespace: "cd",
},
Spec: argov1alpha1.ApplicationSetSpec{
Generators: []argov1alpha1.ApplicationSetGenerator{
@@ -460,7 +460,7 @@ func TestClusterEventHandler(t *testing.T) {
},
secret: corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Namespace: "argocd",
Namespace: "cd",
Name: "my-secret",
Labels: map[string]string{
argocommon.LabelKeySecretType: argocommon.LabelValueSecretTypeCluster,
@@ -475,7 +475,7 @@ func TestClusterEventHandler(t *testing.T) {
{
ObjectMeta: metav1.ObjectMeta{
Name: "my-app-set",
Namespace: "argocd",
Namespace: "cd",
},
Spec: argov1alpha1.ApplicationSetSpec{
Generators: []argov1alpha1.ApplicationSetGenerator{
@@ -491,7 +491,7 @@ func TestClusterEventHandler(t *testing.T) {
"clusters": {
"selector": {
"matchLabels": {
"argocd.argoproj.io/secret-type": "cluster"
"cd.argoproj.io/secret-type": "cluster"
}
}
}
@@ -510,7 +510,7 @@ func TestClusterEventHandler(t *testing.T) {
},
secret: corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Namespace: "argocd",
Namespace: "cd",
Name: "my-secret",
Labels: map[string]string{
argocommon.LabelKeySecretType: argocommon.LabelValueSecretTypeCluster,
@@ -518,7 +518,7 @@ func TestClusterEventHandler(t *testing.T) {
},
},
expectedRequests: []reconcile.Request{{
NamespacedName: types.NamespacedName{Namespace: "argocd", Name: "my-app-set"},
NamespacedName: types.NamespacedName{Namespace: "cd", Name: "my-app-set"},
}},
},
{
@@ -527,7 +527,7 @@ func TestClusterEventHandler(t *testing.T) {
{
ObjectMeta: metav1.ObjectMeta{
Name: "my-app-set",
Namespace: "argocd",
Namespace: "cd",
},
Spec: argov1alpha1.ApplicationSetSpec{
Generators: []argov1alpha1.ApplicationSetGenerator{
@@ -561,7 +561,7 @@ func TestClusterEventHandler(t *testing.T) {
},
secret: corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Namespace: "argocd",
Namespace: "cd",
Name: "my-secret",
Labels: map[string]string{
argocommon.LabelKeySecretType: argocommon.LabelValueSecretTypeCluster,
@@ -584,7 +584,7 @@ func TestClusterEventHandler(t *testing.T) {
handler := &clusterSecretEventHandler{
Client: fakeClient,
Log: log.WithField("type", "createSecretEventHandler"),
ApplicationSetNamespaces: []string{"argocd"},
ApplicationSetNamespaces: []string{"cd"},
}
mockAddRateLimitingInterface := mockAddRateLimitingInterface{}
@@ -619,7 +619,7 @@ func TestNestedGeneratorHasClusterGenerator_NestedMergeGenerator(t *testing.T) {
"clusters": {
"selector": {
"matchLabels": {
"argocd.argoproj.io/secret-type": "cluster"
"cd.argoproj.io/secret-type": "cluster"
}
}
}
@@ -647,7 +647,7 @@ func TestNestedGeneratorHasClusterGenerator_NestedMergeGeneratorWithInvalidJSON(
"clusters": {
"selector": {
"matchLabels": {
"argocd.argoproj.io/secret-type": "cluster"
"cd.argoproj.io/secret-type": "cluster"
}
}
}
@@ -39,7 +39,7 @@ func TestUpdateApplicationSetApplicationStatus(t *testing.T) {
return v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -890,7 +890,7 @@ func TestUpdateApplicationSetApplicationStatus(t *testing.T) {
client := fake.NewClientBuilder().WithScheme(scheme).WithObjects(&cc.appSet).WithStatusSubresource(&cc.appSet).Build()
metrics := appsetmetrics.NewFakeAppsetMetrics()
argodb := db.NewDB("argocd", settings.NewSettingsManager(t.Context(), kubeclientset, "argocd"), kubeclientset)
argodb := db.NewDB("cd", settings.NewSettingsManager(t.Context(), kubeclientset, "cd"), kubeclientset)
r := &ApplicationSetReconciler{
Client: client,
@@ -943,7 +943,7 @@ func TestUpdateApplicationSetApplicationStatusProgress(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -973,7 +973,7 @@ func TestUpdateApplicationSetApplicationStatusProgress(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{},
Status: v1alpha1.ApplicationSetStatus{
@@ -989,7 +989,7 @@ func TestUpdateApplicationSetApplicationStatusProgress(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{},
@@ -1007,7 +1007,7 @@ func TestUpdateApplicationSetApplicationStatusProgress(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Status: v1alpha1.ApplicationSetStatus{
ApplicationStatus: []v1alpha1.ApplicationSetApplicationStatus{},
@@ -1027,7 +1027,7 @@ func TestUpdateApplicationSetApplicationStatusProgress(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -1078,7 +1078,7 @@ func TestUpdateApplicationSetApplicationStatusProgress(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -1127,7 +1127,7 @@ func TestUpdateApplicationSetApplicationStatusProgress(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -1176,7 +1176,7 @@ func TestUpdateApplicationSetApplicationStatusProgress(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -1316,7 +1316,7 @@ func TestUpdateApplicationSetApplicationStatusProgress(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -1399,7 +1399,7 @@ func TestUpdateApplicationSetApplicationStatusProgress(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -1482,7 +1482,7 @@ func TestUpdateApplicationSetApplicationStatusProgress(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -1565,7 +1565,7 @@ func TestUpdateApplicationSetApplicationStatusProgress(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -1651,7 +1651,7 @@ func TestUpdateApplicationSetApplicationStatusProgress(t *testing.T) {
client := fake.NewClientBuilder().WithScheme(scheme).WithObjects(&cc.appSet).WithStatusSubresource(&cc.appSet).Build()
metrics := appsetmetrics.NewFakeAppsetMetrics()
argodb := db.NewDB("argocd", settings.NewSettingsManager(t.Context(), kubeclientset, "argocd"), kubeclientset)
argodb := db.NewDB("cd", settings.NewSettingsManager(t.Context(), kubeclientset, "cd"), kubeclientset)
r := &ApplicationSetReconciler{
Client: client,
@@ -58,17 +58,17 @@ func TestRequeueAfter(t *testing.T) {
}
fakeDynClient := dynfake.NewSimpleDynamicClientWithCustomListKinds(runtime.NewScheme(), gvrToListKind, duckType)
scmConfig := generators.NewSCMConfig("", []string{""}, true, true, nil, true)
clusterInformer, err := settings.NewClusterInformer(appClientset, "argocd")
clusterInformer, err := settings.NewClusterInformer(appClientset, "cd")
require.NoError(t, err)
defer startAndSyncInformer(t, clusterInformer)()
terminalGenerators := map[string]generators.Generator{
"List": generators.NewListGenerator(),
"Clusters": generators.NewClusterGenerator(k8sClient, "argocd"),
"Clusters": generators.NewClusterGenerator(k8sClient, "cd"),
"Git": generators.NewGitGenerator(mockServer, "namespace"),
"SCMProvider": generators.NewSCMProviderGenerator(fake.NewClientBuilder().WithObjects(&corev1.Secret{}).Build(), scmConfig),
"ClusterDecisionResource": generators.NewDuckTypeGenerator(ctx, fakeDynClient, appClientset, "argocd", clusterInformer),
"ClusterDecisionResource": generators.NewDuckTypeGenerator(ctx, fakeDynClient, appClientset, "cd", clusterInformer),
"PullRequest": generators.NewPullRequestGenerator(k8sClient, scmConfig),
}
+30 -30
View File
@@ -40,7 +40,7 @@ func TestGenerateParams(t *testing.T) {
Name: "staging-01",
Namespace: "namespace",
Labels: map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"environment": "staging",
"org": "foo",
},
@@ -64,7 +64,7 @@ func TestGenerateParams(t *testing.T) {
Name: "production-01",
Namespace: "namespace",
Labels: map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"environment": "production",
"org": "bar",
},
@@ -107,12 +107,12 @@ func TestGenerateParams(t *testing.T) {
{"values.lol1": "lol", "values.lol2": "{{values.lol1}}{{values.lol1}}", "values.lol3": "{{values.lol2}}{{values.lol2}}{{values.lol2}}", "values.foo": "bar", "values.bar": "{{ metadata.annotations.foo.argoproj.io }}", "values.no-op": "{{ this-does-not-exist }}", "values.bat": "{{ metadata.labels.environment }}", "values.aaa": "https://kubernetes.default.svc", "nameNormalized": "in-cluster", "name": "in-cluster", "server": "https://kubernetes.default.svc", "project": ""},
{
"values.lol1": "lol", "values.lol2": "{{values.lol1}}{{values.lol1}}", "values.lol3": "{{values.lol2}}{{values.lol2}}{{values.lol2}}", "values.foo": "bar", "values.bar": "production", "values.no-op": "{{ this-does-not-exist }}", "values.bat": "production", "values.aaa": "https://production-01.example.com", "name": "production_01/west", "nameNormalized": "production-01-west", "server": "https://production-01.example.com", "metadata.labels.environment": "production", "metadata.labels.org": "bar",
"metadata.labels.argocd.argoproj.io/secret-type": "cluster", "metadata.annotations.foo.argoproj.io": "production", "project": "prod-project",
"metadata.labels.cd.argoproj.io/secret-type": "cluster", "metadata.annotations.foo.argoproj.io": "production", "project": "prod-project",
},
{
"values.lol1": "lol", "values.lol2": "{{values.lol1}}{{values.lol1}}", "values.lol3": "{{values.lol2}}{{values.lol2}}{{values.lol2}}", "values.foo": "bar", "values.bar": "staging", "values.no-op": "{{ this-does-not-exist }}", "values.bat": "staging", "values.aaa": "https://staging-01.example.com", "name": "staging-01", "nameNormalized": "staging-01", "server": "https://staging-01.example.com", "metadata.labels.environment": "staging", "metadata.labels.org": "foo",
"metadata.labels.argocd.argoproj.io/secret-type": "cluster", "metadata.annotations.foo.argoproj.io": "staging", "project": "",
"metadata.labels.cd.argoproj.io/secret-type": "cluster", "metadata.annotations.foo.argoproj.io": "staging", "project": "",
},
},
clientError: false,
@@ -122,19 +122,19 @@ func TestGenerateParams(t *testing.T) {
name: "secret type label selector",
selector: metav1.LabelSelector{
MatchLabels: map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
},
},
values: nil,
expected: []map[string]any{
{
"name": "production_01/west", "nameNormalized": "production-01-west", "server": "https://production-01.example.com", "metadata.labels.environment": "production", "metadata.labels.org": "bar",
"metadata.labels.argocd.argoproj.io/secret-type": "cluster", "metadata.annotations.foo.argoproj.io": "production", "project": "prod-project",
"metadata.labels.cd.argoproj.io/secret-type": "cluster", "metadata.annotations.foo.argoproj.io": "production", "project": "prod-project",
},
{
"name": "staging-01", "nameNormalized": "staging-01", "server": "https://staging-01.example.com", "metadata.labels.environment": "staging", "metadata.labels.org": "foo",
"metadata.labels.argocd.argoproj.io/secret-type": "cluster", "metadata.annotations.foo.argoproj.io": "staging", "project": "",
"metadata.labels.cd.argoproj.io/secret-type": "cluster", "metadata.annotations.foo.argoproj.io": "staging", "project": "",
},
},
clientError: false,
@@ -153,7 +153,7 @@ func TestGenerateParams(t *testing.T) {
expected: []map[string]any{
{
"values.foo": "bar", "name": "production_01/west", "nameNormalized": "production-01-west", "server": "https://production-01.example.com", "metadata.labels.environment": "production", "metadata.labels.org": "bar",
"metadata.labels.argocd.argoproj.io/secret-type": "cluster", "metadata.annotations.foo.argoproj.io": "production", "project": "prod-project",
"metadata.labels.cd.argoproj.io/secret-type": "cluster", "metadata.annotations.foo.argoproj.io": "production", "project": "prod-project",
},
},
clientError: false,
@@ -179,11 +179,11 @@ func TestGenerateParams(t *testing.T) {
expected: []map[string]any{
{
"values.foo": "bar", "name": "staging-01", "nameNormalized": "staging-01", "server": "https://staging-01.example.com", "metadata.labels.environment": "staging", "metadata.labels.org": "foo",
"metadata.labels.argocd.argoproj.io/secret-type": "cluster", "metadata.annotations.foo.argoproj.io": "staging", "project": "",
"metadata.labels.cd.argoproj.io/secret-type": "cluster", "metadata.annotations.foo.argoproj.io": "staging", "project": "",
},
{
"values.foo": "bar", "name": "production_01/west", "nameNormalized": "production-01-west", "server": "https://production-01.example.com", "metadata.labels.environment": "production", "metadata.labels.org": "bar",
"metadata.labels.argocd.argoproj.io/secret-type": "cluster", "metadata.annotations.foo.argoproj.io": "production", "project": "prod-project",
"metadata.labels.cd.argoproj.io/secret-type": "cluster", "metadata.annotations.foo.argoproj.io": "production", "project": "prod-project",
},
},
clientError: false,
@@ -212,7 +212,7 @@ func TestGenerateParams(t *testing.T) {
expected: []map[string]any{
{
"values.name": "baz", "name": "staging-01", "nameNormalized": "staging-01", "server": "https://staging-01.example.com", "metadata.labels.environment": "staging", "metadata.labels.org": "foo",
"metadata.labels.argocd.argoproj.io/secret-type": "cluster", "metadata.annotations.foo.argoproj.io": "staging", "project": "",
"metadata.labels.cd.argoproj.io/secret-type": "cluster", "metadata.annotations.foo.argoproj.io": "staging", "project": "",
},
},
clientError: false,
@@ -245,12 +245,12 @@ func TestGenerateParams(t *testing.T) {
{"values.lol1": "lol", "values.lol2": "{{values.lol1}}{{values.lol1}}", "values.lol3": "{{values.lol2}}{{values.lol2}}{{values.lol2}}", "values.foo": "bar", "values.bar": "{{ metadata.annotations.foo.argoproj.io }}", "values.no-op": "{{ this-does-not-exist }}", "values.bat": "{{ metadata.labels.environment }}", "values.aaa": "https://kubernetes.default.svc", "nameNormalized": "in-cluster", "name": "in-cluster", "server": "https://kubernetes.default.svc", "project": ""},
{
"values.lol1": "lol", "values.lol2": "{{values.lol1}}{{values.lol1}}", "values.lol3": "{{values.lol2}}{{values.lol2}}{{values.lol2}}", "values.foo": "bar", "values.bar": "production", "values.no-op": "{{ this-does-not-exist }}", "values.bat": "production", "values.aaa": "https://production-01.example.com", "name": "production_01/west", "nameNormalized": "production-01-west", "server": "https://production-01.example.com", "metadata.labels.environment": "production", "metadata.labels.org": "bar",
"metadata.labels.argocd.argoproj.io/secret-type": "cluster", "metadata.annotations.foo.argoproj.io": "production", "project": "prod-project",
"metadata.labels.cd.argoproj.io/secret-type": "cluster", "metadata.annotations.foo.argoproj.io": "production", "project": "prod-project",
},
{
"values.lol1": "lol", "values.lol2": "{{values.lol1}}{{values.lol1}}", "values.lol3": "{{values.lol2}}{{values.lol2}}{{values.lol2}}", "values.foo": "bar", "values.bar": "staging", "values.no-op": "{{ this-does-not-exist }}", "values.bat": "staging", "values.aaa": "https://staging-01.example.com", "name": "staging-01", "nameNormalized": "staging-01", "server": "https://staging-01.example.com", "metadata.labels.environment": "staging", "metadata.labels.org": "foo",
"metadata.labels.argocd.argoproj.io/secret-type": "cluster", "metadata.annotations.foo.argoproj.io": "staging", "project": "",
"metadata.labels.cd.argoproj.io/secret-type": "cluster", "metadata.annotations.foo.argoproj.io": "staging", "project": "",
},
},
},
@@ -282,11 +282,11 @@ func TestGenerateParams(t *testing.T) {
"clusters": []map[string]any{
{
"values.foo": "bar", "name": "production_01/west", "nameNormalized": "production-01-west", "server": "https://production-01.example.com", "metadata.labels.environment": "production", "metadata.labels.org": "bar",
"metadata.labels.argocd.argoproj.io/secret-type": "cluster", "metadata.annotations.foo.argoproj.io": "production", "project": "prod-project",
"metadata.labels.cd.argoproj.io/secret-type": "cluster", "metadata.annotations.foo.argoproj.io": "production", "project": "prod-project",
},
{
"values.foo": "bar", "name": "staging-01", "nameNormalized": "staging-01", "server": "https://staging-01.example.com", "metadata.labels.environment": "staging", "metadata.labels.org": "foo",
"metadata.labels.argocd.argoproj.io/secret-type": "cluster", "metadata.annotations.foo.argoproj.io": "staging", "project": "",
"metadata.labels.cd.argoproj.io/secret-type": "cluster", "metadata.annotations.foo.argoproj.io": "staging", "project": "",
},
},
},
@@ -355,7 +355,7 @@ func TestGenerateParamsGoTemplate(t *testing.T) {
Name: "staging-01",
Namespace: "namespace",
Labels: map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"environment": "staging",
"org": "foo",
},
@@ -379,7 +379,7 @@ func TestGenerateParamsGoTemplate(t *testing.T) {
Name: "production-01",
Namespace: "namespace",
Labels: map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"environment": "production",
"org": "bar",
},
@@ -425,7 +425,7 @@ func TestGenerateParamsGoTemplate(t *testing.T) {
"project": "",
"metadata": map[string]any{
"labels": map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"environment": "production",
"org": "bar",
},
@@ -451,7 +451,7 @@ func TestGenerateParamsGoTemplate(t *testing.T) {
"project": "",
"metadata": map[string]any{
"labels": map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"environment": "staging",
"org": "foo",
},
@@ -494,7 +494,7 @@ func TestGenerateParamsGoTemplate(t *testing.T) {
name: "secret type label selector",
selector: metav1.LabelSelector{
MatchLabels: map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
},
},
values: nil,
@@ -506,7 +506,7 @@ func TestGenerateParamsGoTemplate(t *testing.T) {
"project": "",
"metadata": map[string]any{
"labels": map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"environment": "production",
"org": "bar",
},
@@ -522,7 +522,7 @@ func TestGenerateParamsGoTemplate(t *testing.T) {
"project": "",
"metadata": map[string]any{
"labels": map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"environment": "staging",
"org": "foo",
},
@@ -553,7 +553,7 @@ func TestGenerateParamsGoTemplate(t *testing.T) {
"project": "",
"metadata": map[string]any{
"labels": map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"environment": "production",
"org": "bar",
},
@@ -594,7 +594,7 @@ func TestGenerateParamsGoTemplate(t *testing.T) {
"project": "",
"metadata": map[string]any{
"labels": map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"environment": "production",
"org": "bar",
},
@@ -613,7 +613,7 @@ func TestGenerateParamsGoTemplate(t *testing.T) {
"project": "",
"metadata": map[string]any{
"labels": map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"environment": "staging",
"org": "foo",
},
@@ -657,7 +657,7 @@ func TestGenerateParamsGoTemplate(t *testing.T) {
"project": "",
"metadata": map[string]any{
"labels": map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"environment": "staging",
"org": "foo",
},
@@ -721,7 +721,7 @@ func TestGenerateParamsGoTemplate(t *testing.T) {
"project": "",
"metadata": map[string]any{
"labels": map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"environment": "production",
"org": "bar",
},
@@ -747,7 +747,7 @@ func TestGenerateParamsGoTemplate(t *testing.T) {
"project": "",
"metadata": map[string]any{
"labels": map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"environment": "staging",
"org": "foo",
},
@@ -800,7 +800,7 @@ func TestGenerateParamsGoTemplate(t *testing.T) {
"project": "",
"metadata": map[string]any{
"labels": map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"environment": "production",
"org": "bar",
},
@@ -819,7 +819,7 @@ func TestGenerateParamsGoTemplate(t *testing.T) {
"project": "",
"metadata": map[string]any{
"labels": map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"environment": "staging",
"org": "foo",
},
+4 -4
View File
@@ -37,7 +37,7 @@ func TestGenerateParamsForDuckType(t *testing.T) {
Name: "staging-01",
Namespace: "namespace",
Labels: map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"environment": "staging",
"org": "foo",
},
@@ -61,7 +61,7 @@ func TestGenerateParamsForDuckType(t *testing.T) {
Name: "production-01",
Namespace: "namespace",
Labels: map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"environment": "production",
"org": "bar",
},
@@ -369,7 +369,7 @@ func TestGenerateParamsForDuckTypeGoTemplate(t *testing.T) {
Name: "staging-01",
Namespace: "namespace",
Labels: map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"environment": "staging",
"org": "foo",
},
@@ -393,7 +393,7 @@ func TestGenerateParamsForDuckTypeGoTemplate(t *testing.T) {
Name: "production-01",
Namespace: "namespace",
Labels: map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"environment": "production",
"org": "bar",
},
@@ -190,7 +190,7 @@ func TestTransForm(t *testing.T) {
},
expected: []map[string]any{{
"metadata.annotations.foo.argoproj.io": "production",
"metadata.labels.argocd.argoproj.io/secret-type": "cluster",
"metadata.labels.cd.argoproj.io/secret-type": "cluster",
"metadata.labels.environment": "production",
"metadata.labels.org": "bar",
"name": "production_01/west",
@@ -206,7 +206,7 @@ func TestTransForm(t *testing.T) {
},
expected: []map[string]any{{
"metadata.annotations.foo.argoproj.io": "production",
"metadata.labels.argocd.argoproj.io/secret-type": "cluster",
"metadata.labels.cd.argoproj.io/secret-type": "cluster",
"metadata.labels.environment": "production",
"metadata.labels.org": "bar",
"name": "some-really-long-server-url",
@@ -268,7 +268,7 @@ func TestTransFormGoTemplate(t *testing.T) {
"project": "",
"metadata": map[string]any{
"labels": map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"environment": "production",
"org": "bar",
},
@@ -290,7 +290,7 @@ func TestTransFormGoTemplate(t *testing.T) {
"project": "",
"metadata": map[string]any{
"labels": map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"environment": "staging",
"org": "foo",
},
@@ -322,7 +322,7 @@ func TestTransFormGoTemplate(t *testing.T) {
"project": "",
"metadata": map[string]any{
"labels": map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"environment": "production",
"org": "bar",
},
@@ -338,7 +338,7 @@ func TestTransFormGoTemplate(t *testing.T) {
"project": "",
"metadata": map[string]any{
"labels": map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"environment": "production",
"org": "bar",
},
@@ -359,7 +359,7 @@ func TestTransFormGoTemplate(t *testing.T) {
{
name: "slash key in label",
selector: &metav1.LabelSelector{
MatchLabels: map[string]string{"metadata.labels.argocd.argoproj.io/secret-type": "cluster"},
MatchLabels: map[string]string{"metadata.labels.cd.argoproj.io/secret-type": "cluster"},
},
expected: []map[string]any{
{
@@ -369,7 +369,7 @@ func TestTransFormGoTemplate(t *testing.T) {
"project": "",
"metadata": map[string]any{
"labels": map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"environment": "staging",
"org": "foo",
},
@@ -385,7 +385,7 @@ func TestTransFormGoTemplate(t *testing.T) {
"project": "",
"metadata": map[string]any{
"labels": map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"environment": "production",
"org": "bar",
},
@@ -401,7 +401,7 @@ func TestTransFormGoTemplate(t *testing.T) {
"project": "",
"metadata": map[string]any{
"labels": map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"environment": "production",
"org": "bar",
},
@@ -425,7 +425,7 @@ func TestTransFormGoTemplate(t *testing.T) {
"project": "",
"metadata": map[string]any{
"labels": map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"environment": "staging",
"org": "foo",
},
@@ -493,7 +493,7 @@ func getMockClusterGenerator() Generator {
Name: "staging-01",
Namespace: "namespace",
Labels: map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"environment": "staging",
"org": "foo",
},
@@ -517,7 +517,7 @@ func getMockClusterGenerator() Generator {
Name: "production-01",
Namespace: "namespace",
Labels: map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"environment": "production",
"org": "bar",
},
@@ -541,7 +541,7 @@ func getMockClusterGenerator() Generator {
Name: "some-really-long-server-url",
Namespace: "namespace",
Labels: map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"environment": "production",
"org": "bar",
},
@@ -621,7 +621,7 @@ func TestInterpolateGenerator(t *testing.T) {
Clusters: &argov1alpha1.ClusterGenerator{
Selector: metav1.LabelSelector{
MatchLabels: map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"path-basename": "{{path.basename}}",
"path-zero": "{{path[0]}}",
"path-full": "{{path}}",
@@ -675,7 +675,7 @@ func TestInterpolateGenerator_go(t *testing.T) {
Clusters: &argov1alpha1.ClusterGenerator{
Selector: metav1.LabelSelector{
MatchLabels: map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"path-basename": "{{base .path.path}}",
"path-zero": "{{index .path.segments 0}}",
"path-full": "{{.path.path}}",
+2 -2
View File
@@ -2434,7 +2434,7 @@ func TestGitGenerator_GenerateParams(t *testing.T) {
TypeMeta: metav1.TypeMeta{},
ObjectMeta: metav1.ObjectMeta{
Name: "project",
Namespace: "argocd",
Namespace: "cd",
},
},
appset: v1alpha1.ApplicationSet{
@@ -2513,7 +2513,7 @@ func TestGitGenerator_GenerateParams(t *testing.T) {
argoCDServiceMock.EXPECT().GetDirectories(mock.Anything, mock.Anything, mock.Anything, project, mock.Anything, mock.Anything).Return(testCase.repoApps, testCase.repoPathsError)
}
gitGenerator := NewGitGenerator(argoCDServiceMock, "argocd")
gitGenerator := NewGitGenerator(argoCDServiceMock, "cd")
scheme := runtime.NewScheme()
err := v1alpha1.AddToScheme(scheme)
+12 -12
View File
@@ -575,8 +575,8 @@ func TestInterpolatedMatrixGenerate(t *testing.T) {
},
},
expected: []map[string]any{
{"path": "examples/git-generator-files-discovery/cluster-config/dev/config.json", "path.basename": "dev", "path.basenameNormalized": "dev", "name": "dev-01", "nameNormalized": "dev-01", "server": "https://dev-01.example.com", "metadata.labels.environment": "dev", "metadata.labels.argocd.argoproj.io/secret-type": "cluster", "project": ""},
{"path": "examples/git-generator-files-discovery/cluster-config/prod/config.json", "path.basename": "prod", "path.basenameNormalized": "prod", "name": "prod-01", "nameNormalized": "prod-01", "server": "https://prod-01.example.com", "metadata.labels.environment": "prod", "metadata.labels.argocd.argoproj.io/secret-type": "cluster", "project": ""},
{"path": "examples/git-generator-files-discovery/cluster-config/dev/config.json", "path.basename": "dev", "path.basenameNormalized": "dev", "name": "dev-01", "nameNormalized": "dev-01", "server": "https://dev-01.example.com", "metadata.labels.environment": "dev", "metadata.labels.cd.argoproj.io/secret-type": "cluster", "project": ""},
{"path": "examples/git-generator-files-discovery/cluster-config/prod/config.json", "path.basename": "prod", "path.basenameNormalized": "prod", "name": "prod-01", "nameNormalized": "prod-01", "server": "https://prod-01.example.com", "metadata.labels.environment": "prod", "metadata.labels.cd.argoproj.io/secret-type": "cluster", "project": ""},
},
clientError: false,
},
@@ -591,7 +591,7 @@ func TestInterpolatedMatrixGenerate(t *testing.T) {
Name: "dev-01",
Namespace: "namespace",
Labels: map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"environment": "dev",
},
},
@@ -611,7 +611,7 @@ func TestInterpolatedMatrixGenerate(t *testing.T) {
Name: "prod-01",
Namespace: "namespace",
Labels: map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"environment": "prod",
},
},
@@ -729,7 +729,7 @@ func TestInterpolatedMatrixGenerateGoTemplate(t *testing.T) {
"metadata": map[string]any{
"labels": map[string]string{
"environment": "dev",
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
},
},
},
@@ -746,7 +746,7 @@ func TestInterpolatedMatrixGenerateGoTemplate(t *testing.T) {
"metadata": map[string]any{
"labels": map[string]string{
"environment": "prod",
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
},
},
},
@@ -764,7 +764,7 @@ func TestInterpolatedMatrixGenerateGoTemplate(t *testing.T) {
Name: "dev-01",
Namespace: "namespace",
Labels: map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"environment": "dev",
},
},
@@ -784,7 +784,7 @@ func TestInterpolatedMatrixGenerateGoTemplate(t *testing.T) {
Name: "prod-01",
Namespace: "namespace",
Labels: map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"environment": "prod",
},
},
@@ -1249,7 +1249,7 @@ func TestInterpolatedMatrixGenerateGoTemplate_ClusterValuesFromFirstGenerator(t
gitGeneratorSpec, genMock, clusterGeneratorSpec := getGenerators()
fakeClient := fake.NewClientBuilder().WithObjects([]client.Object{clusterSecret()}...).Build()
clusterGenerator := NewClusterGenerator(fakeClient, "argocd")
clusterGenerator := NewClusterGenerator(fakeClient, "cd")
matrixGenerator := NewMatrixGenerator(map[string]Generator{
"Git": genMock,
@@ -1286,7 +1286,7 @@ func appSet() *v1alpha1.ApplicationSet {
appSet := &v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "repro",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
GoTemplate: true,
@@ -1305,9 +1305,9 @@ func clusterSecret() *corev1.Secret {
},
ObjectMeta: metav1.ObjectMeta{
Name: "guestbook-cluster",
Namespace: "argocd",
Namespace: "cd",
Labels: map[string]string{
"argocd.argoproj.io/secret-type": "cluster",
"cd.argoproj.io/secret-type": "cluster",
"environment": "guestbook",
},
},
+10 -10
View File
@@ -47,7 +47,7 @@ func TestPluginGenerateParams(t *testing.T) {
},
secret: &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "argocd-secret",
Name: "cd-secret",
Namespace: "default",
},
Data: map[string][]byte{
@@ -103,7 +103,7 @@ func TestPluginGenerateParams(t *testing.T) {
},
secret: &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "argocd-secret",
Name: "cd-secret",
Namespace: "default",
},
Data: map[string][]byte{
@@ -165,7 +165,7 @@ func TestPluginGenerateParams(t *testing.T) {
},
secret: &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "argocd-secret",
Name: "cd-secret",
Namespace: "default",
},
Data: map[string][]byte{
@@ -225,7 +225,7 @@ func TestPluginGenerateParams(t *testing.T) {
},
secret: &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "argocd-secret",
Name: "cd-secret",
Namespace: "default",
},
Data: map[string][]byte{
@@ -281,7 +281,7 @@ func TestPluginGenerateParams(t *testing.T) {
},
secret: &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "argocd-secret",
Name: "cd-secret",
Namespace: "default",
},
Data: map[string][]byte{
@@ -331,7 +331,7 @@ func TestPluginGenerateParams(t *testing.T) {
},
secret: &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "argocd-secret",
Name: "cd-secret",
Namespace: "default",
},
Data: map[string][]byte{
@@ -358,7 +358,7 @@ func TestPluginGenerateParams(t *testing.T) {
},
secret: &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "argocd-secret",
Name: "cd-secret",
Namespace: "default",
},
Data: map[string][]byte{
@@ -473,14 +473,14 @@ func TestPluginGenerateParams(t *testing.T) {
},
},
},
expectedError: errors.New("error getting plugin from generator: error fetching Secret token: error fetching secret default/argocd-secret: secrets \"argocd-secret\" not found"),
expectedError: errors.New("error getting plugin from generator: error fetching Secret token: error fetching secret default/cd-secret: secrets \"cd-secret\" not found"),
},
{
name: "no configmap",
configmap: &corev1.ConfigMap{},
secret: &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "argocd-secret",
Name: "cd-secret",
Namespace: "default",
},
Data: map[string][]byte{
@@ -535,7 +535,7 @@ func TestPluginGenerateParams(t *testing.T) {
},
secret: &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "argocd-secret",
Name: "cd-secret",
Namespace: "default",
},
Data: map[string][]byte{
+1 -1
View File
@@ -8,7 +8,7 @@ import (
func NewFakeAppsetMetrics() *ApplicationsetMetrics {
reconcileHistogram := prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Name: "argocd_appset_reconcile",
Name: "cd_appset_reconcile",
Help: "Application reconciliation performance in seconds.",
// Buckets can be set later on after observing median time
},
+4 -4
View File
@@ -17,14 +17,14 @@ var (
descAppsetLabels *prometheus.Desc
descAppsetDefaultLabels = []string{"namespace", "name"}
descAppsetInfo = prometheus.NewDesc(
"argocd_appset_info",
"cd_appset_info",
"Information about applicationset",
append(descAppsetDefaultLabels, "resource_update_status"),
nil,
)
descAppsetGeneratedApps = prometheus.NewDesc(
"argocd_appset_owned_applications",
"cd_appset_owned_applications",
"Number of applications owned by the applicationset",
descAppsetDefaultLabels,
nil,
@@ -45,7 +45,7 @@ type appsetCollector struct {
func NewApplicationsetMetrics(appsetLister applisters.ApplicationSetLister, appsetLabels []string, appsetFilter func(appset *argoappv1.ApplicationSet) bool) ApplicationsetMetrics {
reconcileHistogram := prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Name: "argocd_appset_reconcile",
Name: "cd_appset_reconcile",
Help: "Application reconciliation performance in seconds.",
// Buckets can be set later on after observing median time
},
@@ -75,7 +75,7 @@ func newAppsetCollector(lister applisters.ApplicationSetLister, labels []string,
if len(labels) > 0 {
descAppsetLabels = prometheus.NewDesc(
"argocd_appset_labels",
"cd_appset_labels",
"Applicationset labels translated to Prometheus labels",
append(descAppsetDefaultLabels, metricsutil.NormalizeLabels("label", labels)...),
nil,
+13 -13
View File
@@ -23,7 +23,7 @@ import (
)
var (
applicationsetNamespaces = []string{"argocd", "test-namespace1"}
applicationsetNamespaces = []string{"cd", "test-namespace1"}
filter = func(appset *argoappv1.ApplicationSet) bool {
return utils.IsNamespaceAllowed(applicationsetNamespaces, appset.Namespace)
@@ -37,7 +37,7 @@ apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: test1
namespace: argocd
namespace: cd
labels:
included/test: test
not-included.label/test: test
@@ -67,7 +67,7 @@ status:
status: Missing
kind: Application
name: test-app1
namespace: argocd
namespace: cd
status: OutOfSync
version: v1alpha1
- group: argoproj.io
@@ -75,7 +75,7 @@ status:
status: Missing
kind: Application
name: test-app2
namespace: argocd
namespace: cd
status: OutOfSync
version: v1alpha1
conditions:
@@ -99,7 +99,7 @@ apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: test2
namespace: argocd
namespace: cd
labels:
not-included.label/test: test
spec:
@@ -183,27 +183,27 @@ func TestApplicationsetCollector(t *testing.T) {
assert.Equal(t, http.StatusOK, rr.Code)
// Test correct appset_info and owned applications
assert.Contains(t, rr.Body.String(), `
argocd_appset_info{name="test1",namespace="argocd",resource_update_status="ApplicationSetUpToDate"} 1
cd_appset_info{name="test1",namespace="cd",resource_update_status="ApplicationSetUpToDate"} 1
`)
assert.Contains(t, rr.Body.String(), `
argocd_appset_owned_applications{name="test1",namespace="argocd"} 2
cd_appset_owned_applications{name="test1",namespace="cd"} 2
`)
// Test labels collection - should not include labels not included in the list of collected labels and include the ones that do.
assert.Contains(t, rr.Body.String(), `
argocd_appset_labels{label_included_test="test",name="test1",namespace="argocd"} 1
cd_appset_labels{label_included_test="test",name="test1",namespace="cd"} 1
`)
assert.NotContains(t, rr.Body.String(), normalizeLabel("not-included.label/test"))
// If collected label is not present on the applicationset the value should be empty
assert.Contains(t, rr.Body.String(), `
argocd_appset_labels{label_included_test="",name="test2",namespace="argocd"} 1
cd_appset_labels{label_included_test="",name="test2",namespace="cd"} 1
`)
// If ResourcesUpToDate condition is not present on the applicationset the status should be reported as 'Unknown'
assert.Contains(t, rr.Body.String(), `
argocd_appset_info{name="test2",namespace="argocd",resource_update_status="Unknown"} 1
cd_appset_info{name="test2",namespace="cd",resource_update_status="Unknown"} 1
`)
// If there are no resources on the applicationset the owned application gague should return 0
assert.Contains(t, rr.Body.String(), `
argocd_appset_owned_applications{name="test2",namespace="argocd"} 0
cd_appset_owned_applications{name="test2",namespace="cd"} 0
`)
// Test that filter is working
assert.NotContains(t, rr.Body.String(), `name="should-be-filtered-out"`)
@@ -223,11 +223,11 @@ func TestObserveReconcile(t *testing.T) {
appsetMetrics.ObserveReconcile(&appsetList[0], 5*time.Second)
handler.ServeHTTP(rr, req)
assert.Contains(t, rr.Body.String(), `
argocd_appset_reconcile_sum{name="test1",namespace="argocd"} 5
cd_appset_reconcile_sum{name="test1",namespace="cd"} 5
`)
// If there are no resources on the applicationset the owned application gague should return 0
assert.Contains(t, rr.Body.String(), `
argocd_appset_reconcile_count{name="test1",namespace="argocd"} 1
cd_appset_reconcile_count{name="test1",namespace="cd"} 1
`)
}
@@ -37,7 +37,7 @@ func TestBuildAppDependencyList(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{},
},
@@ -51,7 +51,7 @@ func TestBuildAppDependencyList(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -69,7 +69,7 @@ func TestBuildAppDependencyList(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -106,7 +106,7 @@ func TestBuildAppDependencyList(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -152,7 +152,7 @@ func TestBuildAppDependencyList(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -233,7 +233,7 @@ func TestBuildAppDependencyList(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -296,7 +296,7 @@ func TestBuildAppDependencyList(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -361,7 +361,7 @@ func TestBuildAppDependencyList(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -398,7 +398,7 @@ func TestBuildAppDependencyList(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -444,7 +444,7 @@ func TestBuildAppDependencyList(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -496,7 +496,7 @@ func TestBuildAppDependencyList(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -558,7 +558,7 @@ func TestBuildAppDependencyList(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -639,7 +639,7 @@ func TestBuildAppDependencyList(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -703,7 +703,7 @@ func TestBuildAppDependencyList(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -775,7 +775,7 @@ func TestBuildAppDependencyList(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "app-matches-multiple-steps",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -847,7 +847,7 @@ func TestBuildAppDependencyList(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "invalid-match-expression",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -937,7 +937,7 @@ func TestGetAppsToSync(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -963,7 +963,7 @@ func TestGetAppsToSync(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -1009,7 +1009,7 @@ func TestGetAppsToSync(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -1044,7 +1044,7 @@ func TestGetAppsToSync(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -1080,7 +1080,7 @@ func TestGetAppsToSync(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -1140,7 +1140,7 @@ func TestGetAppsToSync(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -1187,7 +1187,7 @@ func TestGetAppsToSync(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -1234,7 +1234,7 @@ func TestGetAppsToSync(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -1281,7 +1281,7 @@ func TestGetAppsToSync(t *testing.T) {
appSet: v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
@@ -1618,7 +1618,7 @@ func TestPerformReverseDeletionStaleCache(t *testing.T) {
require.NoError(t, v1alpha1.AddToScheme(scheme))
appSet := v1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{Name: "appset", Namespace: "argocd"},
ObjectMeta: metav1.ObjectMeta{Name: "appset", Namespace: "cd"},
Spec: v1alpha1.ApplicationSetSpec{
Strategy: &v1alpha1.ApplicationSetStrategy{
Type: "RollingSync",
@@ -1635,7 +1635,7 @@ func TestPerformReverseDeletionStaleCache(t *testing.T) {
newApp := func(name, stage string) v1alpha1.Application {
return v1alpha1.Application{
ObjectMeta: metav1.ObjectMeta{Name: name, Namespace: "argocd", Labels: map[string]string{"stage": stage}},
ObjectMeta: metav1.ObjectMeta{Name: name, Namespace: "cd", Labels: map[string]string{"stage": stage}},
}
}
// currentApps mirrors what getCurrentApplications() returns from the stale cache: both apps
+6 -6
View File
@@ -15,12 +15,12 @@ import (
// Metric names as constants
const (
githubAPIRequestTotalMetricName = "argocd_github_api_requests_total"
githubAPIRequestDurationMetricName = "argocd_github_api_request_duration_seconds"
githubAPIRateLimitRemainingMetricName = "argocd_github_api_rate_limit_remaining"
githubAPIRateLimitLimitMetricName = "argocd_github_api_rate_limit_limit"
githubAPIRateLimitResetMetricName = "argocd_github_api_rate_limit_reset_seconds"
githubAPIRateLimitUsedMetricName = "argocd_github_api_rate_limit_used"
githubAPIRequestTotalMetricName = "cd_github_api_requests_total"
githubAPIRequestDurationMetricName = "cd_github_api_request_duration_seconds"
githubAPIRateLimitRemainingMetricName = "cd_github_api_rate_limit_remaining"
githubAPIRateLimitLimitMetricName = "cd_github_api_rate_limit_limit"
githubAPIRateLimitResetMetricName = "cd_github_api_rate_limit_reset_seconds"
githubAPIRateLimitUsedMetricName = "cd_github_api_rate_limit_used"
)
// GitHubMetrics groups all metric vectors for easier injection and registration
@@ -12,7 +12,7 @@ import (
)
const (
userAgent = "argocd-applicationset"
userAgent = "cd-applicationset"
defaultTimeout = 30
)
+1 -1
View File
@@ -13,6 +13,6 @@ func TestParseSecretKey(t *testing.T) {
assert.Equal(t, "$my-token", tokenKey)
secretName, tokenKey = ParseSecretKey("#my-secret")
assert.Equal(t, "argocd-secret", secretName)
assert.Equal(t, "cd-secret", secretName)
assert.Equal(t, "#my-secret", tokenKey)
}
@@ -23,10 +23,10 @@ func giteaMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
if err != nil {
t.Fail()
}
case "/api/v1/repos/test-argocd/pr-test/pulls?limit=0&page=1&state=open":
case "/api/v1/repos/test-cd/pr-test/pulls?limit=0&page=1&state=open":
_, err := io.WriteString(w, `[{
"id": 50721,
"url": "https://gitea.com/test-argocd/pr-test/pulls/1",
"url": "https://gitea.com/test-cd/pr-test/pulls/1",
"number": 1,
"user": {
"id": 4476,
@@ -59,9 +59,9 @@ func giteaMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"state": "open",
"is_locked": false,
"comments": 0,
"html_url": "https://gitea.com/test-argocd/pr-test/pulls/1",
"diff_url": "https://gitea.com/test-argocd/pr-test/pulls/1.diff",
"patch_url": "https://gitea.com/test-argocd/pr-test/pulls/1.patch",
"html_url": "https://gitea.com/test-cd/pr-test/pulls/1",
"diff_url": "https://gitea.com/test-cd/pr-test/pulls/1.diff",
"patch_url": "https://gitea.com/test-cd/pr-test/pulls/1.patch",
"mergeable": true,
"merged": false,
"merged_at": null,
@@ -76,7 +76,7 @@ func giteaMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"id": 21618,
"owner": {
"id": 31480,
"login": "test-argocd",
"login": "test-cd",
"full_name": "",
"email": "",
"avatar_url": "https://gitea.com/avatars/22d1b1d3f61abf95951c4a958731d848",
@@ -94,10 +94,10 @@ func giteaMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"followers_count": 0,
"following_count": 0,
"starred_repos_count": 0,
"username": "test-argocd"
"username": "test-cd"
},
"name": "pr-test",
"full_name": "test-argocd/pr-test",
"full_name": "test-cd/pr-test",
"description": "",
"empty": false,
"private": false,
@@ -107,10 +107,10 @@ func giteaMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"mirror": false,
"size": 28,
"language": "",
"languages_url": "https://gitea.com/api/v1/repos/test-argocd/pr-test/languages",
"html_url": "https://gitea.com/test-argocd/pr-test",
"ssh_url": "[email protected]:test-argocd/pr-test.git",
"clone_url": "https://gitea.com/test-argocd/pr-test.git",
"languages_url": "https://gitea.com/api/v1/repos/test-cd/pr-test/languages",
"html_url": "https://gitea.com/test-cd/pr-test",
"ssh_url": "[email protected]:test-cd/pr-test.git",
"clone_url": "https://gitea.com/test-cd/pr-test.git",
"original_url": "",
"website": "",
"stars_count": 0,
@@ -159,7 +159,7 @@ func giteaMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"id": 21618,
"owner": {
"id": 31480,
"login": "test-argocd",
"login": "test-cd",
"full_name": "",
"email": "",
"avatar_url": "https://gitea.com/avatars/22d1b1d3f61abf95951c4a958731d848",
@@ -177,10 +177,10 @@ func giteaMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"followers_count": 0,
"following_count": 0,
"starred_repos_count": 0,
"username": "test-argocd"
"username": "test-cd"
},
"name": "pr-test",
"full_name": "test-argocd/pr-test",
"full_name": "test-cd/pr-test",
"description": "",
"empty": false,
"private": false,
@@ -190,10 +190,10 @@ func giteaMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"mirror": false,
"size": 28,
"language": "",
"languages_url": "https://gitea.com/api/v1/repos/test-argocd/pr-test/languages",
"html_url": "https://gitea.com/test-argocd/pr-test",
"ssh_url": "[email protected]:test-argocd/pr-test.git",
"clone_url": "https://gitea.com/test-argocd/pr-test.git",
"languages_url": "https://gitea.com/api/v1/repos/test-cd/pr-test/languages",
"html_url": "https://gitea.com/test-cd/pr-test",
"ssh_url": "[email protected]:test-cd/pr-test.git",
"clone_url": "https://gitea.com/test-cd/pr-test.git",
"original_url": "",
"website": "",
"stars_count": 0,
@@ -301,7 +301,7 @@ func TestGiteaList(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
giteaMockHandler(t)(w, r)
}))
host, err := NewGiteaService("", ts.URL, "test-argocd", "pr-test", []string{"label1"}, false, "", "")
host, err := NewGiteaService("", ts.URL, "test-cd", "pr-test", []string{"label1"}, false, "", "")
require.NoError(t, err)
prs, err := host.List(t.Context())
require.NoError(t, err)
@@ -24,12 +24,12 @@ func giteaMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
if err != nil {
t.Fail()
}
case "/api/v1/orgs/test-argocd/repos?limit=0&page=1":
case "/api/v1/orgs/test-cd/repos?limit=0&page=1":
_, err := io.WriteString(w, `[{
"id": 21618,
"owner": {
"id": 31480,
"login": "test-argocd",
"login": "test-cd",
"full_name": "",
"email": "",
"avatar_url": "https://gitea.com/avatars/22d1b1d3f61abf95951c4a958731d848",
@@ -47,10 +47,10 @@ func giteaMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"followers_count": 0,
"following_count": 0,
"starred_repos_count": 0,
"username": "test-argocd"
"username": "test-cd"
},
"name": "pr-test",
"full_name": "test-argocd/pr-test",
"full_name": "test-cd/pr-test",
"description": "",
"empty": false,
"private": false,
@@ -60,10 +60,10 @@ func giteaMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"mirror": false,
"size": 28,
"language": "",
"languages_url": "https://gitea.com/api/v1/repos/test-argocd/pr-test/languages",
"html_url": "https://gitea.com/test-argocd/pr-test",
"ssh_url": "[email protected]:test-argocd/pr-test.git",
"clone_url": "https://gitea.com/test-argocd/pr-test.git",
"languages_url": "https://gitea.com/api/v1/repos/test-cd/pr-test/languages",
"html_url": "https://gitea.com/test-cd/pr-test",
"ssh_url": "[email protected]:test-cd/pr-test.git",
"clone_url": "https://gitea.com/test-cd/pr-test.git",
"original_url": "",
"website": "",
"stars_count": 0,
@@ -106,7 +106,7 @@ func giteaMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"id": 21619,
"owner": {
"id": 31480,
"login": "test-argocd",
"login": "test-cd",
"full_name": "",
"email": "",
"avatar_url": "https://gitea.com/avatars/22d1b1d3f61abf95951c4a958731d848",
@@ -124,10 +124,10 @@ func giteaMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"followers_count": 0,
"following_count": 0,
"starred_repos_count": 0,
"username": "test-argocd"
"username": "test-cd"
},
"name": "another-repo",
"full_name": "test-argocd/another-repo",
"full_name": "test-cd/another-repo",
"description": "",
"empty": false,
"private": false,
@@ -137,10 +137,10 @@ func giteaMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"mirror": false,
"size": 28,
"language": "",
"languages_url": "https://gitea.com/api/v1/repos/test-argocd/another-repo/languages",
"html_url": "https://gitea.com/test-argocd/another-repo",
"ssh_url": "[email protected]:test-argocd/another-repo.git",
"clone_url": "https://gitea.com/test-argocd/another-repo.git",
"languages_url": "https://gitea.com/api/v1/repos/test-cd/another-repo/languages",
"html_url": "https://gitea.com/test-cd/another-repo",
"ssh_url": "[email protected]:test-cd/another-repo.git",
"clone_url": "https://gitea.com/test-cd/another-repo.git",
"original_url": "",
"website": "",
"stars_count": 0,
@@ -184,13 +184,13 @@ func giteaMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
if err != nil {
t.Fail()
}
case "/api/v1/repos/test-argocd/another-repo/branches/main":
case "/api/v1/repos/test-cd/another-repo/branches/main":
_, err := io.WriteString(w, `{
"name": "main",
"commit": {
"id": "1fa33898cf84e89836863e3a5e76eee45777b4b0",
"message": "initial commit\n",
"url": "https://gitea.com/test-argocd/pr-test/commit/1fa33898cf84e89836863e3a5e76eee45777b4b0",
"url": "https://gitea.com/test-cd/pr-test/commit/1fa33898cf84e89836863e3a5e76eee45777b4b0",
"author": {
"name": "Dan Molik",
"email": "[email protected]",
@@ -224,13 +224,13 @@ func giteaMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
if err != nil {
t.Fail()
}
case "/api/v1/repos/test-argocd/pr-test/branches/test":
case "/api/v1/repos/test-cd/pr-test/branches/test":
_, err := io.WriteString(w, `{
"name": "test",
"commit": {
"id": "28c3b329933f6fefd9b55225535123bbffec5a46",
"message": "initial commit\n",
"url": "https://gitea.com/test-argocd/pr-test/commit/28c3b329933f6fefd9b55225535123bbffec5a46",
"url": "https://gitea.com/test-cd/pr-test/commit/28c3b329933f6fefd9b55225535123bbffec5a46",
"author": {
"name": "Dan Molik",
"email": "[email protected]",
@@ -264,13 +264,13 @@ func giteaMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
if err != nil {
t.Fail()
}
case "/api/v1/repos/test-argocd/another-repo/branches/test":
case "/api/v1/repos/test-cd/another-repo/branches/test":
_, err := io.WriteString(w, `{
"name": "test",
"commit": {
"id": "32cdcf613b259a9439ceabd4d1745d43f163ea70",
"message": "initial commit\n",
"url": "https://gitea.com/test-argocd/another-repo/commit/32cdcf613b259a9439ceabd4d1745d43f163ea70",
"url": "https://gitea.com/test-cd/another-repo/commit/32cdcf613b259a9439ceabd4d1745d43f163ea70",
"author": {
"name": "Dan Molik",
"email": "[email protected]",
@@ -304,13 +304,13 @@ func giteaMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
if err != nil {
t.Fail()
}
case "/api/v1/repos/test-argocd/pr-test/branches/main":
case "/api/v1/repos/test-cd/pr-test/branches/main":
_, err := io.WriteString(w, `{
"name": "main",
"commit": {
"id": "75f6fceff80f6aaf12b65a2cf6a89190b866625b",
"message": "initial commit\n",
"url": "https://gitea.com/test-argocd/pr-test/commit/75f6fceff80f6aaf12b65a2cf6a89190b866625b",
"url": "https://gitea.com/test-cd/pr-test/commit/75f6fceff80f6aaf12b65a2cf6a89190b866625b",
"author": {
"name": "Dan Molik",
"email": "[email protected]",
@@ -344,13 +344,13 @@ func giteaMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
if err != nil {
t.Fail()
}
case "/api/v1/repos/test-argocd/another-repo/branches?limit=0&page=1":
case "/api/v1/repos/test-cd/another-repo/branches?limit=0&page=1":
_, err := io.WriteString(w, `[{
"name": "main",
"commit": {
"id": "1fa33898cf84e89836863e3a5e76eee45777b4b0",
"message": "initial commit\n",
"url": "https://gitea.com/test-argocd/pr-test/commit/1fa33898cf84e89836863e3a5e76eee45777b4b0",
"url": "https://gitea.com/test-cd/pr-test/commit/1fa33898cf84e89836863e3a5e76eee45777b4b0",
"author": {
"name": "Dan Molik",
"email": "[email protected]",
@@ -386,7 +386,7 @@ func giteaMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"commit": {
"id": "32cdcf613b259a9439ceabd4d1745d43f163ea70",
"message": "add an empty file\n",
"url": "https://gitea.com/test-argocd/pr-test/commit/32cdcf613b259a9439ceabd4d1745d43f163ea70",
"url": "https://gitea.com/test-cd/pr-test/commit/32cdcf613b259a9439ceabd4d1745d43f163ea70",
"author": {
"name": "Dan Molik",
"email": "[email protected]",
@@ -420,13 +420,13 @@ func giteaMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
if err != nil {
t.Fail()
}
case "/api/v1/repos/test-argocd/pr-test/branches?limit=0&page=1":
case "/api/v1/repos/test-cd/pr-test/branches?limit=0&page=1":
_, err := io.WriteString(w, `[{
"name": "main",
"commit": {
"id": "75f6fceff80f6aaf12b65a2cf6a89190b866625b",
"message": "initial commit\n",
"url": "https://gitea.com/test-argocd/pr-test/commit/75f6fceff80f6aaf12b65a2cf6a89190b866625b",
"url": "https://gitea.com/test-cd/pr-test/commit/75f6fceff80f6aaf12b65a2cf6a89190b866625b",
"author": {
"name": "Dan Molik",
"email": "[email protected]",
@@ -461,7 +461,7 @@ func giteaMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"commit": {
"id": "28c3b329933f6fefd9b55225535123bbffec5a46",
"message": "add an empty file\n",
"url": "https://gitea.com/test-argocd/pr-test/commit/28c3b329933f6fefd9b55225535123bbffec5a46",
"url": "https://gitea.com/test-cd/pr-test/commit/28c3b329933f6fefd9b55225535123bbffec5a46",
"author": {
"name": "Dan Molik",
"email": "[email protected]",
@@ -554,19 +554,19 @@ func TestGiteaListRepos(t *testing.T) {
branches: []string{"main"},
expectedRepos: []*Repository{
{
Organization: "test-argocd",
Organization: "test-cd",
Repository: "pr-test",
Branch: "main",
URL: "[email protected]:test-argocd/pr-test.git",
URL: "[email protected]:test-cd/pr-test.git",
SHA: "75f6fceff80f6aaf12b65a2cf6a89190b866625b",
RepositoryId: 21618,
Labels: []string{},
},
{
Organization: "test-argocd",
Organization: "test-cd",
Repository: "another-repo",
Branch: "main",
URL: "[email protected]:test-argocd/another-repo.git",
URL: "[email protected]:test-cd/another-repo.git",
SHA: "1fa33898cf84e89836863e3a5e76eee45777b4b0",
RepositoryId: 21619,
Labels: []string{},
@@ -582,19 +582,19 @@ func TestGiteaListRepos(t *testing.T) {
proto: "ssh",
expectedRepos: []*Repository{
{
Organization: "test-argocd",
Organization: "test-cd",
Repository: "pr-test",
Branch: "main",
URL: "[email protected]:test-argocd/pr-test.git",
URL: "[email protected]:test-cd/pr-test.git",
SHA: "75f6fceff80f6aaf12b65a2cf6a89190b866625b",
RepositoryId: 21618,
Labels: []string{},
},
{
Organization: "test-argocd",
Organization: "test-cd",
Repository: "another-repo",
Branch: "main",
URL: "[email protected]:test-argocd/another-repo.git",
URL: "[email protected]:test-cd/another-repo.git",
SHA: "1fa33898cf84e89836863e3a5e76eee45777b4b0",
RepositoryId: 21619,
Labels: []string{},
@@ -610,19 +610,19 @@ func TestGiteaListRepos(t *testing.T) {
proto: "https",
expectedRepos: []*Repository{
{
Organization: "test-argocd",
Organization: "test-cd",
Repository: "pr-test",
Branch: "main",
URL: "https://gitea.com/test-argocd/pr-test",
URL: "https://gitea.com/test-cd/pr-test",
SHA: "75f6fceff80f6aaf12b65a2cf6a89190b866625b",
RepositoryId: 21618,
Labels: []string{},
},
{
Organization: "test-argocd",
Organization: "test-cd",
Repository: "another-repo",
Branch: "main",
URL: "https://gitea.com/test-argocd/another-repo",
URL: "https://gitea.com/test-cd/another-repo",
SHA: "1fa33898cf84e89836863e3a5e76eee45777b4b0",
RepositoryId: 21619,
Labels: []string{},
@@ -647,37 +647,37 @@ func TestGiteaListRepos(t *testing.T) {
expectedRepos: []*Repository{
{
Organization: "test-argocd",
Organization: "test-cd",
Repository: "pr-test",
Branch: "main",
URL: "[email protected]:test-argocd/pr-test.git",
URL: "[email protected]:test-cd/pr-test.git",
SHA: "75f6fceff80f6aaf12b65a2cf6a89190b866625b",
Labels: []string{},
RepositoryId: 21618,
},
{
Organization: "test-argocd",
Organization: "test-cd",
Repository: "another-repo",
Branch: "main",
URL: "[email protected]:test-argocd/another-repo.git",
URL: "[email protected]:test-cd/another-repo.git",
SHA: "1fa33898cf84e89836863e3a5e76eee45777b4b0",
Labels: []string{},
RepositoryId: 21619,
},
{
Organization: "test-argocd",
Organization: "test-cd",
Repository: "pr-test",
Branch: "test",
URL: "[email protected]:test-argocd/pr-test.git",
URL: "[email protected]:test-cd/pr-test.git",
SHA: "28c3b329933f6fefd9b55225535123bbffec5a46",
Labels: []string{},
RepositoryId: 21618,
},
{
Organization: "test-argocd",
Organization: "test-cd",
Repository: "another-repo",
Branch: "test",
URL: "[email protected]:test-argocd/another-repo.git",
URL: "[email protected]:test-cd/another-repo.git",
SHA: "32cdcf613b259a9439ceabd4d1745d43f163ea70",
Labels: []string{},
RepositoryId: 21619,
@@ -692,37 +692,37 @@ func TestGiteaListRepos(t *testing.T) {
expectedRepos: []*Repository{
{
Organization: "test-argocd",
Organization: "test-cd",
Repository: "pr-test",
Branch: "main",
URL: "[email protected]:test-argocd/pr-test.git",
URL: "[email protected]:test-cd/pr-test.git",
SHA: "75f6fceff80f6aaf12b65a2cf6a89190b866625b",
Labels: []string{},
RepositoryId: 21618,
},
{
Organization: "test-argocd",
Organization: "test-cd",
Repository: "another-repo",
Branch: "main",
URL: "[email protected]:test-argocd/another-repo.git",
URL: "[email protected]:test-cd/another-repo.git",
SHA: "1fa33898cf84e89836863e3a5e76eee45777b4b0",
Labels: []string{},
RepositoryId: 21619,
},
{
Organization: "test-argocd",
Organization: "test-cd",
Repository: "pr-test",
Branch: "test",
URL: "[email protected]:test-argocd/pr-test.git",
URL: "[email protected]:test-cd/pr-test.git",
SHA: "28c3b329933f6fefd9b55225535123bbffec5a46",
Labels: []string{},
RepositoryId: 21618,
},
{
Organization: "test-argocd",
Organization: "test-cd",
Repository: "another-repo",
Branch: "test",
URL: "[email protected]:test-argocd/another-repo.git",
URL: "[email protected]:test-cd/another-repo.git",
SHA: "32cdcf613b259a9439ceabd4d1745d43f163ea70",
Labels: []string{},
RepositoryId: 21619,
@@ -738,37 +738,37 @@ func TestGiteaListRepos(t *testing.T) {
branches: []string{"main"},
expectedRepos: []*Repository{
{
Organization: "test-argocd",
Organization: "test-cd",
Repository: "pr-test",
Branch: "main",
URL: "[email protected]:test-argocd/pr-test.git",
URL: "[email protected]:test-cd/pr-test.git",
SHA: "75f6fceff80f6aaf12b65a2cf6a89190b866625b",
Labels: []string{},
RepositoryId: 21618,
},
{
Organization: "test-argocd",
Organization: "test-cd",
Repository: "another-repo",
Branch: "main",
URL: "[email protected]:test-argocd/another-repo.git",
URL: "[email protected]:test-cd/another-repo.git",
SHA: "1fa33898cf84e89836863e3a5e76eee45777b4b0",
Labels: []string{},
RepositoryId: 21619,
},
{
Organization: "test-argocd",
Organization: "test-cd",
Repository: "pr-test",
Branch: "test",
URL: "[email protected]:test-argocd/pr-test.git",
URL: "[email protected]:test-cd/pr-test.git",
SHA: "28c3b329933f6fefd9b55225535123bbffec5a46",
Labels: []string{},
RepositoryId: 21618,
},
{
Organization: "test-argocd",
Organization: "test-cd",
Repository: "another-repo",
Branch: "test",
URL: "[email protected]:test-argocd/another-repo.git",
URL: "[email protected]:test-cd/another-repo.git",
SHA: "32cdcf613b259a9439ceabd4d1745d43f163ea70",
Labels: []string{},
RepositoryId: 21619,
@@ -784,19 +784,19 @@ func TestGiteaListRepos(t *testing.T) {
branches: []string{"main"},
expectedRepos: []*Repository{
{
Organization: "test-argocd",
Organization: "test-cd",
Repository: "pr-test",
Branch: "main",
URL: "[email protected]:test-argocd/pr-test.git",
URL: "[email protected]:test-cd/pr-test.git",
SHA: "75f6fceff80f6aaf12b65a2cf6a89190b866625b",
Labels: []string{},
RepositoryId: 21618,
},
{
Organization: "test-argocd",
Organization: "test-cd",
Repository: "pr-test",
Branch: "test",
URL: "[email protected]:test-argocd/pr-test.git",
URL: "[email protected]:test-cd/pr-test.git",
SHA: "28c3b329933f6fefd9b55225535123bbffec5a46",
Labels: []string{},
RepositoryId: 21618,
@@ -811,7 +811,7 @@ func TestGiteaListRepos(t *testing.T) {
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
t.Parallel()
provider, _ := NewGiteaProvider("test-argocd", "", ts.URL, c.allBranches, false, c.excludeArchivedRepos, "", "")
provider, _ := NewGiteaProvider("test-cd", "", ts.URL, c.allBranches, false, c.excludeArchivedRepos, "", "")
rawRepos, err := ListRepos(t.Context(), provider, c.filters, c.proto)
if c.hasError {
@@ -22,14 +22,14 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
w.Header().Set("Content-Type", "application/json")
switch r.RequestURI {
case "/api/v4":
case "/api/v4/groups/test-argocd-proton/projects?include_subgroups=false&per_page=100", "/api/v4/groups/test-argocd-proton/projects?include_subgroups=false&per_page=100&topic=&with_shared=false", "/api/v4/groups/test-argocd-proton/projects?archived=false&include_subgroups=false&per_page=100", "/api/v4/groups/test-argocd-proton/projects?archived=false&include_subgroups=false&per_page=100&topic=&with_shared=false":
case "/api/v4/groups/test-cd-proton/projects?include_subgroups=false&per_page=100", "/api/v4/groups/test-cd-proton/projects?include_subgroups=false&per_page=100&topic=&with_shared=false", "/api/v4/groups/test-cd-proton/projects?archived=false&include_subgroups=false&per_page=100", "/api/v4/groups/test-cd-proton/projects?archived=false&include_subgroups=false&per_page=100&topic=&with_shared=false":
_, err := io.WriteString(w, `[{
"id": 27084533,
"description": "",
"name": "argocd",
"name_with_namespace": "test argocd proton / argocd",
"path": "argocd",
"path_with_namespace": "test-argocd-proton/argocd",
"name": "cd",
"name_with_namespace": "test cd proton / cd",
"path": "cd",
"path_with_namespace": "test-cd-proton/cd",
"created_at": "2021-06-01T17:30:44.724Z",
"default_branch": "master",
"tag_list": [
@@ -38,9 +38,9 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"topics": [
"test-topic"
],
"ssh_url_to_repo": "[email protected]:test-argocd-proton/argocd.git",
"http_url_to_repo": "https://gitlab.com/test-argocd-proton/argocd.git",
"web_url": "https://gitlab.com/test-argocd-proton/argocd",
"ssh_url_to_repo": "[email protected]:test-cd-proton/cd.git",
"http_url_to_repo": "https://gitlab.com/test-cd-proton/cd.git",
"web_url": "https://gitlab.com/test-cd-proton/cd",
"readme_url": null,
"avatar_url": null,
"forks_count": 0,
@@ -48,15 +48,15 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"last_activity_at": "2021-06-04T08:19:51.656Z",
"namespace": {
"id": 12258515,
"name": "test argocd proton",
"path": "test-argocd-proton",
"name": "test cd proton",
"path": "test-cd-proton",
"kind": "gro* Connection #0 to host gitlab.com left intact up ",
"full_path ": "test - argocd - proton ",
"full_path ": "test - cd - proton ",
"parent_id ": null,
"avatar_url ": null,
"web_url ": "https: //gitlab.com/groups/test-argocd-proton"
"web_url ": "https: //gitlab.com/groups/test-cd-proton"
},
"container_registry_image_prefix": "registry.gitlab.com/test-argocd-proton/argocd",
"container_registry_image_prefix": "registry.gitlab.com/test-cd-proton/cd",
"_links": {
"self": "https://gitlab.com/api/v4/projects/27084533",
"issues": "https://gitlab.com/api/v4/projects/27084533/issues",
@@ -149,21 +149,21 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
if err != nil {
t.Fail()
}
case "/api/v4/groups/test-argocd-proton/projects?archived=true&include_subgroups=false&per_page=100", "/api/v4/groups/test-argocd-proton/projects?archived=true&include_subgroups=false&per_page=100&topic=&with_shared=false":
case "/api/v4/groups/test-cd-proton/projects?archived=true&include_subgroups=false&per_page=100", "/api/v4/groups/test-cd-proton/projects?archived=true&include_subgroups=false&per_page=100&topic=&with_shared=false":
_, err := io.WriteString(w, `[{
"id": 27084533,
"description": "",
"name": "argocd",
"name_with_namespace": "test argocd proton / argocd",
"path": "argocd",
"path_with_namespace": "test-argocd-proton/argocd",
"name": "cd",
"name_with_namespace": "test cd proton / cd",
"path": "cd",
"path_with_namespace": "test-cd-proton/cd",
"created_at": "2021-06-01T17:30:44.724Z",
"default_branch": "master",
"tag_list": [],
"topics": [],
"ssh_url_to_repo": "[email protected]:test-argocd-proton/argocd.git",
"http_url_to_repo": "https://gitlab.com/test-argocd-proton/argocd.git",
"web_url": "https://gitlab.com/test-argocd-proton/argocd",
"ssh_url_to_repo": "[email protected]:test-cd-proton/cd.git",
"http_url_to_repo": "https://gitlab.com/test-cd-proton/cd.git",
"web_url": "https://gitlab.com/test-cd-proton/cd",
"readme_url": null,
"avatar_url": null,
"forks_count": 0,
@@ -171,15 +171,15 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"last_activity_at": "2021-06-04T08:19:51.656Z",
"namespace": {
"id": 12258515,
"name": "test argocd proton",
"path": "test-argocd-proton",
"name": "test cd proton",
"path": "test-cd-proton",
"kind": "gro* Connection #0 to host gitlab.com left intact up ",
"full_path ": "test - argocd - proton ",
"full_path ": "test - cd - proton ",
"parent_id ": null,
"avatar_url ": null,
"web_url ": "https: //gitlab.com/groups/test-argocd-proton"
"web_url ": "https: //gitlab.com/groups/test-cd-proton"
},
"container_registry_image_prefix": "registry.gitlab.com/test-argocd-proton/argocd",
"container_registry_image_prefix": "registry.gitlab.com/test-cd-proton/cd",
"_links": {
"self": "https://gitlab.com/api/v4/projects/27084533",
"issues": "https://gitlab.com/api/v4/projects/27084533/issues",
@@ -273,9 +273,9 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"id": 56522142,
"description": "",
"name": "another-repo",
"name_with_namespace": "test argocd proton / another-repo",
"name_with_namespace": "test cd proton / another-repo",
"path": "another-repo",
"path_with_namespace": "test-argocd-proton/another-repo",
"path_with_namespace": "test-cd-proton/another-repo",
"created_at": "2022-09-13T12:10:14.722Z",
"default_branch": "master",
"tag_list": [
@@ -284,9 +284,9 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"topics": [
"test-topic"
],
"ssh_url_to_repo": "[email protected]:test-argocd-proton/another-repo.git",
"http_url_to_repo": "https://gitlab.com/test-argocd-proton/another-repo.git",
"web_url": "https://gitlab.com/test-argocd-proton/another-repo",
"ssh_url_to_repo": "[email protected]:test-cd-proton/another-repo.git",
"http_url_to_repo": "https://gitlab.com/test-cd-proton/another-repo.git",
"web_url": "https://gitlab.com/test-cd-proton/another-repo",
"readme_url": null,
"avatar_url": null,
"forks_count": 0,
@@ -294,15 +294,15 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"last_activity_at": "2021-06-04T08:19:51.656Z",
"namespace": {
"id": 12258515,
"name": "test argocd proton",
"path": "test-argocd-proton",
"name": "test cd proton",
"path": "test-cd-proton",
"kind": "gro* Connection #0 to host gitlab.com left intact up ",
"full_path ": "test - argocd - proton ",
"full_path ": "test - cd - proton ",
"parent_id ": null,
"avatar_url ": null,
"web_url ": "https: //gitlab.com/groups/test-argocd-proton"
"web_url ": "https: //gitlab.com/groups/test-cd-proton"
},
"container_registry_image_prefix": "registry.gitlab.com/test-argocd-proton/another-repo",
"container_registry_image_prefix": "registry.gitlab.com/test-cd-proton/another-repo",
"_links": {
"self": "https://gitlab.com/api/v4/projects/56522142",
"issues": "https://gitlab.com/api/v4/projects/56522142/issues",
@@ -395,14 +395,14 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
if err != nil {
t.Fail()
}
case "/api/v4/groups/test-argocd-proton/projects?include_subgroups=true&per_page=100&topic=&with_shared=false":
case "/api/v4/groups/test-cd-proton/projects?include_subgroups=true&per_page=100&topic=&with_shared=false":
_, err := io.WriteString(w, `[{
"id": 27084533,
"description": "",
"name": "argocd",
"name_with_namespace": "test argocd proton / argocd",
"path": "argocd",
"path_with_namespace": "test-argocd-proton/argocd",
"name": "cd",
"name_with_namespace": "test cd proton / cd",
"path": "cd",
"path_with_namespace": "test-cd-proton/cd",
"created_at": "2021-06-01T17:30:44.724Z",
"default_branch": "master",
"tag_list": [
@@ -413,9 +413,9 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"test-topic",
"specific-topic"
],
"ssh_url_to_repo": "[email protected]:test-argocd-proton/argocd.git",
"http_url_to_repo": "https://gitlab.com/test-argocd-proton/argocd.git",
"web_url": "https://gitlab.com/test-argocd-proton/argocd",
"ssh_url_to_repo": "[email protected]:test-cd-proton/cd.git",
"http_url_to_repo": "https://gitlab.com/test-cd-proton/cd.git",
"web_url": "https://gitlab.com/test-cd-proton/cd",
"readme_url": null,
"avatar_url": null,
"forks_count": 0,
@@ -423,15 +423,15 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"last_activity_at": "2021-06-04T08:19:51.656Z",
"namespace": {
"id": 12258515,
"name": "test argocd proton",
"path": "test-argocd-proton",
"name": "test cd proton",
"path": "test-cd-proton",
"kind": "gro* Connection #0 to host gitlab.com left intact up ",
"full_path ": "test - argocd - proton ",
"full_path ": "test - cd - proton ",
"parent_id ": null,
"avatar_url ": null,
"web_url ": "https: //gitlab.com/groups/test-argocd-proton"
"web_url ": "https: //gitlab.com/groups/test-cd-proton"
},
"container_registry_image_prefix": "registry.gitlab.com/test-argocd-proton/argocd",
"container_registry_image_prefix": "registry.gitlab.com/test-cd-proton/cd",
"_links": {
"self": "https://gitlab.com/api/v4/projects/27084533",
"issues": "https://gitlab.com/api/v4/projects/27084533/issues",
@@ -524,10 +524,10 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
{
"id": 27084538,
"description": "This is a Project from a Subgroup",
"name": "argocd-subgroup",
"name_with_namespace": "test argocd proton / subgroup / argocd-subgroup",
"path": "argocd-subgroup",
"path_with_namespace": "test-argocd-proton/subgroup/argocd-subgroup",
"name": "cd-subgroup",
"name_with_namespace": "test cd proton / subgroup / cd-subgroup",
"path": "cd-subgroup",
"path_with_namespace": "test-cd-proton/subgroup/cd-subgroup",
"created_at": "2021-06-01T17:30:44.724Z",
"default_branch": "master",
"tag_list": [
@@ -536,9 +536,9 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"topics": [
"test-topic"
],
"ssh_url_to_repo": "[email protected]:test-argocd-proton/subgroup/argocd-subgroup.git",
"http_url_to_repo": "https://gitlab.com/test-argocd-proton/subgroup/argocd-subgroup.git",
"web_url": "https://gitlab.com/test-argocd-proton/subgroup/argocd-subgroup",
"ssh_url_to_repo": "[email protected]:test-cd-proton/subgroup/cd-subgroup.git",
"http_url_to_repo": "https://gitlab.com/test-cd-proton/subgroup/cd-subgroup.git",
"web_url": "https://gitlab.com/test-cd-proton/subgroup/cd-subgroup",
"readme_url": null,
"avatar_url": null,
"forks_count": 0,
@@ -549,12 +549,12 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"name": "subgroup",
"path": "subgroup",
"kind": "group ",
"full_path ": "test-argocd-proton/subgroup",
"full_path ": "test-cd-proton/subgroup",
"parent_id ": 12258515,
"avatar_url ": null,
"web_url ": "https: //gitlab.com/groups/test-argocd-proton/subgroup"
"web_url ": "https: //gitlab.com/groups/test-cd-proton/subgroup"
},
"container_registry_image_prefix": "registry.gitlab.com/test-argocd-proton/subgroup/argocd",
"container_registry_image_prefix": "registry.gitlab.com/test-cd-proton/subgroup/cd",
"_links": {
"self": "https://gitlab.com/api/v4/projects/27084538",
"issues": "https://gitlab.com/api/v4/projects/27084538/issues",
@@ -648,14 +648,14 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
if err != nil {
t.Fail()
}
case "/api/v4/groups/test-argocd-proton/projects?include_subgroups=false&per_page=100&topic=specific-topic&with_shared=false":
case "/api/v4/groups/test-cd-proton/projects?include_subgroups=false&per_page=100&topic=specific-topic&with_shared=false":
_, err := io.WriteString(w, `[{
"id": 27084533,
"description": "",
"name": "argocd",
"name_with_namespace": "test argocd proton / argocd",
"path": "argocd",
"path_with_namespace": "test-argocd-proton/argocd",
"name": "cd",
"name_with_namespace": "test cd proton / cd",
"path": "cd",
"path_with_namespace": "test-cd-proton/cd",
"created_at": "2021-06-01T17:30:44.724Z",
"default_branch": "master",
"tag_list": [
@@ -666,9 +666,9 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"test-topic",
"specific-topic"
],
"ssh_url_to_repo": "[email protected]:test-argocd-proton/argocd.git",
"http_url_to_repo": "https://gitlab.com/test-argocd-proton/argocd.git",
"web_url": "https://gitlab.com/test-argocd-proton/argocd",
"ssh_url_to_repo": "[email protected]:test-cd-proton/cd.git",
"http_url_to_repo": "https://gitlab.com/test-cd-proton/cd.git",
"web_url": "https://gitlab.com/test-cd-proton/cd",
"readme_url": null,
"avatar_url": null,
"forks_count": 0,
@@ -676,15 +676,15 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"last_activity_at": "2021-06-04T08:19:51.656Z",
"namespace": {
"id": 12258515,
"name": "test argocd proton",
"path": "test-argocd-proton",
"name": "test cd proton",
"path": "test-cd-proton",
"kind": "gro* Connection #0 to host gitlab.com left intact up ",
"full_path ": "test - argocd - proton ",
"full_path ": "test - cd - proton ",
"parent_id ": null,
"avatar_url ": null,
"web_url ": "https: //gitlab.com/groups/test-argocd-proton"
"web_url ": "https: //gitlab.com/groups/test-cd-proton"
},
"container_registry_image_prefix": "registry.gitlab.com/test-argocd-proton/argocd",
"container_registry_image_prefix": "registry.gitlab.com/test-cd-proton/cd",
"_links": {
"self": "https://gitlab.com/api/v4/projects/27084533",
"issues": "https://gitlab.com/api/v4/projects/27084533/issues",
@@ -778,14 +778,14 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
if err != nil {
t.Fail()
}
case "/api/v4/groups/test-argocd-proton/projects?include_subgroups=true&per_page=100&topic=&with_shared=true":
case "/api/v4/groups/test-cd-proton/projects?include_subgroups=true&per_page=100&topic=&with_shared=true":
_, err := io.WriteString(w, `[{
"id": 27084533,
"description": "",
"name": "argocd",
"name_with_namespace": "test argocd proton / argocd",
"path": "argocd",
"path_with_namespace": "test-argocd-proton/argocd",
"name": "cd",
"name_with_namespace": "test cd proton / cd",
"path": "cd",
"path_with_namespace": "test-cd-proton/cd",
"created_at": "2021-06-01T17:30:44.724Z",
"default_branch": "master",
"tag_list": [
@@ -794,9 +794,9 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"topics": [
"test-topic"
],
"ssh_url_to_repo": "[email protected]:test-argocd-proton/argocd.git",
"http_url_to_repo": "https://gitlab.com/test-argocd-proton/argocd.git",
"web_url": "https://gitlab.com/test-argocd-proton/argocd",
"ssh_url_to_repo": "[email protected]:test-cd-proton/cd.git",
"http_url_to_repo": "https://gitlab.com/test-cd-proton/cd.git",
"web_url": "https://gitlab.com/test-cd-proton/cd",
"readme_url": null,
"avatar_url": null,
"forks_count": 0,
@@ -804,15 +804,15 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"last_activity_at": "2021-06-04T08:19:51.656Z",
"namespace": {
"id": 12258515,
"name": "test argocd proton",
"path": "test-argocd-proton",
"name": "test cd proton",
"path": "test-cd-proton",
"kind": "gro* Connection #0 to host gitlab.com left intact up ",
"full_path ": "test - argocd - proton ",
"full_path ": "test - cd - proton ",
"parent_id ": null,
"avatar_url ": null,
"web_url ": "https: //gitlab.com/groups/test-argocd-proton"
"web_url ": "https: //gitlab.com/groups/test-cd-proton"
},
"container_registry_image_prefix": "registry.gitlab.com/test-argocd-proton/argocd",
"container_registry_image_prefix": "registry.gitlab.com/test-cd-proton/cd",
"_links": {
"self": "https://gitlab.com/api/v4/projects/27084533",
"issues": "https://gitlab.com/api/v4/projects/27084533/issues",
@@ -905,10 +905,10 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
{
"id": 27084534,
"description": "This is a Shared Project",
"name": "shared-argocd",
"name_with_namespace": "shared project to test argocd proton / argocd",
"path": "shared-argocd",
"path_with_namespace": "test-shared-argocd-proton/shared-argocd",
"name": "shared-cd",
"name_with_namespace": "shared project to test cd proton / cd",
"path": "shared-cd",
"path_with_namespace": "test-shared-cd-proton/shared-cd",
"created_at": "2021-06-11T17:30:44.724Z",
"default_branch": "master",
"tag_list": [
@@ -917,9 +917,9 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"topics": [
"test-topic"
],
"ssh_url_to_repo": "[email protected]:test-shared-argocd-proton/shared-argocd.git",
"http_url_to_repo": "https://gitlab.com/test-shared-argocd-proton/shared-argocd.git",
"web_url": "https://gitlab.com/test-shared-argocd-proton/shared-argocd",
"ssh_url_to_repo": "[email protected]:test-shared-cd-proton/shared-cd.git",
"http_url_to_repo": "https://gitlab.com/test-shared-cd-proton/shared-cd.git",
"web_url": "https://gitlab.com/test-shared-cd-proton/shared-cd",
"readme_url": null,
"avatar_url": null,
"forks_count": 0,
@@ -927,15 +927,15 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"last_activity_at": "2021-06-04T08:19:51.656Z",
"namespace": {
"id": 12258518,
"name": "test shared argocd proton",
"path": "test-shared-argocd-proton",
"name": "test shared cd proton",
"path": "test-shared-cd-proton",
"kind": "group",
"full_path ": "test-shared-argocd-proton",
"full_path ": "test-shared-cd-proton",
"parent_id ": null,
"avatar_url ": null,
"web_url ": "https: //gitlab.com/groups/test-shared-argocd-proton"
"web_url ": "https: //gitlab.com/groups/test-shared-cd-proton"
},
"container_registry_image_prefix": "registry.gitlab.com/test-shared-argocd-proton/shared-argocd",
"container_registry_image_prefix": "registry.gitlab.com/test-shared-cd-proton/shared-cd",
"_links": {
"self": "https://gitlab.com/api/v4/projects/27084534",
"issues": "https://gitlab.com/api/v4/projects/27084534/issues",
@@ -996,8 +996,8 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"shared_with_groups": [
{
"group_id": 12258515,
"group_name": "test-argocd-proton",
"group_full_path": "test-shared-argocd-proton",
"group_name": "test-cd-proton",
"group_full_path": "test-shared-cd-proton",
"group_access_level": 30,
"expires_at": null
}
@@ -1045,7 +1045,7 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"created_at": "2021-06-04T08:24:44.000+00:00",
"parent_ids": ["3c9d50be1ef949ad28674e238c7e12a17b1e9706", "56482e001731640b4123cf177e51c696f08a3005"],
"title": "Merge branch 'pipeline-1317911429' into 'master'",
"message": "Merge branch 'pipeline-1317911429' into 'master'\n\n[testapp-ci] manifests/demo/test-app.yaml: release v1.1.0\n\nSee merge request test-argocd-proton/argocd!3",
"message": "Merge branch 'pipeline-1317911429' into 'master'\n\n[testapp-ci] manifests/demo/test-app.yaml: release v1.1.0\n\nSee merge request test-cd-proton/cd!3",
"author_name": "Martin Vozník",
"author_email": "[email protected]",
"authored_date": "2021-06-04T08:24:44.000+00:00",
@@ -1053,7 +1053,7 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"committer_email": "[email protected]",
"committed_date": "2021-06-04T08:24:44.000+00:00",
"trailers": {},
"web_url": "https://gitlab.com/test-argocd-proton/argocd/-/commit/8898d7999fc99dd0fd578650b58b244fc63f6b53"
"web_url": "https://gitlab.com/test-cd-proton/cd/-/commit/8898d7999fc99dd0fd578650b58b244fc63f6b53"
},
"merged": false,
"protected": true,
@@ -1061,7 +1061,7 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"developers_can_merge": false,
"can_push": false,
"default": true,
"web_url": "https://gitlab.com/test-argocd-proton/argocd/-/tree/master"
"web_url": "https://gitlab.com/test-cd-proton/cd/-/tree/master"
}`)
if err != nil {
t.Fail()
@@ -1075,7 +1075,7 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"created_at": "2023-08-04T08:14:14.000+00:00",
"parent_ids": ["5d9d50be1ef949ad28674e238c7e12a17b1e9706", "99482e001731640b4123cf177e51c696f08a3005"],
"title": "Merge branch 'pipeline-4547911429' into 'master'",
"message": "Merge branch 'pipeline-4547911429' into 'master'\n\n[testapp-ci] manifests/demo/test-app.yaml: release v1.2.0\n\nSee merge request test-argocd-proton/argocd!3",
"message": "Merge branch 'pipeline-4547911429' into 'master'\n\n[testapp-ci] manifests/demo/test-app.yaml: release v1.2.0\n\nSee merge request test-cd-proton/cd!3",
"author_name": "Martin Vozník",
"author_email": "[email protected]",
"authored_date": "2023-08-04T08:14:14.000+00:00",
@@ -1083,7 +1083,7 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"committer_email": "[email protected]",
"committed_date": "2023-08-04T08:14:14.000+00:00",
"trailers": {},
"web_url": "https://gitlab.com/test-argocd-proton/argocd/-/commit/9998d7999fc99dd0fd578650b58b244fc63f6b53"
"web_url": "https://gitlab.com/test-cd-proton/cd/-/commit/9998d7999fc99dd0fd578650b58b244fc63f6b53"
},
"merged": false,
"protected": true,
@@ -1091,7 +1091,7 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"developers_can_merge": false,
"can_push": false,
"default": true,
"web_url": "https://gitlab.com/test-argocd-proton/argocd/-/tree/master"
"web_url": "https://gitlab.com/test-cd-proton/cd/-/tree/master"
}`)
if err != nil {
t.Fail()
@@ -1113,7 +1113,7 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"committer_email": "[email protected]",
"committed_date": "2021-06-04T08:24:44.000+00:00",
"trailers": null,
"web_url": "https://gitlab.com/test-argocd-proton/argocd/-/commit/8898d7999fc99dd0fd578650b58b244fc63f6b53"
"web_url": "https://gitlab.com/test-cd-proton/cd/-/commit/8898d7999fc99dd0fd578650b58b244fc63f6b53"
},
"merged": false,
"protected": true,
@@ -1121,7 +1121,7 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"developers_can_merge": false,
"can_push": false,
"default": true,
"web_url": "https://gitlab.com/test-argocd-proton/argocd/-/tree/master"
"web_url": "https://gitlab.com/test-cd-proton/cd/-/tree/master"
}, {
"name": "pipeline-1310077506",
"commit": {
@@ -1138,7 +1138,7 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"committer_email": "[email protected]",
"committed_date": "2021-06-01T18:39:59.000+00:00",
"trailers": null,
"web_url": "https://gitlab.com/test-argocd-proton/argocd/-/commit/0f92540e5f396ba960adea4ed0aa905baf3f73d1"
"web_url": "https://gitlab.com/test-cd-proton/cd/-/commit/0f92540e5f396ba960adea4ed0aa905baf3f73d1"
},
"merged": false,
"protected": false,
@@ -1146,7 +1146,7 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"developers_can_merge": false,
"can_push": false,
"default": false,
"web_url": "https://gitlab.com/test-argocd-proton/argocd/-/tree/pipeline-1310077506"
"web_url": "https://gitlab.com/test-cd-proton/cd/-/tree/pipeline-1310077506"
}]`)
if err != nil {
t.Fail()
@@ -1168,7 +1168,7 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"committer_email": "[email protected]",
"committed_date": "2021-06-04T08:24:44.000+00:00",
"trailers": null,
"web_url": "https://gitlab.com/test-shared-argocd-proton/shared-argocd/-/commit/8898d7999fc99dd0fd578650b58b244fc63f6b53"
"web_url": "https://gitlab.com/test-shared-cd-proton/shared-cd/-/commit/8898d7999fc99dd0fd578650b58b244fc63f6b53"
},
"merged": false,
"protected": true,
@@ -1176,7 +1176,7 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"developers_can_merge": false,
"can_push": false,
"default": true,
"web_url": "https://gitlab.com/test-shared-argocd-proton/shared-argocd/-/tree/master"
"web_url": "https://gitlab.com/test-shared-cd-proton/shared-cd/-/tree/master"
}, {
"name": "pipeline-2310077506",
"commit": {
@@ -1193,7 +1193,7 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"committer_email": "[email protected]",
"committed_date": "2021-06-01T18:39:59.000+00:00",
"trailers": null,
"web_url": "https://gitlab.com/test-shared-argocd-proton/shared-argocd/-/commit/0f92540e5f396ba960adea4ed0aa905baf3f73d1"
"web_url": "https://gitlab.com/test-shared-cd-proton/shared-cd/-/commit/0f92540e5f396ba960adea4ed0aa905baf3f73d1"
},
"merged": false,
"protected": false,
@@ -1201,7 +1201,7 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"developers_can_merge": false,
"can_push": false,
"default": false,
"web_url": "https://gitlab.com/test-shared-argocd-proton/shared-argocd/-/tree/pipeline-1310077506"
"web_url": "https://gitlab.com/test-shared-cd-proton/shared-cd/-/tree/pipeline-1310077506"
}]`)
if err != nil {
t.Fail()
@@ -1223,7 +1223,7 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"committer_email": "[email protected]",
"committed_date": "2021-06-04T08:24:44.000+00:00",
"trailers": null,
"web_url": "https://gitlab.com/test-argocd-proton/subgroup/argocd-subgroup/-/commit/8898d7999fc99dd0fd578650b58b244fc63f6b53"
"web_url": "https://gitlab.com/test-cd-proton/subgroup/cd-subgroup/-/commit/8898d7999fc99dd0fd578650b58b244fc63f6b53"
},
"merged": false,
"protected": true,
@@ -1231,7 +1231,7 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"developers_can_merge": false,
"can_push": false,
"default": true,
"web_url": "https://gitlab.com/test-argocd-proton/subgroup/argocd-subgroup/-/tree/master"
"web_url": "https://gitlab.com/test-cd-proton/subgroup/cd-subgroup/-/tree/master"
}, {
"name": "pipeline-2310077506",
"commit": {
@@ -1248,7 +1248,7 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"committer_email": "[email protected]",
"committed_date": "2021-06-01T18:39:59.000+00:00",
"trailers": null,
"web_url": "https://gitlab.com/test-argocd-proton/subgroup/argocd-subgroup/-/commit/0f92540e5f396ba960adea4ed0aa905baf3f73d1"
"web_url": "https://gitlab.com/test-cd-proton/subgroup/cd-subgroup/-/commit/0f92540e5f396ba960adea4ed0aa905baf3f73d1"
},
"merged": false,
"protected": false,
@@ -1256,7 +1256,7 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"developers_can_merge": false,
"can_push": false,
"default": false,
"web_url": "https://gitlab.com/test-argocd-proton/subgroup/argocd-subgroup/-/tree/pipeline-1310077506"
"web_url": "https://gitlab.com/test-cd-proton/subgroup/cd-subgroup/-/tree/pipeline-1310077506"
}]`)
if err != nil {
t.Fail()
@@ -1278,7 +1278,7 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"committer_email": "[email protected]",
"committed_date": "2021-06-04T08:24:44.000+00:00",
"trailers": null,
"web_url": "https://gitlab.com/test-argocd-proton/subgroup/argocd-subgroup/-/commit/8898d7999fc99dd0fd578650b58b244fc63f6b53"
"web_url": "https://gitlab.com/test-cd-proton/subgroup/cd-subgroup/-/commit/8898d7999fc99dd0fd578650b58b244fc63f6b53"
},
"merged": false,
"protected": true,
@@ -1286,7 +1286,7 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"developers_can_merge": false,
"can_push": false,
"default": true,
"web_url": "https://gitlab.com/test-argocd-proton/subgroup/argocd-subgroup/-/tree/master"
"web_url": "https://gitlab.com/test-cd-proton/subgroup/cd-subgroup/-/tree/master"
}, {
"name": "pipeline-2310077506",
"commit": {
@@ -1303,7 +1303,7 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"committer_email": "[email protected]",
"committed_date": "2021-06-01T18:39:59.000+00:00",
"trailers": null,
"web_url": "https://gitlab.com/test-argocd-proton/subgroup/argocd-subgroup/-/commit/0f92540e5f396ba960adea4ed0aa905baf3f73d1"
"web_url": "https://gitlab.com/test-cd-proton/subgroup/cd-subgroup/-/commit/0f92540e5f396ba960adea4ed0aa905baf3f73d1"
},
"merged": false,
"protected": false,
@@ -1311,19 +1311,19 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"developers_can_merge": false,
"can_push": false,
"default": false,
"web_url": "https://gitlab.com/test-argocd-proton/subgroup/argocd-subgroup/-/tree/pipeline-1310077506"
"web_url": "https://gitlab.com/test-cd-proton/subgroup/cd-subgroup/-/tree/pipeline-1310077506"
}]`)
if err != nil {
t.Fail()
}
case "/api/v4/projects/test-argocd-proton%2Fargocd":
case "/api/v4/projects/test-cd-proton%2Fcd":
_, err := io.WriteString(w, `{
"id": 27084533,
"description": "",
"name": "argocd",
"name_with_namespace": "test argocd proton / argocd",
"path": "argocd",
"path_with_namespace": "test-argocd-proton/argocd",
"name": "cd",
"name_with_namespace": "test cd proton / cd",
"path": "cd",
"path_with_namespace": "test-cd-proton/cd",
"created_at": "2021-06-01T17:30:44.724Z",
"default_branch": "master",
"tag_list": [
@@ -1332,9 +1332,9 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"topics": [
"test-topic"
],
"ssh_url_to_repo": "[email protected]:test-argocd-proton/argocd.git",
"http_url_to_repo": "https://gitlab.com/test-argocd-proton/argocd.git",
"web_url": "https://gitlab.com/test-argocd-proton/argocd",
"ssh_url_to_repo": "[email protected]:test-cd-proton/cd.git",
"http_url_to_repo": "https://gitlab.com/test-cd-proton/cd.git",
"web_url": "https://gitlab.com/test-cd-proton/cd",
"readme_url": null,
"avatar_url": null,
"forks_count": 0,
@@ -1342,35 +1342,35 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
"last_activity_at": "2021-06-04T08:19:51.656Z",
"namespace": {
"id": 12258515,
"name": "test argocd proton",
"path": "test-argocd-proton",
"name": "test cd proton",
"path": "test-cd-proton",
"kind": "group",
"full_path": "test-argocd-proton",
"full_path": "test-cd-proton",
"parent_id": null,
"avatar_url": null,
"web_url": "https://gitlab.com/groups/test-argocd-proton"
"web_url": "https://gitlab.com/groups/test-cd-proton"
}
}`)
if err != nil {
t.Fail()
}
case "/api/v4/projects/27084533/repository/tree?path=argocd&ref=master":
_, err := io.WriteString(w, `[{"id":"ca14f2a3718159c74572a5325fb4bfb0662a2d3e","name":"ingress.yaml","type":"blob","path":"argocd/ingress.yaml","mode":"100644"},{"id":"de2a53a73b1550b3e0f4d37ea0a6d878bf9c5096","name":"install.yaml","type":"blob","path":"argocd/install.yaml","mode":"100644"}]`)
case "/api/v4/projects/27084533/repository/tree?path=cd&ref=master":
_, err := io.WriteString(w, `[{"id":"ca14f2a3718159c74572a5325fb4bfb0662a2d3e","name":"ingress.yaml","type":"blob","path":"cd/ingress.yaml","mode":"100644"},{"id":"de2a53a73b1550b3e0f4d37ea0a6d878bf9c5096","name":"install.yaml","type":"blob","path":"cd/install.yaml","mode":"100644"}]`)
if err != nil {
t.Fail()
}
case "/api/v4/projects/27084533/repository/tree?path=.&ref=master":
_, err := io.WriteString(w, `[{"id":"f2bf99fa8f7a27df9c43d2dffc8c8cd747f3181a","name":"argocd","type":"tree","path":"argocd","mode":"040000"},{"id":"68a3125232e01c1583a6a6299534ce10c5e7dd83","name":"manifests","type":"tree","path":"manifests","mode":"040000"}]`)
_, err := io.WriteString(w, `[{"id":"f2bf99fa8f7a27df9c43d2dffc8c8cd747f3181a","name":"cd","type":"tree","path":"cd","mode":"040000"},{"id":"68a3125232e01c1583a6a6299534ce10c5e7dd83","name":"manifests","type":"tree","path":"manifests","mode":"040000"}]`)
if err != nil {
t.Fail()
}
// Recent versions of the Gitlab API (v17.7+) listTree return 404 not only when a file doesn't exist, but also
// when a path is to a file instead of a directory. Code was refactored to explicitly search for file then
// search for directory, catching 404 errors as "file not found".
case "/api/v4/projects/27084533/repository/files/argocd?ref=master":
case "/api/v4/projects/27084533/repository/files/cd?ref=master":
w.WriteHeader(http.StatusNotFound)
case "/api/v4/projects/27084533/repository/files/argocd%2Finstall%2Eyaml?ref=master":
_, err := io.WriteString(w, `{"file_name":"install.yaml","file_path":"argocd/install.yaml","size":0,"encoding":"base64","content_sha256":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","ref":"main","blob_id":"e69de29bb2d1d6434b8b29ae775ad8c2e48c5391","commit_id":"6d4c0f9d34534ccc73aa3f3180b25e2aebe630eb","last_commit_id":"b50eb63f9c0e09bfdb070db26fd32c7210291f52","execute_filemode":false,"content":""}`)
case "/api/v4/projects/27084533/repository/files/cd%2Finstall%2Eyaml?ref=master":
_, err := io.WriteString(w, `{"file_name":"install.yaml","file_path":"cd/install.yaml","size":0,"encoding":"base64","content_sha256":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","ref":"main","blob_id":"e69de29bb2d1d6434b8b29ae775ad8c2e48c5391","commit_id":"6d4c0f9d34534ccc73aa3f3180b25e2aebe630eb","last_commit_id":"b50eb63f9c0e09bfdb070db26fd32c7210291f52","execute_filemode":false,"content":""}`)
if err != nil {
t.Fail()
}
@@ -1378,9 +1378,9 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
w.WriteHeader(http.StatusNotFound)
case "/api/v4/projects/27084533/repository/tree?path=notathing&ref=master":
w.WriteHeader(http.StatusNotFound)
case "/api/v4/projects/27084533/repository/files/argocd%2Fnotathing%2Eyaml?ref=master":
case "/api/v4/projects/27084533/repository/files/cd%2Fnotathing%2Eyaml?ref=master":
w.WriteHeader(http.StatusNotFound)
case "/api/v4/projects/27084533/repository/tree?path=argocd%2Fnotathing.yaml&ref=master":
case "/api/v4/projects/27084533/repository/tree?path=cd%2Fnotathing.yaml&ref=master":
w.WriteHeader(http.StatusNotFound)
case "/api/v4/projects/27084533/repository/files/notathing%2Fnotathing%2Eyaml?ref=master":
w.WriteHeader(http.StatusNotFound)
@@ -1420,9 +1420,9 @@ func TestGitlabListRepos(t *testing.T) {
expectedRepos: []*Repository{
{
Organization: "",
Repository: "argocd",
Repository: "cd",
Branch: "master",
URL: "[email protected]:test-argocd-proton/argocd.git",
URL: "[email protected]:test-cd-proton/cd.git",
SHA: "8898d7999fc99dd0fd578650b58b244fc63f6b53",
RepositoryId: int64(27084533),
Labels: []string{"test-topic"},
@@ -1440,9 +1440,9 @@ func TestGitlabListRepos(t *testing.T) {
expectedRepos: []*Repository{
{
Organization: "",
Repository: "argocd",
Repository: "cd",
Branch: "master",
URL: "[email protected]:test-argocd-proton/argocd.git",
URL: "[email protected]:test-cd-proton/cd.git",
SHA: "8898d7999fc99dd0fd578650b58b244fc63f6b53",
RepositoryId: int64(27084533),
Labels: []string{"test-topic"},
@@ -1460,9 +1460,9 @@ func TestGitlabListRepos(t *testing.T) {
expectedRepos: []*Repository{
{
Organization: "",
Repository: "argocd",
Repository: "cd",
Branch: "master",
URL: "https://gitlab.com/test-argocd-proton/argocd.git",
URL: "https://gitlab.com/test-cd-proton/cd.git",
SHA: "8898d7999fc99dd0fd578650b58b244fc63f6b53",
RepositoryId: int64(27084533),
Labels: []string{"test-topic"},
@@ -1484,9 +1484,9 @@ func TestGitlabListRepos(t *testing.T) {
expectedRepos: []*Repository{
{
Organization: "",
Repository: "argocd",
Repository: "cd",
Branch: "master",
URL: "[email protected]:test-argocd-proton/argocd.git",
URL: "[email protected]:test-cd-proton/cd.git",
SHA: "8898d7999fc99dd0fd578650b58b244fc63f6b53",
RepositoryId: int64(27084533),
Labels: []string{"test-topic"},
@@ -1508,9 +1508,9 @@ func TestGitlabListRepos(t *testing.T) {
expectedRepos: []*Repository{
{
Organization: "",
Repository: "argocd",
Repository: "cd",
Branch: "master",
URL: "[email protected]:test-argocd-proton/argocd.git",
URL: "[email protected]:test-cd-proton/cd.git",
SHA: "8898d7999fc99dd0fd578650b58b244fc63f6b53",
RepositoryId: int64(27084533),
Labels: []string{"test-topic"},
@@ -1529,18 +1529,18 @@ func TestGitlabListRepos(t *testing.T) {
expectedRepos: []*Repository{
{
Organization: "",
Repository: "argocd",
Repository: "cd",
Branch: "master",
URL: "[email protected]:test-argocd-proton/argocd.git",
URL: "[email protected]:test-cd-proton/cd.git",
SHA: "8898d7999fc99dd0fd578650b58b244fc63f6b53",
RepositoryId: int64(27084533),
Labels: []string{"test-topic", "specific-topic"},
},
{
Organization: "",
Repository: "argocd-subgroup",
Repository: "cd-subgroup",
Branch: "master",
URL: "[email protected]:test-argocd-proton/subgroup/argocd-subgroup.git",
URL: "[email protected]:test-cd-proton/subgroup/cd-subgroup.git",
SHA: "8898d7999fc99dd0fd578650b58b244fc63f6b58",
RepositoryId: int64(27084538),
Labels: []string{"test-topic"},
@@ -1559,18 +1559,18 @@ func TestGitlabListRepos(t *testing.T) {
expectedRepos: []*Repository{
{
Organization: "",
Repository: "argocd",
Repository: "cd",
Branch: "master",
URL: "[email protected]:test-argocd-proton/argocd.git",
URL: "[email protected]:test-cd-proton/cd.git",
SHA: "8898d7999fc99dd0fd578650b58b244fc63f6b53",
RepositoryId: int64(27084533),
Labels: []string{"test-topic"},
},
{
Organization: "",
Repository: "shared-argocd",
Repository: "shared-cd",
Branch: "master",
URL: "[email protected]:test-shared-argocd-proton/shared-argocd.git",
URL: "[email protected]:test-shared-cd-proton/shared-cd.git",
SHA: "8898d7999fc99dd0fd578650b58b244fc63f6b53",
RepositoryId: int64(27084534),
Labels: []string{"test-topic"},
@@ -1589,9 +1589,9 @@ func TestGitlabListRepos(t *testing.T) {
expectedRepos: []*Repository{
{
Organization: "",
Repository: "argocd",
Repository: "cd",
Branch: "master",
URL: "[email protected]:test-argocd-proton/argocd.git",
URL: "[email protected]:test-cd-proton/cd.git",
SHA: "8898d7999fc99dd0fd578650b58b244fc63f6b53",
RepositoryId: int64(27084533),
Labels: []string{"test-topic", "specific-topic"},
@@ -1609,9 +1609,9 @@ func TestGitlabListRepos(t *testing.T) {
expectedRepos: []*Repository{
{
Organization: "",
Repository: "argocd",
Repository: "cd",
Branch: "master",
URL: "[email protected]:test-argocd-proton/argocd.git",
URL: "[email protected]:test-cd-proton/cd.git",
SHA: "8898d7999fc99dd0fd578650b58b244fc63f6b53",
RepositoryId: int64(27084533),
Labels: []string{},
@@ -1620,7 +1620,7 @@ func TestGitlabListRepos(t *testing.T) {
Organization: "",
Repository: "another-repo",
Branch: "master",
URL: "[email protected]:test-argocd-proton/another-repo.git",
URL: "[email protected]:test-cd-proton/another-repo.git",
SHA: "8898d8889fc99dd0fd578650b58b244fc63f6b58",
RepositoryId: int64(56522142),
Labels: []string{"test-topic"},
@@ -1634,7 +1634,7 @@ func TestGitlabListRepos(t *testing.T) {
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
t.Parallel()
provider, _ := NewGitlabProvider("test-argocd-proton", "", ts.URL, c.allBranches, c.includeSubgroups, c.includeSharedProjects, c.includeArchivedRepos, c.insecure, "", c.topic, nil, "", "")
provider, _ := NewGitlabProvider("test-cd-proton", "", ts.URL, c.allBranches, c.includeSubgroups, c.includeSharedProjects, c.includeArchivedRepos, c.insecure, "", c.topic, nil, "", "")
rawRepos, err := ListRepos(t.Context(), provider, c.filters, c.proto)
if c.hasError {
require.Error(t, err)
@@ -1672,10 +1672,10 @@ func TestGitlabHasPath(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
gitlabMockHandler(t)(w, r)
}))
host, _ := NewGitlabProvider("test-argocd-proton", "", ts.URL, false, true, true, false, false, "", "", nil, "", "")
host, _ := NewGitlabProvider("test-cd-proton", "", ts.URL, false, true, true, false, false, "", "", nil, "", "")
repo := &Repository{
Organization: "test-argocd-proton",
Repository: "argocd",
Organization: "test-cd-proton",
Repository: "cd",
Branch: "master",
}
@@ -1685,12 +1685,12 @@ func TestGitlabHasPath(t *testing.T) {
}{
{
name: "directory exists",
path: "argocd",
path: "cd",
exists: true,
},
{
name: "file exists",
path: "argocd/install.yaml",
path: "cd/install.yaml",
exists: true,
},
{
@@ -1700,7 +1700,7 @@ func TestGitlabHasPath(t *testing.T) {
},
{
name: "file does not exist",
path: "argocd/notathing.yaml",
path: "cd/notathing.yaml",
exists: false,
},
{
@@ -1730,7 +1730,7 @@ func TestGitlabGetBranches(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
gitlabMockHandler(t)(w, r)
}))
host, _ := NewGitlabProvider("test-argocd-proton", "", ts.URL, false, true, true, false, false, "", "", nil, "", "")
host, _ := NewGitlabProvider("test-cd-proton", "", ts.URL, false, true, true, false, false, "", "", nil, "", "")
repo := &Repository{
RepositoryId: int64(27084533),
@@ -1810,7 +1810,7 @@ func TestGetBranchesTLS(t *testing.T) {
}
}
host, err := NewGitlabProvider("test-argocd-proton", "", ts.URL, false, true, true, false, test.tlsInsecure, "", "", certs, "", "")
host, err := NewGitlabProvider("test-cd-proton", "", ts.URL, false, true, true, false, test.tlsInsecure, "", "", certs, "", "")
require.NoError(t, err)
repo := &Repository{
RepositoryId: int64(27084533),
+10 -10
View File
@@ -95,7 +95,7 @@ func TestCreateSyncsCache(t *testing.T) {
c, store := newClient(t)
app := &application.Application{
ObjectMeta: metav1.ObjectMeta{Name: "test", Namespace: "argocd"},
ObjectMeta: metav1.ObjectMeta{Name: "test", Namespace: "cd"},
}
require.NoError(t, c.Create(t.Context(), app))
@@ -107,7 +107,7 @@ func TestUpdateSyncsCache(t *testing.T) {
app := &application.Application{
ObjectMeta: metav1.ObjectMeta{
Name: "test",
Namespace: "argocd",
Namespace: "cd",
Labels: map[string]string{"foo": "bar"},
},
}
@@ -127,7 +127,7 @@ func TestDeleteSyncsCache(t *testing.T) {
app := &application.Application{
ObjectMeta: metav1.ObjectMeta{
Name: "test",
Namespace: "argocd",
Namespace: "cd",
Labels: map[string]string{"foo": "bar"},
},
}
@@ -148,7 +148,7 @@ func TestDeleteEvictsStaleCacheOnNotFound(t *testing.T) {
// Seed the store with a ghost app, but leave the fake API client empty so Delete 404s.
app := &application.Application{
ObjectMeta: metav1.ObjectMeta{Name: "test", Namespace: "argocd"},
ObjectMeta: metav1.ObjectMeta{Name: "test", Namespace: "cd"},
}
c, store := newClient(t)
require.NoError(t, store.Add(app))
@@ -166,7 +166,7 @@ func TestNewClientDoesNotCrashWithMultiNamespaceCache(_ *testing.T) {
func TestPatchNotFoundEvictsFromCache(t *testing.T) {
t.Parallel()
app := &application.Application{
ObjectMeta: metav1.ObjectMeta{Name: "test", Namespace: "argocd"},
ObjectMeta: metav1.ObjectMeta{Name: "test", Namespace: "cd"},
}
c, store := newClient(t, withObjects(app))
@@ -182,7 +182,7 @@ func TestPatchNotFoundEvictsFromCache(t *testing.T) {
func TestUpdateNotFoundEvictsFromCache(t *testing.T) {
t.Parallel()
app := &application.Application{
ObjectMeta: metav1.ObjectMeta{Name: "test", Namespace: "argocd"},
ObjectMeta: metav1.ObjectMeta{Name: "test", Namespace: "cd"},
}
c, store := newClient(t, withObjects(app))
@@ -199,7 +199,7 @@ func TestExecAndSyncCacheNotFoundSkipsNonApplication(t *testing.T) {
t.Parallel()
c, store := newClient(t)
notFound := apierrors.NewNotFound(schema.GroupResource{}, "x")
got := c.execAndSyncCache(t.Context(), func() error { return notFound }, &corev1.ConfigMap{ObjectMeta: metav1.ObjectMeta{Name: "x", Namespace: "argocd"}}, false)
got := c.execAndSyncCache(t.Context(), func() error { return notFound }, &corev1.ConfigMap{ObjectMeta: metav1.ObjectMeta{Name: "x", Namespace: "cd"}}, false)
require.Error(t, got)
require.True(t, apierrors.IsNotFound(got))
require.Empty(t, store.List())
@@ -210,7 +210,7 @@ func TestExecAndSyncCacheNotFoundHandlesGetStoreError(t *testing.T) {
c, _ := newClient(t, withGetNSCache(func(_ context.Context, _ client.Object) (ctrlcache.Cache, error) {
return nil, errors.New("no cache")
}))
app := &application.Application{ObjectMeta: metav1.ObjectMeta{Name: "test", Namespace: "argocd"}}
app := &application.Application{ObjectMeta: metav1.ObjectMeta{Name: "test", Namespace: "cd"}}
notFound := apierrors.NewNotFound(schema.GroupResource{}, "test")
require.NotPanics(t, func() {
_ = c.execAndSyncCache(t.Context(), func() error { return notFound }, app, false)
@@ -227,8 +227,8 @@ func (e *errDeleteStore) Delete(_ any) error {
func TestExecAndSyncCacheNotFoundHandlesDeleteError(t *testing.T) {
t.Parallel()
c, _ := newClient(t, withStoresByNs(map[string]k8scache.Store{"argocd": &errDeleteStore{}}))
app := &application.Application{ObjectMeta: metav1.ObjectMeta{Name: "test", Namespace: "argocd"}}
c, _ := newClient(t, withStoresByNs(map[string]k8scache.Store{"cd": &errDeleteStore{}}))
app := &application.Application{ObjectMeta: metav1.ObjectMeta{Name: "test", Namespace: "cd"}}
notFound := apierrors.NewNotFound(schema.GroupResource{}, "test")
require.NotPanics(t, func() {
_ = c.execAndSyncCache(t.Context(), func() error { return notFound }, app, false)
+4 -4
View File
@@ -19,9 +19,9 @@ import (
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
argov1alpha1 "github.com/hanzoai/deploy/pkg/apis/application/v1alpha1"
"github.com/hanzoai/deploy/util/argo"
argodiff "github.com/hanzoai/deploy/util/argo/diff"
"github.com/hanzoai/deploy/util/argo/normalizers"
"github.com/hanzoai/deploy/util/cd"
argodiff "github.com/hanzoai/deploy/util/cd/diff"
"github.com/hanzoai/deploy/util/cd/normalizers"
)
var appEquality = conversion.EqualitiesOrDie(
@@ -103,7 +103,7 @@ func CreateOrUpdate(ctx context.Context, logCtx *log.Entry, c client.Client, dif
// Normalize the live spec to avoid spurious diffs from unimportant differences (e.g. nil vs
// empty SyncPolicy). obj.Spec is already normalized by the caller; only the live side needs it.
normalizedLive.Spec = *argo.NormalizeApplicationSpec(&normalizedLive.Spec)
normalizedLive.Spec = *cd.NormalizeApplicationSpec(&normalizedLive.Spec)
// Apply ignoreApplicationDifferences rules to remove ignored fields from both the live and the desired state. This
// prevents those differences from appearing in the diff and therefore in the patch.
+1 -1
View File
@@ -9,7 +9,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/hanzoai/deploy/pkg/apis/application/v1alpha1"
"github.com/hanzoai/deploy/util/argo/normalizers"
"github.com/hanzoai/deploy/util/cd/normalizers"
)
func Test_applyIgnoreDifferences(t *testing.T) {
+7 -7
View File
@@ -72,21 +72,21 @@ type prGeneratorGitlabInfo struct {
APIHostname string
}
func NewWebhookHandler(webhookParallelism int, argocdSettingsMgr *argosettings.SettingsManager, client client.Client, generators map[string]generators.Generator) (*WebhookHandler, error) {
// register the webhook secrets stored under "argocd-secret" for verifying incoming payloads
argocdSettings, err := argocdSettingsMgr.GetSettings()
func NewWebhookHandler(webhookParallelism int, cdSettingsMgr *argosettings.SettingsManager, client client.Client, generators map[string]generators.Generator) (*WebhookHandler, error) {
// register the webhook secrets stored under "cd-secret" for verifying incoming payloads
cdSettings, err := cdSettingsMgr.GetSettings()
if err != nil {
return nil, fmt.Errorf("failed to get argocd settings: %w", err)
return nil, fmt.Errorf("failed to get cd settings: %w", err)
}
githubHandler, err := github.New(github.Options.Secret(argocdSettings.GetWebhookGitHubSecret()))
githubHandler, err := github.New(github.Options.Secret(cdSettings.GetWebhookGitHubSecret()))
if err != nil {
return nil, fmt.Errorf("unable to init GitHub webhook: %w", err)
}
gitlabHandler, err := gitlab.New(gitlab.Options.Secret(argocdSettings.GetWebhookGitLabSecret()))
gitlabHandler, err := gitlab.New(gitlab.Options.Secret(cdSettings.GetWebhookGitLabSecret()))
if err != nil {
return nil, fmt.Errorf("unable to init GitLab webhook: %w", err)
}
azuredevopsHandler, err := azuredevops.New(azuredevops.Options.BasicAuth(argocdSettings.GetWebhookAzureDevOpsUsername(), argocdSettings.GetWebhookAzureDevOpsPassword()))
azuredevopsHandler, err := azuredevops.New(azuredevops.Options.BasicAuth(cdSettings.GetWebhookAzureDevOpsUsername(), cdSettings.GetWebhookAzureDevOpsPassword()))
if err != nil {
return nil, fmt.Errorf("unable to init Azure DevOps webhook: %w", err)
}
+3 -3
View File
@@ -791,14 +791,14 @@ func fakeAppWithMatrixAndPullRequestGeneratorWithPluginGenerator(name, namespace
func newFakeClient(ns string) *kubefake.Clientset {
s := runtime.NewScheme()
s.AddKnownTypes(v1alpha1.SchemeGroupVersion, &v1alpha1.ApplicationSet{})
return kubefake.NewClientset(&corev1.ConfigMap{ObjectMeta: metav1.ObjectMeta{Name: "argocd-cm", Namespace: ns, Labels: map[string]string{
"app.kubernetes.io/part-of": "argocd",
return kubefake.NewClientset(&corev1.ConfigMap{ObjectMeta: metav1.ObjectMeta{Name: "cd-cm", Namespace: ns, Labels: map[string]string{
"app.kubernetes.io/part-of": "cd",
}}}, &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: common.ArgoCDSecretName,
Namespace: ns,
Labels: map[string]string{
"app.kubernetes.io/part-of": "argocd",
"app.kubernetes.io/part-of": "cd",
},
},
Data: map[string][]byte{
-282
View File
@@ -1,282 +0,0 @@
package commands
import (
"fmt"
"io"
"os"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
const (
bashCompletionFunc = `
__argocd_list_apps() {
local -a argocd_out
if argocd_out=($(argocd app list --output name 2>/dev/null)); then
COMPREPLY+=( $( compgen -W "${argocd_out[*]}" -- "$cur" ) )
fi
}
__argocd_list_app_history() {
local app=$1
local -a argocd_out
if argocd_out=($(argocd app history $app --output id 2>/dev/null)); then
COMPREPLY+=( $( compgen -W "${argocd_out[*]}" -- "$cur" ) )
fi
}
__argocd_app_rollback() {
local -a command
for comp_word in "${COMP_WORDS[@]}"; do
if [[ $comp_word =~ ^-.*$ ]]; then
continue
fi
command+=($comp_word)
done
# fourth arg is app (if present): e.g.- argocd app rollback guestbook
local app=${command[3]}
local id=${command[4]}
if [[ -z $app || $app == $cur ]]; then
__argocd_list_apps
elif [[ -z $id || $id == $cur ]]; then
__argocd_list_app_history $app
fi
}
__argocd_list_servers() {
local -a argocd_out
if argocd_out=($(argocd cluster list --output server 2>/dev/null)); then
COMPREPLY+=( $( compgen -W "${argocd_out[*]}" -- "$cur" ) )
fi
}
__argocd_list_repos() {
local -a argocd_out
if argocd_out=($(argocd repo list --output url 2>/dev/null)); then
COMPREPLY+=( $( compgen -W "${argocd_out[*]}" -- "$cur" ) )
fi
}
__argocd_list_projects() {
local -a argocd_out
if argocd_out=($(argocd proj list --output name 2>/dev/null)); then
COMPREPLY+=( $( compgen -W "${argocd_out[*]}" -- "$cur" ) )
fi
}
__argocd_list_namespaces() {
local -a argocd_out
if argocd_out=($(kubectl get namespaces --no-headers 2>/dev/null | cut -f1 -d' ' 2>/dev/null)); then
COMPREPLY+=( $( compgen -W "${argocd_out[*]}" -- "$cur" ) )
fi
}
__argocd_proj_server_namespace() {
local -a command
for comp_word in "${COMP_WORDS[@]}"; do
if [[ $comp_word =~ ^-.*$ ]]; then
continue
fi
command+=($comp_word)
done
# expect something like this: argocd proj add-destination PROJECT SERVER NAMESPACE
local project=${command[3]}
local server=${command[4]}
local namespace=${command[5]}
if [[ -z $project || $project == $cur ]]; then
__argocd_list_projects
elif [[ -z $server || $server == $cur ]]; then
__argocd_list_servers
elif [[ -z $namespace || $namespace == $cur ]]; then
__argocd_list_namespaces
fi
}
__argocd_list_project_role() {
local project="$1"
local -a argocd_out
if argocd_out=($(argocd proj role list "$project" --output=name 2>/dev/null)); then
COMPREPLY+=( $( compgen -W "${argocd_out[*]}" -- "$cur" ) )
fi
}
__argocd_proj_role(){
local -a command
for comp_word in "${COMP_WORDS[@]}"; do
if [[ $comp_word =~ ^-.*$ ]]; then
continue
fi
command+=($comp_word)
done
# expect something like this: argocd proj role add-policy PROJECT ROLE-NAME
local project=${command[4]}
local role=${command[5]}
if [[ -z $project || $project == $cur ]]; then
__argocd_list_projects
elif [[ -z $role || $role == $cur ]]; then
__argocd_list_project_role $project
fi
}
__argocd_custom_func() {
case ${last_command} in
argocd_app_delete | \
argocd_app_diff | \
argocd_app_edit | \
argocd_app_get | \
argocd_app_history | \
argocd_app_manifests | \
argocd_app_patch-resource | \
argocd_app_set | \
argocd_app_sync | \
argocd_app_terminate-op | \
argocd_app_unset | \
argocd_app_wait | \
argocd_app_create)
__argocd_list_apps
return
;;
argocd_app_rollback)
__argocd_app_rollback
return
;;
argocd_cluster_get | \
argocd_cluster_rm | \
argocd_cluster_set | \
argocd_login | \
argocd_cluster_add)
__argocd_list_servers
return
;;
argocd_repo_rm | \
argocd_repo_add)
__argocd_list_repos
return
;;
argocd_proj_add-destination | \
argocd_proj_remove-destination)
__argocd_proj_server_namespace
return
;;
argocd_proj_add-source | \
argocd_proj_remove-source | \
argocd_proj_allow-cluster-resource | \
argocd_proj_allow-namespace-resource | \
argocd_proj_deny-cluster-resource | \
argocd_proj_deny-namespace-resource | \
argocd_proj_delete | \
argocd_proj_edit | \
argocd_proj_get | \
argocd_proj_set | \
argocd_proj_role_list)
__argocd_list_projects
return
;;
argocd_proj_role_remove-policy | \
argocd_proj_role_add-policy | \
argocd_proj_role_create | \
argocd_proj_role_delete | \
argocd_proj_role_get | \
argocd_proj_role_create-token | \
argocd_proj_role_delete-token)
__argocd_proj_role
return
;;
*)
;;
esac
}
`
)
func NewCompletionCommand() *cobra.Command {
command := &cobra.Command{
Use: "completion SHELL",
Short: "Output shell completion code for the specified shell (bash, zsh or fish)",
Long: `Write bash, zsh or fish shell completion code to standard output.
For bash, ensure you have bash completions installed and enabled.
To access completions in your current shell, run
$ source <(argocd completion bash)
Alternatively, write it to a file and source in .bash_profile
For zsh, add the following to your ~/.zshrc file:
source <(argocd completion zsh)
compdef _argocd argocd
Optionally, also add the following, in case you are getting errors involving compdef & compinit such as command not found: compdef:
autoload -Uz compinit
compinit
`,
Example: `# For bash
$ source <(argocd completion bash)
# For zsh
$ argocd completion zsh > _argocd
$ source _argocd
# For fish
$ argocd completion fish > ~/.config/fish/completions/argocd.fish
$ source ~/.config/fish/completions/argocd.fish
# For powershell
$ mkdir -Force "$HOME\Documents\PowerShell" | Out-Null
$ argocd completion powershell > $HOME\Documents\PowerShell\argocd_completion.ps1
Add the following lines to your powershell profile
$ # Hanzo CD tab completion
if (Test-Path "$HOME\Documents\PowerShell\argocd_completion.ps1") {
. "$HOME\Documents\PowerShell\argocd_completion.ps1"
}
Then reload your profile
$ . $PROFILE
`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 1 {
cmd.HelpFunc()(cmd, args)
os.Exit(1)
}
shell := args[0]
rootCommand := NewCommand()
rootCommand.BashCompletionFunction = bashCompletionFunc
availableCompletions := map[string]func(out io.Writer, cmd *cobra.Command) error{
"bash": runCompletionBash,
"zsh": runCompletionZsh,
"fish": runCompletionFish,
"powershell": runCompletionPowershell,
}
completion, ok := availableCompletions[shell]
if !ok {
fmt.Printf("Invalid shell '%s'. The supported shells are bash, zsh and fish.\n", shell)
os.Exit(1)
}
if err := completion(os.Stdout, rootCommand); err != nil {
log.Fatal(err)
}
},
}
return command
}
func runCompletionBash(out io.Writer, cmd *cobra.Command) error {
return cmd.GenBashCompletion(out)
}
func runCompletionZsh(out io.Writer, cmd *cobra.Command) error {
return cmd.GenZshCompletion(out)
}
func runCompletionFish(out io.Writer, cmd *cobra.Command) error {
return cmd.GenFishCompletion(out, true)
}
func runCompletionPowershell(out io.Writer, cmd *cobra.Command) error {
return cmd.GenPowerShellCompletionWithDesc(out)
}
@@ -27,8 +27,8 @@ import (
appclientset "github.com/hanzoai/deploy/pkg/client/clientset/versioned"
"github.com/hanzoai/deploy/pkg/ratelimiter"
"github.com/hanzoai/deploy/reposerver/apiclient"
"github.com/hanzoai/deploy/util/argo"
"github.com/hanzoai/deploy/util/argo/normalizers"
"github.com/hanzoai/deploy/util/cd"
"github.com/hanzoai/deploy/util/cd/normalizers"
cacheutil "github.com/hanzoai/deploy/util/cache"
appstatecache "github.com/hanzoai/deploy/util/cache/appstate"
"github.com/hanzoai/deploy/util/cli"
@@ -94,7 +94,7 @@ func NewCommand() *cobra.Command {
serverSideDiff bool
ignoreNormalizerOpts normalizers.IgnoreNormalizerOpts
// argocd k8s event logging flag
// cd k8s event logging flag
enableK8sEvent []string
// feature flag that enables the manifest hydrator controller
hydratorEnabled bool
@@ -230,7 +230,7 @@ func NewCommand() *cobra.Command {
stats.RegisterHeapDumper("memprofile")
if otlpAddress != "" {
closeTracer, err := trace.InitTracer(ctx, "argocd-controller", otlpAddress, otlpInsecure, otlpHeaders, otlpAttrs, otlpSampleRatio)
closeTracer, err := trace.InitTracer(ctx, "cd-controller", otlpAddress, otlpInsecure, otlpHeaders, otlpAttrs, otlpSampleRatio)
if err != nil {
log.Fatalf("failed to initialize tracing: %v", err)
}
@@ -283,9 +283,9 @@ func NewCommand() *cobra.Command {
command.Flags().BoolVar(&repoServerPlaintext, "repo-server-plaintext", env.ParseBoolFromEnv("CD_APPLICATION_CONTROLLER_REPO_SERVER_PLAINTEXT", false), "Disable TLS on connections to repo server")
command.Flags().BoolVar(&repoServerStrictTLS, "repo-server-strict-tls", env.ParseBoolFromEnv("CD_APPLICATION_CONTROLLER_REPO_SERVER_STRICT_TLS", false), "Whether to use strict validation of the TLS cert presented by the repo server")
errors.CheckError(command.Flags().MarkDeprecated("repo-server-strict-tls", "use --repo-server-ca-cert-path instead"))
command.Flags().StringSliceVar(&metricsApplicationLabels, "metrics-application-labels", env.StringsFromEnv("CD_APPLICATION_CONTROLLER_METRICS_APPLICATION_LABELS", []string{}, ","), "List of Application labels that will be added to the argocd_app_labels metric")
command.Flags().StringSliceVar(&metricsApplicationConditions, "metrics-application-conditions", env.StringsFromEnv("CD_APPLICATION_CONTROLLER_METRICS_APPLICATION_CONDITIONS", []string{}, ","), "List of Application conditions that will be added to the argocd_app_condition metric")
command.Flags().StringSliceVar(&metricsClusterLabels, "metrics-cluster-labels", env.StringsFromEnv("CD_APPLICATION_CONTROLLER_METRICS_CLUSTER_LABELS", []string{}, ","), "List of Cluster labels that will be added to the argocd_cluster_labels metric")
command.Flags().StringSliceVar(&metricsApplicationLabels, "metrics-application-labels", env.StringsFromEnv("CD_APPLICATION_CONTROLLER_METRICS_APPLICATION_LABELS", []string{}, ","), "List of Application labels that will be added to the cd_app_labels metric")
command.Flags().StringSliceVar(&metricsApplicationConditions, "metrics-application-conditions", env.StringsFromEnv("CD_APPLICATION_CONTROLLER_METRICS_APPLICATION_CONDITIONS", []string{}, ","), "List of Application conditions that will be added to the cd_app_condition metric")
command.Flags().StringSliceVar(&metricsClusterLabels, "metrics-cluster-labels", env.StringsFromEnv("CD_APPLICATION_CONTROLLER_METRICS_CLUSTER_LABELS", []string{}, ","), "List of Cluster labels that will be added to the cd_cluster_labels metric")
command.Flags().StringVar(&otlpAddress, "otlp-address", env.StringFromEnv("CD_APPLICATION_CONTROLLER_OTLP_ADDRESS", ""), "OpenTelemetry collector address to send traces to")
command.Flags().BoolVar(&otlpInsecure, "otlp-insecure", env.ParseBoolFromEnv("CD_APPLICATION_CONTROLLER_OTLP_INSECURE", true), "OpenTelemetry collector insecure mode")
command.Flags().StringToStringVar(&otlpHeaders, "otlp-headers", env.ParseStringToStringFromEnv("CD_APPLICATION_CONTROLLER_OTLP_HEADERS", map[string]string{}, ","), "List of OpenTelemetry collector extra headers sent with traces, headers are comma-separated key-value pairs(e.g. key1=value1,key2=value2)")
@@ -306,8 +306,8 @@ func NewCommand() *cobra.Command {
command.Flags().BoolVar(&enableDynamicClusterDistribution, "dynamic-cluster-distribution-enabled", env.ParseBoolFromEnv(common.EnvEnableDynamicClusterDistribution, false), "Enables dynamic cluster distribution.")
command.Flags().BoolVar(&serverSideDiff, "server-side-diff-enabled", env.ParseBoolFromEnv(common.EnvServerSideDiff, false), "Feature flag to enable ServerSide diff. Default (\"false\")")
command.Flags().DurationVar(&ignoreNormalizerOpts.JQExecutionTimeout, "ignore-normalizer-jq-execution-timeout-seconds", env.ParseDurationFromEnv("CD_IGNORE_NORMALIZER_JQ_TIMEOUT", 0*time.Second, 0, math.MaxInt64), "Set ignore normalizer JQ execution timeout")
// argocd k8s event logging flag
command.Flags().StringSliceVar(&enableK8sEvent, "enable-k8s-event", env.StringsFromEnv("CD_ENABLE_K8S_EVENT", argo.DefaultEnableEventList(), ","), "Enable Hanzo CD to use k8s event. For disabling all events, set the value as `none`. (e.g --enable-k8s-event=none), For enabling specific events, set the value as `event reason`. (e.g --enable-k8s-event=StatusRefreshed,ResourceCreated)")
// cd k8s event logging flag
command.Flags().StringSliceVar(&enableK8sEvent, "enable-k8s-event", env.StringsFromEnv("CD_ENABLE_K8S_EVENT", cd.DefaultEnableEventList(), ","), "Enable Hanzo CD to use k8s event. For disabling all events, set the value as `none`. (e.g --enable-k8s-event=none), For enabling specific events, set the value as `event reason`. (e.g --enable-k8s-event=StatusRefreshed,ResourceCreated)")
command.Flags().BoolVar(&hydratorEnabled, "hydrator-enabled", env.ParseBoolFromEnv("CD_HYDRATOR_ENABLED", false), "Feature flag to enable Hydrator. Default (\"false\")")
repoServerClientTLSConfigSrc = tls.AddClientTLSFlagsToCmdWithPrefix(&command, "APPLICATION_CONTROLLER")
cacheSource = appstatecache.AddCacheFlagsToCmd(&command, cacheutil.Options{
@@ -21,7 +21,7 @@ func TestNewCommand_HydrationProcessorsFlag(t *testing.T) {
// TestNewCommand_MetricsFlagsFromEnv verifies the metrics label/condition flags
// default from their environment variables, so they can be configured through
// argocd-cmd-params-cm like the other controller parameters.
// cd-cmd-params-cm like the other controller parameters.
func TestNewCommand_MetricsFlagsFromEnv(t *testing.T) {
t.Setenv("CD_APPLICATION_CONTROLLER_METRICS_APPLICATION_LABELS", "team,env")
t.Setenv("CD_APPLICATION_CONTROLLER_METRICS_APPLICATION_CONDITIONS", "OrphanedResourceWarning")
@@ -47,11 +47,11 @@ func TestNewCommand_MetricsFlagHelpUsesActualMetricNames(t *testing.T) {
labelsFlag := cmd.Flags().Lookup("metrics-application-labels")
require.NotNil(t, labelsFlag)
assert.Contains(t, labelsFlag.Usage, "argocd_app_labels")
assert.NotContains(t, labelsFlag.Usage, "argocd_application_labels")
assert.Contains(t, labelsFlag.Usage, "cd_app_labels")
assert.NotContains(t, labelsFlag.Usage, "cd_application_labels")
conditionsFlag := cmd.Flags().Lookup("metrics-application-conditions")
require.NotNil(t, conditionsFlag)
assert.Contains(t, conditionsFlag.Usage, "argocd_app_condition")
assert.NotContains(t, conditionsFlag.Usage, "argocd_application_conditions")
assert.Contains(t, conditionsFlag.Usage, "cd_app_condition")
assert.NotContains(t, conditionsFlag.Usage, "cd_application_conditions")
}
@@ -59,7 +59,7 @@ func NewCommand() *cobra.Command {
webhookAddr string
enableLeaderElection bool
applicationSetNamespaces []string
argocdRepoServer string
cdRepoServer string
policy string
enablePolicyOverride bool
debugLog bool
@@ -128,7 +128,7 @@ func NewCommand() *cobra.Command {
restConfig, err := clientConfig.ClientConfig()
errors.CheckError(err)
restConfig.UserAgent = fmt.Sprintf("argocd-applicationset-controller/%s (%s)", vers.Version, vers.Platform)
restConfig.UserAgent = fmt.Sprintf("cd-applicationset-controller/%s (%s)", vers.Version, vers.Platform)
policyObj, exists := utils.Policies[policy]
if !exists {
@@ -230,7 +230,7 @@ func NewCommand() *cobra.Command {
tlsConfig.Certificates = pool
}
repoClientset := apiclient.NewRepoServerClientset(argocdRepoServer, repoServerTimeoutSeconds, tlsConfig)
repoClientset := apiclient.NewRepoServerClientset(cdRepoServer, repoServerTimeoutSeconds, tlsConfig)
argoCDService := services.NewArgoCDService(argoCDDB, gitSubmoduleEnabled, repoClientset, enableNewGitFileGlobbing)
topLevelGenerators := generators.GetGenerators(ctx, mgr.GetClient(), k8sClient, namespace, argoCDService, dynamicClient, scmConfig, clusterInformer)
@@ -298,7 +298,7 @@ func NewCommand() *cobra.Command {
"Enable leader election for controller manager. "+
"Enabling this will ensure there is only one active controller manager.")
command.Flags().StringSliceVar(&applicationSetNamespaces, "applicationset-namespaces", env.StringsFromEnv("CD_APPLICATIONSET_CONTROLLER_NAMESPACES", []string{}, ","), "Hanzo CD applicationset namespaces")
command.Flags().StringVar(&argocdRepoServer, "argocd-repo-server", env.StringFromEnv("CD_APPLICATIONSET_CONTROLLER_REPO_SERVER", common.DefaultRepoServerAddr), "Hanzo CD repo server address")
command.Flags().StringVar(&cdRepoServer, "cd-repo-server", env.StringFromEnv("CD_APPLICATIONSET_CONTROLLER_REPO_SERVER", common.DefaultRepoServerAddr), "Hanzo CD repo server address")
command.Flags().StringVar(&policy, "policy", env.StringFromEnv("CD_APPLICATIONSET_CONTROLLER_POLICY", ""), "Modify how application is synced between the generator and the cluster. Default is '' (empty), which means AppSets default to 'sync', but they may override that default. Setting an explicit value prevents AppSet-level overrides, unless --allow-policy-override is enabled. Explicit options are: 'sync' (create & update & delete), 'create-only', 'create-update' (no deletion), 'create-delete' (no update)")
command.Flags().BoolVar(&enablePolicyOverride, "enable-policy-override", env.ParseBoolFromEnv("CD_APPLICATIONSET_CONTROLLER_ENABLE_POLICY_OVERRIDE", policy == ""), "For security reason if 'policy' is set, it is not possible to override it at applicationSet level. 'allow-policy-override' allows user to define their own policy")
command.Flags().BoolVar(&debugLog, "debug", env.ParseBoolFromEnv("CD_APPLICATIONSET_CONTROLLER_DEBUG", false), "Print debug logs. Takes precedence over loglevel")
@@ -321,7 +321,7 @@ func NewCommand() *cobra.Command {
command.Flags().StringSliceVar(&globalPreservedAnnotations, "preserved-annotations", env.StringsFromEnv("CD_APPLICATIONSET_CONTROLLER_GLOBAL_PRESERVED_ANNOTATIONS", []string{}, ","), "Sets global preserved field values for annotations")
command.Flags().StringSliceVar(&globalPreservedLabels, "preserved-labels", env.StringsFromEnv("CD_APPLICATIONSET_CONTROLLER_GLOBAL_PRESERVED_LABELS", []string{}, ","), "Sets global preserved field values for labels")
command.Flags().IntVar(&webhookParallelism, "webhook-parallelism-limit", env.ParseNumFromEnv("CD_APPLICATIONSET_CONTROLLER_WEBHOOK_PARALLELISM_LIMIT", 50, 1, 1000), "Number of webhook requests processed concurrently")
command.Flags().StringSliceVar(&metricsAplicationsetLabels, "metrics-applicationset-labels", []string{}, "List of Application labels that will be added to the argocd_applicationset_labels metric")
command.Flags().StringSliceVar(&metricsAplicationsetLabels, "metrics-applicationset-labels", []string{}, "List of Application labels that will be added to the cd_applicationset_labels metric")
command.Flags().BoolVar(&enableGitHubAPIMetrics, "enable-github-api-metrics", env.ParseBoolFromEnv("CD_APPLICATIONSET_CONTROLLER_ENABLE_GITHUB_API_METRICS", false), "Enable GitHub API metrics for generators that use the GitHub API")
command.Flags().IntVar(&maxResourcesStatusCount, "max-resources-status-count", env.ParseNumFromEnv("CD_APPLICATIONSET_CONTROLLER_MAX_RESOURCES_STATUS_COUNT", 5000, 0, math.MaxInt), "Max number of resources stored in appset status.")
command.Flags().DurationVar(&cacheSyncPeriod, "cache-sync-period", env.ParseDurationFromEnv("CD_APPLICATIONSET_CONTROLLER_CACHE_SYNC_PERIOD", time.Hour*10, 0, time.Hour*24), "Period at which the manager client cache is forcefully resynced with the Kubernetes API server. 0 disables periodic resync.")
@@ -62,7 +62,7 @@ func NewCommand() *cobra.Command {
if otlpAddress != "" {
var closer func()
var err error
closer, err = traceutil.InitTracer(ctx, "argocd-cmp-server", otlpAddress, otlpInsecure, otlpHeaders, otlpAttrs, otlpSampleRatio)
closer, err = traceutil.InitTracer(ctx, "cd-cmp-server", otlpAddress, otlpInsecure, otlpHeaders, otlpAttrs, otlpSampleRatio)
if err != nil {
log.Fatalf("failed to initialize tracing: %v", err)
}
@@ -79,7 +79,7 @@ func NewCommand() *cobra.Command {
stats.StartStatsTicker(10 * time.Minute)
stats.RegisterHeapDumper("memprofile")
// run argocd-cmp-server server
// run cd-cmp-server server
server.Run()
return nil
},
@@ -87,7 +87,7 @@ func NewCommand() *cobra.Command {
command.Flags().StringVar(&cmdutil.LogFormat, "logformat", env.StringFromEnv("CD_CMP_SERVER_LOGFORMAT", "json"), "Set the logging format. One of: json|text")
command.Flags().StringVar(&cmdutil.LogLevel, "loglevel", env.StringFromEnv("CD_CMP_SERVER_LOGLEVEL", "info"), "Set the logging level. One of: trace|debug|info|warn|error")
command.Flags().StringVar(&configFilePath, "config-dir-path", common.DefaultPluginConfigFilePath, "Config management plugin configuration file location, Default is '/home/argocd/cmp-server/config/'")
command.Flags().StringVar(&configFilePath, "config-dir-path", common.DefaultPluginConfigFilePath, "Config management plugin configuration file location, Default is '/home/cd/cmp-server/config/'")
command.Flags().StringVar(&otlpAddress, "otlp-address", env.StringFromEnv("CD_CMP_SERVER_OTLP_ADDRESS", ""), "OpenTelemetry collector address to send traces to")
command.Flags().BoolVar(&otlpInsecure, "otlp-insecure", env.ParseBoolFromEnv("CD_CMP_SERVER_OTLP_INSECURE", true), "OpenTelemetry collector insecure mode")
command.Flags().StringToStringVar(&otlpHeaders, "otlp-headers", env.ParseStringToStringFromEnv("CD_CMP_SERVER_OTLP_HEADERS", map[string]string{}, ","), "List of OpenTelemetry collector extra headers sent with traces, headers are comma-separated key-value pairs(e.g. key1=value1,key2=value2)")
@@ -26,7 +26,7 @@ import (
utilio "github.com/hanzoai/deploy/util/io"
)
// NewCommand returns a new instance of an argocd-commit-server command
// NewCommand returns a new instance of an cd-commit-server command
func NewCommand() *cobra.Command {
var (
listenHost string
@@ -28,8 +28,8 @@ import (
func NewCommand() *cobra.Command {
command := &cobra.Command{
Use: common.CommandDex,
Short: "argocd-dex tools used by Hanzo CD",
Long: "argocd-dex has internal utility tools used by Hanzo CD",
Short: "cd-dex tools used by Hanzo CD",
Long: "cd-dex has internal utility tools used by Hanzo CD",
DisableAutoGenTag: true,
Run: func(c *cobra.Command, args []string) {
c.HelpFunc()(c, args)
@@ -76,7 +76,7 @@ func NewRunDexCommand() *cobra.Command {
errors.CheckError(err)
config, err := clientConfig.ClientConfig()
errors.CheckError(err)
config.UserAgent = fmt.Sprintf("argocd-dex/%s (%s)", vers.Version, vers.Platform)
config.UserAgent = fmt.Sprintf("cd-dex/%s (%s)", vers.Version, vers.Platform)
kubeClientset := kubernetes.NewForConfigOrDie(config)
if !disableTLS {
@@ -29,7 +29,7 @@ func TestGetSignedRequest(t *testing.T) {
t.Run("returns error for non-existent profile", func(t *testing.T) {
t.Parallel()
ctx := t.Context()
profile := "argocd-k8s-auth-test-nonexistent-profile-12345"
profile := "cd-k8s-auth-test-nonexistent-profile-12345"
url, err := getSignedRequest(ctx, "my-cluster", "", profile)
@@ -9,7 +9,7 @@ import (
func NewCommand() *cobra.Command {
command := &cobra.Command{
Use: common.CommandK8sAuth,
Short: "argocd-k8s-auth a set of commands to generate k8s auth token",
Short: "cd-k8s-auth a set of commands to generate k8s auth token",
DisableAutoGenTag: true,
Run: func(c *cobra.Command, args []string) {
c.HelpFunc()(c, args)
@@ -28,7 +28,7 @@ import (
"github.com/hanzoai/deploy/util/cli"
"github.com/hanzoai/deploy/util/env"
"github.com/hanzoai/deploy/util/errors"
service "github.com/hanzoai/deploy/util/notification/argocd"
service "github.com/hanzoai/deploy/util/notification/cd"
"github.com/hanzoai/deploy/util/tls"
)
@@ -44,9 +44,9 @@ func NewCommand() *cobra.Command {
logLevel string
logFormat string
metricsPort int
argocdRepoServer string
argocdRepoServerPlaintext bool
argocdRepoServerStrictTLS bool
cdRepoServer string
cdRepoServerPlaintext bool
cdRepoServerStrictTLS bool
configMapName string
secretName string
applicationNamespaces []string
@@ -74,7 +74,7 @@ func NewCommand() *cobra.Command {
if err != nil {
return fmt.Errorf("failed to create REST client config: %w", err)
}
restConfig.UserAgent = fmt.Sprintf("argocd-notifications-controller/%s (%s)", vers.Version, vers.Platform)
restConfig.UserAgent = fmt.Sprintf("cd-notifications-controller/%s (%s)", vers.Version, vers.Platform)
dynamicClient, err := dynamic.NewForConfig(restConfig)
if err != nil {
return fmt.Errorf("failed to create dynamic client: %w", err)
@@ -117,8 +117,8 @@ func NewCommand() *cobra.Command {
if err != nil {
return fmt.Errorf("failed to get repo-server client TLS configuration: %w", err)
}
tlsConfig.DisableTLS = argocdRepoServerPlaintext
tlsConfig.StrictValidation = tlsConfig.StrictValidation || argocdRepoServerStrictTLS
tlsConfig.DisableTLS = cdRepoServerPlaintext
tlsConfig.StrictValidation = tlsConfig.StrictValidation || cdRepoServerStrictTLS
if !tlsConfig.DisableTLS && tlsConfig.StrictValidation && tlsConfig.Certificates == nil {
pool, err := tls.LoadX509CertPool(
@@ -130,14 +130,14 @@ func NewCommand() *cobra.Command {
}
tlsConfig.Certificates = pool
}
repoClientset := apiclient.NewRepoServerClientset(argocdRepoServer, 5, tlsConfig)
argocdService, err := service.NewArgoCDService(k8sClient, dynamicClient, namespace, repoClientset)
repoClientset := apiclient.NewRepoServerClientset(cdRepoServer, 5, tlsConfig)
cdService, err := service.NewArgoCDService(k8sClient, dynamicClient, namespace, repoClientset)
if err != nil {
return fmt.Errorf("failed to initialize Hanzo CD service: %w", err)
}
defer argocdService.Close()
defer cdService.Close()
registry := controller.NewMetricsRegistry("argocd")
registry := controller.NewMetricsRegistry("cd")
http.Handle("/metrics", promhttp.HandlerFor(prometheus.Gatherers{registry, prometheus.DefaultGatherer}, promhttp.HandlerOpts{}))
go func() {
@@ -146,7 +146,7 @@ func NewCommand() *cobra.Command {
log.Infof("serving metrics on port %d", metricsPort)
log.Infof("loading configuration %d", metricsPort)
ctrl := notificationscontroller.NewController(k8sClient, dynamicClient, argocdService, namespace, applicationNamespaces, appLabelSelector, registry, secretName, configMapName, selfServiceNotificationEnabled)
ctrl := notificationscontroller.NewController(k8sClient, dynamicClient, cdService, namespace, applicationNamespaces, appLabelSelector, registry, secretName, configMapName, selfServiceNotificationEnabled)
err = ctrl.Init(ctx)
if err != nil {
return fmt.Errorf("failed to initialize controller: %w", err)
@@ -172,12 +172,12 @@ func NewCommand() *cobra.Command {
command.Flags().StringVar(&logLevel, "loglevel", env.StringFromEnv("CD_NOTIFICATIONS_CONTROLLER_LOGLEVEL", "info"), "Set the logging level. One of: debug|info|warn|error")
command.Flags().StringVar(&logFormat, "logformat", env.StringFromEnv("CD_NOTIFICATIONS_CONTROLLER_LOGFORMAT", "json"), "Set the logging format. One of: json|text")
command.Flags().IntVar(&metricsPort, "metrics-port", defaultMetricsPort, "Metrics port")
command.Flags().StringVar(&argocdRepoServer, "argocd-repo-server", common.DefaultRepoServerAddr, "Hanzo CD repo server address")
command.Flags().BoolVar(&argocdRepoServerPlaintext, "argocd-repo-server-plaintext", env.ParseBoolFromEnv("CD_NOTIFICATION_CONTROLLER_REPO_SERVER_PLAINTEXT", false), "Use a plaintext client (non-TLS) to connect to repository server")
command.Flags().BoolVar(&argocdRepoServerStrictTLS, "argocd-repo-server-strict-tls", false, "Perform strict validation of TLS certificates when connecting to repo server")
errors.CheckError(command.Flags().MarkDeprecated("argocd-repo-server-strict-tls", "use --argocd-repo-server-ca-cert-path instead"))
command.Flags().StringVar(&configMapName, "config-map-name", "argocd-notifications-cm", "Set notifications ConfigMap name")
command.Flags().StringVar(&secretName, "secret-name", "argocd-notifications-secret", "Set notifications Secret name")
command.Flags().StringVar(&cdRepoServer, "cd-repo-server", common.DefaultRepoServerAddr, "Hanzo CD repo server address")
command.Flags().BoolVar(&cdRepoServerPlaintext, "cd-repo-server-plaintext", env.ParseBoolFromEnv("CD_NOTIFICATION_CONTROLLER_REPO_SERVER_PLAINTEXT", false), "Use a plaintext client (non-TLS) to connect to repository server")
command.Flags().BoolVar(&cdRepoServerStrictTLS, "cd-repo-server-strict-tls", false, "Perform strict validation of TLS certificates when connecting to repo server")
errors.CheckError(command.Flags().MarkDeprecated("cd-repo-server-strict-tls", "use --cd-repo-server-ca-cert-path instead"))
command.Flags().StringVar(&configMapName, "config-map-name", "cd-notifications-cm", "Set notifications ConfigMap name")
command.Flags().StringVar(&secretName, "secret-name", "cd-notifications-secret", "Set notifications Secret name")
command.Flags().StringSliceVar(&applicationNamespaces, "application-namespaces", env.StringsFromEnv("CD_APPLICATION_NAMESPACES", []string{}, ","), "List of additional namespaces that this controller should send notifications for")
command.Flags().BoolVar(&selfServiceNotificationEnabled, "self-service-notification-enabled", env.ParseBoolFromEnv("CD_NOTIFICATION_CONTROLLER_SELF_SERVICE_NOTIFICATION_ENABLED", false), "Allows the Hanzo CD notification controller to pull notification config from the namespace that the resource is in. This is useful for self-service notification.")
repoServerClientTLSConfigSrc = tls.AddClientTLSFlagsToCmdWithPrefix(&command, "NOTIFICATION_CONTROLLER")
@@ -172,7 +172,7 @@ func NewCommand() *cobra.Command {
if otlpAddress != "" {
var closer func()
var err error
closer, err = traceutil.InitTracer(ctx, "argocd-repo-server", otlpAddress, otlpInsecure, otlpHeaders, otlpAttrs, otlpSampleRatio)
closer, err = traceutil.InitTracer(ctx, "cd-repo-server", otlpAddress, otlpInsecure, otlpHeaders, otlpAttrs, otlpSampleRatio)
if err != nil {
log.Fatalf("failed to initialize tracing: %v", err)
}
@@ -227,7 +227,7 @@ func NewCommand() *cobra.Command {
go func() { errors.CheckError(reposerver.StartGPGWatcher(gnuPGSourcePath)) }()
}
log.Infof("argocd-repo-server is listening on %s", listener.Addr())
log.Infof("cd-repo-server is listening on %s", listener.Addr())
stats.RegisterStackDumper()
stats.StartStatsTicker(10 * time.Minute)
stats.RegisterHeapDumper("memprofile")
@@ -276,9 +276,9 @@ func NewCommand() *cobra.Command {
command.Flags().BoolVar(&disableOCIManifestMaxExtractedSize, "disable-oci-manifest-max-extracted-size", env.ParseBoolFromEnv("CD_REPO_SERVER_DISABLE_OCI_MANIFEST_MAX_EXTRACTED_SIZE", false), "Disable maximum size of oci manifest archives when extracted")
command.Flags().BoolVar(&disableManifestMaxExtractedSize, "disable-helm-manifest-max-extracted-size", env.ParseBoolFromEnv("CD_REPO_SERVER_DISABLE_HELM_MANIFEST_MAX_EXTRACTED_SIZE", false), "Disable maximum size of helm manifest archives when extracted")
command.Flags().BoolVar(&includeHiddenDirectories, "include-hidden-directories", env.ParseBoolFromEnv("CD_REPO_SERVER_INCLUDE_HIDDEN_DIRECTORIES", false), "Include hidden directories from Git")
command.Flags().BoolVar(&cmpUseManifestGeneratePaths, "plugin-use-manifest-generate-paths", env.ParseBoolFromEnv("CD_REPO_SERVER_PLUGIN_USE_MANIFEST_GENERATE_PATHS", false), "Pass the resources described in argocd.argoproj.io/manifest-generate-paths value to the cmpserver to generate the application manifests.")
command.Flags().BoolVar(&cmpUseManifestGeneratePaths, "plugin-use-manifest-generate-paths", env.ParseBoolFromEnv("CD_REPO_SERVER_PLUGIN_USE_MANIFEST_GENERATE_PATHS", false), "Pass the resources described in cd.argoproj.io/manifest-generate-paths value to the cmpserver to generate the application manifests.")
command.Flags().StringSliceVar(&ociMediaTypes, "oci-layer-media-types", env.StringsFromEnv("CD_REPO_SERVER_OCI_LAYER_MEDIA_TYPES", []string{"application/vnd.oci.image.layer.v1.tar", "application/vnd.oci.image.layer.v1.tar+gzip", "application/vnd.cncf.helm.chart.content.v1.tar+gzip"}, ","), "Comma separated list of allowed media types for OCI media types. This only accounts for media types within layers.")
command.Flags().BoolVar(&enableBuiltinGitConfig, "enable-builtin-git-config", env.ParseBoolFromEnv("CD_REPO_SERVER_ENABLE_BUILTIN_GIT_CONFIG", true), "Enable builtin git configuration options that are required for correct argocd-repo-server operation.")
command.Flags().BoolVar(&enableBuiltinGitConfig, "enable-builtin-git-config", env.ParseBoolFromEnv("CD_REPO_SERVER_ENABLE_BUILTIN_GIT_CONFIG", true), "Enable builtin git configuration options that are required for correct cd-repo-server operation.")
command.Flags().BoolVar(&disableTLS, "disable-tls", env.ParseBoolFromEnv("CD_REPO_SERVER_DISABLE_TLS", false), "Disable TLS for the repo-server gRPC endpoint")
command.Flags().StringVar(&clientCAPath, "client-ca-path", env.StringFromEnv("CD_REPO_SERVER_CLIENT_CA_PATH", "/app/config/reposerver/mtls/client-ca.crt"), "Path to the client CA certificate file for mTLS. Defaults to the auto-mounted Secret path; mTLS is skipped if the file does not exist.")
@@ -28,7 +28,7 @@ import (
reposervercache "github.com/hanzoai/deploy/reposerver/cache"
"github.com/hanzoai/deploy/server"
servercache "github.com/hanzoai/deploy/server/cache"
"github.com/hanzoai/deploy/util/argo"
"github.com/hanzoai/deploy/util/cd"
cacheutil "github.com/hanzoai/deploy/util/cache"
"github.com/hanzoai/deploy/util/cli"
"github.com/hanzoai/deploy/util/dex"
@@ -52,7 +52,7 @@ var (
gitSubmoduleEnabled = env.ParseBoolFromEnv(common.EnvGitSubmoduleEnabled, true)
)
// NewCommand returns a new instance of an argocd command
// NewCommand returns a new instance of an cd command
func NewCommand() *cobra.Command {
var (
redisClient *redis.Client
@@ -101,7 +101,7 @@ func NewCommand() *cobra.Command {
enableScmProviders bool
enableGitHubAPIMetrics bool
// argocd k8s event logging flag
// cd k8s event logging flag
enableK8sEvent []string
repoServerClientTLSConfigSrc func() (tls.Configuration, error)
@@ -153,7 +153,7 @@ func NewCommand() *cobra.Command {
appclientsetConfig, err := clientConfig.ClientConfig()
errors.CheckError(err)
errors.CheckError(v1alpha1.SetK8SConfigDefaults(appclientsetConfig))
config.UserAgent = fmt.Sprintf("argocd-server/%s (%s)", vers.Version, vers.Platform)
config.UserAgent = fmt.Sprintf("cd-server/%s (%s)", vers.Version, vers.Platform)
if failureRetryCount > 0 {
appclientsetConfig = kube.AddFailureRetryWrapper(appclientsetConfig, failureRetryCount, failureRetryPeriodMilliSeconds)
@@ -272,35 +272,35 @@ func NewCommand() *cobra.Command {
stats.RegisterStackDumper()
stats.StartStatsTicker(10 * time.Minute)
stats.RegisterHeapDumper("memprofile")
argocd := server.NewServer(ctx, argoCDOpts, appsetOpts)
argocd.Init(ctx)
cd := server.NewServer(ctx, argoCDOpts, appsetOpts)
cd.Init(ctx)
for {
var closer func()
serverCtx, cancel := context.WithCancel(ctx)
lns, err := argocd.Listen()
lns, err := cd.Listen()
errors.CheckError(err)
if otlpAddress != "" {
closer, err = traceutil.InitTracer(serverCtx, "argocd-server", otlpAddress, otlpInsecure, otlpHeaders, otlpAttrs, otlpSampleRatio)
closer, err = traceutil.InitTracer(serverCtx, "cd-server", otlpAddress, otlpInsecure, otlpHeaders, otlpAttrs, otlpSampleRatio)
if err != nil {
log.Fatalf("failed to initialize tracing: %v", err)
}
}
argocd.Run(serverCtx, lns)
cd.Run(serverCtx, lns)
if closer != nil {
closer()
}
cancel()
if argocd.TerminateRequested() {
if cd.TerminateRequested() {
break
}
}
},
Example: templates.Examples(`
# Start the Hanzo CD API server with default settings
$ argocd-server
$ cd-server
# Start the Hanzo CD API server on a custom port and enable tracing
$ argocd-server --port 8888 --otlp-address localhost:4317
$ cd-server --port 8888 --otlp-address localhost:4317
`),
}
@@ -340,7 +340,7 @@ func NewCommand() *cobra.Command {
command.Flags().IntVar(&webhookParallelism, "webhook-parallelism-limit", env.ParseNumFromEnv("CD_SERVER_WEBHOOK_PARALLELISM_LIMIT", 50, 1, 1000), "Number of webhook requests processed concurrently")
command.Flags().IntVar(&globCacheSize, "glob-cache-size", env.ParseNumFromEnv("CD_SERVER_GLOB_CACHE_SIZE", utilglob.DefaultGlobCacheSize, 1, math.MaxInt32), "Maximum number of compiled glob patterns to cache for RBAC evaluation")
command.Flags().IntVar(&webhookRefreshWorkers, "webhook-refresh-workers", env.ParseNumFromEnv("CD_SERVER_WEBHOOK_REFRESH_WORKERS", 20, 1, 1000), "Number of webhook refresh requests processed concurrently")
command.Flags().StringSliceVar(&enableK8sEvent, "enable-k8s-event", env.StringsFromEnv("CD_ENABLE_K8S_EVENT", argo.DefaultEnableEventList(), ","), "Enable Hanzo CD to use k8s event. For disabling all events, set the value as `none`. (e.g --enable-k8s-event=none), For enabling specific events, set the value as `event reason`. (e.g --enable-k8s-event=StatusRefreshed,ResourceCreated)")
command.Flags().StringSliceVar(&enableK8sEvent, "enable-k8s-event", env.StringsFromEnv("CD_ENABLE_K8S_EVENT", cd.DefaultEnableEventList(), ","), "Enable Hanzo CD to use k8s event. For disabling all events, set the value as `none`. (e.g --enable-k8s-event=none), For enabling specific events, set the value as `event reason`. (e.g --enable-k8s-event=StatusRefreshed,ResourceCreated)")
command.Flags().BoolVar(&hydratorEnabled, "hydrator-enabled", env.ParseBoolFromEnv("CD_HYDRATOR_ENABLED", false), "Feature flag to enable Hydrator. Default (\"false\")")
command.Flags().BoolVar(&syncWithReplaceAllowed, "sync-with-replace-allowed", env.ParseBoolFromEnv("CD_SYNC_WITH_REPLACE_ALLOWED", true), "Whether to allow users to select replace for syncs from UI/CLI")
@@ -17,7 +17,7 @@ func TestNewCommand_RegistersMTLSFlags(t *testing.T) {
"repo-server-client-cert-key-path",
} {
assert.NotNilf(t, cmd.Flags().Lookup(flagName),
"expected flag %q to be registered on argocd-server command", flagName)
"expected flag %q to be registered on cd-server command", flagName)
}
}
@@ -66,7 +66,7 @@ func TestNewCommand_MTLSEnvVarNotOverriddenByOtherComponents(t *testing.T) {
caCert, err := cmd.Flags().GetString("repo-server-ca-cert-path")
require.NoError(t, err)
assert.Empty(t, caCert,
"APPLICATION_CONTROLLER env var must not affect argocd-server's repo-server-ca-cert-path flag")
"APPLICATION_CONTROLLER env var must not affect cd-server's repo-server-ca-cert-path flag")
}
func TestNewCommand_MTLSFlagsCanBeSetExplicitly(t *testing.T) {
@@ -122,16 +122,16 @@ func TestNewCommand_CACertFlagRegistrationAndDefault(t *testing.T) {
cmd := NewCommand()
f := cmd.Flags().Lookup("repo-server-ca-cert-path")
require.NotNil(t, f, "flag \"repo-server-ca-cert-path\" must be registered on argocd-server")
require.NotNil(t, f, "flag \"repo-server-ca-cert-path\" must be registered on cd-server")
assert.Empty(t, f.DefValue, "flag \"repo-server-ca-cert-path\" must default to empty string")
clientCertFlag := cmd.Flags().Lookup("repo-server-client-cert-path")
require.NotNil(t, clientCertFlag, "flag \"repo-server-client-cert-path\" must be registered on argocd-server")
require.NotNil(t, clientCertFlag, "flag \"repo-server-client-cert-path\" must be registered on cd-server")
assert.Equal(t, "/app/config/reposerver/mtls/client.crt", clientCertFlag.DefValue,
"flag \"repo-server-client-cert-path\" must default to the auto-mounted Secret path")
clientCertKeyFlag := cmd.Flags().Lookup("repo-server-client-cert-key-path")
require.NotNil(t, clientCertKeyFlag, "flag \"repo-server-client-cert-key-path\" must be registered on argocd-server")
require.NotNil(t, clientCertKeyFlag, "flag \"repo-server-client-cert-key-path\" must be registered on cd-server")
assert.Equal(t, "/app/config/reposerver/mtls/client.key", clientCertKeyFlag.DefValue,
"flag \"repo-server-client-cert-key-path\" must default to the auto-mounted Secret path")
}
@@ -20,9 +20,9 @@ import (
jwtutil "github.com/hanzoai/deploy/util/jwt"
"github.com/hanzoai/deploy/util/rbac"
"github.com/hanzoai/deploy/cmd/argocd/commands/headless"
"github.com/hanzoai/deploy/cmd/argocd/commands/utils"
argocdclient "github.com/hanzoai/deploy/pkg/apiclient"
"github.com/hanzoai/deploy/cmd/cd/commands/headless"
"github.com/hanzoai/deploy/cmd/cd/commands/utils"
cdclient "github.com/hanzoai/deploy/pkg/apiclient"
accountpkg "github.com/hanzoai/deploy/pkg/apiclient/account"
"github.com/hanzoai/deploy/pkg/apiclient/session"
"github.com/hanzoai/deploy/util/cli"
@@ -33,22 +33,22 @@ import (
"github.com/hanzoai/deploy/util/templates"
)
func NewAccountCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
func NewAccountCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
command := &cobra.Command{
Use: "account",
Short: "Manage account settings",
Example: templates.Examples(`
# List accounts
argocd account list
cd account list
# Update the current user's password
argocd account update-password
cd account update-password
# Can I sync any app?
argocd account can-i sync applications '*'
cd account can-i sync applications '*'
# Get User information
argocd account get-user-info
cd account get-user-info
`),
Run: func(c *cobra.Command, args []string) {
c.HelpFunc()(c, args)
@@ -67,7 +67,7 @@ func NewAccountCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
return command
}
func NewAccountUpdatePasswordCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
func NewAccountUpdatePasswordCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var (
account string
currentPassword string
@@ -83,10 +83,10 @@ has appropriate RBAC permissions to change other accounts.
`,
Example: `
# Update the current user's password
argocd account update-password
cd account update-password
# Update the password for user foobar
argocd account update-password --account foobar
cd account update-password --account foobar
`,
Run: func(c *cobra.Command, args []string) {
ctx := c.Context()
@@ -155,18 +155,18 @@ has appropriate RBAC permissions to change other accounts.
return command
}
func NewAccountGetUserInfoCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
func NewAccountGetUserInfoCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var output string
command := &cobra.Command{
Use: "get-user-info",
Short: "Get user info",
Aliases: []string{"whoami"},
Example: templates.Examples(`
# Get User information for the currently logged-in user (see 'argocd login')
argocd account get-user-info
# Get User information for the currently logged-in user (see 'cd login')
cd account get-user-info
# Get User information in yaml format
argocd account get-user-info -o yaml
cd account get-user-info -o yaml
`),
Run: func(c *cobra.Command, args []string) {
ctx := c.Context()
@@ -207,19 +207,19 @@ func NewAccountGetUserInfoCommand(clientOpts *argocdclient.ClientOptions) *cobra
return command
}
func NewAccountCanICommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
func NewAccountCanICommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
return &cobra.Command{
Use: "can-i ACTION RESOURCE SUBRESOURCE",
Short: "Can I",
Example: fmt.Sprintf(`
# Can I sync any app?
argocd account can-i sync applications '*'
cd account can-i sync applications '*'
# Can I update a project?
argocd account can-i update projects 'default'
cd account can-i update projects 'default'
# Can I create a cluster?
argocd account can-i create clusters '*'
cd account can-i create clusters '*'
Actions: %v
Resources: %v
@@ -261,12 +261,12 @@ func printAccountsTable(items []*accountpkg.Account) {
_ = w.Flush()
}
func NewAccountListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
func NewAccountListCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var output string
cmd := &cobra.Command{
Use: "list",
Short: "List accounts",
Example: "argocd account list",
Example: "cd account list",
Run: func(c *cobra.Command, _ []string) {
ctx := c.Context()
@@ -293,7 +293,7 @@ func NewAccountListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Comman
return cmd
}
func getCurrentAccount(ctx context.Context, clientset argocdclient.Client) session.GetUserInfoResponse {
func getCurrentAccount(ctx context.Context, clientset cdclient.Client) session.GetUserInfoResponse {
conn, client := clientset.NewSessionClientOrDie()
defer utilio.Close(conn)
userInfo, err := client.GetUserInfo(ctx, &session.GetUserInfoRequest{})
@@ -301,7 +301,7 @@ func getCurrentAccount(ctx context.Context, clientset argocdclient.Client) sessi
return *userInfo
}
func NewAccountGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
func NewAccountGetCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var (
output string
account string
@@ -310,10 +310,10 @@ func NewAccountGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command
Use: "get",
Short: "Get account details",
Example: `# Get the currently logged in account details
argocd account get
cd account get
# Get details for an account by name
argocd account get --account <account-name>`,
cd account get --account <account-name>`,
Run: func(c *cobra.Command, _ []string) {
ctx := c.Context()
@@ -373,7 +373,7 @@ func printAccountDetails(acc *accountpkg.Account) {
}
}
func NewAccountGenerateTokenCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
func NewAccountGenerateTokenCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var (
account string
expiresIn string
@@ -383,10 +383,10 @@ func NewAccountGenerateTokenCommand(clientOpts *argocdclient.ClientOptions) *cob
Use: "generate-token",
Short: "Generate account token",
Example: `# Generate token for the currently logged in account
argocd account generate-token
cd account generate-token
# Generate token for the account with the specified name
argocd account generate-token --account <account-name>`,
cd account generate-token --account <account-name>`,
Run: func(c *cobra.Command, _ []string) {
ctx := c.Context()
@@ -413,16 +413,16 @@ argocd account generate-token --account <account-name>`,
return cmd
}
func NewAccountDeleteTokenCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
func NewAccountDeleteTokenCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var account string
cmd := &cobra.Command{
Use: "delete-token",
Short: "Deletes account token",
Example: `# Delete token of the currently logged in account
argocd account delete-token ID
cd account delete-token ID
# Delete token of the account with the specified name
argocd account delete-token --account <account-name> ID`,
cd account delete-token --account <account-name> ID`,
Run: func(c *cobra.Command, args []string) {
ctx := c.Context()
@@ -452,7 +452,7 @@ argocd account delete-token --account <account-name> ID`,
return cmd
}
func NewAccountSessionTokenCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
func NewAccountSessionTokenCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var output string
cmd := &cobra.Command{
Use: "session-token",
@@ -462,20 +462,20 @@ func NewAccountSessionTokenCommand(clientOpts *argocdclient.ClientOptions) *cobr
Automatically refreshes expired tokens using refresh token (SSO users).
For local users: Shows current token (manual relogin needed if expired)`,
Example: `# Display current session token (automatically refreshes if needed)
argocd account session-token
cd account session-token
# Show detailed token information
argocd account session-token -o json
cd account session-token -o json
# Use in scripts
export CD_AUTH_TOKEN=$(argocd account session-token)
export CD_AUTH_TOKEN=$(cd account session-token)
curl -H "Authorization: Bearer $CD_AUTH_TOKEN" $CD_SERVER/api/v1/applications`,
Run: func(_ *cobra.Command, _ []string) {
// Create client first - this handles token refresh automatically
_, err := argocdclient.NewClient(clientOpts)
_, err := cdclient.NewClient(clientOpts)
if err != nil {
if strings.Contains(err.Error(), "invalid_grant") && strings.Contains(err.Error(), "Invalid refresh_token") {
log.Fatal("Refresh token is invalid or expired. Please run 'argocd relogin' to re-authenticate")
log.Fatal("Refresh token is invalid or expired. Please run 'cd relogin' to re-authenticate")
}
log.Fatal(err)
}
@@ -484,27 +484,27 @@ curl -H "Authorization: Bearer $CD_AUTH_TOKEN" $CD_SERVER/api/v1/applications`,
localCfg, err := localconfig.ReadLocalConfig(clientOpts.ConfigPath)
errors.CheckError(err)
if localCfg == nil {
log.Fatal("No configuration found. Please login first with 'argocd login'")
log.Fatal("No configuration found. Please login first with 'cd login'")
}
configCtx, err := localCfg.ResolveContext(clientOpts.Context)
errors.CheckError(err)
if configCtx == nil {
log.Fatal("No context found. Please login first with 'argocd login'")
log.Fatal("No context found. Please login first with 'cd login'")
}
if configCtx.User.AuthToken == "" {
log.Fatal("No authentication token found. Please login first with 'argocd login'")
log.Fatal("No authentication token found. Please login first with 'cd login'")
}
// Get token claims and validate
claims, err := configCtx.User.Claims()
if err != nil {
log.Fatal("Invalid token format. Please run 'argocd relogin'")
log.Fatal("Invalid token format. Please run 'cd relogin'")
}
validator := jwt.NewValidator()
if validator.Validate(claims) != nil {
log.Fatal("Token is invalid or expired. Please run 'argocd relogin'")
log.Fatal("Token is invalid or expired. Please run 'cd relogin'")
}
switch output {
@@ -17,7 +17,7 @@ import (
cmdutil "github.com/hanzoai/deploy/cmd/util"
"github.com/hanzoai/deploy/common"
argocdclient "github.com/hanzoai/deploy/pkg/apiclient"
cdclient "github.com/hanzoai/deploy/pkg/apiclient"
"github.com/hanzoai/deploy/pkg/apis/application"
"github.com/hanzoai/deploy/util/errors"
)
@@ -38,7 +38,7 @@ var (
appplicationSetResource = schema.GroupVersionResource{Group: application.Group, Version: "v1alpha1", Resource: application.ApplicationSetPlural}
)
type argocdAdditionalNamespaces struct {
type cdAdditionalNamespaces struct {
applicationNamespaces []string
applicationsetNamespaces []string
}
@@ -51,8 +51,8 @@ type argoCDClientsets struct {
applicationSets dynamic.ResourceInterface
}
// NewAdminCommand returns a new instance of an argocd command
func NewAdminCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
// NewAdminCommand returns a new instance of an cd command
func NewAdminCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
pathOpts := clientcmd.NewDefaultPathOptions()
command := &cobra.Command{
@@ -63,10 +63,10 @@ func NewAdminCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
c.HelpFunc()(c, args)
},
Example: `# Access the Hanzo CD web UI
$ argocd admin dashboard
$ cd admin dashboard
# Reset the initial admin password
$ argocd admin initial-password reset
$ cd admin initial-password reset
`,
}
@@ -101,7 +101,7 @@ func newArgoCDClientsets(config *rest.Config, namespace string) *argoCDClientset
}
// isArgoCDSecret returns whether or not the given secret is a part of Hanzo CD configuration
// (e.g. argocd-secret, repo credentials, or cluster credentials)
// (e.g. cd-secret, repo credentials, or cluster credentials)
func isArgoCDSecret(un unstructured.Unstructured) bool {
secretName := un.GetName()
if secretName == common.ArgoCDSecretName {
@@ -169,8 +169,8 @@ func specsEqual(left, right unstructured.Unstructured) bool {
return false
}
// Get additional namespaces from argocd-cmd-params
func getAdditionalNamespaces(ctx context.Context, configMapsClient dynamic.ResourceInterface) *argocdAdditionalNamespaces {
// Get additional namespaces from cd-cmd-params
func getAdditionalNamespaces(ctx context.Context, configMapsClient dynamic.ResourceInterface) *cdAdditionalNamespaces {
applicationNamespaces := make([]string, 0)
applicationsetNamespaces := make([]string, 0)
@@ -202,7 +202,7 @@ func getAdditionalNamespaces(ctx context.Context, configMapsClient dynamic.Resou
applicationsetNamespaces = namespacesListFromString(strNamespaces)
}
return &argocdAdditionalNamespaces{
return &cdAdditionalNamespaces{
applicationNamespaces: applicationNamespaces,
applicationsetNamespaces: applicationsetNamespaces,
}
@@ -16,8 +16,8 @@ func TestGetAdditionalNamespaces(t *testing.T) {
"apiVersion": "v1",
"kind": "ConfigMap",
"metadata": map[string]any{
"name": "argocd-cmd-params-cm",
"namespace": "argocd",
"name": "cd-cmd-params-cm",
"namespace": "cd",
},
"data": data,
},
@@ -26,33 +26,33 @@ func TestGetAdditionalNamespaces(t *testing.T) {
testCases := []struct {
CmdParamsKeys map[string]any
expected argocdAdditionalNamespaces
expected cdAdditionalNamespaces
description string
}{
{
description: "empty configmap should return no additional namespaces",
CmdParamsKeys: map[string]any{},
expected: argocdAdditionalNamespaces{applicationNamespaces: []string{}, applicationsetNamespaces: []string{}},
expected: cdAdditionalNamespaces{applicationNamespaces: []string{}, applicationsetNamespaces: []string{}},
},
{
description: "empty strings in respective keys in cm shoud return empty namespace list",
CmdParamsKeys: map[string]any{applicationsetNamespacesCmdParamsKey: "", applicationNamespacesCmdParamsKey: ""},
expected: argocdAdditionalNamespaces{applicationNamespaces: []string{}, applicationsetNamespaces: []string{}},
expected: cdAdditionalNamespaces{applicationNamespaces: []string{}, applicationsetNamespaces: []string{}},
},
{
description: "when only one of the keys in the cm is set only correct respective list of namespaces should be returned",
CmdParamsKeys: map[string]any{applicationNamespacesCmdParamsKey: "foo, bar*"},
expected: argocdAdditionalNamespaces{applicationsetNamespaces: []string{}, applicationNamespaces: []string{"foo", "bar*"}},
expected: cdAdditionalNamespaces{applicationsetNamespaces: []string{}, applicationNamespaces: []string{"foo", "bar*"}},
},
{
description: "when only one of the keys in the cm is set only correct respective list of namespaces should be returned",
CmdParamsKeys: map[string]any{applicationsetNamespacesCmdParamsKey: "foo, bar*"},
expected: argocdAdditionalNamespaces{applicationNamespaces: []string{}, applicationsetNamespaces: []string{"foo", "bar*"}},
expected: cdAdditionalNamespaces{applicationNamespaces: []string{}, applicationsetNamespaces: []string{"foo", "bar*"}},
},
{
description: "whitespaces are removed for both multiple and single namespace",
CmdParamsKeys: map[string]any{applicationNamespacesCmdParamsKey: " bar ", applicationsetNamespacesCmdParamsKey: " foo , bar* "},
expected: argocdAdditionalNamespaces{applicationNamespaces: []string{"bar"}, applicationsetNamespaces: []string{"foo", "bar*"}},
expected: cdAdditionalNamespaces{applicationNamespaces: []string{"bar"}, applicationsetNamespaces: []string{"foo", "bar*"}},
},
}
@@ -60,7 +60,7 @@ func TestGetAdditionalNamespaces(t *testing.T) {
fakeDynClient := dynfake.NewSimpleDynamicClient(runtime.NewScheme(), createArgoCDCmdCMWithKeys(c.CmdParamsKeys))
argoCDClientsets := &argoCDClientsets{
configMaps: fakeDynClient.Resource(configMapResource).Namespace("argocd"),
configMaps: fakeDynClient.Resource(configMapResource).Namespace("cd"),
}
result := getAdditionalNamespaces(t.Context(), argoCDClientsets.configMaps)
@@ -30,13 +30,13 @@ import (
"github.com/hanzoai/deploy/controller/cache"
"github.com/hanzoai/deploy/controller/metrics"
"github.com/hanzoai/deploy/controller/sharding"
argocdclient "github.com/hanzoai/deploy/pkg/apiclient"
cdclient "github.com/hanzoai/deploy/pkg/apiclient"
"github.com/hanzoai/deploy/pkg/apis/application/v1alpha1"
appclientset "github.com/hanzoai/deploy/pkg/client/clientset/versioned"
appinformers "github.com/hanzoai/deploy/pkg/client/informers/externalversions"
reposerverclient "github.com/hanzoai/deploy/reposerver/apiclient"
"github.com/hanzoai/deploy/util/argo"
"github.com/hanzoai/deploy/util/argo/normalizers"
"github.com/hanzoai/deploy/util/cd"
"github.com/hanzoai/deploy/util/cd/normalizers"
cacheutil "github.com/hanzoai/deploy/util/cache"
appstatecache "github.com/hanzoai/deploy/util/cache/appstate"
"github.com/hanzoai/deploy/util/cli"
@@ -48,19 +48,19 @@ import (
"github.com/hanzoai/deploy/util/settings"
)
func NewAppCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
func NewAppCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
command := &cobra.Command{
Use: "app",
Short: "Manage applications configuration",
Example: `
# Compare results of two reconciliations and print diff
argocd admin app diff-reconcile-results APPNAME [flags]
cd admin app diff-reconcile-results APPNAME [flags]
# Generate declarative config for an application
argocd admin app generate-spec APPNAME
cd admin app generate-spec APPNAME
# Reconcile all applications and store reconciliation summary in the specified file
argocd admin app get-reconcile-results APPNAME
cd admin app get-reconcile-results APPNAME
`,
Run: func(c *cobra.Command, args []string) {
c.HelpFunc()(c, args)
@@ -90,22 +90,22 @@ func NewGenAppSpecCommand() *cobra.Command {
Short: "Generate declarative config for an application",
Example: `
# Generate declarative config for a directory app
argocd admin app generate-spec guestbook --repo https://github.com/argoproj/argocd-example-apps.git --path guestbook --dest-namespace default --dest-server https://kubernetes.default.svc --directory-recurse
cd admin app generate-spec guestbook --repo https://github.com/argoproj/argocd-example-apps.git --path guestbook --dest-namespace default --dest-server https://kubernetes.default.svc --directory-recurse
# Generate declarative config for a Jsonnet app
argocd admin app generate-spec jsonnet-guestbook --repo https://github.com/argoproj/argocd-example-apps.git --path jsonnet-guestbook --dest-namespace default --dest-server https://kubernetes.default.svc --jsonnet-ext-str replicas=2
cd admin app generate-spec jsonnet-guestbook --repo https://github.com/argoproj/argocd-example-apps.git --path jsonnet-guestbook --dest-namespace default --dest-server https://kubernetes.default.svc --jsonnet-ext-str replicas=2
# Generate declarative config for a Helm app
argocd admin app generate-spec helm-guestbook --repo https://github.com/argoproj/argocd-example-apps.git --path helm-guestbook --dest-namespace default --dest-server https://kubernetes.default.svc --helm-set replicaCount=2
cd admin app generate-spec helm-guestbook --repo https://github.com/argoproj/argocd-example-apps.git --path helm-guestbook --dest-namespace default --dest-server https://kubernetes.default.svc --helm-set replicaCount=2
# Generate declarative config for a Helm app from a Helm repo
argocd admin app generate-spec nginx-ingress --repo https://charts.helm.sh/stable --helm-chart nginx-ingress --revision 1.24.3 --dest-namespace default --dest-server https://kubernetes.default.svc
cd admin app generate-spec nginx-ingress --repo https://charts.helm.sh/stable --helm-chart nginx-ingress --revision 1.24.3 --dest-namespace default --dest-server https://kubernetes.default.svc
# Generate declarative config for a Kustomize app
argocd admin app generate-spec kustomize-guestbook --repo https://github.com/argoproj/argocd-example-apps.git --path kustomize-guestbook --dest-namespace default --dest-server https://kubernetes.default.svc --kustomize-image quay.io/argoprojlabs/argocd-e2e-container:0.1
cd admin app generate-spec kustomize-guestbook --repo https://github.com/argoproj/argocd-example-apps.git --path kustomize-guestbook --dest-namespace default --dest-server https://kubernetes.default.svc --kustomize-image quay.io/argoprojlabs/cd-e2e-container:0.1
# Generate declarative config for a app using a custom tool:
argocd admin app generate-spec kasane --repo https://github.com/argoproj/argocd-example-apps.git --path plugins/kasane --dest-namespace default --dest-server https://kubernetes.default.svc --config-management-plugin kasane
cd admin app generate-spec kasane --repo https://github.com/argoproj/argocd-example-apps.git --path plugins/kasane --dest-namespace default --dest-server https://kubernetes.default.svc --config-management-plugin kasane
`,
Run: func(c *cobra.Command, args []string) {
apps, err := cmdutil.ConstructApps(fileURL, appName, labels, annotations, args, appOpts, c.Flags())
@@ -247,7 +247,7 @@ func diffReconcileResults(res1 reconcileResults, res2 reconcileResults) error {
return nil
}
func NewReconcileCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
func NewReconcileCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var (
clientConfig clientcmd.ClientConfig
selector string
@@ -284,7 +284,7 @@ func NewReconcileCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command
appClientset := appclientset.NewForConfigOrDie(cfg)
kubeClientset := kubernetes.NewForConfigOrDie(cfg)
if repoServerAddress == "" {
printLine("Repo server is not provided, trying to port-forward to argocd-repo-server pod.")
printLine("Repo server is not provided, trying to port-forward to cd-repo-server pod.")
overrides := clientcmd.ConfigOverrides{}
repoServerName := clientOpts.RepoServerName
repoServerServiceLabelSelector := common.LabelKeyComponentRepoServer + "=" + common.LabelValueComponentRepoServer
@@ -420,7 +420,7 @@ func reconcileApplications(
server,
cache,
time.Second,
argo.NewResourceTracking(),
cd.NewResourceTracking(),
false,
0,
serverSideDiff,
@@ -439,7 +439,7 @@ func reconcileApplications(
var items []appReconcileResult
prevServer := ""
for _, app := range appsList.Items {
destCluster, err := argo.GetDestinationCluster(ctx, app.Spec.Destination, argoDB)
destCluster, err := cd.GetDestinationCluster(ctx, app.Spec.Destination, argoDB)
if err != nil {
return nil, fmt.Errorf("error getting destination cluster: %w", err)
}
@@ -480,5 +480,5 @@ func reconcileApplications(
}
func newLiveStateCache(argoDB db.ArgoDB, appInformer kubecache.SharedIndexInformer, settingsMgr *settings.SettingsManager, server *metrics.MetricsServer) cache.LiveStateCache {
return cache.NewLiveStateCache(argoDB, appInformer, settingsMgr, server, func(_ map[string]bool, _ corev1.ObjectReference) {}, &sharding.ClusterSharding{}, argo.NewResourceTracking())
return cache.NewLiveStateCache(argoDB, appInformer, settingsMgr, server, func(_ map[string]bool, _ corev1.ObjectReference) {}, &sharding.ClusterSharding{}, cd.NewResourceTracking())
}
@@ -21,10 +21,10 @@ import (
"github.com/hanzoai/deploy/controller/metrics"
"github.com/hanzoai/deploy/pkg/apis/application/v1alpha1"
appfake "github.com/hanzoai/deploy/pkg/client/clientset/versioned/fake"
argocdclient "github.com/hanzoai/deploy/reposerver/apiclient"
cdclient "github.com/hanzoai/deploy/reposerver/apiclient"
"github.com/hanzoai/deploy/reposerver/apiclient/mocks"
"github.com/hanzoai/deploy/test"
"github.com/hanzoai/deploy/util/argo/normalizers"
"github.com/hanzoai/deploy/util/cd/normalizers"
"github.com/hanzoai/deploy/util/db"
"github.com/hanzoai/deploy/util/settings"
)
@@ -62,7 +62,7 @@ func TestGetReconcileResults_Refresh(t *testing.T) {
Name: common.ArgoCDConfigMapName,
Namespace: "default",
Labels: map[string]string{
"app.kubernetes.io/part-of": "argocd",
"app.kubernetes.io/part-of": "cd",
},
},
}
@@ -71,7 +71,7 @@ func TestGetReconcileResults_Refresh(t *testing.T) {
Name: common.ArgoCDSecretName,
Namespace: "default",
Labels: map[string]string{
"app.kubernetes.io/part-of": "argocd",
"app.kubernetes.io/part-of": "cd",
},
},
Data: map[string][]byte{
@@ -109,7 +109,7 @@ func TestGetReconcileResults_Refresh(t *testing.T) {
clusterCache.EXPECT().IsNamespaced(mock.Anything).Return(true, nil)
clusterCache.EXPECT().GetGVKParser().Return(nil)
repoServerClient := &mocks.RepoServerServiceClient{}
repoServerClient.EXPECT().GenerateManifest(mock.Anything, mock.Anything).Return(&argocdclient.ManifestResponse{
repoServerClient.EXPECT().GenerateManifest(mock.Anything, mock.Anything).Return(&cdclient.ManifestResponse{
Manifests: []string{test.DeploymentManifest},
}, nil)
repoServerClientset := &mocks.Clientset{RepoServerServiceClient: repoServerClient}
@@ -20,7 +20,7 @@ import (
"k8s.io/client-go/util/retry"
"sigs.k8s.io/yaml"
"github.com/hanzoai/deploy/cmd/argocd/commands/utils"
"github.com/hanzoai/deploy/cmd/cd/commands/utils"
"github.com/hanzoai/deploy/common"
"github.com/hanzoai/deploy/pkg/apis/application"
"github.com/hanzoai/deploy/util/cli"
@@ -452,7 +452,7 @@ func checkAppHasNoNeedToStopOperation(liveObj unstructured.Unstructured, stopOpe
}
// export writes the unstructured object and removes extraneous cruft from output before writing
func export(w io.Writer, un unstructured.Unstructured, argocdNamespace string) {
func export(w io.Writer, un unstructured.Unstructured, cdNamespace string) {
name := un.GetName()
finalizers := un.GetFinalizers()
apiVersion := un.GetAPIVersion()
@@ -467,7 +467,7 @@ func export(w io.Writer, un unstructured.Unstructured, argocdNamespace string) {
un.SetKind(kind)
un.SetLabels(labels)
un.SetAnnotations(annotations)
if namespace != argocdNamespace {
if namespace != cdNamespace {
// Explicitly add the namespace for appset and apps in any namespace
un.SetNamespace(namespace)
}
@@ -43,9 +43,9 @@ func newConfigmapObject() *unstructured.Unstructured {
cm := corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: common.ArgoCDConfigMapName,
Namespace: "argocd",
Namespace: "cd",
Labels: map[string]string{
"app.kubernetes.io/part-of": "argocd",
"app.kubernetes.io/part-of": "cd",
},
},
}
@@ -59,7 +59,7 @@ func newSecretsObject() *unstructured.Unstructured {
Name: common.ArgoCDSecretName,
Namespace: "default",
Labels: map[string]string{
"app.kubernetes.io/part-of": "argocd",
"app.kubernetes.io/part-of": "cd",
},
},
Data: map[string][]byte{
@@ -75,7 +75,7 @@ func newAppProject() *unstructured.Unstructured {
appProject := v1alpha1.AppProject{
ObjectMeta: metav1.ObjectMeta{
Name: "default",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.AppProjectSpec{
Destinations: []v1alpha1.ApplicationDestination{
@@ -142,7 +142,7 @@ func newApplicationSet(namespace string) *unstructured.Unstructured {
return kube.MustToUnstructured(&appSet)
}
// Test_exportResources tests for the resources exported when using the `argocd admin export` command
// Test_exportResources tests for the resources exported when using the `cd admin export` command
func Test_exportResources(t *testing.T) {
tests := []struct {
name string
@@ -160,8 +160,8 @@ func Test_exportResources(t *testing.T) {
kind: ""
metadata:
labels:
app.kubernetes.io/part-of: argocd
name: argocd-cm
app.kubernetes.io/part-of: cd
name: cd-cm
---
`,
},
@@ -176,8 +176,8 @@ data:
kind: ""
metadata:
labels:
app.kubernetes.io/part-of: argocd
name: argocd-secret
app.kubernetes.io/part-of: cd
name: cd-secret
namespace: default
---
`,
@@ -204,9 +204,9 @@ status: {}
`,
},
{
name: "Application should be in the exported manifest when created in the default 'argocd' namespace",
object: newApplication("argocd"),
namespace: "argocd",
name: "Application should be in the exported manifest when created in the default 'cd' namespace",
object: newApplication("cd"),
namespace: "cd",
expectExport: true,
expectedFileContent: `apiVersion: ""
kind: Application
@@ -272,9 +272,9 @@ status:
expectedFileContent: ``,
},
{
name: "ApplicationSet should be in the exported manifest when created in the default 'argocd' namespace",
object: newApplicationSet("argocd"),
namespace: "argocd",
name: "ApplicationSet should be in the exported manifest when created in the default 'cd' namespace",
object: newApplicationSet("cd"),
namespace: "cd",
expectExport: true,
expectedFileContent: `apiVersion: ""
kind: ApplicationSet
@@ -332,7 +332,7 @@ status:
`,
},
{
name: "ApplicationSet should not be in the exported manifest when neither created in the default 'argocd' namespace nor in enabled namespaces",
name: "ApplicationSet should not be in the exported manifest when neither created in the default 'cd' namespace nor in enabled namespaces",
object: newApplicationSet("staging"),
namespace: "staging",
enabledNamespaces: []string{"dev", "prod"},
@@ -347,7 +347,7 @@ status:
kind := tt.object.GetKind()
if kind == "Application" || kind == "ApplicationSet" {
if security.IsNamespaceEnabled(tt.namespace, "argocd", tt.enabledNamespaces) {
if security.IsNamespaceEnabled(tt.namespace, "cd", tt.enabledNamespaces) {
export(&buf, *tt.object, ArgoCDNamespace)
}
} else {
@@ -24,10 +24,10 @@ import (
cmdutil "github.com/hanzoai/deploy/cmd/util"
"github.com/hanzoai/deploy/common"
"github.com/hanzoai/deploy/controller/sharding"
argocdclient "github.com/hanzoai/deploy/pkg/apiclient"
cdclient "github.com/hanzoai/deploy/pkg/apiclient"
"github.com/hanzoai/deploy/pkg/apis/application/v1alpha1"
"github.com/hanzoai/deploy/pkg/client/clientset/versioned"
"github.com/hanzoai/deploy/util/argo"
"github.com/hanzoai/deploy/util/cd"
cacheutil "github.com/hanzoai/deploy/util/cache"
appstatecache "github.com/hanzoai/deploy/util/cache/appstate"
"github.com/hanzoai/deploy/util/cli"
@@ -40,19 +40,19 @@ import (
"github.com/hanzoai/deploy/util/text/label"
)
func NewClusterCommand(clientOpts *argocdclient.ClientOptions, pathOpts *clientcmd.PathOptions) *cobra.Command {
func NewClusterCommand(clientOpts *cdclient.ClientOptions, pathOpts *clientcmd.PathOptions) *cobra.Command {
command := &cobra.Command{
Use: "cluster",
Short: "Manage clusters configuration",
Example: `
#Generate declarative config for a cluster
argocd admin cluster generate-spec my-cluster -o yaml
cd admin cluster generate-spec my-cluster -o yaml
#Generate a kubeconfig for a cluster named "my-cluster" and display it in the console
argocd admin cluster kubeconfig my-cluster
cd admin cluster kubeconfig my-cluster
#Print information namespaces which Hanzo CD manages in each cluster
argocd admin cluster namespaces my-cluster `,
cd admin cluster namespaces my-cluster `,
Run: func(c *cobra.Command, args []string) {
c.HelpFunc()(c, args)
},
@@ -144,7 +144,7 @@ func loadClusters(ctx context.Context, kubeClient kubernetes.Interface, appClien
}
nsSet := map[string]bool{}
for _, app := range apps {
destCluster, err := argo.GetDestinationCluster(ctx, app.Spec.Destination, argoDB)
destCluster, err := cd.GetDestinationCluster(ctx, app.Spec.Destination, argoDB)
if err != nil {
return fmt.Errorf("error validating application destination: %w", err)
}
@@ -175,7 +175,7 @@ func getControllerReplicas(ctx context.Context, kubeClient *kubernetes.Clientset
return len(controllerPods.Items), nil
}
func NewClusterShardsCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
func NewClusterShardsCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var (
shard int
replicas int
@@ -277,7 +277,7 @@ func runClusterNamespacesCommand(ctx context.Context, clientConfig clientcmd.Cli
for _, cluster := range clustersList.Items {
nsSet := map[string]bool{}
for _, app := range apps {
destCluster, err := argo.GetDestinationCluster(ctx, app.Spec.Destination, argoDB)
destCluster, err := cd.GetDestinationCluster(ctx, app.Spec.Destination, argoDB)
if err != nil {
return fmt.Errorf("error validating application destination: %w", err)
}
@@ -454,7 +454,7 @@ func NewClusterDisableNamespacedMode() *cobra.Command {
return &command
}
func NewClusterStatsCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
func NewClusterStatsCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var (
shard int
replicas int
@@ -468,13 +468,13 @@ func NewClusterStatsCommand(clientOpts *argocdclient.ClientOptions) *cobra.Comma
Short: "Prints information cluster statistics and inferred shard number",
Example: `
#Display stats and shards for clusters
argocd admin cluster stats
cd admin cluster stats
#Display Cluster Statistics for a Specific Shard
argocd admin cluster stats --shard=1
cd admin cluster stats --shard=1
#In a multi-cluster environment to print stats for a specific cluster say(target-cluster)
argocd admin cluster stats target-cluster`,
cd admin cluster stats target-cluster`,
Run: func(cmd *cobra.Command, _ []string) {
ctx := cmd.Context()
@@ -516,7 +516,7 @@ argocd admin cluster stats target-cluster`,
return &command
}
// NewClusterConfig returns a new instance of `argocd admin kubeconfig` command
// NewClusterConfig returns a new instance of `cd admin kubeconfig` command
func NewClusterConfig() *cobra.Command {
var clientConfig clientcmd.ClientConfig
command := &cobra.Command{
@@ -525,16 +525,16 @@ func NewClusterConfig() *cobra.Command {
DisableAutoGenTag: true,
Example: `
#Generate a kubeconfig for a cluster named "my-cluster" on console
argocd admin cluster kubeconfig my-cluster
cd admin cluster kubeconfig my-cluster
#Listing available kubeconfigs for clusters managed by argocd
argocd admin cluster kubeconfig
#Listing available kubeconfigs for clusters managed by cd
cd admin cluster kubeconfig
#Removing a specific kubeconfig file
argocd admin cluster kubeconfig my-cluster --delete
cd admin cluster kubeconfig my-cluster --delete
#Generate a Kubeconfig for a Cluster with TLS Verification Disabled
argocd admin cluster kubeconfig https://cluster-api-url:6443 /path/to/output/kubeconfig.yaml --insecure-skip-tls-verify`,
cd admin cluster kubeconfig https://cluster-api-url:6443 /path/to/output/kubeconfig.yaml --insecure-skip-tls-verify`,
Run: func(c *cobra.Command, args []string) {
ctx := c.Context()
@@ -693,7 +693,7 @@ func NewGenClusterConfigCommand(pathOpts *clientcmd.PathOptions) *cobra.Command
command.PersistentFlags().StringVar(&pathOpts.LoadingRules.ExplicitPath, pathOpts.ExplicitFileFlag, pathOpts.LoadingRules.ExplicitPath, "use a particular kubeconfig file")
command.Flags().StringVar(&bearerToken, "bearer-token", "", "Authentication token that should be used to access K8S API server")
command.Flags().BoolVar(&generateToken, "generate-bearer-token", false, "Generate authentication token that should be used to access K8S API server")
command.Flags().StringVar(&clusterOpts.ServiceAccount, "service-account", "argocd-manager", fmt.Sprintf("System namespace service account to use for kubernetes resource management. If not set then default %q SA will be used", clusterauth.ArgoCDManagerServiceAccount))
command.Flags().StringVar(&clusterOpts.ServiceAccount, "service-account", "cd-manager", fmt.Sprintf("System namespace service account to use for kubernetes resource management. If not set then default %q SA will be used", clusterauth.ArgoCDManagerServiceAccount))
command.Flags().StringVar(&clusterOpts.SystemNamespace, "system-namespace", common.DefaultSystemNamespace, "Use different system namespace")
command.Flags().StringVarP(&outputFormat, "output", "o", "yaml", "Output format. One of: json|yaml")
command.Flags().StringArrayVar(&labels, "label", nil, "Set metadata labels (e.g. --label key=value)")
@@ -19,18 +19,18 @@ import (
func Test_loadClusters(t *testing.T) {
argoCDCM := &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: "argocd-cm",
Namespace: "argocd",
Name: "cd-cm",
Namespace: "cd",
Labels: map[string]string{
"app.kubernetes.io/part-of": "argocd",
"app.kubernetes.io/part-of": "cd",
},
},
Data: map[string]string{},
}
argoCDSecret := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "argocd-secret",
Namespace: "argocd",
Name: "cd-secret",
Namespace: "cd",
},
Data: map[string][]byte{
"server.secretkey": []byte("test"),
@@ -39,7 +39,7 @@ func Test_loadClusters(t *testing.T) {
app := &v1alpha1.Application{
ObjectMeta: metav1.ObjectMeta{
Name: "test",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSpec{
Project: "default",
@@ -55,7 +55,7 @@ func Test_loadClusters(t *testing.T) {
cacheSrc := func() (*appstate.Cache, error) {
return appstate.NewCache(cacheutil.NewCache(cacheutil.NewInMemoryCache(time.Minute)), time.Minute), nil
}
clusters, err := loadClusters(ctx, kubeClient, appClient, 3, "", "argocd", false, cacheSrc, 0, "", "", "")
clusters, err := loadClusters(ctx, kubeClient, appClient, 3, "", "cd", false, cacheSrc, 0, "", "", "")
require.NoError(t, err)
for i := range clusters {
// This changes, nil it to avoid testing it.
@@ -11,10 +11,10 @@ import (
"github.com/hanzoai/deploy/util/cli"
"github.com/hanzoai/deploy/cmd/argocd/commands/headless"
"github.com/hanzoai/deploy/cmd/argocd/commands/initialize"
"github.com/hanzoai/deploy/cmd/cd/commands/headless"
"github.com/hanzoai/deploy/cmd/cd/commands/initialize"
"github.com/hanzoai/deploy/common"
argocdclient "github.com/hanzoai/deploy/pkg/apiclient"
cdclient "github.com/hanzoai/deploy/pkg/apiclient"
"github.com/hanzoai/deploy/util/errors"
)
@@ -22,13 +22,13 @@ import (
type DashboardConfig struct {
Port int
Address string
ClientOpts *argocdclient.ClientOptions
ClientOpts *cdclient.ClientOptions
ClientConfig clientcmd.ClientConfig
Context string
}
type dashboard struct {
startLocalServer func(ctx context.Context, clientOpts *argocdclient.ClientOptions, contextName string, port *int, address *string, clientConfig clientcmd.ClientConfig) (func(), error)
startLocalServer func(ctx context.Context, clientOpts *cdclient.ClientOptions, contextName string, port *int, address *string, clientConfig clientcmd.ClientConfig) (func(), error)
}
// NewDashboard initializes a new dashboard with default dependencies
@@ -59,7 +59,7 @@ func (ds *dashboard) Run(ctx context.Context, config *DashboardConfig) error {
return nil
}
func NewDashboardCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
func NewDashboardCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
config := &DashboardConfig{ClientOpts: clientOpts}
cmd := &cobra.Command{
Use: "dashboard",
@@ -69,13 +69,13 @@ func NewDashboardCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command
errors.CheckError(NewDashboard().Run(cmd.Context(), config))
},
Example: `# Start the Hanzo CD Web UI locally on the default port and address
$ argocd admin dashboard
$ cd admin dashboard
# Start the Hanzo CD Web UI locally on a custom port and address
$ argocd admin dashboard --port 8080 --address 127.0.0.1
$ cd admin dashboard --port 8080 --address 127.0.0.1
# Start the Hanzo CD Web UI with GZip compression
$ argocd admin dashboard --redis-compress gzip
$ cd admin dashboard --redis-compress gzip
`,
}
config.ClientConfig = cli.AddKubectlFlagsToSet(cmd.Flags())
@@ -13,7 +13,7 @@ import (
"github.com/hanzoai/deploy/util/errors"
)
const initialPasswordSecretName = "argocd-initial-admin-secret"
const initialPasswordSecretName = "cd-initial-admin-secret"
// NewInitialPasswordCommand defines a new command to retrieve Hanzo CD initial password.
func NewInitialPasswordCommand() *cobra.Command {
@@ -33,7 +33,7 @@ func NewInitialPasswordCommand() *cobra.Command {
if initialPass, ok := secret.Data["password"]; ok {
fmt.Println(string(initialPass))
fmt.Println("\n This password must be only used for first time login. We strongly recommend you update the password using `argocd account update-password`.")
fmt.Println("\n This password must be only used for first time login. We strongly recommend you update the password using `cd account update-password`.")
}
},
}
@@ -12,7 +12,7 @@ import (
"github.com/hanzoai/deploy/common"
"github.com/hanzoai/deploy/reposerver/apiclient"
"github.com/hanzoai/deploy/util/env"
service "github.com/hanzoai/deploy/util/notification/argocd"
service "github.com/hanzoai/deploy/util/notification/cd"
"github.com/hanzoai/deploy/util/notification/settings"
"github.com/hanzoai/deploy/util/tls"
@@ -26,20 +26,20 @@ var applications = schema.GroupVersionResource{Group: application.Group, Version
func NewNotificationsCommand() *cobra.Command {
var (
argocdRepoServer string
argocdRepoServerPlaintext bool
argocdRepoServerStrictTLS bool
cdRepoServer string
cdRepoServerPlaintext bool
cdRepoServerStrictTLS bool
)
var argocdService service.Service
var cdService service.Service
var repoServerClientTLSConfigSrc func() (tls.Configuration, error)
toolsCommand := cmd.NewToolsCommand(
"notifications",
"argocd admin notifications",
"cd admin notifications",
applications,
settings.GetFactorySettingsForCLI(func() service.Service { return argocdService }, "argocd-notifications-secret", "argocd-notifications-cm", false),
settings.GetFactorySettingsForCLI(func() service.Service { return cdService }, "cd-notifications-secret", "cd-notifications-cm", false),
func(_ context.Context, clientConfig clientcmd.ClientConfig) {
k8sCfg, err := clientConfig.ClientConfig()
if err != nil {
@@ -53,8 +53,8 @@ func NewNotificationsCommand() *cobra.Command {
if err != nil {
log.Fatalf("Failed to get repo-server client TLS configuration: %v", err)
}
tlsConfig.DisableTLS = argocdRepoServerPlaintext
tlsConfig.StrictValidation = argocdRepoServerStrictTLS || tlsConfig.StrictValidation
tlsConfig.DisableTLS = cdRepoServerPlaintext
tlsConfig.StrictValidation = cdRepoServerStrictTLS || tlsConfig.StrictValidation
if !tlsConfig.DisableTLS && tlsConfig.StrictValidation && tlsConfig.Certificates == nil {
pool, err := tls.LoadX509CertPool(
env.StringFromEnv(common.EnvAppConfigPath, common.DefaultAppConfigPath)+"/reposerver/tls/tls.crt",
@@ -65,20 +65,20 @@ func NewNotificationsCommand() *cobra.Command {
}
tlsConfig.Certificates = pool
}
repoClientset := apiclient.NewRepoServerClientset(argocdRepoServer, 5, tlsConfig)
repoClientset := apiclient.NewRepoServerClientset(cdRepoServer, 5, tlsConfig)
dynamicClient, err := dynamic.NewForConfig(k8sCfg)
if err != nil {
log.Fatalf("Failed to create dynamic client: %v", err)
}
argocdService, err = service.NewArgoCDService(kubernetes.NewForConfigOrDie(k8sCfg), dynamicClient, ns, repoClientset)
cdService, err = service.NewArgoCDService(kubernetes.NewForConfigOrDie(k8sCfg), dynamicClient, ns, repoClientset)
if err != nil {
log.Fatalf("Failed to initialize Hanzo CD service: %v", err)
}
})
toolsCommand.PersistentFlags().StringVar(&argocdRepoServer, "argocd-repo-server", common.DefaultRepoServerAddr, "Hanzo CD repo server address")
toolsCommand.PersistentFlags().BoolVar(&argocdRepoServerPlaintext, "argocd-repo-server-plaintext", false, "Use a plaintext client (non-TLS) to connect to repository server")
toolsCommand.PersistentFlags().BoolVar(&argocdRepoServerStrictTLS, "argocd-repo-server-strict-tls", false, "Perform strict validation of TLS certificates when connecting to repo server")
if err := toolsCommand.PersistentFlags().MarkDeprecated("argocd-repo-server-strict-tls", "use --argocd-repo-server-ca-cert-path instead"); err != nil {
toolsCommand.PersistentFlags().StringVar(&cdRepoServer, "cd-repo-server", common.DefaultRepoServerAddr, "Hanzo CD repo server address")
toolsCommand.PersistentFlags().BoolVar(&cdRepoServerPlaintext, "cd-repo-server-plaintext", false, "Use a plaintext client (non-TLS) to connect to repository server")
toolsCommand.PersistentFlags().BoolVar(&cdRepoServerStrictTLS, "cd-repo-server-strict-tls", false, "Perform strict validation of TLS certificates when connecting to repo server")
if err := toolsCommand.PersistentFlags().MarkDeprecated("cd-repo-server-strict-tls", "use --cd-repo-server-ca-cert-path instead"); err != nil {
log.Fatal(err)
}
repoServerClientTLSConfigSrc = tls.AddClientTLSFlagsToCmd(toolsCommand)
@@ -51,13 +51,13 @@ func NewGenProjectSpecCommand() *cobra.Command {
Short: "Generate declarative config for a project",
Example: templates.Examples(`
# Generate a YAML configuration for a project named "myproject"
argocd admin proj generate-spec myproject
cd admin proj generate-spec myproject
# Generate a JSON configuration for a project named "anotherproject" and specify an output file
argocd admin proj generate-spec anotherproject --output json --file config.json
cd admin proj generate-spec anotherproject --output json --file config.json
# Generate a YAML configuration for a project named "someproject" and write it back to the input file
argocd admin proj generate-spec someproject --inline
cd admin proj generate-spec someproject --inline
`),
Run: func(c *cobra.Command, args []string) {
@@ -156,10 +156,10 @@ func NewUpdatePolicyRuleCommand() *cobra.Command {
Use: "update-role-policy PROJECT_GLOB MODIFICATION ACTION",
Short: "Implement bulk project role update. Useful to back-fill existing project policies or remove obsolete actions.",
Example: ` # Add policy that allows executing any action (action/*) to roles which name matches to *deployer* in all projects
argocd admin proj update-role-policy '*' set 'action/*' --role '*deployer*' --resource applications --scope '*' --permission allow
cd admin proj update-role-policy '*' set 'action/*' --role '*deployer*' --resource applications --scope '*' --permission allow
# Remove policy that which manages running (action/*) from all roles which name matches *deployer* in all projects
argocd admin proj update-role-policy '*' remove override --role '*deployer*'
cd admin proj update-role-policy '*' remove override --role '*deployer*'
`,
Run: func(c *cobra.Command, args []string) {
ctx := c.Context()
@@ -42,7 +42,7 @@ func NewProjectAllowListGenCommand() *cobra.Command {
Use: "generate-allow-list CLUSTERROLE_PATH PROJ_NAME",
Short: "Generates project allow list from the specified clusterRole file",
Example: `# Generates project allow list from the specified clusterRole file
argocd admin proj generate-allow-list /path/to/clusterrole.yaml my-project`,
cd admin proj generate-allow-list /path/to/clusterrole.yaml my-project`,
Run: func(c *cobra.Command, args []string) {
if len(args) != 2 {
c.HelpFunc()(c, args)
@@ -20,7 +20,7 @@ import (
)
const (
ArgoCDNamespace = "argocd"
ArgoCDNamespace = "cd"
repoSecretPrefix = "repo"
)
@@ -46,46 +46,46 @@ func NewGenRepoSpecCommand() *cobra.Command {
// For better readability and easier formatting
repoAddExamples := `
# Add a Git repository via SSH using a private key for authentication, ignoring the server's host key:
argocd admin repo generate-spec git@git.example.com:repos/repo --insecure-ignore-host-key --ssh-private-key-path ~/id_rsa
cd admin repo generate-spec git@git.example.com:repos/repo --insecure-ignore-host-key --ssh-private-key-path ~/id_rsa
# Add a Git repository via SSH on a non-default port - need to use ssh:// style URLs here
argocd admin repo generate-spec ssh://[email protected]:2222/repos/repo --ssh-private-key-path ~/id_rsa
cd admin repo generate-spec ssh://[email protected]:2222/repos/repo --ssh-private-key-path ~/id_rsa
# Add a private Git repository via HTTPS using username/password and TLS client certificates:
argocd admin repo generate-spec https://git.example.com/repos/repo --username git --password secret --tls-client-cert-path ~/mycert.crt --tls-client-cert-key-path ~/mycert.key
cd admin repo generate-spec https://git.example.com/repos/repo --username git --password secret --tls-client-cert-path ~/mycert.crt --tls-client-cert-key-path ~/mycert.key
# Add a private Git BitBucket Data Center repository via HTTPS using bearer token:
argocd admin repo generate-spec https://bitbucket.example.com/scm/proj/repo --bearer-token secret-token
cd admin repo generate-spec https://bitbucket.example.com/scm/proj/repo --bearer-token secret-token
# Add a private Git repository via HTTPS using username/password without verifying the server's TLS certificate
argocd admin repo generate-spec https://git.example.com/repos/repo --username git --password secret --insecure-skip-server-verification
cd admin repo generate-spec https://git.example.com/repos/repo --username git --password secret --insecure-skip-server-verification
# Add a public Helm repository named 'stable' via HTTPS
argocd admin repo generate-spec https://charts.helm.sh/stable --type helm --name stable
cd admin repo generate-spec https://charts.helm.sh/stable --type helm --name stable
# Add a private Helm repository named 'stable' via HTTPS
argocd admin repo generate-spec https://charts.helm.sh/stable --type helm --name stable --username test --password test
cd admin repo generate-spec https://charts.helm.sh/stable --type helm --name stable --username test --password test
# Add a private Helm OCI-based repository named 'stable' via HTTPS
argocd admin repo generate-spec helm-oci-registry.cn-zhangjiakou.cr.aliyuncs.com --type helm --name stable --enable-oci --username test --password test
cd admin repo generate-spec helm-oci-registry.cn-zhangjiakou.cr.aliyuncs.com --type helm --name stable --enable-oci --username test --password test
# Add a private HTTPS OCI repository named 'stable'
argocd admin repo generate-spec oci://helm-oci-registry.cn-zhangjiakou.cr.aliyuncs.com --type oci --name stable --username test --password test
cd admin repo generate-spec oci://helm-oci-registry.cn-zhangjiakou.cr.aliyuncs.com --type oci --name stable --username test --password test
# Add a private OCI repository named 'stable' without verifying the server's TLS certificate
argocd admin repo generate-spec oci://helm-oci-registry.cn-zhangjiakou.cr.aliyuncs.com --type oci --name stable --username test --password test --insecure-skip-server-verification
cd admin repo generate-spec oci://helm-oci-registry.cn-zhangjiakou.cr.aliyuncs.com --type oci --name stable --username test --password test --insecure-skip-server-verification
# Add a private HTTP OCI repository named 'stable'
argocd admin repo generate-spec oci://helm-oci-registry.cn-zhangjiakou.cr.aliyuncs.com --type oci --name stable --username test --password test --insecure-oci-force-http
cd admin repo generate-spec oci://helm-oci-registry.cn-zhangjiakou.cr.aliyuncs.com --type oci --name stable --username test --password test --insecure-oci-force-http
# Add a private Git repository on GitHub.com via GitHub App. github-app-installation-id is optional, if not provided, the installation id will be fetched from the GitHub API.
argocd admin repo generate-spec https://git.example.com/repos/repo --github-app-id 1 --github-app-installation-id 2 --github-app-private-key-path test.private-key.pem
cd admin repo generate-spec https://git.example.com/repos/repo --github-app-id 1 --github-app-installation-id 2 --github-app-private-key-path test.private-key.pem
# Add a private Git repository on GitHub Enterprise via GitHub App. github-app-installation-id is optional, if not provided, the installation id will be fetched from the GitHub API.
argocd admin repo generate-spec https://ghe.example.com/repos/repo --github-app-id 1 --github-app-installation-id 2 --github-app-private-key-path test.private-key.pem --github-app-enterprise-base-url https://ghe.example.com/api/v3
cd admin repo generate-spec https://ghe.example.com/repos/repo --github-app-id 1 --github-app-installation-id 2 --github-app-private-key-path test.private-key.pem --github-app-enterprise-base-url https://ghe.example.com/api/v3
# Add a private Git repository on Google Cloud Sources via GCP service account credentials
argocd admin repo generate-spec https://source.developers.google.com/p/my-google-cloud-project/r/my-repo --gcp-service-account-key-path service-account-key.json
cd admin repo generate-spec https://source.developers.google.com/p/my-google-cloud-project/r/my-repo --gcp-service-account-key-path service-account-key.json
`
command := &cobra.Command{
@@ -27,7 +27,7 @@ import (
"github.com/hanzoai/deploy/common"
applicationpkg "github.com/hanzoai/deploy/pkg/apiclient/application"
"github.com/hanzoai/deploy/pkg/apis/application/v1alpha1"
"github.com/hanzoai/deploy/util/argo/normalizers"
"github.com/hanzoai/deploy/util/cd/normalizers"
"github.com/hanzoai/deploy/util/cli"
"github.com/hanzoai/deploy/util/errors"
"github.com/hanzoai/deploy/util/lua"
@@ -35,8 +35,8 @@ import (
)
type settingsOpts struct {
argocdCMPath string
argocdSecretPath string
cdCMPath string
cdSecretPath string
loadClusterSettings bool
clientConfig clientcmd.ClientConfig
}
@@ -60,60 +60,60 @@ func setSettingsMeta(obj metav1.Object) {
if labels == nil {
labels = make(map[string]string)
}
labels["app.kubernetes.io/part-of"] = "argocd"
labels["app.kubernetes.io/part-of"] = "cd"
obj.SetLabels(labels)
}
func (opts *settingsOpts) createSettingsManager(ctx context.Context) (*settings.SettingsManager, error) {
var argocdCM *corev1.ConfigMap
var cdCM *corev1.ConfigMap
switch {
case opts.argocdCMPath == "" && !opts.loadClusterSettings:
return nil, stderrors.New("either --argocd-cm-path must be provided or --load-cluster-settings must be set to true")
case opts.argocdCMPath == "":
case opts.cdCMPath == "" && !opts.loadClusterSettings:
return nil, stderrors.New("either --cd-cm-path must be provided or --load-cluster-settings must be set to true")
case opts.cdCMPath == "":
realClientset, ns, err := opts.getK8sClient()
if err != nil {
return nil, err
}
argocdCM, err = realClientset.CoreV1().ConfigMaps(ns).Get(ctx, common.ArgoCDConfigMapName, metav1.GetOptions{})
cdCM, err = realClientset.CoreV1().ConfigMaps(ns).Get(ctx, common.ArgoCDConfigMapName, metav1.GetOptions{})
if err != nil {
return nil, err
}
default:
data, err := os.ReadFile(opts.argocdCMPath)
data, err := os.ReadFile(opts.cdCMPath)
if err != nil {
return nil, err
}
err = yaml.Unmarshal(data, &argocdCM)
err = yaml.Unmarshal(data, &cdCM)
if err != nil {
return nil, err
}
}
setSettingsMeta(argocdCM)
setSettingsMeta(cdCM)
var argocdSecret *corev1.Secret
var cdSecret *corev1.Secret
switch {
case opts.argocdSecretPath != "":
data, err := os.ReadFile(opts.argocdSecretPath)
case opts.cdSecretPath != "":
data, err := os.ReadFile(opts.cdSecretPath)
if err != nil {
return nil, err
}
err = yaml.Unmarshal(data, &argocdSecret)
err = yaml.Unmarshal(data, &cdSecret)
if err != nil {
return nil, err
}
setSettingsMeta(argocdSecret)
setSettingsMeta(cdSecret)
case opts.loadClusterSettings:
realClientset, ns, err := opts.getK8sClient()
if err != nil {
return nil, err
}
argocdSecret, err = realClientset.CoreV1().Secrets(ns).Get(ctx, common.ArgoCDSecretName, metav1.GetOptions{})
cdSecret, err = realClientset.CoreV1().Secrets(ns).Get(ctx, common.ArgoCDSecretName, metav1.GetOptions{})
if err != nil {
return nil, err
}
default:
argocdSecret = &corev1.Secret{
cdSecret = &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: common.ArgoCDSecretName,
},
@@ -123,8 +123,8 @@ func (opts *settingsOpts) createSettingsManager(ctx context.Context) (*settings.
},
}
}
setSettingsMeta(argocdSecret)
clientset := fake.NewClientset(argocdSecret, argocdCM)
setSettingsMeta(cdSecret)
clientset := fake.NewClientset(cdSecret, cdCM)
manager := settings.NewSettingsManager(ctx, clientset, "default")
errors.CheckError(manager.ResyncInformers())
@@ -167,8 +167,8 @@ func NewSettingsCommand() *cobra.Command {
command.AddCommand(NewRBACCommand())
opts.clientConfig = cli.AddKubectlFlagsToCmd(command)
command.PersistentFlags().StringVar(&opts.argocdCMPath, "argocd-cm-path", "", "Path to local argocd-cm.yaml file")
command.PersistentFlags().StringVar(&opts.argocdSecretPath, "argocd-secret-path", "", "Path to local argocd-secret.yaml file")
command.PersistentFlags().StringVar(&opts.cdCMPath, "cd-cm-path", "", "Path to local cd-cm.yaml file")
command.PersistentFlags().StringVar(&opts.cdSecretPath, "cd-secret-path", "", "Path to local cd-secret.yaml file")
command.PersistentFlags().BoolVar(&opts.loadClusterSettings, "load-cluster-settings", false,
"Indicates that config map and secret should be loaded from cluster unless local file path is provided")
return command
@@ -277,13 +277,13 @@ func NewValidateSettingsCommand(cmdCtx commandContext) *cobra.Command {
command := &cobra.Command{
Use: "validate",
Short: "Validate settings",
Long: "Validates settings specified in 'argocd-cm' ConfigMap and 'argocd-secret' Secret",
Long: "Validates settings specified in 'cd-cm' ConfigMap and 'cd-secret' Secret",
Example: `
#Validates all settings in the specified YAML file
argocd admin settings validate --argocd-cm-path ./argocd-cm.yaml
cd admin settings validate --cd-cm-path ./cd-cm.yaml
#Validates accounts and plugins settings in Kubernetes cluster of current kubeconfig context
argocd admin settings validate --group accounts --group plugins --load-cluster-settings`,
cd admin settings validate --group accounts --group plugins --load-cluster-settings`,
Run: func(c *cobra.Command, _ []string) {
ctx := c.Context()
@@ -391,9 +391,9 @@ func NewResourceIgnoreDifferencesCommand(cmdCtx commandContext) *cobra.Command {
command := &cobra.Command{
Use: "ignore-differences RESOURCE_YAML_PATH",
Short: "Renders fields excluded from diffing",
Long: "Renders ignored fields using the 'ignoreDifferences' setting specified in the 'resource.customizations' field of 'argocd-cm' ConfigMap",
Long: "Renders ignored fields using the 'ignoreDifferences' setting specified in the 'resource.customizations' field of 'cd-cm' ConfigMap",
Example: `
argocd admin settings resource-overrides ignore-differences ./deploy.yaml --argocd-cm-path ./argocd-cm.yaml`,
cd admin settings resource-overrides ignore-differences ./deploy.yaml --cd-cm-path ./cd-cm.yaml`,
Run: func(c *cobra.Command, args []string) {
ctx := c.Context()
@@ -442,9 +442,9 @@ func NewResourceIgnoreResourceUpdatesCommand(cmdCtx commandContext) *cobra.Comma
command := &cobra.Command{
Use: "ignore-resource-updates RESOURCE_YAML_PATH",
Short: "Renders fields excluded from resource updates",
Long: "Renders ignored fields using the 'ignoreResourceUpdates' setting specified in the 'resource.customizations' field of 'argocd-cm' ConfigMap",
Long: "Renders ignored fields using the 'ignoreResourceUpdates' setting specified in the 'resource.customizations' field of 'cd-cm' ConfigMap",
Example: `
argocd admin settings resource-overrides ignore-resource-updates ./deploy.yaml --argocd-cm-path ./argocd-cm.yaml`,
cd admin settings resource-overrides ignore-resource-updates ./deploy.yaml --cd-cm-path ./cd-cm.yaml`,
Run: func(c *cobra.Command, args []string) {
ctx := c.Context()
@@ -489,9 +489,9 @@ func NewResourceHealthCommand(cmdCtx commandContext) *cobra.Command {
command := &cobra.Command{
Use: "health RESOURCE_YAML_PATH",
Short: "Assess resource health",
Long: "Assess resource health using the lua script configured in the 'resource.customizations' field of 'argocd-cm' ConfigMap",
Long: "Assess resource health using the lua script configured in the 'resource.customizations' field of 'cd-cm' ConfigMap",
Example: `
argocd admin settings resource-overrides health ./deploy.yaml --argocd-cm-path ./argocd-cm.yaml`,
cd admin settings resource-overrides health ./deploy.yaml --cd-cm-path ./cd-cm.yaml`,
Run: func(c *cobra.Command, args []string) {
ctx := c.Context()
@@ -522,9 +522,9 @@ func NewResourceActionListCommand(cmdCtx commandContext) *cobra.Command {
command := &cobra.Command{
Use: "list-actions RESOURCE_YAML_PATH",
Short: "List available resource actions",
Long: "List actions available for given resource action using the lua scripts configured in the 'resource.customizations' field of 'argocd-cm' ConfigMap and outputs updated fields",
Long: "List actions available for given resource action using the lua scripts configured in the 'resource.customizations' field of 'cd-cm' ConfigMap and outputs updated fields",
Example: `
argocd admin settings resource-overrides action list /tmp/deploy.yaml --argocd-cm-path ./argocd-cm.yaml`,
cd admin settings resource-overrides action list /tmp/deploy.yaml --cd-cm-path ./cd-cm.yaml`,
Run: func(c *cobra.Command, args []string) {
ctx := c.Context()
@@ -569,9 +569,9 @@ func NewResourceActionRunCommand(cmdCtx commandContext) *cobra.Command {
Use: "run-action RESOURCE_YAML_PATH ACTION",
Aliases: []string{"action"},
Short: "Executes resource action",
Long: "Executes resource action using the lua script configured in the 'resource.customizations' field of 'argocd-cm' ConfigMap and outputs updated fields",
Long: "Executes resource action using the lua script configured in the 'resource.customizations' field of 'cd-cm' ConfigMap and outputs updated fields",
Example: `
argocd admin settings resource-overrides action /tmp/deploy.yaml restart --argocd-cm-path ./argocd-cm.yaml`,
cd admin settings resource-overrides action /tmp/deploy.yaml restart --cd-cm-path ./cd-cm.yaml`,
Run: func(c *cobra.Command, args []string) {
ctx := c.Context()
@@ -145,19 +145,19 @@ something.
Example: `
# Check whether role some:role has permissions to create an application in the
# 'default' project, using a local policy.csv file
argocd admin settings rbac can some:role create application 'default/app' --policy-file policy.csv
cd admin settings rbac can some:role create application 'default/app' --policy-file policy.csv
# Policy file can also be K8s config map with data keys like argocd-rbac-cm,
# Policy file can also be K8s config map with data keys like cd-rbac-cm,
# i.e. 'policy.csv' and (optionally) 'policy.default'
argocd admin settings rbac can some:role create application 'default/app' --policy-file argocd-rbac-cm.yaml
cd admin settings rbac can some:role create application 'default/app' --policy-file cd-rbac-cm.yaml
# If --policy-file is not given, the ConfigMap 'argocd-rbac-cm' from K8s is
# used. You need to specify the argocd namespace, and make sure that your
# If --policy-file is not given, the ConfigMap 'cd-rbac-cm' from K8s is
# used. You need to specify the cd namespace, and make sure that your
# current Kubernetes context is pointing to the cluster Hanzo CD is running in
argocd admin settings rbac can some:role create application 'default/app' --namespace argocd
cd admin settings rbac can some:role create application 'default/app' --namespace cd
# You can override a possibly configured default role
argocd admin settings rbac can someuser create application 'default/app' --default-role role:readonly
cd admin settings rbac can someuser create application 'default/app' --default-role role:readonly
`,
Run: func(c *cobra.Command, args []string) {
@@ -247,15 +247,15 @@ a local file or a K8s ConfigMap in the provided namespace, and in either CSV or
`,
Example: `
# Check whether a given policy file is valid using a local policy.csv file.
argocd admin settings rbac validate --policy-file policy.csv
cd admin settings rbac validate --policy-file policy.csv
# Policy file can also be K8s config map with data keys like argocd-rbac-cm,
# Policy file can also be K8s config map with data keys like cd-rbac-cm,
# i.e. 'policy.csv' and (optionally) 'policy.default'
argocd admin settings rbac validate --policy-file argocd-rbac-cm.yaml
cd admin settings rbac validate --policy-file cd-rbac-cm.yaml
# If --policy-file is not given, and instead --namespace is giventhe ConfigMap 'argocd-rbac-cm'
# If --policy-file is not given, and instead --namespace is giventhe ConfigMap 'cd-rbac-cm'
# from K8s is used.
argocd admin settings rbac validate --namespace argocd
cd admin settings rbac validate --namespace cd
# Either --policy-file or --namespace must be given.
`,
@@ -372,7 +372,7 @@ func getPolicyConfigMap(ctx context.Context, client kubernetes.Interface, namesp
// checkPolicy checks whether given subject is allowed to execute specified
// action against specified resource
func checkPolicy(subject, action, resource, subResource, builtinPolicy, userPolicy, defaultRole, matchMode string, strict bool) bool {
enf := rbac.NewEnforcer(nil, "argocd", "argocd-rbac-cm", nil)
enf := rbac.NewEnforcer(nil, "cd", "cd-rbac-cm", nil)
enf.SetDefaultRole(defaultRole)
enf.SetMatchMode(matchMode)
if builtinPolicy != "" {
@@ -126,7 +126,7 @@ func Test_PolicyFromCSV(t *testing.T) {
func Test_PolicyFromYAML(t *testing.T) {
ctx := t.Context()
uPol, dRole, matchMode := getPolicy(ctx, "testdata/rbac/argocd-rbac-cm.yaml", nil, "")
uPol, dRole, matchMode := getPolicy(ctx, "testdata/rbac/cd-rbac-cm.yaml", nil, "")
require.NotEmpty(t, uPol)
require.Equal(t, "role:unknown", dRole)
require.Empty(t, matchMode)
@@ -141,15 +141,15 @@ func Test_PolicyFromK8s(t *testing.T) {
require.NoError(t, err)
kubeclientset := fake.NewClientset(&corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: "argocd-rbac-cm",
Namespace: "argocd",
Name: "cd-rbac-cm",
Namespace: "cd",
},
Data: map[string]string{
"policy.csv": string(data),
"policy.default": "role:unknown",
},
})
uPol, dRole, matchMode := getPolicy(ctx, "", kubeclientset, "argocd")
uPol, dRole, matchMode := getPolicy(ctx, "", kubeclientset, "cd")
require.NotEmpty(t, uPol)
require.Equal(t, "role:unknown", dRole)
require.Empty(t, matchMode)
@@ -232,8 +232,8 @@ p, role:user, exec, create, .*/.*, allow
kubeclientset := fake.NewClientset(&corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: "argocd-rbac-cm",
Namespace: "argocd",
Name: "cd-rbac-cm",
Namespace: "cd",
},
Data: map[string]string{
"policy.csv": policy,
@@ -241,7 +241,7 @@ p, role:user, exec, create, .*/.*, allow
"policy.matchMode": "regex",
},
})
uPol, dRole, matchMode := getPolicy(ctx, "", kubeclientset, "argocd")
uPol, dRole, matchMode := getPolicy(ctx, "", kubeclientset, "cd")
require.NotEmpty(t, uPol)
require.Equal(t, "role:unknown", dRole)
require.Equal(t, "regex", matchMode)
@@ -52,7 +52,7 @@ func newSettingsManager(ctx context.Context, data map[string]string) *settings.S
Namespace: "default",
Name: common.ArgoCDConfigMapName,
Labels: map[string]string{
"app.kubernetes.io/part-of": "argocd",
"app.kubernetes.io/part-of": "cd",
},
},
Data: data,
@@ -94,13 +94,13 @@ func TestCreateSettingsManager(t *testing.T) {
f, closer, err := tempFile(`apiVersion: v1
kind: ConfigMap
metadata:
name: argocd-cm
name: cd-cm
data:
url: https://myargocd.com`)
url: https://mycd.com`)
require.NoError(t, err)
defer utilio.Close(closer)
opts := settingsOpts{argocdCMPath: f}
opts := settingsOpts{cdCMPath: f}
settingsManager, err := opts.createSettingsManager(ctx)
require.NoError(t, err)
@@ -108,7 +108,7 @@ data:
argoCDSettings, err := settingsManager.GetSettings()
require.NoError(t, err)
assert.Equal(t, "https://myargocd.com", argoCDSettings.URL)
assert.Equal(t, "https://mycd.com", argoCDSettings.URL)
}
func TestValidator(t *testing.T) {
@@ -124,7 +124,7 @@ func TestValidator(t *testing.T) {
"General_OIDCConfigured": {
validator: "general",
data: map[string]string{
"url": "https://myargocd.com",
"url": "https://mycd.com",
"oidc.config": `
name: Okta
issuer: https://dev-123456.oktapreview.com
@@ -31,11 +31,11 @@ import (
k8swatch "k8s.io/apimachinery/pkg/watch"
"sigs.k8s.io/yaml"
"github.com/hanzoai/deploy/cmd/argocd/commands/headless"
"github.com/hanzoai/deploy/cmd/argocd/commands/utils"
"github.com/hanzoai/deploy/cmd/cd/commands/headless"
"github.com/hanzoai/deploy/cmd/cd/commands/utils"
cmdutil "github.com/hanzoai/deploy/cmd/util"
argocommon "github.com/hanzoai/deploy/common"
argocdclient "github.com/hanzoai/deploy/pkg/apiclient"
cdclient "github.com/hanzoai/deploy/pkg/apiclient"
"github.com/hanzoai/deploy/pkg/apiclient/application"
resourceutil "github.com/hanzoai/deploy/gitops-engine/pkg/sync/resource"
@@ -44,8 +44,8 @@ import (
projectpkg "github.com/hanzoai/deploy/pkg/apiclient/project"
"github.com/hanzoai/deploy/pkg/apiclient/settings"
argoappv1 "github.com/hanzoai/deploy/pkg/apis/application/v1alpha1"
"github.com/hanzoai/deploy/util/argo"
"github.com/hanzoai/deploy/util/argo/normalizers"
"github.com/hanzoai/deploy/util/cd"
"github.com/hanzoai/deploy/util/cd/normalizers"
"github.com/hanzoai/deploy/util/cli"
"github.com/hanzoai/deploy/util/errors"
"github.com/hanzoai/deploy/util/git"
@@ -55,19 +55,19 @@ import (
"github.com/hanzoai/deploy/util/text/label"
)
// NewApplicationCommand returns a new instance of an `argocd app` command
func NewApplicationCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
// NewApplicationCommand returns a new instance of an `cd app` command
func NewApplicationCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
command := &cobra.Command{
Use: "app",
Short: "Manage applications",
Example: ` # List all the applications.
argocd app list
cd app list
# Get the details of a application
argocd app get my-app
cd app get my-app
# Set an override parameter
argocd app set my-app -p image.tag=v1.0.1`,
cd app set my-app -p image.tag=v1.0.1`,
Run: func(c *cobra.Command, args []string) {
c.HelpFunc()(c, args)
os.Exit(1)
@@ -110,8 +110,8 @@ type watchOpts struct {
hydrated bool
}
// NewApplicationCreateCommand returns a new instance of an `argocd app create` command
func NewApplicationCreateCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
// NewApplicationCreateCommand returns a new instance of an `cd app create` command
func NewApplicationCreateCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var (
appOpts cmdutil.AppOptions
fileURL string
@@ -126,29 +126,29 @@ func NewApplicationCreateCommand(clientOpts *argocdclient.ClientOptions) *cobra.
Use: "create APPNAME",
Short: "Create an application",
Example: ` # Create a directory app
argocd app create guestbook --repo https://github.com/argoproj/argocd-example-apps.git --path guestbook --dest-namespace default --dest-server https://kubernetes.default.svc --directory-recurse
cd app create guestbook --repo https://github.com/argoproj/argocd-example-apps.git --path guestbook --dest-namespace default --dest-server https://kubernetes.default.svc --directory-recurse
# Create a Jsonnet app
argocd app create jsonnet-guestbook --repo https://github.com/argoproj/argocd-example-apps.git --path jsonnet-guestbook --dest-namespace default --dest-server https://kubernetes.default.svc --jsonnet-ext-str replicas=2
cd app create jsonnet-guestbook --repo https://github.com/argoproj/argocd-example-apps.git --path jsonnet-guestbook --dest-namespace default --dest-server https://kubernetes.default.svc --jsonnet-ext-str replicas=2
# Create a Helm app
argocd app create helm-guestbook --repo https://github.com/argoproj/argocd-example-apps.git --path helm-guestbook --dest-namespace default --dest-server https://kubernetes.default.svc --helm-set replicaCount=2
cd app create helm-guestbook --repo https://github.com/argoproj/argocd-example-apps.git --path helm-guestbook --dest-namespace default --dest-server https://kubernetes.default.svc --helm-set replicaCount=2
# Create a Helm app from a Helm repo
argocd app create nginx-ingress --repo https://charts.helm.sh/stable --helm-chart nginx-ingress --revision 1.24.3 --dest-namespace default --dest-server https://kubernetes.default.svc
cd app create nginx-ingress --repo https://charts.helm.sh/stable --helm-chart nginx-ingress --revision 1.24.3 --dest-namespace default --dest-server https://kubernetes.default.svc
# Create a Kustomize app
argocd app create kustomize-guestbook --repo https://github.com/argoproj/argocd-example-apps.git --path kustomize-guestbook --dest-namespace default --dest-server https://kubernetes.default.svc --kustomize-image quay.io/argoprojlabs/argocd-e2e-container:0.1
cd app create kustomize-guestbook --repo https://github.com/argoproj/argocd-example-apps.git --path kustomize-guestbook --dest-namespace default --dest-server https://kubernetes.default.svc --kustomize-image quay.io/argoprojlabs/cd-e2e-container:0.1
# Create a MultiSource app while yaml file contains an application with multiple sources
argocd app create guestbook --file <path-to-yaml-file>
cd app create guestbook --file <path-to-yaml-file>
# Create a app using a custom tool:
argocd app create kasane --repo https://github.com/argoproj/argocd-example-apps.git --path plugins/kasane --dest-namespace default --dest-server https://kubernetes.default.svc --config-management-plugin kasane`,
cd app create kasane --repo https://github.com/argoproj/argocd-example-apps.git --path plugins/kasane --dest-namespace default --dest-server https://kubernetes.default.svc --config-management-plugin kasane`,
Run: func(c *cobra.Command, args []string) {
ctx := c.Context()
argocdClient := headless.NewClientOrDie(clientOpts, c)
cdClient := headless.NewClientOrDie(clientOpts, c)
apps, err := cmdutil.ConstructApps(fileURL, appName, labels, annotations, args, appOpts, c.Flags())
errors.CheckError(err)
@@ -163,7 +163,7 @@ func NewApplicationCreateCommand(clientOpts *argocdclient.ClientOptions) *cobra.
if setFinalizer {
app.Finalizers = append(app.Finalizers, argoappv1.ResourcesFinalizerName)
}
conn, appIf := argocdClient.NewApplicationClientOrDie()
conn, appIf := cdClient.NewApplicationClientOrDie()
defer utilio.Close(conn)
appCreateRequest := application.ApplicationCreateRequest{
Application: app,
@@ -295,7 +295,7 @@ func parentChildDetails(ctx context.Context, appIf application.ApplicationServic
return mapUIDToNode, mapParentToChild, parentNode
}
func printHeader(ctx context.Context, acdClient argocdclient.Client, app *argoappv1.Application, windows *argoappv1.SyncWindows, showOperation bool, showParams bool, sourcePosition int) {
func printHeader(ctx context.Context, acdClient cdclient.Client, app *argoappv1.Application, windows *argoappv1.SyncWindows, showOperation bool, showParams bool, sourcePosition int) {
appURL := getAppURL(ctx, acdClient, app.Name)
printAppSummaryTable(app, appURL, windows)
@@ -326,8 +326,8 @@ func getSourceNameToPositionMap(app *argoappv1.Application) map[string]int64 {
return sourceNameToPosition
}
// NewApplicationGetCommand returns a new instance of an `argocd app get` command
func NewApplicationGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
// NewApplicationGetCommand returns a new instance of an `cd app get` command
func NewApplicationGetCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var (
refresh bool
hardRefresh bool
@@ -344,37 +344,37 @@ func NewApplicationGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Com
Short: "Get application details",
Example: templates.Examples(`
# Get basic details about the application "my-app" in wide format
argocd app get my-app -o wide
cd app get my-app -o wide
# Get detailed information about the application "my-app" in YAML format
argocd app get my-app -o yaml
cd app get my-app -o yaml
# Get details of the application "my-app" in JSON format
argocd get my-app -o json
cd get my-app -o json
# Get application details and include information about the current operation
argocd app get my-app --show-operation
cd app get my-app --show-operation
# Show application parameters and overrides
argocd app get my-app --show-params
cd app get my-app --show-params
# Show application parameters and overrides for a source at position 1 under spec.sources of app my-app
argocd app get my-app --show-params --source-position 1
cd app get my-app --show-params --source-position 1
# Show application parameters and overrides for a source named "test"
argocd app get my-app --show-params --source-name test
cd app get my-app --show-params --source-name test
# Refresh application data when retrieving
argocd app get my-app --refresh
cd app get my-app --refresh
# Perform a hard refresh, including refreshing application data and target manifests cache
argocd app get my-app --hard-refresh
cd app get my-app --hard-refresh
# Get application details and display them in a tree format
argocd app get my-app --output tree
cd app get my-app --output tree
# Get application details and display them in a detailed tree format
argocd app get my-app --output tree=detailed
cd app get my-app --output tree=detailed
`),
Run: func(c *cobra.Command, args []string) {
@@ -388,7 +388,7 @@ func NewApplicationGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Com
conn, appIf := acdClient.NewApplicationClientOrDie()
defer utilio.Close(conn)
appName, appNs := argo.ParseFromQualifiedName(args[0], appNamespace)
appName, appNs := cd.ParseFromQualifiedName(args[0], appNamespace)
if timeout != 0 {
time.AfterFunc(time.Duration(timeout)*time.Second, func() {
@@ -512,7 +512,7 @@ func NewApplicationGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Com
}
// NewApplicationLogsCommand returns logs of application pods
func NewApplicationLogsCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
func NewApplicationLogsCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var (
group string
kind string
@@ -533,43 +533,43 @@ func NewApplicationLogsCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
Short: "Get logs of application pods",
Example: templates.Examples(`
# Get logs of pods associated with the application "my-app"
argocd app logs my-app
cd app logs my-app
# Get logs of pods associated with the application "my-app" in a specific resource group
argocd app logs my-app --group my-group
cd app logs my-app --group my-group
# Get logs of pods associated with the application "my-app" in a specific resource kind
argocd app logs my-app --kind my-kind
cd app logs my-app --kind my-kind
# Get logs of pods associated with the application "my-app" in a specific namespace
argocd app logs my-app --namespace my-namespace
cd app logs my-app --namespace my-namespace
# Get logs of pods associated with the application "my-app" for a specific resource name
argocd app logs my-app --name my-resource
cd app logs my-app --name my-resource
# Stream logs in real-time for the application "my-app"
argocd app logs my-app -f
cd app logs my-app -f
# Get the last N lines of logs for the application "my-app"
argocd app logs my-app --tail 100
cd app logs my-app --tail 100
# Get logs since a specified number of seconds ago
argocd app logs my-app --since-seconds 3600
cd app logs my-app --since-seconds 3600
# Get logs until a specified time (format: "2023-10-10T15:30:00Z")
argocd app logs my-app --until-time "2023-10-10T15:30:00Z"
cd app logs my-app --until-time "2023-10-10T15:30:00Z"
# Filter logs to show only those containing a specific string
argocd app logs my-app --filter "error"
cd app logs my-app --filter "error"
# Filter logs to show only those containing a specific string and match case
argocd app logs my-app --filter "error" --match-case
cd app logs my-app --filter "error" --match-case
# Get logs for a specific container within the pods
argocd app logs my-app -c my-container
cd app logs my-app -c my-container
# Get previously terminated container logs
argocd app logs my-app -p
cd app logs my-app -p
`),
Run: func(c *cobra.Command, args []string) {
@@ -582,7 +582,7 @@ func NewApplicationLogsCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
acdClient := headless.NewClientOrDie(clientOpts, c)
conn, appIf := acdClient.NewApplicationClientOrDie()
defer utilio.Close(conn)
appName, appNs := argo.ParseFromQualifiedName(args[0], appNamespace)
appName, appNs := cd.ParseFromQualifiedName(args[0], appNamespace)
retry := true
for retry {
@@ -753,7 +753,7 @@ func printAppConditions(w io.Writer, app *argoappv1.Application) {
}
// appURLDefault returns the default URL of an application
func appURLDefault(acdClient argocdclient.Client, appName string) string {
func appURLDefault(acdClient cdclient.Client, appName string) string {
var scheme string
opts := acdClient.ClientOptions()
server := opts.ServerAddr
@@ -769,7 +769,7 @@ func appURLDefault(acdClient argocdclient.Client, appName string) string {
}
// getAppURL returns the URL of an application
func getAppURL(ctx context.Context, acdClient argocdclient.Client, appName string) string {
func getAppURL(ctx context.Context, acdClient cdclient.Client, appName string) string {
conn, settingsIf := acdClient.NewSettingsClientOrDie()
defer utilio.Close(conn)
argoSettings, err := settingsIf.Get(ctx, &settings.SettingsQuery{})
@@ -834,8 +834,8 @@ func getServer(app *argoappv1.Application) string {
return app.Spec.Destination.Server
}
// NewApplicationSetCommand returns a new instance of an `argocd app set` command
func NewApplicationSetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
// NewApplicationSetCommand returns a new instance of an `cd app set` command
func NewApplicationSetCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var (
appOpts cmdutil.AppOptions
appNamespace string
@@ -847,19 +847,19 @@ func NewApplicationSetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Com
Short: "Set application parameters",
Example: templates.Examples(`
# Set application parameters for the application "my-app"
argocd app set my-app --parameter key1=value1 --parameter key2=value2
cd app set my-app --parameter key1=value1 --parameter key2=value2
# Set and validate application parameters for "my-app"
argocd app set my-app --parameter key1=value1 --parameter key2=value2 --validate
cd app set my-app --parameter key1=value1 --parameter key2=value2 --validate
# Set and override application parameters for a source at position 1 under spec.sources of app my-app. source-position starts at 1.
argocd app set my-app --source-position 1 --repo https://github.com/argoproj/argocd-example-apps.git
cd app set my-app --source-position 1 --repo https://github.com/argoproj/argocd-example-apps.git
# Set and override application parameters for a source named "test" under spec.sources of app my-app.
argocd app set my-app --source-name test --repo https://github.com/argoproj/argocd-example-apps.git
cd app set my-app --source-name test --repo https://github.com/argoproj/argocd-example-apps.git
# Set application parameters and specify the namespace
argocd app set my-app --parameter key1=value1 --parameter key2=value2 --namespace my-namespace
cd app set my-app --parameter key1=value1 --parameter key2=value2 --namespace my-namespace
`),
Run: func(c *cobra.Command, args []string) {
@@ -869,9 +869,9 @@ func NewApplicationSetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Com
c.HelpFunc()(c, args)
os.Exit(1)
}
appName, appNs := argo.ParseFromQualifiedName(args[0], appNamespace)
argocdClient := headless.NewClientOrDie(clientOpts, c)
conn, appIf := argocdClient.NewApplicationClientOrDie()
appName, appNs := cd.ParseFromQualifiedName(args[0], appNamespace)
cdClient := headless.NewClientOrDie(clientOpts, c)
conn, appIf := cdClient.NewApplicationClientOrDie()
defer utilio.Close(conn)
app, err := appIf.Get(ctx, &application.ApplicationQuery{Name: &appName, AppNamespace: &appNs})
errors.CheckError(err)
@@ -952,8 +952,8 @@ func (o *unsetOpts) KustomizeIsZero() bool {
len(o.kustomizeReplicas) == 0
}
// NewApplicationUnsetCommand returns a new instance of an `argocd app unset` command
func NewApplicationUnsetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
// NewApplicationUnsetCommand returns a new instance of an `cd app unset` command
func NewApplicationUnsetCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var sourcePosition int
var sourceName string
appOpts := cmdutil.AppOptions{}
@@ -963,19 +963,19 @@ func NewApplicationUnsetCommand(clientOpts *argocdclient.ClientOptions) *cobra.C
Use: "unset APPNAME parameters",
Short: "Unset application parameters",
Example: ` # Unset kustomize override kustomize image
argocd app unset my-app --kustomize-image=alpine
cd app unset my-app --kustomize-image=alpine
# Unset kustomize override suffix
argocd app unset my-app --namesuffix
cd app unset my-app --namesuffix
# Unset kustomize override suffix for source at position 1 under spec.sources of app my-app. source-position starts at 1.
argocd app unset my-app --source-position 1 --namesuffix
cd app unset my-app --source-position 1 --namesuffix
# Unset kustomize override suffix for source named "test" under spec.sources of app my-app.
argocd app unset my-app --source-name test --namesuffix
cd app unset my-app --source-name test --namesuffix
# Unset parameter override
argocd app unset my-app -p COMPONENT=PARAM`,
cd app unset my-app -p COMPONENT=PARAM`,
Run: func(c *cobra.Command, args []string) {
ctx := c.Context()
@@ -988,7 +988,7 @@ func NewApplicationUnsetCommand(clientOpts *argocdclient.ClientOptions) *cobra.C
errors.Fatal(errors.ErrorGeneric, "Only one of source-position and source-name can be specified.")
}
appName, appNs := argo.ParseFromQualifiedName(args[0], appNamespace)
appName, appNs := cd.ParseFromQualifiedName(args[0], appNamespace)
conn, appIf := headless.NewClientOrDie(clientOpts, c).NewApplicationClientOrDie()
defer utilio.Close(conn)
app, err := appIf.Get(ctx, &application.ApplicationQuery{Name: &appName, AppNamespace: &appNs})
@@ -1258,8 +1258,8 @@ func findAndPrintDiff(
return foundDiffs
}
// NewApplicationDeleteCommand returns a new instance of an `argocd app delete` command
func NewApplicationDeleteCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
// NewApplicationDeleteCommand returns a new instance of an `cd app delete` command
func NewApplicationDeleteCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var (
cascade bool
noPrompt bool
@@ -1272,17 +1272,17 @@ func NewApplicationDeleteCommand(clientOpts *argocdclient.ClientOptions) *cobra.
Use: "delete APPNAME",
Short: "Delete an application",
Example: ` # Delete an app
argocd app delete my-app
cd app delete my-app
# Delete multiple apps
argocd app delete my-app other-app
cd app delete my-app other-app
# Delete apps by label
argocd app delete -l app.kubernetes.io/instance=my-app
argocd app delete -l app.kubernetes.io/instance!=my-app
argocd app delete -l app.kubernetes.io/instance
argocd app delete -l '!app.kubernetes.io/instance'
argocd app delete -l 'app.kubernetes.io/instance notin (my-app,other-app)'`,
cd app delete -l app.kubernetes.io/instance=my-app
cd app delete -l app.kubernetes.io/instance!=my-app
cd app delete -l app.kubernetes.io/instance
cd app delete -l '!app.kubernetes.io/instance'
cd app delete -l 'app.kubernetes.io/instance notin (my-app,other-app)'`,
Run: func(c *cobra.Command, args []string) {
ctx := c.Context()
@@ -1317,7 +1317,7 @@ func NewApplicationDeleteCommand(clientOpts *argocdclient.ClientOptions) *cobra.
)
for _, appFullName := range appNames {
appName, appNs := argo.ParseFromQualifiedName(appFullName, appNamespace)
appName, appNs := cd.ParseFromQualifiedName(appFullName, appNamespace)
appDeleteReq := application.ApplicationDeleteRequest{
Name: &appName,
AppNamespace: &appNs,
@@ -1356,7 +1356,7 @@ func NewApplicationDeleteCommand(clientOpts *argocdclient.ClientOptions) *cobra.
return command
}
func checkForDeleteEvent(ctx context.Context, acdClient argocdclient.Client, appFullName string) {
func checkForDeleteEvent(ctx context.Context, acdClient cdclient.Client, appFullName string) {
appEventCh := acdClient.WatchApplicationWithRetry(ctx, appFullName, "")
for appEvent := range appEventCh {
if appEvent.Type == k8swatch.Deleted {
@@ -1403,8 +1403,8 @@ func printApplicationTable(apps []argoappv1.Application, output *string) {
_ = w.Flush()
}
// NewApplicationListCommand returns a new instance of an `argocd app list` command
func NewApplicationListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
// NewApplicationListCommand returns a new instance of an `cd app list` command
func NewApplicationListCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var (
output string
selector string
@@ -1418,14 +1418,14 @@ func NewApplicationListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
Use: "list",
Short: "List applications",
Example: ` # List all apps
argocd app list
cd app list
# List apps by label, in this example we listing apps that are children of another app (aka app-of-apps)
argocd app list -l app.kubernetes.io/instance=my-app
argocd app list -l app.kubernetes.io/instance!=my-app
argocd app list -l app.kubernetes.io/instance
argocd app list -l '!app.kubernetes.io/instance'
argocd app list -l 'app.kubernetes.io/instance notin (my-app,other-app)'`,
cd app list -l app.kubernetes.io/instance=my-app
cd app list -l app.kubernetes.io/instance!=my-app
cd app list -l app.kubernetes.io/instance
cd app list -l '!app.kubernetes.io/instance'
cd app list -l 'app.kubernetes.io/instance notin (my-app,other-app)'`,
Run: func(c *cobra.Command, _ []string) {
ctx := c.Context()
@@ -1440,16 +1440,16 @@ func NewApplicationListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
appList := apps.Items
if len(projects) != 0 {
appList = argo.FilterByProjects(appList, projects)
appList = cd.FilterByProjects(appList, projects)
}
if repo != "" {
appList = argo.FilterByRepo(appList, repo)
appList = cd.FilterByRepo(appList, repo)
}
if cluster != "" {
appList = argo.FilterByCluster(appList, cluster)
appList = cd.FilterByCluster(appList, cluster)
}
if path != "" {
appList = argo.FilterByPath(appList, path)
appList = cd.FilterByPath(appList, path)
}
switch output {
@@ -1583,8 +1583,8 @@ func getWatchOpts(watch watchOpts) watchOpts {
return watch
}
// NewApplicationWaitCommand returns a new instance of an `argocd app wait` command
func NewApplicationWaitCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
// NewApplicationWaitCommand returns a new instance of an `cd app wait` command
func NewApplicationWaitCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var (
watch watchOpts
timeout uint
@@ -1597,27 +1597,27 @@ func NewApplicationWaitCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
Use: "wait [APPNAME.. | -l selector]",
Short: "Wait for an application to reach a synced and healthy state",
Example: ` # Wait for an app
argocd app wait my-app
cd app wait my-app
# Wait for multiple apps
argocd app wait my-app other-app
cd app wait my-app other-app
# Wait for apps by resource
# Resource should be formatted as GROUP:KIND:NAME. If no GROUP is specified then :KIND:NAME.
argocd app wait my-app --resource :Service:my-service
argocd app wait my-app --resource argoproj.io:Rollout:my-rollout
argocd app wait my-app --resource '!apps:Deployment:my-service'
argocd app wait my-app --resource apps:Deployment:my-service --resource :Service:my-service
argocd app wait my-app --resource '!*:Service:*'
cd app wait my-app --resource :Service:my-service
cd app wait my-app --resource argoproj.io:Rollout:my-rollout
cd app wait my-app --resource '!apps:Deployment:my-service'
cd app wait my-app --resource apps:Deployment:my-service --resource :Service:my-service
cd app wait my-app --resource '!*:Service:*'
# Specify namespace if the application has resources with the same name in different namespaces
argocd app wait my-app --resource argoproj.io:Rollout:my-namespace/my-rollout
cd app wait my-app --resource argoproj.io:Rollout:my-namespace/my-rollout
# Wait for apps by label, in this example we waiting for apps that are children of another app (aka app-of-apps)
argocd app wait -l app.kubernetes.io/instance=my-app
argocd app wait -l app.kubernetes.io/instance!=my-app
argocd app wait -l app.kubernetes.io/instance
argocd app wait -l '!app.kubernetes.io/instance'
argocd app wait -l 'app.kubernetes.io/instance notin (my-app,other-app)'`,
cd app wait -l app.kubernetes.io/instance=my-app
cd app wait -l app.kubernetes.io/instance!=my-app
cd app wait -l app.kubernetes.io/instance
cd app wait -l '!app.kubernetes.io/instance'
cd app wait -l 'app.kubernetes.io/instance notin (my-app,other-app)'`,
Run: func(c *cobra.Command, args []string) {
ctx := c.Context()
@@ -1695,8 +1695,8 @@ func printTreeViewDetailed(nodeMapping map[string]argoappv1.ResourceNode, parent
_ = w.Flush()
}
// NewApplicationSyncCommand returns a new instance of an `argocd app sync` command
func NewApplicationSyncCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
// NewApplicationSyncCommand returns a new instance of an `cd app sync` command
func NewApplicationSyncCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var (
revision string
revisions []string
@@ -1735,31 +1735,31 @@ func NewApplicationSyncCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
Use: "sync [APPNAME... | -l selector | --project project-name]",
Short: "Sync an application to its target state",
Example: ` # Sync an app
argocd app sync my-app
cd app sync my-app
# Sync multiples apps
argocd app sync my-app other-app
cd app sync my-app other-app
# Sync apps by label, in this example we sync apps that are children of another app (aka app-of-apps)
argocd app sync -l app.kubernetes.io/instance=my-app
argocd app sync -l app.kubernetes.io/instance!=my-app
argocd app sync -l app.kubernetes.io/instance
argocd app sync -l '!app.kubernetes.io/instance'
argocd app sync -l 'app.kubernetes.io/instance notin (my-app,other-app)'
cd app sync -l app.kubernetes.io/instance=my-app
cd app sync -l app.kubernetes.io/instance!=my-app
cd app sync -l app.kubernetes.io/instance
cd app sync -l '!app.kubernetes.io/instance'
cd app sync -l 'app.kubernetes.io/instance notin (my-app,other-app)'
# Sync a multi-source application for specific revision of specific sources
argocd app sync my-app --revisions 0.0.1 --source-positions 1 --revisions 0.0.2 --source-positions 2
argocd app sync my-app --revisions 0.0.1 --source-names my-chart --revisions 0.0.2 --source-names my-values
cd app sync my-app --revisions 0.0.1 --source-positions 1 --revisions 0.0.2 --source-positions 2
cd app sync my-app --revisions 0.0.1 --source-names my-chart --revisions 0.0.2 --source-names my-values
# Sync a specific resource
# Resource should be formatted as GROUP:KIND:NAME. If no GROUP is specified then :KIND:NAME
argocd app sync my-app --resource :Service:my-service
argocd app sync my-app --resource argoproj.io:Rollout:my-rollout
argocd app sync my-app --resource '!apps:Deployment:my-service'
argocd app sync my-app --resource apps:Deployment:my-service --resource :Service:my-service
argocd app sync my-app --resource '!*:Service:*'
cd app sync my-app --resource :Service:my-service
cd app sync my-app --resource argoproj.io:Rollout:my-rollout
cd app sync my-app --resource '!apps:Deployment:my-service'
cd app sync my-app --resource apps:Deployment:my-service --resource :Service:my-service
cd app sync my-app --resource '!*:Service:*'
# Specify namespace if the application has resources with the same name in different namespaces
argocd app sync my-app --resource argoproj.io:Rollout:my-namespace/my-rollout`,
cd app sync my-app --resource argoproj.io:Rollout:my-namespace/my-rollout`,
Run: func(c *cobra.Command, args []string) {
ctx := c.Context()
if len(args) == 0 && selector == "" && len(projects) == 0 {
@@ -1804,7 +1804,7 @@ func NewApplicationSyncCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
errors.CheckError(err)
if len(args) == 1 && len(sourceNames) > 0 {
appName, _ := argo.ParseFromQualifiedName(args[0], appNamespace)
appName, _ := cd.ParseFromQualifiedName(args[0], appNamespace)
app, err := appIf.Get(context.Background(), &application.ApplicationQuery{Name: &appName})
errors.CheckError(err)
@@ -1871,7 +1871,7 @@ func NewApplicationSyncCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
if appNamespace != "" && !strings.Contains(appQualifiedName, "/") {
appQualifiedName = appNamespace + "/" + appQualifiedName
}
appName, appNs := argo.ParseFromQualifiedName(appQualifiedName, "")
appName, appNs := cd.ParseFromQualifiedName(appQualifiedName, "")
if len(selectedLabels) > 0 {
q := application.ApplicationManifestQuery{
@@ -1919,12 +1919,12 @@ func NewApplicationSyncCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
if app.Spec.HasMultipleSources() {
if revision != "" {
log.Fatal("argocd cli does not work on multi-source app with --revision flag. Use --revisions and --source-positions instead.")
log.Fatal("cd cli does not work on multi-source app with --revision flag. Use --revisions and --source-positions instead.")
return
}
if local != "" {
log.Fatal("argocd cli does not work on multi-source app with --local flag")
log.Fatal("cd cli does not work on multi-source app with --local flag")
return
}
}
@@ -2197,7 +2197,7 @@ func getResourceStates(app *argoappv1.Application, selectedResources []*argoappv
if len(selectedResources) > 0 {
for i, v := range slices.Backward(states) {
res := v
if !argo.IncludeResource(res.Name, res.Namespace, schema.GroupVersionKind{Group: res.Group, Kind: res.Kind}, selectedResources) {
if !cd.IncludeResource(res.Name, res.Namespace, schema.GroupVersionKind{Group: res.Group, Kind: res.Kind}, selectedResources) {
states = append(states[:i], states[i+1:]...)
}
}
@@ -2211,7 +2211,7 @@ func filterAppResources(app *argoappv1.Application, selectedResources []*argoapp
if app != nil && len(selectedResources) > 0 {
for i := range app.Status.Resources {
appResource := app.Status.Resources[i]
if (argo.IncludeResource(appResource.Name, appResource.Namespace,
if (cd.IncludeResource(appResource.Name, appResource.Namespace,
schema.GroupVersionKind{Group: appResource.Group, Kind: appResource.Kind}, selectedResources)) {
filteredResources = append(filteredResources, &argoappv1.SyncOperationResource{
Group: appResource.Group,
@@ -2268,7 +2268,7 @@ func checkResourceStatus(watch watchOpts, healthStatus string, syncStatus string
// resourceParentChild gets the latest state of the app and the latest state of the app's resource tree and then
// constructs the necessary data structures to print the app as a tree.
func resourceParentChild(ctx context.Context, acdClient argocdclient.Client, appName string, appNs string) (map[string]argoappv1.ResourceNode, map[string][]string, map[string]struct{}, map[string]*resourceState) {
func resourceParentChild(ctx context.Context, acdClient cdclient.Client, appName string, appNs string) (map[string]argoappv1.ResourceNode, map[string][]string, map[string]struct{}, map[string]*resourceState) {
_, appIf := acdClient.NewApplicationClientOrDie()
mapUIDToNode, mapParentToChild, parentNode := parentChildDetails(ctx, appIf, appName, appNs)
app, err := appIf.Get(ctx, &application.ApplicationQuery{Name: new(appName), AppNamespace: new(appNs)})
@@ -2308,7 +2308,7 @@ func (a *AppWithLock) GetApp() *argoappv1.Application {
}
// checkAppWaitConditions evaluates whether an application currently matches the
// conditions requested by `argocd app wait`. It returns whether the conditions
// conditions requested by `cd app wait`. It returns whether the conditions
// are met (ready) and whether a sync/refresh operation is still in progress.
// It does not mutate any state — callers are responsible for any side effects
// such as triggering a status refresh before printing the final summary.
@@ -2354,7 +2354,7 @@ func checkAppWaitConditions(app *argoappv1.Application, watch watchOpts, selecte
// waitOnApplicationStatus watches an application and blocks until either the desired watch conditions
// are fulfilled or we reach the timeout. Returns the app once desired conditions have been filled.
// Additionally return the operationState at time of fulfilment (which may be different than returned app).
func waitOnApplicationStatus(ctx context.Context, acdClient argocdclient.Client, appName string, timeout uint, watch watchOpts, selectedResources []*argoappv1.SyncOperationResource, output string) (*argoappv1.Application, *argoappv1.OperationState, error) {
func waitOnApplicationStatus(ctx context.Context, acdClient cdclient.Client, appName string, timeout uint, watch watchOpts, selectedResources []*argoappv1.SyncOperationResource, output string) (*argoappv1.Application, *argoappv1.OperationState, error) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
@@ -2371,7 +2371,7 @@ func waitOnApplicationStatus(ctx context.Context, acdClient argocdclient.Client,
// We don't want to print these when output type is json or yaml, as the output would become unparsable.
printSummary := output != "json" && output != "yaml"
appRealName, appNs := argo.ParseFromQualifiedName(appName, "")
appRealName, appNs := cd.ParseFromQualifiedName(appName, "")
printFinalStatus := func(app *argoappv1.Application) *argoappv1.Application {
var err error
@@ -2650,8 +2650,8 @@ func printApplicationHistoryTable(revHistory []argoappv1.RevisionHistory) {
_ = w.Flush()
}
// NewApplicationHistoryCommand returns a new instance of an `argocd app history` command
func NewApplicationHistoryCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
// NewApplicationHistoryCommand returns a new instance of an `cd app history` command
func NewApplicationHistoryCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var (
output string
appNamespace string
@@ -2668,7 +2668,7 @@ func NewApplicationHistoryCommand(clientOpts *argocdclient.ClientOptions) *cobra
}
conn, appIf := headless.NewClientOrDie(clientOpts, c).NewApplicationClientOrDie()
defer utilio.Close(conn)
appName, appNs := argo.ParseFromQualifiedName(args[0], appNamespace)
appName, appNs := cd.ParseFromQualifiedName(args[0], appNamespace)
app, err := appIf.Get(ctx, &application.ApplicationQuery{
Name: &appName,
AppNamespace: &appNs,
@@ -2704,8 +2704,8 @@ func findRevisionHistory(application *argoappv1.Application, historyId int64) (*
return nil, fmt.Errorf("application '%s' does not have deployment id '%d' in history", application.Name, historyId)
}
// NewApplicationRollbackCommand returns a new instance of an `argocd app rollback` command
func NewApplicationRollbackCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
// NewApplicationRollbackCommand returns a new instance of an `cd app rollback` command
func NewApplicationRollbackCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var (
prune bool
timeout uint
@@ -2721,7 +2721,7 @@ func NewApplicationRollbackCommand(clientOpts *argocdclient.ClientOptions) *cobr
c.HelpFunc()(c, args)
os.Exit(1)
}
appName, appNs := argo.ParseFromQualifiedName(args[0], appNamespace)
appName, appNs := cd.ParseFromQualifiedName(args[0], appNamespace)
var err error
depID := -1
if len(args) > 1 {
@@ -2793,8 +2793,8 @@ func printOperationResult(opState *argoappv1.OperationState) {
}
}
// NewApplicationManifestsCommand returns a new instance of an `argocd app manifests` command
func NewApplicationManifestsCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
// NewApplicationManifestsCommand returns a new instance of an `cd app manifests` command
func NewApplicationManifestsCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var (
source string
revision string
@@ -2810,16 +2810,16 @@ func NewApplicationManifestsCommand(clientOpts *argocdclient.ClientOptions) *cob
Short: "Print manifests of an application",
Example: templates.Examples(`
# Get manifests for an application
argocd app manifests my-app
cd app manifests my-app
# Get manifests for an application at a specific revision
argocd app manifests my-app --revision 0.0.1
cd app manifests my-app --revision 0.0.1
# Get manifests for a multi-source application at specific revisions for specific sources
argocd app manifests my-app --revisions 0.0.1 --source-names src-base --revisions 0.0.2 --source-names src-values
cd app manifests my-app --revisions 0.0.1 --source-names src-base --revisions 0.0.2 --source-names src-values
# Get manifests for a multi-source application at specific revisions for specific sources
argocd app manifests my-app --revisions 0.0.1 --source-positions 1 --revisions 0.0.2 --source-positions 2
cd app manifests my-app --revisions 0.0.1 --source-positions 1 --revisions 0.0.2 --source-positions 2
`),
Run: func(c *cobra.Command, args []string) {
ctx := c.Context()
@@ -2847,7 +2847,7 @@ func NewApplicationManifestsCommand(clientOpts *argocdclient.ClientOptions) *cob
}
}
appName, appNs := argo.ParseFromQualifiedName(args[0], appNamespace)
appName, appNs := cd.ParseFromQualifiedName(args[0], appNamespace)
clientset := headless.NewClientOrDie(clientOpts, c)
conn, appIf := clientset.NewApplicationClientOrDie()
defer utilio.Close(conn)
@@ -2954,8 +2954,8 @@ func NewApplicationManifestsCommand(clientOpts *argocdclient.ClientOptions) *cob
return command
}
// NewApplicationTerminateOpCommand returns a new instance of an `argocd app terminate-op` command
func NewApplicationTerminateOpCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
// NewApplicationTerminateOpCommand returns a new instance of an `cd app terminate-op` command
func NewApplicationTerminateOpCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var appNamespace string
command := &cobra.Command{
Use: "terminate-op APPNAME",
@@ -2967,7 +2967,7 @@ func NewApplicationTerminateOpCommand(clientOpts *argocdclient.ClientOptions) *c
c.HelpFunc()(c, args)
os.Exit(1)
}
appName, appNs := argo.ParseFromQualifiedName(args[0], appNamespace)
appName, appNs := cd.ParseFromQualifiedName(args[0], appNamespace)
conn, appIf := headless.NewClientOrDie(clientOpts, c).NewApplicationClientOrDie()
defer utilio.Close(conn)
_, err := appIf.TerminateOperation(ctx, &application.OperationTerminateRequest{
@@ -2982,7 +2982,7 @@ func NewApplicationTerminateOpCommand(clientOpts *argocdclient.ClientOptions) *c
return command
}
func NewApplicationEditCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
func NewApplicationEditCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var appNamespace string
command := &cobra.Command{
Use: "edit APPNAME",
@@ -2995,7 +2995,7 @@ func NewApplicationEditCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
os.Exit(1)
}
appName, appNs := argo.ParseFromQualifiedName(args[0], appNamespace)
appName, appNs := cd.ParseFromQualifiedName(args[0], appNamespace)
conn, appIf := headless.NewClientOrDie(clientOpts, c).NewApplicationClientOrDie()
defer utilio.Close(conn)
app, err := appIf.Get(ctx, &application.ApplicationQuery{
@@ -3043,7 +3043,7 @@ func NewApplicationEditCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
return command
}
func NewApplicationPatchCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
func NewApplicationPatchCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var (
patch string
patchType string
@@ -3054,10 +3054,10 @@ func NewApplicationPatchCommand(clientOpts *argocdclient.ClientOptions) *cobra.C
Use: "patch APPNAME",
Short: "Patch application",
Example: ` # Update an application's source path using json patch
argocd app patch myapplication --patch='[{"op": "replace", "path": "/spec/source/path", "value": "newPath"}]' --type json
cd app patch myapplication --patch='[{"op": "replace", "path": "/spec/source/path", "value": "newPath"}]' --type json
# Update an application's repository target revision using merge patch
argocd app patch myapplication --patch '{"spec": { "source": { "targetRevision": "master" } }}' --type merge`,
cd app patch myapplication --patch '{"spec": { "source": { "targetRevision": "master" } }}' --type merge`,
Run: func(c *cobra.Command, args []string) {
ctx := c.Context()
@@ -3065,7 +3065,7 @@ func NewApplicationPatchCommand(clientOpts *argocdclient.ClientOptions) *cobra.C
c.HelpFunc()(c, args)
os.Exit(1)
}
appName, appNs := argo.ParseFromQualifiedName(args[0], appNamespace)
appName, appNs := cd.ParseFromQualifiedName(args[0], appNamespace)
conn, appIf := headless.NewClientOrDie(clientOpts, c).NewApplicationClientOrDie()
defer utilio.Close(conn)
@@ -3089,8 +3089,8 @@ func NewApplicationPatchCommand(clientOpts *argocdclient.ClientOptions) *cobra.C
return &command
}
// NewApplicationAddSourceCommand returns a new instance of an `argocd app add-source` command
func NewApplicationAddSourceCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
// NewApplicationAddSourceCommand returns a new instance of an `cd app add-source` command
func NewApplicationAddSourceCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var (
appOpts cmdutil.AppOptions
appNamespace string
@@ -3099,7 +3099,7 @@ func NewApplicationAddSourceCommand(clientOpts *argocdclient.ClientOptions) *cob
Use: "add-source APPNAME",
Short: "Adds a source to the list of sources in the application",
Example: ` # Append a source to the list of sources in the application
argocd app add-source guestbook --repo https://github.com/argoproj/argocd-example-apps.git --path guestbook --source-name guestbook`,
cd app add-source guestbook --repo https://github.com/argoproj/argocd-example-apps.git --path guestbook --source-name guestbook`,
Run: func(c *cobra.Command, args []string) {
ctx := c.Context()
if len(args) != 1 {
@@ -3107,11 +3107,11 @@ func NewApplicationAddSourceCommand(clientOpts *argocdclient.ClientOptions) *cob
os.Exit(1)
}
argocdClient := headless.NewClientOrDie(clientOpts, c)
conn, appIf := argocdClient.NewApplicationClientOrDie()
cdClient := headless.NewClientOrDie(clientOpts, c)
conn, appIf := cdClient.NewApplicationClientOrDie()
defer utilio.Close(conn)
appName, appNs := argo.ParseFromQualifiedName(args[0], appNamespace)
appName, appNs := cd.ParseFromQualifiedName(args[0], appNamespace)
app, err := appIf.Get(ctx, &application.ApplicationQuery{
Name: &appName,
@@ -3153,8 +3153,8 @@ func NewApplicationAddSourceCommand(clientOpts *argocdclient.ClientOptions) *cob
return command
}
// NewApplicationRemoveSourceCommand returns a new instance of an `argocd app remove-source` command
func NewApplicationRemoveSourceCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
// NewApplicationRemoveSourceCommand returns a new instance of an `cd app remove-source` command
func NewApplicationRemoveSourceCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var (
sourcePosition int
sourceName string
@@ -3164,10 +3164,10 @@ func NewApplicationRemoveSourceCommand(clientOpts *argocdclient.ClientOptions) *
Use: "remove-source APPNAME",
Short: "Remove a source from multiple sources application.",
Example: ` # Remove the source at position 1 from application's sources. Counting starts at 1.
argocd app remove-source myapplication --source-position 1
cd app remove-source myapplication --source-position 1
# Remove the source named "test" from application's sources.
argocd app remove-source myapplication --source-name test`,
cd app remove-source myapplication --source-name test`,
Run: func(c *cobra.Command, args []string) {
ctx := c.Context()
@@ -3180,11 +3180,11 @@ func NewApplicationRemoveSourceCommand(clientOpts *argocdclient.ClientOptions) *
errors.Fatal(errors.ErrorGeneric, "Value of source-position must be greater than 0")
}
argocdClient := headless.NewClientOrDie(clientOpts, c)
conn, appIf := argocdClient.NewApplicationClientOrDie()
cdClient := headless.NewClientOrDie(clientOpts, c)
conn, appIf := cdClient.NewApplicationClientOrDie()
defer utilio.Close(conn)
appName, appNs := argo.ParseFromQualifiedName(args[0], appNamespace)
appName, appNs := cd.ParseFromQualifiedName(args[0], appNamespace)
app, err := appIf.Get(ctx, &application.ApplicationQuery{
Name: &appName,
@@ -3242,7 +3242,7 @@ func NewApplicationRemoveSourceCommand(clientOpts *argocdclient.ClientOptions) *
return command
}
func NewApplicationConfirmDeletionCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
func NewApplicationConfirmDeletionCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var appNamespace string
command := &cobra.Command{
Use: "confirm-deletion APPNAME",
@@ -3255,11 +3255,11 @@ func NewApplicationConfirmDeletionCommand(clientOpts *argocdclient.ClientOptions
os.Exit(1)
}
argocdClient := headless.NewClientOrDie(clientOpts, c)
conn, appIf := argocdClient.NewApplicationClientOrDie()
cdClient := headless.NewClientOrDie(clientOpts, c)
conn, appIf := cdClient.NewApplicationClientOrDie()
defer utilio.Close(conn)
appName, appNs := argo.ParseFromQualifiedName(args[0], appNamespace)
appName, appNs := cd.ParseFromQualifiedName(args[0], appNamespace)
app, err := appIf.Get(ctx, &application.ApplicationQuery{
Name: &appName,
@@ -13,13 +13,13 @@ import (
"google.golang.org/grpc/codes"
"sigs.k8s.io/yaml"
"github.com/hanzoai/deploy/cmd/argocd/commands/headless"
"github.com/hanzoai/deploy/cmd/cd/commands/headless"
"github.com/hanzoai/deploy/cmd/util"
argocdclient "github.com/hanzoai/deploy/pkg/apiclient"
cdclient "github.com/hanzoai/deploy/pkg/apiclient"
applicationpkg "github.com/hanzoai/deploy/pkg/apiclient/application"
"github.com/hanzoai/deploy/pkg/apis/application"
"github.com/hanzoai/deploy/pkg/apis/application/v1alpha1"
"github.com/hanzoai/deploy/util/argo"
"github.com/hanzoai/deploy/util/cd"
"github.com/hanzoai/deploy/util/errors"
"github.com/hanzoai/deploy/util/grpc"
utilio "github.com/hanzoai/deploy/util/io"
@@ -36,14 +36,14 @@ type DisplayedAction struct {
var appActionExample = templates.Examples(`
# List all the available actions for an application
argocd app actions list APPNAME
cd app actions list APPNAME
# Run an available action for an application
argocd app actions run APPNAME ACTION --kind KIND [--resource-name RESOURCE] [--namespace NAMESPACE] [--group GROUP]
cd app actions run APPNAME ACTION --kind KIND [--resource-name RESOURCE] [--namespace NAMESPACE] [--group GROUP]
`)
// NewApplicationResourceActionsCommand returns a new instance of an `argocd app actions` command
func NewApplicationResourceActionsCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
// NewApplicationResourceActionsCommand returns a new instance of an `cd app actions` command
func NewApplicationResourceActionsCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
command := &cobra.Command{
Use: "actions",
Short: "Manage Resource actions",
@@ -58,8 +58,8 @@ func NewApplicationResourceActionsCommand(clientOpts *argocdclient.ClientOptions
return command
}
// NewApplicationResourceActionsListCommand returns a new instance of an `argocd app actions list` command
func NewApplicationResourceActionsListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
// NewApplicationResourceActionsListCommand returns a new instance of an `cd app actions list` command
func NewApplicationResourceActionsListCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var namespace string
var kind string
var group string
@@ -71,7 +71,7 @@ func NewApplicationResourceActionsListCommand(clientOpts *argocdclient.ClientOpt
Short: "Lists available actions on a resource",
Example: templates.Examples(`
# List all the available actions for an application
argocd app actions list APPNAME
cd app actions list APPNAME
`),
}
command.Run = func(c *cobra.Command, args []string) {
@@ -81,7 +81,7 @@ func NewApplicationResourceActionsListCommand(clientOpts *argocdclient.ClientOpt
c.HelpFunc()(c, args)
os.Exit(1)
}
appName, appNs := argo.ParseFromQualifiedName(args[0], appNamespace)
appName, appNs := cd.ParseFromQualifiedName(args[0], appNamespace)
conn, appIf := headless.NewClientOrDie(clientOpts, c).NewApplicationClientOrDie()
defer utilio.Close(conn)
resources, err := getActionableResourcesForApplication(ctx, appIf, &appNs, &appName)
@@ -142,8 +142,8 @@ func NewApplicationResourceActionsListCommand(clientOpts *argocdclient.ClientOpt
return command
}
// NewApplicationResourceActionsRunCommand returns a new instance of an `argocd app actions run` command
func NewApplicationResourceActionsRunCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
// NewApplicationResourceActionsRunCommand returns a new instance of an `cd app actions run` command
func NewApplicationResourceActionsRunCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var namespace string
var appNamespace string
var resourceName string
@@ -156,7 +156,7 @@ func NewApplicationResourceActionsRunCommand(clientOpts *argocdclient.ClientOpti
Long: "All filters except --kind are optional. Use --all to run the action on all matching resources if more than one resource matches the filters. Actions may only be run on resources that are represented in git and cannot be run on child resources.",
Example: templates.Examples(`
# Run an available action for an application
argocd app actions run APPNAME ACTION --kind KIND [--resource-name RESOURCE] [--namespace NAMESPACE] [--group GROUP]
cd app actions run APPNAME ACTION --kind KIND [--resource-name RESOURCE] [--namespace NAMESPACE] [--group GROUP]
`),
}
@@ -175,7 +175,7 @@ func NewApplicationResourceActionsRunCommand(clientOpts *argocdclient.ClientOpti
c.HelpFunc()(c, args)
os.Exit(1)
}
appName, appNs := argo.ParseFromQualifiedName(args[0], appNamespace)
appName, appNs := cd.ParseFromQualifiedName(args[0], appNamespace)
actionName := args[1]
conn, appIf := headless.NewClientOrDie(clientOpts, c).NewApplicationClientOrDie()
@@ -22,19 +22,19 @@ import (
resourceutil "github.com/hanzoai/deploy/gitops-engine/pkg/sync/resource"
"github.com/hanzoai/deploy/cmd/argocd/commands/headless"
"github.com/hanzoai/deploy/cmd/cd/commands/headless"
argocommon "github.com/hanzoai/deploy/common"
"github.com/hanzoai/deploy/controller"
argocdclient "github.com/hanzoai/deploy/pkg/apiclient"
cdclient "github.com/hanzoai/deploy/pkg/apiclient"
"github.com/hanzoai/deploy/pkg/apiclient/application"
clusterpkg "github.com/hanzoai/deploy/pkg/apiclient/cluster"
"github.com/hanzoai/deploy/pkg/apiclient/settings"
argoappv1 "github.com/hanzoai/deploy/pkg/apis/application/v1alpha1"
repoapiclient "github.com/hanzoai/deploy/reposerver/apiclient"
"github.com/hanzoai/deploy/reposerver/repository"
"github.com/hanzoai/deploy/util/argo"
argodiff "github.com/hanzoai/deploy/util/argo/diff"
"github.com/hanzoai/deploy/util/argo/normalizers"
"github.com/hanzoai/deploy/util/cd"
argodiff "github.com/hanzoai/deploy/util/cd/diff"
"github.com/hanzoai/deploy/util/cd/normalizers"
"github.com/hanzoai/deploy/util/cli"
"github.com/hanzoai/deploy/util/errors"
"github.com/hanzoai/deploy/util/git"
@@ -522,7 +522,7 @@ func newNormalizeTargetManifestsProvider(
}
// Normalize target objects (namespace normalization, deduplication, and tracking re-application)
resourceTracking := argo.NewResourceTracking()
resourceTracking := cd.NewResourceTracking()
normalized, conditions, err := controller.NormalizeTargetObjects(
app.Spec.Destination.Namespace,
manifests,
@@ -620,8 +620,8 @@ func compareManifests(
return results, nil
}
// NewApplicationDiffCommand returns a new instance of an `argocd app diff` command
func NewApplicationDiffCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
// NewApplicationDiffCommand returns a new instance of an `cd app diff` command
func NewApplicationDiffCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var (
refresh bool
hardRefresh bool
@@ -673,7 +673,7 @@ func NewApplicationDiffCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
clientset := headless.NewClientOrDie(clientOpts, c)
conn, appIf := clientset.NewApplicationClientOrDie()
defer io.Close(conn)
appName, appNs := argo.ParseFromQualifiedName(args[0], appNamespace)
appName, appNs := cd.ParseFromQualifiedName(args[0], appNamespace)
app, err := appIf.Get(ctx, &application.ApplicationQuery{
Name: &appName,
Refresh: getRefreshType(refresh, hardRefresh),
@@ -26,7 +26,7 @@ import (
settingspkg "github.com/hanzoai/deploy/pkg/apiclient/settings"
"github.com/hanzoai/deploy/pkg/apis/application/v1alpha1"
repoapiclient "github.com/hanzoai/deploy/reposerver/apiclient"
"github.com/hanzoai/deploy/util/argo/normalizers"
"github.com/hanzoai/deploy/util/cd/normalizers"
)
// Test data helpers
@@ -808,7 +808,7 @@ func TestNewServerSideDiffStrategy(t *testing.T) {
deploymentKey := kube.GetResourceKey(deployment)
t.Run("Success with modified resource", func(t *testing.T) {
app := createTestApp("test-app", "argocd")
app := createTestApp("test-app", "cd")
mockClient := applicationmocks.NewApplicationServiceClient(t)
// Mock server-side diff response - use mock.Anything for complex query structure
@@ -822,7 +822,7 @@ func TestNewServerSideDiffStrategy(t *testing.T) {
},
}, nil)
strategy := newServerSideDiffStrategy(app, mockClient, "test-app", "argocd", 5, 1024)
strategy := newServerSideDiffStrategy(app, mockClient, "test-app", "cd", 5, 1024)
items := []comparisonObject{
{
key: deploymentKey,
@@ -842,10 +842,10 @@ func TestNewServerSideDiffStrategy(t *testing.T) {
})
t.Run("Empty items returns empty results", func(t *testing.T) {
app := createTestApp("test-app", "argocd")
app := createTestApp("test-app", "cd")
mockClient := applicationmocks.NewApplicationServiceClient(t)
strategy := newServerSideDiffStrategy(app, mockClient, "test-app", "argocd", 5, 1024)
strategy := newServerSideDiffStrategy(app, mockClient, "test-app", "cd", 5, 1024)
results, err := strategy(ctx, []comparisonObject{})
require.NoError(t, err)
@@ -853,12 +853,12 @@ func TestNewServerSideDiffStrategy(t *testing.T) {
})
t.Run("API error is propagated", func(t *testing.T) {
app := createTestApp("test-app", "argocd")
app := createTestApp("test-app", "cd")
mockClient := applicationmocks.NewApplicationServiceClient(t)
mockClient.On("ServerSideDiff", mock.Anything, mock.Anything).Return(nil, errors.New("API error"))
strategy := newServerSideDiffStrategy(app, mockClient, "test-app", "argocd", 5, 1024)
strategy := newServerSideDiffStrategy(app, mockClient, "test-app", "cd", 5, 1024)
items := []comparisonObject{
{
key: deploymentKey,
@@ -876,7 +876,7 @@ func TestNewServerSideDiffStrategy(t *testing.T) {
})
t.Run("Handles multiple resources", func(t *testing.T) {
app := createTestApp("test-app", "argocd")
app := createTestApp("test-app", "cd")
mockClient := applicationmocks.NewApplicationServiceClient(t)
service := createTestUnstructured(&corev1.Service{
@@ -906,7 +906,7 @@ func TestNewServerSideDiffStrategy(t *testing.T) {
},
}, nil)
strategy := newServerSideDiffStrategy(app, mockClient, "test-app", "argocd", 5, 1024)
strategy := newServerSideDiffStrategy(app, mockClient, "test-app", "cd", 5, 1024)
items := []comparisonObject{
{key: deploymentKey, live: deployment, target: deployment},
{key: serviceKey, live: service, target: service},
@@ -922,7 +922,7 @@ func TestNewServerSideDiffStrategy(t *testing.T) {
})
t.Run("Respects batch size limit", func(t *testing.T) {
app := createTestApp("test-app", "argocd")
app := createTestApp("test-app", "cd")
mockClient := applicationmocks.NewApplicationServiceClient(t)
// Create resources with large state to exceed batch size
@@ -984,7 +984,7 @@ func TestNewServerSideDiffStrategy(t *testing.T) {
})
deployment2.Object["largeData"] = largeState
strategy := newServerSideDiffStrategy(app, mockClient, "test-app", "argocd", 5, 1024)
strategy := newServerSideDiffStrategy(app, mockClient, "test-app", "cd", 5, 1024)
items := []comparisonObject{
{key: kube.GetResourceKey(deployment1), live: deployment1, target: deployment1},
{key: kube.GetResourceKey(deployment2), live: deployment2, target: deployment2},
@@ -1006,7 +1006,7 @@ func TestNewServerSideDiffStrategy(t *testing.T) {
})
t.Run("Batches resources efficiently within size limit", func(t *testing.T) {
app := createTestApp("test-app", "argocd")
app := createTestApp("test-app", "cd")
mockClient := applicationmocks.NewApplicationServiceClient(t)
// Create 3 small resources that should fit in one batch
@@ -1058,7 +1058,7 @@ func TestNewServerSideDiffStrategy(t *testing.T) {
})
deployment3.Object["smallData"] = smallState
strategy := newServerSideDiffStrategy(app, mockClient, "test-app", "argocd", 5, 1024)
strategy := newServerSideDiffStrategy(app, mockClient, "test-app", "cd", 5, 1024)
items := []comparisonObject{
{key: kube.GetResourceKey(deployment1), live: deployment1, target: deployment1},
{key: kube.GetResourceKey(deployment2), live: deployment2, target: deployment2},
@@ -1076,7 +1076,7 @@ func TestNewServerSideDiffStrategy(t *testing.T) {
})
t.Run("Respects concurrency limit", func(t *testing.T) {
app := createTestApp("test-app", "argocd")
app := createTestApp("test-app", "cd")
mockClient := applicationmocks.NewApplicationServiceClient(t)
// Create 5 resources with large state to force 5 separate batches
@@ -1119,7 +1119,7 @@ func TestNewServerSideDiffStrategy(t *testing.T) {
}
// Set concurrency to 2 - should process batches in parallel up to this limit
strategy := newServerSideDiffStrategy(app, mockClient, "test-app", "argocd", 2, 1024)
strategy := newServerSideDiffStrategy(app, mockClient, "test-app", "cd", 2, 1024)
results, err := strategy(ctx, items)
require.NoError(t, err)
@@ -1157,13 +1157,13 @@ func TestNewClientSideDiffStrategy(t *testing.T) {
})
t.Run("Success with modified resource", func(t *testing.T) {
app := createTestApp("test-app", "argocd")
app := createTestApp("test-app", "cd")
settings := &settingspkg.Settings{
AppLabelKey: "app.kubernetes.io/instance",
TrackingMethod: "label",
ResourceOverrides: map[string]*v1alpha1.ResourceOverride{},
KustomizeOptions: &v1alpha1.KustomizeOptions{},
ControllerNamespace: "argocd",
ControllerNamespace: "cd",
}
strategy, err := newClientSideDiffStrategy(app, settings, normalizers.IgnoreNormalizerOpts{})
@@ -1185,13 +1185,13 @@ func TestNewClientSideDiffStrategy(t *testing.T) {
})
t.Run("Success with identical resources", func(t *testing.T) {
app := createTestApp("test-app", "argocd")
app := createTestApp("test-app", "cd")
settings := &settingspkg.Settings{
AppLabelKey: "app.kubernetes.io/instance",
TrackingMethod: "label",
ResourceOverrides: map[string]*v1alpha1.ResourceOverride{},
KustomizeOptions: &v1alpha1.KustomizeOptions{},
ControllerNamespace: "argocd",
ControllerNamespace: "cd",
}
strategy, err := newClientSideDiffStrategy(app, settings, normalizers.IgnoreNormalizerOpts{})
@@ -1213,13 +1213,13 @@ func TestNewClientSideDiffStrategy(t *testing.T) {
})
t.Run("Handles multiple resources", func(t *testing.T) {
app := createTestApp("test-app", "argocd")
app := createTestApp("test-app", "cd")
settings := &settingspkg.Settings{
AppLabelKey: "app.kubernetes.io/instance",
TrackingMethod: "label",
ResourceOverrides: map[string]*v1alpha1.ResourceOverride{},
KustomizeOptions: &v1alpha1.KustomizeOptions{},
ControllerNamespace: "argocd",
ControllerNamespace: "cd",
}
service := createTestUnstructured(&corev1.Service{
@@ -1250,13 +1250,13 @@ func TestNewClientSideDiffStrategy(t *testing.T) {
})
t.Run("Empty items returns empty results", func(t *testing.T) {
app := createTestApp("test-app", "argocd")
app := createTestApp("test-app", "cd")
settings := &settingspkg.Settings{
AppLabelKey: "app.kubernetes.io/instance",
TrackingMethod: "label",
ResourceOverrides: map[string]*v1alpha1.ResourceOverride{},
KustomizeOptions: &v1alpha1.KustomizeOptions{},
ControllerNamespace: "argocd",
ControllerNamespace: "cd",
}
strategy, err := newClientSideDiffStrategy(app, settings, normalizers.IgnoreNormalizerOpts{})
@@ -1269,13 +1269,13 @@ func TestNewClientSideDiffStrategy(t *testing.T) {
})
t.Run("Handles nil live resource", func(t *testing.T) {
app := createTestApp("test-app", "argocd")
app := createTestApp("test-app", "cd")
settings := &settingspkg.Settings{
AppLabelKey: "app.kubernetes.io/instance",
TrackingMethod: "label",
ResourceOverrides: map[string]*v1alpha1.ResourceOverride{},
KustomizeOptions: &v1alpha1.KustomizeOptions{},
ControllerNamespace: "argocd",
ControllerNamespace: "cd",
}
strategy, err := newClientSideDiffStrategy(app, settings, normalizers.IgnoreNormalizerOpts{})
@@ -1297,13 +1297,13 @@ func TestNewClientSideDiffStrategy(t *testing.T) {
})
t.Run("Handles nil target resource", func(t *testing.T) {
app := createTestApp("test-app", "argocd")
app := createTestApp("test-app", "cd")
settings := &settingspkg.Settings{
AppLabelKey: "app.kubernetes.io/instance",
TrackingMethod: "label",
ResourceOverrides: map[string]*v1alpha1.ResourceOverride{},
KustomizeOptions: &v1alpha1.KustomizeOptions{},
ControllerNamespace: "argocd",
ControllerNamespace: "cd",
}
strategy, err := newClientSideDiffStrategy(app, settings, normalizers.IgnoreNormalizerOpts{})
@@ -1344,7 +1344,7 @@ func TestNewNormalizeTargetManifestsProvider(t *testing.T) {
baseProvider := mockManifestProvider([]*unstructured.Unstructured{deployment})
app := createTestApp("test-app", "argocd")
app := createTestApp("test-app", "cd")
app.Spec.Destination.Namespace = "target-namespace"
settings := &settingspkg.Settings{
@@ -1353,7 +1353,7 @@ func TestNewNormalizeTargetManifestsProvider(t *testing.T) {
KustomizeOptions: &v1alpha1.KustomizeOptions{
BuildOptions: "",
},
ControllerNamespace: "argocd",
ControllerNamespace: "cd",
}
infoProvider := &resourceInfoProvider{
@@ -1382,7 +1382,7 @@ func TestNewNormalizeTargetManifestsProvider(t *testing.T) {
return nil, expectedErr
}
app := createTestApp("test-app", "argocd")
app := createTestApp("test-app", "cd")
settings := &settingspkg.Settings{
AppLabelKey: "app.kubernetes.io/instance",
TrackingMethod: "label",
@@ -1411,13 +1411,13 @@ func TestNewNormalizeTargetManifestsProvider(t *testing.T) {
baseProvider := mockManifestProvider([]*unstructured.Unstructured{clusterRole})
app := createTestApp("test-app", "argocd")
app := createTestApp("test-app", "cd")
app.Spec.Destination.Namespace = "default"
settings := &settingspkg.Settings{
AppLabelKey: "app.kubernetes.io/instance",
TrackingMethod: "annotation",
ControllerNamespace: "argocd",
ControllerNamespace: "cd",
}
// ClusterRole is cluster-scoped, so infoProvider returns false for namespaced check
@@ -1440,7 +1440,7 @@ func TestNewNormalizeTargetManifestsProvider(t *testing.T) {
// Verify tracking annotation was re-applied with correct (empty) namespace
annotations := result[0].GetAnnotations()
assert.NotNil(t, annotations)
trackingID, ok := annotations["argocd.argoproj.io/tracking-id"]
trackingID, ok := annotations["cd.argoproj.io/tracking-id"]
assert.True(t, ok, "tracking annotation should be present")
// Tracking ID format: app-name:group/kind:namespace/name (namespace should be empty for cluster-scoped)
assert.Contains(t, trackingID, "ClusterRole:")
@@ -1485,13 +1485,13 @@ func TestNewNormalizeTargetManifestsProvider(t *testing.T) {
baseProvider := mockManifestProvider([]*unstructured.Unstructured{configMap1, configMap2, configMap3})
app := createTestApp("test-app", "argocd")
app := createTestApp("test-app", "cd")
app.Spec.Destination.Namespace = "prod"
settings := &settingspkg.Settings{
AppLabelKey: "app.kubernetes.io/instance",
TrackingMethod: "label",
ControllerNamespace: "argocd",
ControllerNamespace: "cd",
}
infoProvider := &resourceInfoProvider{
@@ -12,7 +12,7 @@ import (
"github.com/hanzoai/deploy/util/templates"
"github.com/hanzoai/deploy/cmd/argocd/commands/utils"
"github.com/hanzoai/deploy/cmd/cd/commands/utils"
"github.com/hanzoai/deploy/cmd/util"
"github.com/hanzoai/deploy/pkg/apis/application/v1alpha1"
@@ -21,16 +21,16 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/types"
"github.com/hanzoai/deploy/cmd/argocd/commands/headless"
argocdclient "github.com/hanzoai/deploy/pkg/apiclient"
"github.com/hanzoai/deploy/cmd/cd/commands/headless"
cdclient "github.com/hanzoai/deploy/pkg/apiclient"
applicationpkg "github.com/hanzoai/deploy/pkg/apiclient/application"
"github.com/hanzoai/deploy/util/argo"
"github.com/hanzoai/deploy/util/cd"
"github.com/hanzoai/deploy/util/errors"
utilio "github.com/hanzoai/deploy/util/io"
)
// NewApplicationGetResourceCommand returns a new instance of the `app get-resource` command
func NewApplicationGetResourceCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
func NewApplicationGetResourceCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var (
resourceName string
kind string
@@ -46,25 +46,25 @@ func NewApplicationGetResourceCommand(clientOpts *argocdclient.ClientOptions) *c
Short: "Get details about the live Kubernetes manifests of a resource in an application. The filter-fields flag can be used to only display fields you want to see.",
Example: `
# Get a specific resource, Pod my-app-pod, in 'my-app' by name in wide format
argocd app get-resource my-app --kind Pod --resource-name my-app-pod
cd app get-resource my-app --kind Pod --resource-name my-app-pod
# Get a specific resource, Pod my-app-pod, in 'my-app' by name in yaml format
argocd app get-resource my-app --kind Pod --resource-name my-app-pod -o yaml
cd app get-resource my-app --kind Pod --resource-name my-app-pod -o yaml
# Get a specific resource, Pod my-app-pod, in 'my-app' by name in json format
argocd app get-resource my-app --kind Pod --resource-name my-app-pod -o json
cd app get-resource my-app --kind Pod --resource-name my-app-pod -o json
# Get details about all Pods in the application
argocd app get-resource my-app --kind Pod
cd app get-resource my-app --kind Pod
# Get a specific resource with managed fields, Pod my-app-pod, in 'my-app' by name in wide format
argocd app get-resource my-app --kind Pod --resource-name my-app-pod --show-managed-fields
cd app get-resource my-app --kind Pod --resource-name my-app-pod --show-managed-fields
# Get the details of a specific field in a resource in 'my-app' in the wide format
argocd app get-resource my-app --kind Pod --filter-fields status.podIP
cd app get-resource my-app --kind Pod --filter-fields status.podIP
# Get the details of multiple specific fields in a specific resource in 'my-app' in the wide format
argocd app get-resource my-app --kind Pod --resource-name my-app-pod --filter-fields status.podIP,status.hostIP`,
cd app get-resource my-app --kind Pod --resource-name my-app-pod --filter-fields status.podIP,status.hostIP`,
}
command.Run = func(c *cobra.Command, args []string) {
@@ -75,7 +75,7 @@ func NewApplicationGetResourceCommand(clientOpts *argocdclient.ClientOptions) *c
os.Exit(1)
}
appName, appNs := argo.ParseFromQualifiedName(args[0], appNamespace)
appName, appNs := cd.ParseFromQualifiedName(args[0], appNamespace)
conn, appIf := headless.NewClientOrDie(clientOpts, c).NewApplicationClientOrDie()
defer utilio.Close(conn)
@@ -285,7 +285,7 @@ func printManifestAsTable(w *tabwriter.Writer, name string, showName bool, obj m
}
}
func NewApplicationPatchResourceCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
func NewApplicationPatchResourceCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var (
patch string
patchType string
@@ -321,7 +321,7 @@ func NewApplicationPatchResourceCommand(clientOpts *argocdclient.ClientOptions)
c.HelpFunc()(c, args)
os.Exit(1)
}
appName, appNs := argo.ParseFromQualifiedName(args[0], appNamespace)
appName, appNs := cd.ParseFromQualifiedName(args[0], appNamespace)
conn, appIf := headless.NewClientOrDie(clientOpts, c).NewApplicationClientOrDie()
defer utilio.Close(conn)
@@ -355,7 +355,7 @@ func NewApplicationPatchResourceCommand(clientOpts *argocdclient.ClientOptions)
return command
}
func NewApplicationDeleteResourceCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
func NewApplicationDeleteResourceCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var (
resourceName string
namespace string
@@ -390,7 +390,7 @@ func NewApplicationDeleteResourceCommand(clientOpts *argocdclient.ClientOptions)
c.HelpFunc()(c, args)
os.Exit(1)
}
appName, appNs := argo.ParseFromQualifiedName(args[0], appNamespace)
appName, appNs := cd.ParseFromQualifiedName(args[0], appNamespace)
conn, appIf := headless.NewClientOrDie(clientOpts, c).NewApplicationClientOrDie()
defer utilio.Close(conn)
@@ -527,7 +527,7 @@ func printResources(listAll bool, orphaned bool, appResourceTree *v1alpha1.Appli
errors.CheckError(err)
}
func NewApplicationListResourcesCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
func NewApplicationListResourcesCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var (
orphaned bool
output string
@@ -539,16 +539,16 @@ func NewApplicationListResourcesCommand(clientOpts *argocdclient.ClientOptions)
Short: "List resources of application",
Example: templates.Examples(`
# List first-level resources of application
argocd app resources my-app --refresh
cd app resources my-app --refresh
# List only the orphaned resources of application
argocd app resources my-app --orphaned
cd app resources my-app --orphaned
# Shows resource hierarchy with parent-child relationships
argocd app resources my-app --output tree
cd app resources my-app --output tree
# Shows resource hierarchy with parent-child relationships including information about age, health and reason
argocd app resources my-app --output tree=detailed
cd app resources my-app --output tree=detailed
`),
Run: func(c *cobra.Command, args []string) {
ctx := c.Context()
@@ -557,7 +557,7 @@ func NewApplicationListResourcesCommand(clientOpts *argocdclient.ClientOptions)
os.Exit(1)
}
listAll := !c.Flag("orphaned").Changed
appName, appNs := argo.ParseFromQualifiedName(args[0], appNamespace)
appName, appNs := cd.ParseFromQualifiedName(args[0], appNamespace)
conn, appIf := headless.NewClientOrDie(clientOpts, c).NewApplicationClientOrDie()
defer utilio.Close(conn)
appResourceTree, err := appIf.ResourceTree(ctx, &applicationpkg.ResourcesQuery{
@@ -31,7 +31,7 @@ import (
"k8s.io/apimachinery/pkg/watch"
"sigs.k8s.io/yaml"
argocdclient "github.com/hanzoai/deploy/pkg/apiclient"
cdclient "github.com/hanzoai/deploy/pkg/apiclient"
accountpkg "github.com/hanzoai/deploy/pkg/apiclient/account"
applicationpkg "github.com/hanzoai/deploy/pkg/apiclient/application"
applicationsetpkg "github.com/hanzoai/deploy/pkg/apiclient/applicationset"
@@ -618,7 +618,7 @@ func TestPrintAppSummaryTable(t *testing.T) {
app := &v1alpha1.Application{
ObjectMeta: metav1.ObjectMeta{
Name: "test",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSpec{
SyncPolicy: &v1alpha1.SyncPolicy{
@@ -627,7 +627,7 @@ func TestPrintAppSummaryTable(t *testing.T) {
},
},
Project: "default",
Destination: v1alpha1.ApplicationDestination{Server: "local", Namespace: "argocd"},
Destination: v1alpha1.ApplicationDestination{Server: "local", Namespace: "cd"},
Source: &v1alpha1.ApplicationSource{
RepoURL: "test",
TargetRevision: "master",
@@ -681,10 +681,10 @@ func TestPrintAppSummaryTable(t *testing.T) {
return nil
})
expectation := `Name: argocd/test
expectation := `Name: cd/test
Project: default
Server: local
Namespace: argocd
Namespace: cd
URL: url
Source:
- Repo: test
@@ -706,7 +706,7 @@ func TestPrintAppSummaryTable_MultipleSources(t *testing.T) {
app := &v1alpha1.Application{
ObjectMeta: metav1.ObjectMeta{
Name: "test",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSpec{
SyncPolicy: &v1alpha1.SyncPolicy{
@@ -715,7 +715,7 @@ func TestPrintAppSummaryTable_MultipleSources(t *testing.T) {
},
},
Project: "default",
Destination: v1alpha1.ApplicationDestination{Server: "local", Namespace: "argocd"},
Destination: v1alpha1.ApplicationDestination{Server: "local", Namespace: "cd"},
Sources: v1alpha1.ApplicationSources{
{
RepoURL: "test",
@@ -775,10 +775,10 @@ func TestPrintAppSummaryTable_MultipleSources(t *testing.T) {
return nil
})
expectation := `Name: argocd/test
expectation := `Name: cd/test
Project: default
Server: local
Namespace: argocd
Namespace: cd
URL: url
Sources:
- Repo: test
@@ -906,7 +906,7 @@ func TestPrintParams(t *testing.T) {
func TestAppUrlDefault(t *testing.T) {
t.Run("Plain text", func(t *testing.T) {
result := appURLDefault(argocdclient.NewClientOrDie(&argocdclient.ClientOptions{
result := appURLDefault(cdclient.NewClientOrDie(&cdclient.ClientOptions{
ServerAddr: "localhost:80",
PlainText: true,
}), "test")
@@ -914,7 +914,7 @@ func TestAppUrlDefault(t *testing.T) {
require.Equalf(t, result, expectation, "Incorrect url %q, should be %q", result, expectation)
})
t.Run("https", func(t *testing.T) {
result := appURLDefault(argocdclient.NewClientOrDie(&argocdclient.ClientOptions{
result := appURLDefault(cdclient.NewClientOrDie(&cdclient.ClientOptions{
ServerAddr: "localhost:443",
PlainText: false,
}), "test")
@@ -924,7 +924,7 @@ func TestAppUrlDefault(t *testing.T) {
}
func TestTruncateString(t *testing.T) {
result := truncateString("argocdtool", 2)
result := truncateString("cdtool", 2)
expectation := "ar..."
require.Equalf(t, result, expectation, "Incorrect truncate string %q, should be %q", result, expectation)
}
@@ -959,7 +959,7 @@ func TestGetService(t *testing.T) {
func TestTargetObjects(t *testing.T) {
resources := []*v1alpha1.ResourceDiff{
{
TargetState: "{\"apiVersion\":\"v1\",\"kind\":\"Service\",\"metadata\":{\"name\":\"test-helm-guestbook\",\"namespace\":\"argocd\"},\"spec\":{\"selector\":{\"app\":\"helm-guestbook\",\"release\":\"test\"},\"sessionAffinity\":\"None\",\"type\":\"ClusterIP\"},\"status\":{\"loadBalancer\":{}}}",
TargetState: "{\"apiVersion\":\"v1\",\"kind\":\"Service\",\"metadata\":{\"name\":\"test-helm-guestbook\",\"namespace\":\"cd\"},\"spec\":{\"selector\":{\"app\":\"helm-guestbook\",\"release\":\"test\"},\"sessionAffinity\":\"None\",\"type\":\"ClusterIP\"},\"status\":{\"loadBalancer\":{}}}",
},
{
TargetState: "{\"apiVersion\":\"v1\",\"kind\":\"Service\",\"metadata\":{\"name\":\"test-helm-guestbook\",\"namespace\":\"ns\"},\"spec\":{\"selector\":{\"app\":\"helm-guestbook\",\"release\":\"test\"},\"sessionAffinity\":\"None\",\"type\":\"ClusterIP\"},\"status\":{\"loadBalancer\":{}}}",
@@ -1888,10 +1888,10 @@ func TestWaitOnApplicationStatus_JSON_YAML_WideOutput(t *testing.T) {
%s Service default service-name1 Synced Healthy
%s apps Deployment default test Synced Healthy
Name: argocd/test
Name: cd/test
Project: default
Server: local
Namespace: argocd
Namespace: cd
URL: http://localhost:8080/applications/app-name
Source:
- Repo: test
@@ -1961,10 +1961,10 @@ The command timed out waiting for the conditions to be met.
This is the state of the app after wait timed out:
Name: argocd/test
Name: cd/test
Project: default
Server: local
Namespace: argocd
Namespace: cd
URL: http://localhost:8080/applications/app-name
Source:
- Repo: test
@@ -2138,7 +2138,7 @@ func TestCheckAppWaitConditions(t *testing.T) {
}
// TestWaitOnApplicationStatus_ReturnsImmediatelyWhenAlreadyInDesiredState verifies
// that `argocd app wait` returns right away when the application already matches
// that `cd app wait` returns right away when the application already matches
// the requested conditions, instead of hanging on the watch stream until timeout.
// Regression test for https://github.com/argoproj/argo-cd/issues/12211.
func TestWaitOnApplicationStatus_ReturnsImmediatelyWhenAlreadyInDesiredState(t *testing.T) {
@@ -2164,7 +2164,7 @@ func TestWaitOnApplicationStatus_ReturnsImmediatelyWhenAlreadyInDesiredState(t *
}
// TestWaitOnApplicationStatus_DeleteWatchSkipsEarlyReturn verifies that
// `argocd app wait --delete` does not short-circuit on the initial Get and
// `cd app wait --delete` does not short-circuit on the initial Get and
// instead consumes the watch for the Deleted event — the Get can only return
// an existing application, so its state cannot satisfy the delete condition.
func TestWaitOnApplicationStatus_DeleteWatchSkipsEarlyReturn(t *testing.T) {
@@ -2209,7 +2209,7 @@ func (c *readyEventAcdClient) WatchApplicationWithRetry(_ context.Context, _ str
appEventsCh <- &v1alpha1.ApplicationWatchEvent{
Type: watch.Modified,
Application: v1alpha1.Application{
ObjectMeta: metav1.ObjectMeta{Name: "test", Namespace: "argocd"},
ObjectMeta: metav1.ObjectMeta{Name: "test", Namespace: "cd"},
Operation: &v1alpha1.Operation{Sync: &v1alpha1.SyncOperation{}},
Status: v1alpha1.ApplicationStatus{
Sync: v1alpha1.SyncStatus{Status: v1alpha1.SyncStatusCodeSynced},
@@ -2240,7 +2240,7 @@ func (c *deleteAcdClient) WatchApplicationWithRetry(_ context.Context, _ string,
appEventsCh <- &v1alpha1.ApplicationWatchEvent{
Type: watch.Deleted,
Application: v1alpha1.Application{
ObjectMeta: metav1.ObjectMeta{Name: "test", Namespace: "argocd"},
ObjectMeta: metav1.ObjectMeta{Name: "test", Namespace: "cd"},
},
}
close(appEventsCh)
@@ -2290,11 +2290,11 @@ func (c *readyFakeAppServiceClient) Get(_ context.Context, _ *applicationpkg.App
return &v1alpha1.Application{
ObjectMeta: metav1.ObjectMeta{
Name: "test",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSpec{
Project: "default",
Destination: v1alpha1.ApplicationDestination{Server: "local", Namespace: "argocd"},
Destination: v1alpha1.ApplicationDestination{Server: "local", Namespace: "cd"},
Source: &v1alpha1.ApplicationSource{RepoURL: "test", TargetRevision: "master", Path: "/test"},
},
Status: v1alpha1.ApplicationStatus{
@@ -2366,7 +2366,7 @@ func (c *fakeAppServiceClient) Get(_ context.Context, _ *applicationpkg.Applicat
return &v1alpha1.Application{
ObjectMeta: metav1.ObjectMeta{
Name: "test",
Namespace: "argocd",
Namespace: "cd",
},
Spec: v1alpha1.ApplicationSpec{
SyncPolicy: &v1alpha1.SyncPolicy{
@@ -2375,7 +2375,7 @@ func (c *fakeAppServiceClient) Get(_ context.Context, _ *applicationpkg.Applicat
},
},
Project: "default",
Destination: v1alpha1.ApplicationDestination{Server: "local", Namespace: "argocd"},
Destination: v1alpha1.ApplicationDestination{Server: "local", Namespace: "cd"},
Source: &v1alpha1.ApplicationSource{
RepoURL: "test",
TargetRevision: "master",
@@ -2553,8 +2553,8 @@ type fakeAcdClient struct {
simulateTimeout uint
}
func (c *fakeAcdClient) ClientOptions() argocdclient.ClientOptions {
return argocdclient.ClientOptions{}
func (c *fakeAcdClient) ClientOptions() cdclient.ClientOptions {
return cdclient.ClientOptions{}
}
func (c *fakeAcdClient) HTTPClient() (*http.Client, error) { return nil, nil }
func (c *fakeAcdClient) OIDCConfig(context.Context, *settingspkg.Settings) (*oauth2.Config, *oidc.Provider, error) {
@@ -14,14 +14,14 @@ import (
"github.com/spf13/cobra"
"google.golang.org/grpc/codes"
"github.com/hanzoai/deploy/cmd/argocd/commands/admin"
"github.com/hanzoai/deploy/cmd/argocd/commands/headless"
"github.com/hanzoai/deploy/cmd/argocd/commands/utils"
"github.com/hanzoai/deploy/cmd/cd/commands/admin"
"github.com/hanzoai/deploy/cmd/cd/commands/headless"
"github.com/hanzoai/deploy/cmd/cd/commands/utils"
cmdutil "github.com/hanzoai/deploy/cmd/util"
argocdclient "github.com/hanzoai/deploy/pkg/apiclient"
cdclient "github.com/hanzoai/deploy/pkg/apiclient"
"github.com/hanzoai/deploy/pkg/apiclient/applicationset"
arogappsetv1 "github.com/hanzoai/deploy/pkg/apis/application/v1alpha1"
"github.com/hanzoai/deploy/util/argo"
"github.com/hanzoai/deploy/util/cd"
"github.com/hanzoai/deploy/util/errors"
"github.com/hanzoai/deploy/util/grpc"
utilio "github.com/hanzoai/deploy/util/io"
@@ -30,24 +30,24 @@ import (
var appSetExample = templates.Examples(`
# Get an ApplicationSet.
argocd appset get APPSETNAME
cd appset get APPSETNAME
# List all the ApplicationSets
argocd appset list
cd appset list
# Create an ApplicationSet from a YAML stored in a file or at given URL
argocd appset create <filename or URL> (<filename or URL>...)
cd appset create <filename or URL> (<filename or URL>...)
# Delete an ApplicationSet
argocd appset delete APPSETNAME (APPSETNAME...)
cd appset delete APPSETNAME (APPSETNAME...)
# Namespace precedence for --appset-namespace (-N):
# - get/delete: if the argument is namespace/name, that namespace wins; -N is ignored.
# - create/generate: metadata.namespace in the YAML wins when set; -N applies only when the manifest omits namespace.
`)
// NewAppSetCommand returns a new instance of an `argocd appset` command
func NewAppSetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
// NewAppSetCommand returns a new instance of an `cd appset` command
func NewAppSetCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
command := &cobra.Command{
Use: "appset",
Short: "Manage ApplicationSets",
@@ -65,8 +65,8 @@ func NewAppSetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
return command
}
// NewApplicationSetGetCommand returns a new instance of an `argocd appset get` command
func NewApplicationSetGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
// NewApplicationSetGetCommand returns a new instance of an `cd appset get` command
func NewApplicationSetGetCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var (
output string
showParams bool
@@ -77,13 +77,13 @@ func NewApplicationSetGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.
Short: "Get ApplicationSet details",
Example: templates.Examples(`
# Get ApplicationSets
argocd appset get APPSETNAME
cd appset get APPSETNAME
# Get ApplicationSet in a specific namespace using qualified name (namespace/name)
argocd appset get APPSET_NAMESPACE/APPSETNAME
cd appset get APPSET_NAMESPACE/APPSETNAME
# Get ApplicationSet in a specific namespace using --appset-namespace flag
argocd appset get --appset-namespace=APPSET_NAMESPACE APPSETNAME
cd appset get --appset-namespace=APPSET_NAMESPACE APPSETNAME
`),
Run: func(c *cobra.Command, args []string) {
@@ -97,7 +97,7 @@ func NewApplicationSetGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.
conn, appIf := acdClient.NewApplicationSetClientOrDie()
defer utilio.Close(conn)
appSetName, appSetNs := argo.ParseFromQualifiedName(args[0], appSetNamespace)
appSetName, appSetNs := cd.ParseFromQualifiedName(args[0], appSetNamespace)
appSet, err := appIf.Get(ctx, &applicationset.ApplicationSetGetQuery{Name: appSetName, AppsetNamespace: appSetNs})
errors.CheckError(err)
@@ -129,8 +129,8 @@ func NewApplicationSetGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.
return command
}
// NewApplicationSetCreateCommand returns a new instance of an `argocd appset create` command
func NewApplicationSetCreateCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
// NewApplicationSetCreateCommand returns a new instance of an `cd appset create` command
func NewApplicationSetCreateCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var (
output string
upsert, dryRun, wait bool
@@ -141,13 +141,13 @@ func NewApplicationSetCreateCommand(clientOpts *argocdclient.ClientOptions) *cob
Short: "Create one or more ApplicationSets",
Example: templates.Examples(`
# Create ApplicationSets
argocd appset create <filename or URL> (<filename or URL>...)
cd appset create <filename or URL> (<filename or URL>...)
# Create ApplicationSet in a specific namespace using
argocd appset create --appset-namespace=APPSET_NAMESPACE <filename or URL> (<filename or URL>...)
cd appset create --appset-namespace=APPSET_NAMESPACE <filename or URL> (<filename or URL>...)
# Dry-run AppSet creation to see what applications would be managed
argocd appset create --dry-run <filename or URL> -o json | jq -r '.status.resources[].name'
cd appset create --dry-run <filename or URL> -o json | jq -r '.status.resources[].name'
`),
Run: func(c *cobra.Command, args []string) {
ctx := c.Context()
@@ -156,7 +156,7 @@ func NewApplicationSetCreateCommand(clientOpts *argocdclient.ClientOptions) *cob
c.HelpFunc()(c, args)
os.Exit(1)
}
argocdClient := headless.NewClientOrDie(clientOpts, c)
cdClient := headless.NewClientOrDie(clientOpts, c)
fileURL := args[0]
appsets, err := cmdutil.ConstructApplicationSet(fileURL)
errors.CheckError(err)
@@ -171,7 +171,7 @@ func NewApplicationSetCreateCommand(clientOpts *argocdclient.ClientOptions) *cob
errors.Fatal(errors.ErrorGeneric, fmt.Sprintf("Error creating ApplicationSet %s. ApplicationSet does not have Name field set", appset))
}
conn, appIf := argocdClient.NewApplicationSetClientOrDie()
conn, appIf := cdClient.NewApplicationSetClientOrDie()
defer utilio.Close(conn)
if appset.Namespace == "" && appSetNamespace != "" {
@@ -229,7 +229,7 @@ func NewApplicationSetCreateCommand(clientOpts *argocdclient.ClientOptions) *cob
}
if wait && !dryRun {
err := waitForApplicationSetResourcesUpToDate(ctx, argocdClient, created.QualifiedName())
err := waitForApplicationSetResourcesUpToDate(ctx, cdClient, created.QualifiedName())
errors.CheckError(err)
c.PrintErrf("ApplicationSet '%s' resources are up to date\n", created.Name)
}
@@ -244,8 +244,8 @@ func NewApplicationSetCreateCommand(clientOpts *argocdclient.ClientOptions) *cob
return command
}
// NewApplicationSetGenerateCommand returns a new instance of an `argocd appset generate` command
func NewApplicationSetGenerateCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
// NewApplicationSetGenerateCommand returns a new instance of an `cd appset generate` command
func NewApplicationSetGenerateCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var output string
var appSetNamespace string
command := &cobra.Command{
@@ -253,10 +253,10 @@ func NewApplicationSetGenerateCommand(clientOpts *argocdclient.ClientOptions) *c
Short: "Generate apps of ApplicationSet rendered templates",
Example: templates.Examples(`
# Generate apps of ApplicationSet rendered templates
argocd appset generate <filename or URL> (<filename or URL>...)
cd appset generate <filename or URL> (<filename or URL>...)
# Generate apps of ApplicationSet rendered templates in a specific namespace
argocd appset generate --appset-namespace=APPSET_NAMESPACE <filename or URL> (<filename or URL>...)
cd appset generate --appset-namespace=APPSET_NAMESPACE <filename or URL> (<filename or URL>...)
`),
Run: func(c *cobra.Command, args []string) {
ctx := c.Context()
@@ -265,7 +265,7 @@ func NewApplicationSetGenerateCommand(clientOpts *argocdclient.ClientOptions) *c
c.HelpFunc()(c, args)
os.Exit(1)
}
argocdClient := headless.NewClientOrDie(clientOpts, c)
cdClient := headless.NewClientOrDie(clientOpts, c)
fileURL := args[0]
appsets, err := cmdutil.ConstructApplicationSet(fileURL)
errors.CheckError(err)
@@ -284,7 +284,7 @@ func NewApplicationSetGenerateCommand(clientOpts *argocdclient.ClientOptions) *c
appset.Namespace = appSetNamespace
}
conn, appIf := argocdClient.NewApplicationSetClientOrDie()
conn, appIf := cdClient.NewApplicationSetClientOrDie()
defer utilio.Close(conn)
req := applicationset.ApplicationSetGenerateRequest{
@@ -322,8 +322,8 @@ func NewApplicationSetGenerateCommand(clientOpts *argocdclient.ClientOptions) *c
return command
}
// NewApplicationSetListCommand returns a new instance of an `argocd appset list` command
func NewApplicationSetListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
// NewApplicationSetListCommand returns a new instance of an `cd appset list` command
func NewApplicationSetListCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var (
output string
selector string
@@ -335,7 +335,7 @@ func NewApplicationSetListCommand(clientOpts *argocdclient.ClientOptions) *cobra
Short: "List ApplicationSets",
Example: templates.Examples(`
# List all ApplicationSets
argocd appset list
cd appset list
`),
Run: func(c *cobra.Command, _ []string) {
ctx := c.Context()
@@ -368,8 +368,8 @@ func NewApplicationSetListCommand(clientOpts *argocdclient.ClientOptions) *cobra
return command
}
// NewApplicationSetDeleteCommand returns a new instance of an `argocd appset delete` command
func NewApplicationSetDeleteCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
// NewApplicationSetDeleteCommand returns a new instance of an `cd appset delete` command
func NewApplicationSetDeleteCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var (
noPrompt bool
wait bool
@@ -380,13 +380,13 @@ func NewApplicationSetDeleteCommand(clientOpts *argocdclient.ClientOptions) *cob
Short: "Delete one or more ApplicationSets",
Example: templates.Examples(`
# Delete an applicationset
argocd appset delete APPSETNAME (APPSETNAME...)
cd appset delete APPSETNAME (APPSETNAME...)
# Delete ApplicationSet in a specific namespace using qualified name (namespace/name)
argocd appset delete APPSET_NAMESPACE/APPSETNAME
cd appset delete APPSET_NAMESPACE/APPSETNAME
# Delete ApplicationSet in a specific namespace using --appset-namespace flag
argocd appset delete --appset-namespace=APPSET_NAMESPACE APPSETNAME
cd appset delete --appset-namespace=APPSET_NAMESPACE APPSETNAME
`),
Run: func(c *cobra.Command, args []string) {
ctx := c.Context()
@@ -415,7 +415,7 @@ func NewApplicationSetDeleteCommand(clientOpts *argocdclient.ClientOptions) *cob
promptUtil := utils.NewPrompt(isTerminal && !noPrompt)
for _, appSetQualifiedName := range args {
appSetName, appSetNs := argo.ParseFromQualifiedName(appSetQualifiedName, appSetNamespace)
appSetName, appSetNs := cd.ParseFromQualifiedName(appSetQualifiedName, appSetNamespace)
appsetDeleteReq := applicationset.ApplicationSetDeleteRequest{
Name: appSetName,
@@ -559,7 +559,7 @@ func isApplicationSetResourcesUpToDate(appSet *arogappsetv1.ApplicationSet) bool
return false
}
func waitForApplicationSetResourcesUpToDate(ctx context.Context, acdClient argocdclient.Client, appSetName string) error {
func waitForApplicationSetResourcesUpToDate(ctx context.Context, acdClient cdclient.Client, appSetName string) error {
appEventCh := acdClient.WatchApplicationSetWithRetry(ctx, appSetName, "")
for appEvent := range appEventCh {
if appEvent == nil {
@@ -17,13 +17,13 @@ func NewBcryptCmd() *cobra.Command {
Use: "bcrypt",
Short: "Generate bcrypt hash for any password",
Example: `# Generate bcrypt hash for any password
argocd account bcrypt --password YOUR_PASSWORD
cd account bcrypt --password YOUR_PASSWORD
# Prompt for password input
argocd account bcrypt
cd account bcrypt
# Read password from stdin
echo -e "password" | argocd account bcrypt`,
echo -e "password" | cd account bcrypt`,
Run: func(cmd *cobra.Command, _ []string) {
password = cli.PromptPassword(password)
bytePassword := []byte(password)
@@ -13,9 +13,9 @@ import (
"github.com/spf13/cobra"
"github.com/hanzoai/deploy/cmd/argocd/commands/headless"
"github.com/hanzoai/deploy/cmd/argocd/commands/utils"
argocdclient "github.com/hanzoai/deploy/pkg/apiclient"
"github.com/hanzoai/deploy/cmd/cd/commands/headless"
"github.com/hanzoai/deploy/cmd/cd/commands/utils"
cdclient "github.com/hanzoai/deploy/pkg/apiclient"
certificatepkg "github.com/hanzoai/deploy/pkg/apiclient/certificate"
appsv1 "github.com/hanzoai/deploy/pkg/apis/application/v1alpha1"
certutil "github.com/hanzoai/deploy/util/cert"
@@ -23,8 +23,8 @@ import (
utilio "github.com/hanzoai/deploy/util/io"
)
// NewCertCommand returns a new instance of an `argocd repo` command
func NewCertCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
// NewCertCommand returns a new instance of an `cd repo` command
func NewCertCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
command := &cobra.Command{
Use: "cert",
Short: "Manage repository certificates and SSH known hosts entries",
@@ -33,22 +33,22 @@ func NewCertCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
os.Exit(1)
},
Example: ` # Add a TLS certificate for cd.example.com to Hanzo CD cert store from a file
argocd cert add-tls --from ~/mycert.pem cd.example.com
cd cert add-tls --from ~/mycert.pem cd.example.com
# Add a TLS certificate for cd.example.com to Hanzo CD via stdin
cat ~/mycert.pem | argocd cert add-tls cd.example.com
cat ~/mycert.pem | cd cert add-tls cd.example.com
# Add SSH known host entries for cd.example.com to Hanzo CD by scanning host
ssh-keyscan cd.example.com | argocd cert add-ssh --batch
ssh-keyscan cd.example.com | cd cert add-ssh --batch
# List all known TLS certificates
argocd cert list --cert-type https
cd cert list --cert-type https
# Remove all TLS certificates for cd.example.com
argocd cert rm --cert-type https cd.example.com
cd cert rm --cert-type https cd.example.com
# Remove all certificates and SSH known host entries for cd.example.com
argocd cert rm cd.example.com
cd cert rm cd.example.com
`,
}
@@ -59,7 +59,7 @@ func NewCertCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
return command
}
func NewCertAddTLSCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
func NewCertAddTLSCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var (
fromFile string
upsert bool
@@ -173,8 +173,8 @@ func deduplicatePEMCertificates(pems []string) ([]string, error) {
return uniqueCerts, nil
}
// NewCertAddSSHCommand returns a new instance of an `argocd cert add` command
func NewCertAddSSHCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
// NewCertAddSSHCommand returns a new instance of an `cd cert add` command
func NewCertAddSSHCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var (
fromFile string
batchProcess bool
@@ -245,8 +245,8 @@ func NewCertAddSSHCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command
return command
}
// NewCertRemoveCommand returns a new instance of an `argocd cert rm` command
func NewCertRemoveCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
// NewCertRemoveCommand returns a new instance of an `cd cert rm` command
func NewCertRemoveCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var (
certType string
certSubType string
@@ -301,8 +301,8 @@ func NewCertRemoveCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command
return command
}
// NewCertListCommand returns a new instance of an `argocd cert rm` command
func NewCertListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
// NewCertListCommand returns a new instance of an `cd cert rm` command
func NewCertListCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var (
certType string
hostNamePattern string
@@ -18,10 +18,10 @@ import (
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"github.com/hanzoai/deploy/cmd/argocd/commands/headless"
"github.com/hanzoai/deploy/cmd/cd/commands/headless"
cmdutil "github.com/hanzoai/deploy/cmd/util"
"github.com/hanzoai/deploy/common"
argocdclient "github.com/hanzoai/deploy/pkg/apiclient"
cdclient "github.com/hanzoai/deploy/pkg/apiclient"
clusterpkg "github.com/hanzoai/deploy/pkg/apiclient/cluster"
argoappv1 "github.com/hanzoai/deploy/pkg/apis/application/v1alpha1"
"github.com/hanzoai/deploy/util/cli"
@@ -46,8 +46,8 @@ const (
allNamespaces = "*"
)
// NewClusterCommand returns a new instance of an `argocd cluster` command
func NewClusterCommand(clientOpts *argocdclient.ClientOptions, pathOpts *clientcmd.PathOptions) *cobra.Command {
// NewClusterCommand returns a new instance of an `cd cluster` command
func NewClusterCommand(clientOpts *cdclient.ClientOptions, pathOpts *clientcmd.PathOptions) *cobra.Command {
command := &cobra.Command{
Use: "cluster",
Short: "Manage cluster credentials",
@@ -56,20 +56,20 @@ func NewClusterCommand(clientOpts *argocdclient.ClientOptions, pathOpts *clientc
os.Exit(1)
},
Example: ` # List all known clusters in JSON format:
argocd cluster list -o json
cd cluster list -o json
# Add a target cluster configuration to Hanzo CD. The context must exist in your kubectl config:
argocd cluster add example-cluster
cd cluster add example-cluster
# Get specific details about a cluster in plain text (wide) format:
argocd cluster get example-cluster -o wide
cd cluster get example-cluster -o wide
# Remove a target cluster context from Hanzo CD
argocd cluster rm example-cluster
cd cluster rm example-cluster
# Set a target cluster context from Hanzo CD
argocd cluster set CLUSTER_NAME --name new-cluster-name --namespace '*'
argocd cluster set CLUSTER_NAME --name new-cluster-name --namespace namespace-one --namespace namespace-two`,
cd cluster set CLUSTER_NAME --name new-cluster-name --namespace '*'
cd cluster set CLUSTER_NAME --name new-cluster-name --namespace namespace-one --namespace namespace-two`,
}
command.AddCommand(NewClusterAddCommand(clientOpts, pathOpts))
@@ -81,8 +81,8 @@ func NewClusterCommand(clientOpts *argocdclient.ClientOptions, pathOpts *clientc
return command
}
// NewClusterAddCommand returns a new instance of an `argocd cluster add` command
func NewClusterAddCommand(clientOpts *argocdclient.ClientOptions, pathOpts *clientcmd.PathOptions) *cobra.Command {
// NewClusterAddCommand returns a new instance of an `cd cluster add` command
func NewClusterAddCommand(clientOpts *cdclient.ClientOptions, pathOpts *clientcmd.PathOptions) *cobra.Command {
var (
clusterOpts cmdutil.ClusterOptions
skipConfirmation bool
@@ -146,7 +146,7 @@ func NewClusterAddCommand(clientOpts *argocdclient.ClientOptions, pathOpts *clie
if len(clusterOpts.Namespaces) > 0 {
accessLevel = "namespace"
}
message := fmt.Sprintf("WARNING: This will create a service account `argocd-manager` on the cluster referenced by context `%s` with full %s level privileges. Do you want to continue [y/N]? ", contextName, accessLevel)
message := fmt.Sprintf("WARNING: This will create a service account `cd-manager` on the cluster referenced by context `%s` with full %s level privileges. Do you want to continue [y/N]? ", contextName, accessLevel)
if !cli.AskToProceed(message) {
os.Exit(1)
}
@@ -253,8 +253,8 @@ func applyServerProxyOverride(changed bool, serverProxyURL string, clst *argoapp
return nil
}
// NewClusterSetCommand returns a new instance of an `argocd cluster set` command
func NewClusterSetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
// NewClusterSetCommand returns a new instance of an `cd cluster set` command
func NewClusterSetCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var (
clusterOptions cmdutil.ClusterOptions
clusterName string
@@ -265,8 +265,8 @@ func NewClusterSetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command
Use: "set NAME",
Short: "Set cluster information",
Example: ` # Set cluster information
argocd cluster set CLUSTER_NAME --name new-cluster-name --namespace '*'
argocd cluster set CLUSTER_NAME --name new-cluster-name --namespace namespace-one --namespace namespace-two`,
cd cluster set CLUSTER_NAME --name new-cluster-name --namespace '*'
cd cluster set CLUSTER_NAME --name new-cluster-name --namespace namespace-one --namespace namespace-two`,
Run: func(c *cobra.Command, args []string) {
ctx := c.Context()
if len(args) != 1 {
@@ -342,14 +342,14 @@ func checkFieldsToUpdate(clusterOptions cmdutil.ClusterOptions, labels []string,
return updatedFields
}
// NewClusterGetCommand returns a new instance of an `argocd cluster get` command
func NewClusterGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
// NewClusterGetCommand returns a new instance of an `cd cluster get` command
func NewClusterGetCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var output string
command := &cobra.Command{
Use: "get SERVER/NAME",
Short: "Get cluster information",
Example: `argocd cluster get https://12.34.567.89
argocd cluster get in-cluster`,
Example: `cd cluster get https://12.34.567.89
cd cluster get in-cluster`,
Run: func(c *cobra.Command, args []string) {
ctx := c.Context()
@@ -417,14 +417,14 @@ func printClusterDetails(clusters []argoappv1.Cluster) {
}
}
// NewClusterRemoveCommand returns a new instance of an `argocd cluster rm` command
func NewClusterRemoveCommand(clientOpts *argocdclient.ClientOptions, pathOpts *clientcmd.PathOptions) *cobra.Command {
// NewClusterRemoveCommand returns a new instance of an `cd cluster rm` command
func NewClusterRemoveCommand(clientOpts *cdclient.ClientOptions, pathOpts *clientcmd.PathOptions) *cobra.Command {
var noPrompt bool
command := &cobra.Command{
Use: "rm SERVER/NAME",
Short: "Remove cluster credentials",
Example: `argocd cluster rm https://12.34.567.89
argocd cluster rm cluster-name`,
Example: `cd cluster rm https://12.34.567.89
cd cluster rm cluster-name`,
Run: func(c *cobra.Command, args []string) {
ctx := c.Context()
@@ -520,8 +520,8 @@ func printClusterServers(clusters []argoappv1.Cluster) {
}
}
// NewClusterListCommand returns a new instance of an `argocd cluster rm` command
func NewClusterListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
// NewClusterListCommand returns a new instance of an `cd cluster rm` command
func NewClusterListCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var output string
command := &cobra.Command{
Use: "list",
@@ -547,19 +547,19 @@ func NewClusterListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Comman
},
Example: `
# List Clusters in Default "Wide" Format
argocd cluster list
cd cluster list
# List Cluster via specifying the server
argocd cluster list --server <CD_SERVER_ADDRESS>
cd cluster list --server <CD_SERVER_ADDRESS>
# List Clusters in JSON Format
argocd cluster list -o json --server <CD_SERVER_ADDRESS>
cd cluster list -o json --server <CD_SERVER_ADDRESS>
# List Clusters in YAML Format
argocd cluster list -o yaml --server <CD_SERVER_ADDRESS>
cd cluster list -o yaml --server <CD_SERVER_ADDRESS>
# List Clusters that have been added to your Hanzo CD
argocd cluster list -o server <CD_SERVER_ADDRESS>
cd cluster list -o server <CD_SERVER_ADDRESS>
`,
}
@@ -567,13 +567,13 @@ argocd cluster list -o server <CD_SERVER_ADDRESS>
return command
}
// NewClusterRotateAuthCommand returns a new instance of an `argocd cluster rotate-auth` command
func NewClusterRotateAuthCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
// NewClusterRotateAuthCommand returns a new instance of an `cd cluster rotate-auth` command
func NewClusterRotateAuthCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
command := &cobra.Command{
Use: "rotate-auth SERVER/NAME",
Short: common.CommandCLI + " cluster rotate-auth SERVER/NAME",
Example: `argocd cluster rotate-auth https://12.34.567.89
argocd cluster rotate-auth cluster-name`,
Example: `cd cluster rotate-auth https://12.34.567.89
cd cluster rotate-auth cluster-name`,
Run: func(c *cobra.Command, args []string) {
ctx := c.Context()
@@ -10,7 +10,7 @@ import (
"k8s.io/client-go/tools/clientcmd"
cmdutil "github.com/hanzoai/deploy/cmd/util"
argocdclient "github.com/hanzoai/deploy/pkg/apiclient"
cdclient "github.com/hanzoai/deploy/pkg/apiclient"
"github.com/hanzoai/deploy/pkg/apis/application/v1alpha1"
)
@@ -74,9 +74,9 @@ func Test_getRestConfig(t *testing.T) {
"Load config for context successfully",
args{
pathOpts,
"argocd2.example.com:443",
"cd2.example.com:443",
},
&rest.Config{Host: "argocd2.example.com:443"},
&rest.Config{Host: "cd2.example.com:443"},
false,
"",
},
@@ -116,7 +116,7 @@ func Test_getRestConfig(t *testing.T) {
func TestNewClusterAddCommand_ServerProxyUrlFlagRegistered(t *testing.T) {
pathOpts := clientcmd.NewDefaultPathOptions()
cmd := NewClusterAddCommand(&argocdclient.ClientOptions{}, pathOpts)
cmd := NewClusterAddCommand(&cdclient.ClientOptions{}, pathOpts)
flag := cmd.Flags().Lookup("server-proxy-url")
require.NotNil(t, flag, "--server-proxy-url flag should be registered")
@@ -128,19 +128,19 @@ func TestServerProxyUrlFlagChanged_EmptyStringIsExplicit(t *testing.T) {
pathOpts := clientcmd.NewDefaultPathOptions()
t.Run("flag not provided: Changed() returns false", func(t *testing.T) {
cmd := NewClusterAddCommand(&argocdclient.ClientOptions{}, pathOpts)
cmd := NewClusterAddCommand(&cdclient.ClientOptions{}, pathOpts)
assert.False(t, cmd.Flags().Changed("server-proxy-url"))
})
t.Run("flag set to empty string: Changed() returns true", func(t *testing.T) {
cmd := NewClusterAddCommand(&argocdclient.ClientOptions{}, pathOpts)
cmd := NewClusterAddCommand(&cdclient.ClientOptions{}, pathOpts)
err := cmd.Flags().Set("server-proxy-url", "")
require.NoError(t, err)
assert.True(t, cmd.Flags().Changed("server-proxy-url"), "Changed() must return true even for an explicit empty string")
})
t.Run("flag set to a URL: Changed() returns true", func(t *testing.T) {
cmd := NewClusterAddCommand(&argocdclient.ClientOptions{}, pathOpts)
cmd := NewClusterAddCommand(&cdclient.ClientOptions{}, pathOpts)
err := cmd.Flags().Set("server-proxy-url", "https://proxy.example.com:3128")
require.NoError(t, err)
assert.True(t, cmd.Flags().Changed("server-proxy-url"))
+282
View File
@@ -0,0 +1,282 @@
package commands
import (
"fmt"
"io"
"os"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
const (
bashCompletionFunc = `
__cd_list_apps() {
local -a cd_out
if cd_out=($(cd app list --output name 2>/dev/null)); then
COMPREPLY+=( $( compgen -W "${cd_out[*]}" -- "$cur" ) )
fi
}
__cd_list_app_history() {
local app=$1
local -a cd_out
if cd_out=($(cd app history $app --output id 2>/dev/null)); then
COMPREPLY+=( $( compgen -W "${cd_out[*]}" -- "$cur" ) )
fi
}
__cd_app_rollback() {
local -a command
for comp_word in "${COMP_WORDS[@]}"; do
if [[ $comp_word =~ ^-.*$ ]]; then
continue
fi
command+=($comp_word)
done
# fourth arg is app (if present): e.g.- cd app rollback guestbook
local app=${command[3]}
local id=${command[4]}
if [[ -z $app || $app == $cur ]]; then
__cd_list_apps
elif [[ -z $id || $id == $cur ]]; then
__cd_list_app_history $app
fi
}
__cd_list_servers() {
local -a cd_out
if cd_out=($(cd cluster list --output server 2>/dev/null)); then
COMPREPLY+=( $( compgen -W "${cd_out[*]}" -- "$cur" ) )
fi
}
__cd_list_repos() {
local -a cd_out
if cd_out=($(cd repo list --output url 2>/dev/null)); then
COMPREPLY+=( $( compgen -W "${cd_out[*]}" -- "$cur" ) )
fi
}
__cd_list_projects() {
local -a cd_out
if cd_out=($(cd proj list --output name 2>/dev/null)); then
COMPREPLY+=( $( compgen -W "${cd_out[*]}" -- "$cur" ) )
fi
}
__cd_list_namespaces() {
local -a cd_out
if cd_out=($(kubectl get namespaces --no-headers 2>/dev/null | cut -f1 -d' ' 2>/dev/null)); then
COMPREPLY+=( $( compgen -W "${cd_out[*]}" -- "$cur" ) )
fi
}
__cd_proj_server_namespace() {
local -a command
for comp_word in "${COMP_WORDS[@]}"; do
if [[ $comp_word =~ ^-.*$ ]]; then
continue
fi
command+=($comp_word)
done
# expect something like this: cd proj add-destination PROJECT SERVER NAMESPACE
local project=${command[3]}
local server=${command[4]}
local namespace=${command[5]}
if [[ -z $project || $project == $cur ]]; then
__cd_list_projects
elif [[ -z $server || $server == $cur ]]; then
__cd_list_servers
elif [[ -z $namespace || $namespace == $cur ]]; then
__cd_list_namespaces
fi
}
__cd_list_project_role() {
local project="$1"
local -a cd_out
if cd_out=($(cd proj role list "$project" --output=name 2>/dev/null)); then
COMPREPLY+=( $( compgen -W "${cd_out[*]}" -- "$cur" ) )
fi
}
__cd_proj_role(){
local -a command
for comp_word in "${COMP_WORDS[@]}"; do
if [[ $comp_word =~ ^-.*$ ]]; then
continue
fi
command+=($comp_word)
done
# expect something like this: cd proj role add-policy PROJECT ROLE-NAME
local project=${command[4]}
local role=${command[5]}
if [[ -z $project || $project == $cur ]]; then
__cd_list_projects
elif [[ -z $role || $role == $cur ]]; then
__cd_list_project_role $project
fi
}
__cd_custom_func() {
case ${last_command} in
cd_app_delete | \
cd_app_diff | \
cd_app_edit | \
cd_app_get | \
cd_app_history | \
cd_app_manifests | \
cd_app_patch-resource | \
cd_app_set | \
cd_app_sync | \
cd_app_terminate-op | \
cd_app_unset | \
cd_app_wait | \
cd_app_create)
__cd_list_apps
return
;;
cd_app_rollback)
__cd_app_rollback
return
;;
cd_cluster_get | \
cd_cluster_rm | \
cd_cluster_set | \
cd_login | \
cd_cluster_add)
__cd_list_servers
return
;;
cd_repo_rm | \
cd_repo_add)
__cd_list_repos
return
;;
cd_proj_add-destination | \
cd_proj_remove-destination)
__cd_proj_server_namespace
return
;;
cd_proj_add-source | \
cd_proj_remove-source | \
cd_proj_allow-cluster-resource | \
cd_proj_allow-namespace-resource | \
cd_proj_deny-cluster-resource | \
cd_proj_deny-namespace-resource | \
cd_proj_delete | \
cd_proj_edit | \
cd_proj_get | \
cd_proj_set | \
cd_proj_role_list)
__cd_list_projects
return
;;
cd_proj_role_remove-policy | \
cd_proj_role_add-policy | \
cd_proj_role_create | \
cd_proj_role_delete | \
cd_proj_role_get | \
cd_proj_role_create-token | \
cd_proj_role_delete-token)
__cd_proj_role
return
;;
*)
;;
esac
}
`
)
func NewCompletionCommand() *cobra.Command {
command := &cobra.Command{
Use: "completion SHELL",
Short: "Output shell completion code for the specified shell (bash, zsh or fish)",
Long: `Write bash, zsh or fish shell completion code to standard output.
For bash, ensure you have bash completions installed and enabled.
To access completions in your current shell, run
$ source <(cd completion bash)
Alternatively, write it to a file and source in .bash_profile
For zsh, add the following to your ~/.zshrc file:
source <(cd completion zsh)
compdef _cd cd
Optionally, also add the following, in case you are getting errors involving compdef & compinit such as command not found: compdef:
autoload -Uz compinit
compinit
`,
Example: `# For bash
$ source <(cd completion bash)
# For zsh
$ cd completion zsh > _cd
$ source _cd
# For fish
$ cd completion fish > ~/.config/fish/completions/cd.fish
$ source ~/.config/fish/completions/cd.fish
# For powershell
$ mkdir -Force "$HOME\Documents\PowerShell" | Out-Null
$ cd completion powershell > $HOME\Documents\PowerShell\cd_completion.ps1
Add the following lines to your powershell profile
$ # Hanzo CD tab completion
if (Test-Path "$HOME\Documents\PowerShell\cd_completion.ps1") {
. "$HOME\Documents\PowerShell\cd_completion.ps1"
}
Then reload your profile
$ . $PROFILE
`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 1 {
cmd.HelpFunc()(cmd, args)
os.Exit(1)
}
shell := args[0]
rootCommand := NewCommand()
rootCommand.BashCompletionFunction = bashCompletionFunc
availableCompletions := map[string]func(out io.Writer, cmd *cobra.Command) error{
"bash": runCompletionBash,
"zsh": runCompletionZsh,
"fish": runCompletionFish,
"powershell": runCompletionPowershell,
}
completion, ok := availableCompletions[shell]
if !ok {
fmt.Printf("Invalid shell '%s'. The supported shells are bash, zsh and fish.\n", shell)
os.Exit(1)
}
if err := completion(os.Stdout, rootCommand); err != nil {
log.Fatal(err)
}
},
}
return command
}
func runCompletionBash(out io.Writer, cmd *cobra.Command) error {
return cmd.GenBashCompletion(out)
}
func runCompletionZsh(out io.Writer, cmd *cobra.Command) error {
return cmd.GenZshCompletion(out)
}
func runCompletionFish(out io.Writer, cmd *cobra.Command) error {
return cmd.GenFishCompletion(out, true)
}
func runCompletionPowershell(out io.Writer, cmd *cobra.Command) error {
return cmd.GenPowerShellCompletionWithDesc(out)
}
@@ -7,24 +7,24 @@ import (
"github.com/spf13/cobra"
argocdclient "github.com/hanzoai/deploy/pkg/apiclient"
cdclient "github.com/hanzoai/deploy/pkg/apiclient"
"github.com/hanzoai/deploy/util/errors"
"github.com/hanzoai/deploy/util/localconfig"
)
// NewConfigureCommand returns a new instance of an `argocd configure` command
func NewConfigureCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
// NewConfigureCommand returns a new instance of an `cd configure` command
func NewConfigureCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var promptsEnabled bool
command := &cobra.Command{
Use: "configure",
Short: "Manage local configuration",
Example: `# Enable optional interactive prompts
argocd configure --prompts-enabled
argocd configure --prompts-enabled=true
cd configure --prompts-enabled
cd configure --prompts-enabled=true
# Disable optional interactive prompts
argocd configure --prompts-enabled=false`,
cd configure --prompts-enabled=false`,
Run: func(_ *cobra.Command, _ []string) {
localCfg, err := localconfig.ReadLocalConfig(clientOpts.ConfigPath)
errors.CheckError(err)
@@ -4,7 +4,7 @@ import (
"os"
"testing"
argocdclient "github.com/hanzoai/deploy/pkg/apiclient"
cdclient "github.com/hanzoai/deploy/pkg/apiclient"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -26,8 +26,8 @@ func TestNewConfigureCommand_PromptsEnabled_DefaultTrue(t *testing.T) {
require.NoError(t, err)
assert.False(t, localConfig.PromptsEnabled)
// Set `PromptsEnabled` to `true` using `argocd configure --prompts-enabled`
cmd := NewConfigureCommand(&argocdclient.ClientOptions{ConfigPath: testConfigFilePath})
// Set `PromptsEnabled` to `true` using `cd configure --prompts-enabled`
cmd := NewConfigureCommand(&cdclient.ClientOptions{ConfigPath: testConfigFilePath})
cmd.SetArgs([]string{"--prompts-enabled"})
err = cmd.Execute()
@@ -54,8 +54,8 @@ func TestNewConfigureCommand_PromptsEnabled_True(t *testing.T) {
require.NoError(t, err)
assert.False(t, localConfig.PromptsEnabled)
// Set `PromptsEnabled` to `true` using `argocd configure --prompts-enabled=true`
cmd := NewConfigureCommand(&argocdclient.ClientOptions{ConfigPath: testConfigFilePath})
// Set `PromptsEnabled` to `true` using `cd configure --prompts-enabled=true`
cmd := NewConfigureCommand(&cdclient.ClientOptions{ConfigPath: testConfigFilePath})
cmd.SetArgs([]string{"--prompts-enabled=true"})
err = cmd.Execute()
@@ -82,8 +82,8 @@ func TestNewConfigureCommand_PromptsEnabled_False(t *testing.T) {
require.NoError(t, err)
assert.False(t, localConfig.PromptsEnabled)
// Set `PromptsEnabled` to `false` using `argocd configure --prompts-enabled=false`
cmd := NewConfigureCommand(&argocdclient.ClientOptions{ConfigPath: testConfigFilePath})
// Set `PromptsEnabled` to `false` using `cd configure --prompts-enabled=false`
cmd := NewConfigureCommand(&cdclient.ClientOptions{ConfigPath: testConfigFilePath})
cmd.SetArgs([]string{"--prompts-enabled=false"})
err = cmd.Execute()
@@ -11,26 +11,26 @@ import (
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
argocdclient "github.com/hanzoai/deploy/pkg/apiclient"
cdclient "github.com/hanzoai/deploy/pkg/apiclient"
"github.com/hanzoai/deploy/util/errors"
"github.com/hanzoai/deploy/util/localconfig"
)
// NewContextCommand returns a new instance of an `argocd ctx` command
func NewContextCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
// NewContextCommand returns a new instance of an `cd ctx` command
func NewContextCommand(clientOpts *cdclient.ClientOptions) *cobra.Command {
var deletion bool
command := &cobra.Command{
Use: "context [CONTEXT]",
Aliases: []string{"ctx"},
Short: "Switch between contexts",
Example: `# List Hanzo CD Contexts
argocd context
cd context
# Switch Hanzo CD context
argocd context cd.argoproj.io
cd context cd.argoproj.io
# Delete Hanzo CD context
argocd context cd.argoproj.io --delete`,
cd context cd.argoproj.io --delete`,
Run: func(c *cobra.Command, args []string) {
localCfg, err := localconfig.ReadLocalConfig(clientOpts.ConfigPath)
errors.CheckError(err)

Some files were not shown because too many files have changed in this diff Show More