mirror of
https://github.com/argoproj/argo-cd
synced 2026-04-21 17:07:16 +00:00
chore: enable gofumpt and whitespace linters (#18567)
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
parent
d7e99224d4
commit
7cf5ed06d4
304 changed files with 1689 additions and 2140 deletions
|
|
@ -11,7 +11,7 @@ linters:
|
|||
enable:
|
||||
- errcheck
|
||||
- errorlint
|
||||
- gofmt
|
||||
- gofumpt
|
||||
- goimports
|
||||
- gosimple
|
||||
- govet
|
||||
|
|
@ -20,6 +20,7 @@ linters:
|
|||
- staticcheck
|
||||
- testifylint
|
||||
- unused
|
||||
- whitespace
|
||||
linters-settings:
|
||||
goimports:
|
||||
local-prefixes: github.com/argoproj/argo-cd/v2
|
||||
|
|
|
|||
|
|
@ -65,12 +65,10 @@ const (
|
|||
ReconcileRequeueOnValidationError = time.Minute * 3
|
||||
)
|
||||
|
||||
var (
|
||||
defaultPreservedAnnotations = []string{
|
||||
NotifiedAnnotationKey,
|
||||
argov1alpha1.AnnotationKeyRefresh,
|
||||
}
|
||||
)
|
||||
var defaultPreservedAnnotations = []string{
|
||||
NotifiedAnnotationKey,
|
||||
argov1alpha1.AnnotationKeyRefresh,
|
||||
}
|
||||
|
||||
// ApplicationSetReconciler reconciles a ApplicationSet object
|
||||
type ApplicationSetReconciler struct {
|
||||
|
|
@ -241,7 +239,6 @@ func (r *ApplicationSetReconciler) Reconcile(ctx context.Context, req ctrl.Reque
|
|||
// trigger appropriate application syncs if RollingSync strategy is enabled
|
||||
if progressiveSyncsStrategyEnabled(&applicationSetInfo, "RollingSync") {
|
||||
validApps, err = r.syncValidApplications(logCtx, &applicationSetInfo, appSyncMap, appMap, validApps)
|
||||
|
||||
if err != nil {
|
||||
_ = r.setApplicationSetStatusCondition(ctx,
|
||||
&applicationSetInfo,
|
||||
|
|
@ -455,7 +452,6 @@ func (r *ApplicationSetReconciler) validateGeneratedApplications(ctx context.Con
|
|||
errorsByIndex := map[int]error{}
|
||||
namesSet := map[string]bool{}
|
||||
for i, app := range desiredApplications {
|
||||
|
||||
if !namesSet[app.Name] {
|
||||
namesSet[app.Name] = true
|
||||
} else {
|
||||
|
|
@ -475,7 +471,6 @@ func (r *ApplicationSetReconciler) validateGeneratedApplications(ctx context.Con
|
|||
errorsByIndex[i] = fmt.Errorf("application destination spec is invalid: %s", err.Error())
|
||||
continue
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return errorsByIndex, nil
|
||||
|
|
@ -484,7 +479,6 @@ func (r *ApplicationSetReconciler) validateGeneratedApplications(ctx context.Con
|
|||
func (r *ApplicationSetReconciler) getMinRequeueAfter(applicationSetInfo *argov1alpha1.ApplicationSet) time.Duration {
|
||||
var res time.Duration
|
||||
for _, requestedGenerator := range applicationSetInfo.Spec.Generators {
|
||||
|
||||
relevantGenerators := generators.GetRelevantGenerators(&requestedGenerator, r.Generators)
|
||||
|
||||
for _, g := range relevantGenerators {
|
||||
|
|
@ -536,7 +530,6 @@ func (r *ApplicationSetReconciler) generateApplications(logCtx *log.Entry, appli
|
|||
|
||||
for _, p := range a.Params {
|
||||
app, err := r.Renderer.RenderTemplateParams(tmplApplication, applicationSetInfo.Spec.SyncPolicy, p, applicationSetInfo.Spec.GoTemplate, applicationSetInfo.Spec.GoTemplateOptions)
|
||||
|
||||
if err != nil {
|
||||
logCtx.WithError(err).WithField("params", a.Params).WithField("generator", requestedGenerator).
|
||||
Error("error generating application from params")
|
||||
|
|
@ -550,7 +543,6 @@ func (r *ApplicationSetReconciler) generateApplications(logCtx *log.Entry, appli
|
|||
|
||||
if applicationSetInfo.Spec.TemplatePatch != nil {
|
||||
patchedApplication, err := r.applyTemplatePatch(app, applicationSetInfo, p)
|
||||
|
||||
if err != nil {
|
||||
log.WithError(err).WithField("params", a.Params).WithField("generator", requestedGenerator).
|
||||
Error("error generating application from params")
|
||||
|
|
@ -578,7 +570,6 @@ func (r *ApplicationSetReconciler) generateApplications(logCtx *log.Entry, appli
|
|||
|
||||
func (r *ApplicationSetReconciler) applyTemplatePatch(app *argov1alpha1.Application, applicationSetInfo argov1alpha1.ApplicationSet, params map[string]interface{}) (*argov1alpha1.Application, error) {
|
||||
replacedTemplate, err := r.Renderer.Replace(*applicationSetInfo.Spec.TemplatePatch, params, applicationSetInfo.Spec.GoTemplate, applicationSetInfo.Spec.GoTemplateOptions)
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error replacing values in templatePatch: %w", err)
|
||||
}
|
||||
|
|
@ -656,7 +647,6 @@ func (r *ApplicationSetReconciler) updateCache(ctx context.Context, obj client.O
|
|||
// - For existing application, it will call update
|
||||
// The function also adds owner reference to all applications, and uses it to delete them.
|
||||
func (r *ApplicationSetReconciler) createOrUpdateInCluster(ctx context.Context, logCtx *log.Entry, applicationSet argov1alpha1.ApplicationSet, desiredApplications []argov1alpha1.Application) error {
|
||||
|
||||
var firstError error
|
||||
// Creates or updates the application in appList
|
||||
for _, generatedApp := range desiredApplications {
|
||||
|
|
@ -746,7 +736,6 @@ func (r *ApplicationSetReconciler) createOrUpdateInCluster(ctx context.Context,
|
|||
|
||||
return controllerutil.SetControllerReference(&applicationSet, found, r.Scheme)
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
appLog.WithError(err).WithField("action", action).Errorf("failed to %s Application", action)
|
||||
if firstError == nil {
|
||||
|
|
@ -772,7 +761,6 @@ func (r *ApplicationSetReconciler) createOrUpdateInCluster(ctx context.Context,
|
|||
// createInCluster will filter from the desiredApplications only the application that needs to be created
|
||||
// Then it will call createOrUpdateInCluster to do the actual create
|
||||
func (r *ApplicationSetReconciler) createInCluster(ctx context.Context, logCtx *log.Entry, applicationSet argov1alpha1.ApplicationSet, desiredApplications []argov1alpha1.Application) error {
|
||||
|
||||
var createApps []argov1alpha1.Application
|
||||
current, err := r.getCurrentApplications(ctx, applicationSet)
|
||||
if err != nil {
|
||||
|
|
@ -800,7 +788,6 @@ func (r *ApplicationSetReconciler) createInCluster(ctx context.Context, logCtx *
|
|||
func (r *ApplicationSetReconciler) getCurrentApplications(ctx context.Context, applicationSet argov1alpha1.ApplicationSet) ([]argov1alpha1.Application, error) {
|
||||
var current argov1alpha1.ApplicationList
|
||||
err := r.Client.List(ctx, ¤t, client.MatchingFields{".metadata.controller": applicationSet.Name}, client.InNamespace(applicationSet.Namespace))
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error retrieving applications: %w", err)
|
||||
}
|
||||
|
|
@ -838,7 +825,6 @@ func (r *ApplicationSetReconciler) deleteInCluster(ctx context.Context, logCtx *
|
|||
_, exists := m[app.Name]
|
||||
|
||||
if !exists {
|
||||
|
||||
// Removes the Argo CD resources finalizer if the application contains an invalid target (eg missing cluster)
|
||||
err := r.removeFinalizerOnInvalidDestination(ctx, applicationSet, &app, clusterList, logCtx)
|
||||
if err != nil {
|
||||
|
|
@ -866,7 +852,6 @@ func (r *ApplicationSetReconciler) deleteInCluster(ctx context.Context, logCtx *
|
|||
|
||||
// removeFinalizerOnInvalidDestination removes the Argo CD resources finalizer if the application contains an invalid target (eg missing cluster)
|
||||
func (r *ApplicationSetReconciler) removeFinalizerOnInvalidDestination(ctx context.Context, applicationSet argov1alpha1.ApplicationSet, app *argov1alpha1.Application, clusterList *argov1alpha1.ClusterList, appLog *log.Entry) error {
|
||||
|
||||
// Only check if the finalizers need to be removed IF there are finalizers to remove
|
||||
if len(app.Finalizers) == 0 {
|
||||
return nil
|
||||
|
|
@ -879,12 +864,10 @@ func (r *ApplicationSetReconciler) removeFinalizerOnInvalidDestination(ctx conte
|
|||
appLog.Warnf("The destination cluster for %s couldn't be found: %v", app.Name, err)
|
||||
validDestination = false
|
||||
} else {
|
||||
|
||||
// Detect if the destination's server field does not match an existing cluster
|
||||
|
||||
matchingCluster := false
|
||||
for _, cluster := range clusterList.Items {
|
||||
|
||||
// Server fields must match. Note that ValidateDestination ensures that the server field is set, if applicable.
|
||||
if app.Spec.Destination.Server != cluster.Server {
|
||||
continue
|
||||
|
|
@ -908,7 +891,6 @@ func (r *ApplicationSetReconciler) removeFinalizerOnInvalidDestination(ctx conte
|
|||
// If the destination is invalid (for example the cluster is no longer defined), then remove
|
||||
// the application finalizers to avoid triggering Argo CD bug #5817
|
||||
if !validDestination {
|
||||
|
||||
// Filter out the Argo CD finalizer from the finalizer list
|
||||
var newFinalizers []string
|
||||
for _, existingFinalizer := range app.Finalizers {
|
||||
|
|
@ -958,7 +940,6 @@ func (r *ApplicationSetReconciler) removeOwnerReferencesOnDeleteAppSet(ctx conte
|
|||
}
|
||||
|
||||
func (r *ApplicationSetReconciler) performProgressiveSyncs(ctx context.Context, logCtx *log.Entry, appset argov1alpha1.ApplicationSet, applications []argov1alpha1.Application, desiredApplications []argov1alpha1.Application, appMap map[string]argov1alpha1.Application) (map[string]bool, error) {
|
||||
|
||||
appDependencyList, appStepMap, err := r.buildAppDependencyList(logCtx, appset, desiredApplications)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to build app dependency list: %w", err)
|
||||
|
|
@ -996,7 +977,6 @@ func (r *ApplicationSetReconciler) performProgressiveSyncs(ctx context.Context,
|
|||
|
||||
// this list tracks which Applications belong to each RollingUpdate step
|
||||
func (r *ApplicationSetReconciler) buildAppDependencyList(logCtx *log.Entry, applicationSet argov1alpha1.ApplicationSet, applications []argov1alpha1.Application) ([][]string, map[string]int, error) {
|
||||
|
||||
if applicationSet.Spec.Strategy == nil || applicationSet.Spec.Strategy.Type == "" || applicationSet.Spec.Strategy.Type == "AllAtOnce" {
|
||||
return [][]string{}, map[string]int{}, nil
|
||||
}
|
||||
|
|
@ -1016,11 +996,9 @@ func (r *ApplicationSetReconciler) buildAppDependencyList(logCtx *log.Entry, app
|
|||
// use applicationLabelSelectors to filter generated Applications into steps and status by name
|
||||
for _, app := range applications {
|
||||
for i, step := range steps {
|
||||
|
||||
selected := true // default to true, assuming the current Application is a match for the given step matchExpression
|
||||
|
||||
for _, matchExpression := range step.MatchExpressions {
|
||||
|
||||
if val, ok := app.Labels[matchExpression.Key]; ok {
|
||||
valueMatched := labelMatchedExpression(logCtx, val, matchExpression)
|
||||
|
||||
|
|
@ -1084,7 +1062,6 @@ func (r *ApplicationSetReconciler) buildAppSyncMap(ctx context.Context, applicat
|
|||
|
||||
// detect if we need to halt before progressing to the next step
|
||||
for _, appName := range appDependencyList[i] {
|
||||
|
||||
idx := findApplicationStatusIndex(applicationSet.Status.ApplicationStatus, appName)
|
||||
if idx == -1 {
|
||||
// no Application status found, likely because the Application is being newly created
|
||||
|
|
@ -1095,7 +1072,6 @@ func (r *ApplicationSetReconciler) buildAppSyncMap(ctx context.Context, applicat
|
|||
appStatus := applicationSet.Status.ApplicationStatus[idx]
|
||||
|
||||
if app, ok := appMap[appName]; ok {
|
||||
|
||||
syncEnabled = appSyncEnabledForNextStep(&applicationSet, app, appStatus)
|
||||
if !syncEnabled {
|
||||
break
|
||||
|
|
@ -1112,7 +1088,6 @@ func (r *ApplicationSetReconciler) buildAppSyncMap(ctx context.Context, applicat
|
|||
}
|
||||
|
||||
func appSyncEnabledForNextStep(appset *argov1alpha1.ApplicationSet, app argov1alpha1.Application, appStatus argov1alpha1.ApplicationSetApplicationStatus) bool {
|
||||
|
||||
if progressiveSyncsStrategyEnabled(appset, "RollingSync") {
|
||||
// we still need to complete the current step if the Application is not yet Healthy or there are still pending Application changes
|
||||
return isApplicationHealthy(app) && appStatus.Status == "Healthy"
|
||||
|
|
@ -1155,12 +1130,10 @@ func statusStrings(app argov1alpha1.Application) (string, string, string) {
|
|||
|
||||
// check the status of each Application's status and promote Applications to the next status if needed
|
||||
func (r *ApplicationSetReconciler) updateApplicationSetApplicationStatus(ctx context.Context, logCtx *log.Entry, applicationSet *argov1alpha1.ApplicationSet, applications []argov1alpha1.Application, appStepMap map[string]int) ([]argov1alpha1.ApplicationSetApplicationStatus, error) {
|
||||
|
||||
now := metav1.Now()
|
||||
appStatuses := make([]argov1alpha1.ApplicationSetApplicationStatus, 0, len(applications))
|
||||
|
||||
for _, app := range applications {
|
||||
|
||||
healthStatusString, syncStatusString, operationPhaseString := statusStrings(app)
|
||||
|
||||
idx := findApplicationStatusIndex(applicationSet.Status.ApplicationStatus, app.Name)
|
||||
|
|
@ -1280,7 +1253,6 @@ func (r *ApplicationSetReconciler) updateApplicationSetApplicationStatusProgress
|
|||
}
|
||||
|
||||
for _, appStatus := range applicationSet.Status.ApplicationStatus {
|
||||
|
||||
maxUpdateAllowed := true
|
||||
maxUpdate := &intstr.IntOrString{}
|
||||
if progressiveSyncsStrategyEnabled(applicationSet, "RollingSync") {
|
||||
|
|
@ -1303,7 +1275,6 @@ func (r *ApplicationSetReconciler) updateApplicationSetApplicationStatusProgress
|
|||
maxUpdateAllowed = false
|
||||
logCtx.Infof("Application %v is not allowed to update yet, %v/%v Applications already updating in step %v in AppSet %v", appStatus.Application, updateCountMap[appStepMap[appStatus.Application]], maxUpdateVal, appStepMap[appStatus.Application]+1, applicationSet.Name)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if appStatus.Status == "Waiting" && appSyncMap[appStatus.Application] && maxUpdateAllowed {
|
||||
|
|
@ -1329,7 +1300,6 @@ func (r *ApplicationSetReconciler) updateApplicationSetApplicationStatusProgress
|
|||
}
|
||||
|
||||
func (r *ApplicationSetReconciler) updateApplicationSetApplicationStatusConditions(ctx context.Context, applicationSet *argov1alpha1.ApplicationSet) ([]argov1alpha1.ApplicationSetCondition, error) {
|
||||
|
||||
appSetProgressing := false
|
||||
for _, appStatus := range applicationSet.Status.ApplicationStatus {
|
||||
if appStatus.Status != "Healthy" {
|
||||
|
|
@ -1393,7 +1363,6 @@ func (r *ApplicationSetReconciler) updateResourcesStatus(ctx context.Context, lo
|
|||
namespacedName := types.NamespacedName{Namespace: appset.Namespace, Name: appset.Name}
|
||||
err := r.Client.Status().Update(ctx, appset)
|
||||
if err != nil {
|
||||
|
||||
logCtx.Errorf("unable to set application set status: %v", err)
|
||||
return fmt.Errorf("unable to set application set status: %v", err)
|
||||
}
|
||||
|
|
@ -1495,7 +1464,6 @@ func (r *ApplicationSetReconciler) setAppSetApplicationStatus(ctx context.Contex
|
|||
// Update the newly fetched object with new set of ApplicationStatus
|
||||
err := r.Client.Status().Update(ctx, applicationSet)
|
||||
if err != nil {
|
||||
|
||||
logCtx.Errorf("unable to set application set status: %v", err)
|
||||
return fmt.Errorf("unable to set application set status: %v", err)
|
||||
}
|
||||
|
|
@ -1541,7 +1509,6 @@ func (r *ApplicationSetReconciler) syncValidApplications(logCtx *log.Entry, appl
|
|||
|
||||
// used by the RollingSync Progressive Sync strategy to trigger a sync of a particular Application resource
|
||||
func syncApplication(application argov1alpha1.Application, prune bool) (argov1alpha1.Application, error) {
|
||||
|
||||
operation := argov1alpha1.Operation{
|
||||
InitiatedBy: argov1alpha1.OperationInitiator{
|
||||
Username: "applicationset-controller",
|
||||
|
|
@ -1644,7 +1611,6 @@ func shouldRequeueApplicationSet(appOld *argov1alpha1.Application, appNew *argov
|
|||
!cmp.Equal(appOld.ObjectMeta.GetAnnotations(), appNew.ObjectMeta.GetAnnotations(), cmpopts.EquateEmpty()) ||
|
||||
!cmp.Equal(appOld.ObjectMeta.GetLabels(), appNew.ObjectMeta.GetLabels(), cmpopts.EquateEmpty()) ||
|
||||
!cmp.Equal(appOld.ObjectMeta.GetFinalizers(), appNew.ObjectMeta.GetFinalizers(), cmpopts.EquateEmpty()) {
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -111,7 +111,6 @@ func (r *rendererMock) RenderTemplateParams(tmpl *v1alpha1.Application, syncPoli
|
|||
}
|
||||
|
||||
return args.Get(0).(*v1alpha1.Application), args.Error(1)
|
||||
|
||||
}
|
||||
|
||||
func (r *rendererMock) Replace(tmpl string, replaceMap map[string]interface{}, useGoTemplate bool, goTemplateOptions []string) (string, error) {
|
||||
|
|
@ -180,7 +179,6 @@ func TestExtractApplications(t *testing.T) {
|
|||
}
|
||||
|
||||
t.Run(cc.name, func(t *testing.T) {
|
||||
|
||||
appSet := &v1alpha1.ApplicationSet{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "name",
|
||||
|
|
@ -207,7 +205,6 @@ func TestExtractApplications(t *testing.T) {
|
|||
|
||||
if cc.generateParamsError == nil {
|
||||
for _, p := range cc.params {
|
||||
|
||||
if cc.rendererError != nil {
|
||||
rendererMock.On("RenderTemplateParams", getTempApplication(cc.template), p, false, []string(nil)).
|
||||
Return(nil, cc.rendererError)
|
||||
|
|
@ -254,10 +251,8 @@ func TestExtractApplications(t *testing.T) {
|
|||
if cc.generateParamsError == nil {
|
||||
rendererMock.AssertNumberOfCalls(t, "RenderTemplateParams", len(cc.params))
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestMergeTemplateApplications(t *testing.T) {
|
||||
|
|
@ -316,7 +311,6 @@ func TestMergeTemplateApplications(t *testing.T) {
|
|||
cc := c
|
||||
|
||||
t.Run(cc.name, func(t *testing.T) {
|
||||
|
||||
generatorMock := generatorMock{}
|
||||
generator := v1alpha1.ApplicationSetGenerator{
|
||||
List: &v1alpha1.ListGenerator{},
|
||||
|
|
@ -359,11 +353,9 @@ func TestMergeTemplateApplications(t *testing.T) {
|
|||
assert.Equal(t, cc.expectedApps, got)
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestCreateOrUpdateInCluster(t *testing.T) {
|
||||
|
||||
scheme := runtime.NewScheme()
|
||||
err := v1alpha1.AddToScheme(scheme)
|
||||
assert.NoError(t, err)
|
||||
|
|
@ -871,7 +863,8 @@ func TestCreateOrUpdateInCluster(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
}, {
|
||||
},
|
||||
{
|
||||
name: "Ensure that configured preserved annotations are preserved from an existing app",
|
||||
appSet: v1alpha1.ApplicationSet{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
|
|
@ -938,7 +931,8 @@ func TestCreateOrUpdateInCluster(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
}, {
|
||||
},
|
||||
{
|
||||
name: "Ensure that the app spec is normalized before applying",
|
||||
appSet: v1alpha1.ApplicationSet{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
|
|
@ -992,7 +986,8 @@ func TestCreateOrUpdateInCluster(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
}, {
|
||||
},
|
||||
{
|
||||
// For this use case: https://github.com/argoproj/argo-cd/issues/9101#issuecomment-1191138278
|
||||
name: "Ensure that ignored targetRevision difference doesn't cause an update, even if another field changes",
|
||||
appSet: v1alpha1.ApplicationSet{
|
||||
|
|
@ -1083,7 +1078,8 @@ func TestCreateOrUpdateInCluster(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
}, {
|
||||
},
|
||||
{
|
||||
// For this use case: https://github.com/argoproj/argo-cd/pull/14743#issuecomment-1761954799
|
||||
name: "ignore parameters added to a multi-source app in the cluster",
|
||||
appSet: v1alpha1.ApplicationSet{
|
||||
|
|
@ -1184,7 +1180,8 @@ func TestCreateOrUpdateInCluster(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
}, {
|
||||
},
|
||||
{
|
||||
name: "Demonstrate limitation of MergePatch", // Maybe we can fix this in Argo CD 3.0: https://github.com/argoproj/argo-cd/issues/15975
|
||||
appSet: v1alpha1.ApplicationSet{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
|
|
@ -1282,7 +1279,8 @@ func TestCreateOrUpdateInCluster(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
}, {
|
||||
},
|
||||
{
|
||||
name: "Ensure that argocd post-delete finalizers are preserved from an existing app",
|
||||
appSet: v1alpha1.ApplicationSet{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
|
|
@ -1349,9 +1347,7 @@ func TestCreateOrUpdateInCluster(t *testing.T) {
|
|||
},
|
||||
},
|
||||
} {
|
||||
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
|
||||
initObjs := []crtclient.Object{&c.appSet}
|
||||
|
||||
for _, a := range c.existingApps {
|
||||
|
|
@ -1387,7 +1383,6 @@ func TestCreateOrUpdateInCluster(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRemoveFinalizerOnInvalidDestination_FinalizerTypes(t *testing.T) {
|
||||
|
||||
scheme := runtime.NewScheme()
|
||||
err := v1alpha1.AddToScheme(scheme)
|
||||
assert.NoError(t, err)
|
||||
|
|
@ -1423,7 +1418,6 @@ func TestRemoveFinalizerOnInvalidDestination_FinalizerTypes(t *testing.T) {
|
|||
},
|
||||
} {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
|
||||
appSet := v1alpha1.ApplicationSet{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "name",
|
||||
|
|
@ -1481,9 +1475,9 @@ func TestRemoveFinalizerOnInvalidDestination_FinalizerTypes(t *testing.T) {
|
|||
KubeClientset: kubeclientset,
|
||||
Cache: &fakeCache{},
|
||||
}
|
||||
//settingsMgr := settings.NewSettingsManager(context.TODO(), kubeclientset, "namespace")
|
||||
//argoDB := db.NewDB("namespace", settingsMgr, r.KubeClientset)
|
||||
//clusterList, err := argoDB.ListClusters(context.Background())
|
||||
// settingsMgr := settings.NewSettingsManager(context.TODO(), kubeclientset, "namespace")
|
||||
// argoDB := db.NewDB("namespace", settingsMgr, r.KubeClientset)
|
||||
// clusterList, err := argoDB.ListClusters(context.Background())
|
||||
clusterList, err := utils.ListClusters(context.Background(), kubeclientset, "namespace")
|
||||
assert.NoError(t, err, "Unexpected error")
|
||||
|
||||
|
|
@ -1506,13 +1500,11 @@ func TestRemoveFinalizerOnInvalidDestination_FinalizerTypes(t *testing.T) {
|
|||
|
||||
bytes, _ := json.MarshalIndent(retrievedApp, "", " ")
|
||||
t.Log("Contents of app after call:", string(bytes))
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestRemoveFinalizerOnInvalidDestination_DestinationTypes(t *testing.T) {
|
||||
|
||||
scheme := runtime.NewScheme()
|
||||
err := v1alpha1.AddToScheme(scheme)
|
||||
assert.NoError(t, err)
|
||||
|
|
@ -1584,9 +1576,7 @@ func TestRemoveFinalizerOnInvalidDestination_DestinationTypes(t *testing.T) {
|
|||
expectFinalizerRemoved: false,
|
||||
},
|
||||
} {
|
||||
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
|
||||
appSet := v1alpha1.ApplicationSet{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "name",
|
||||
|
|
@ -1666,7 +1656,6 @@ func TestRemoveFinalizerOnInvalidDestination_DestinationTypes(t *testing.T) {
|
|||
|
||||
bytes, _ := json.MarshalIndent(retrievedApp, "", " ")
|
||||
t.Log("Contents of app after call:", string(bytes))
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -1747,7 +1736,6 @@ func TestRemoveOwnerReferencesOnDeleteAppSet(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCreateApplications(t *testing.T) {
|
||||
|
||||
scheme := runtime.NewScheme()
|
||||
err := v1alpha1.AddToScheme(scheme)
|
||||
assert.NoError(t, err)
|
||||
|
|
@ -1951,7 +1939,6 @@ func TestCreateApplications(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDeleteInCluster(t *testing.T) {
|
||||
|
||||
scheme := runtime.NewScheme()
|
||||
err := v1alpha1.AddToScheme(scheme)
|
||||
assert.NoError(t, err)
|
||||
|
|
@ -2154,7 +2141,6 @@ func TestGetMinRequeueAfter(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestValidateGeneratedApplications(t *testing.T) {
|
||||
|
||||
scheme := runtime.NewScheme()
|
||||
err := v1alpha1.AddToScheme(scheme)
|
||||
assert.NoError(t, err)
|
||||
|
|
@ -2314,9 +2300,7 @@ func TestValidateGeneratedApplications(t *testing.T) {
|
|||
validationErrors: map[int]error{0: fmt.Errorf("application destination spec is invalid: unable to find destination server: there are no clusters with this name: nonexistent-cluster")},
|
||||
},
|
||||
} {
|
||||
|
||||
t.Run(cc.name, func(t *testing.T) {
|
||||
|
||||
secret := &corev1.Secret{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "my-secret",
|
||||
|
|
@ -2394,7 +2378,6 @@ func TestValidateGeneratedApplications(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestReconcilerValidationProjectErrorBehaviour(t *testing.T) {
|
||||
|
||||
scheme := runtime.NewScheme()
|
||||
err := v1alpha1.AddToScheme(scheme)
|
||||
assert.NoError(t, err)
|
||||
|
|
@ -2490,7 +2473,6 @@ func TestReconcilerValidationProjectErrorBehaviour(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestReconcilerCreateAppsRecoveringRenderError(t *testing.T) {
|
||||
|
||||
scheme := runtime.NewScheme()
|
||||
err := v1alpha1.AddToScheme(scheme)
|
||||
assert.NoError(t, err)
|
||||
|
|
@ -2632,7 +2614,6 @@ func TestSetApplicationSetStatusCondition(t *testing.T) {
|
|||
}
|
||||
|
||||
func applicationsUpdateSyncPolicyTest(t *testing.T, applicationsSyncPolicy v1alpha1.ApplicationsSyncPolicy, recordBuffer int, allowPolicyOverride bool) v1alpha1.Application {
|
||||
|
||||
scheme := runtime.NewScheme()
|
||||
err := v1alpha1.AddToScheme(scheme)
|
||||
assert.NoError(t, err)
|
||||
|
|
@ -2749,7 +2730,6 @@ func applicationsUpdateSyncPolicyTest(t *testing.T, applicationsSyncPolicy v1alp
|
|||
}
|
||||
|
||||
func TestUpdateNotPerformedWithSyncPolicyCreateOnly(t *testing.T) {
|
||||
|
||||
applicationsSyncPolicy := v1alpha1.ApplicationsSyncPolicyCreateOnly
|
||||
|
||||
app := applicationsUpdateSyncPolicyTest(t, applicationsSyncPolicy, 1, true)
|
||||
|
|
@ -2759,7 +2739,6 @@ func TestUpdateNotPerformedWithSyncPolicyCreateOnly(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUpdateNotPerformedWithSyncPolicyCreateDelete(t *testing.T) {
|
||||
|
||||
applicationsSyncPolicy := v1alpha1.ApplicationsSyncPolicyCreateDelete
|
||||
|
||||
app := applicationsUpdateSyncPolicyTest(t, applicationsSyncPolicy, 1, true)
|
||||
|
|
@ -2769,7 +2748,6 @@ func TestUpdateNotPerformedWithSyncPolicyCreateDelete(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUpdatePerformedWithSyncPolicyCreateUpdate(t *testing.T) {
|
||||
|
||||
applicationsSyncPolicy := v1alpha1.ApplicationsSyncPolicyCreateUpdate
|
||||
|
||||
app := applicationsUpdateSyncPolicyTest(t, applicationsSyncPolicy, 2, true)
|
||||
|
|
@ -2780,7 +2758,6 @@ func TestUpdatePerformedWithSyncPolicyCreateUpdate(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUpdatePerformedWithSyncPolicySync(t *testing.T) {
|
||||
|
||||
applicationsSyncPolicy := v1alpha1.ApplicationsSyncPolicySync
|
||||
|
||||
app := applicationsUpdateSyncPolicyTest(t, applicationsSyncPolicy, 2, true)
|
||||
|
|
@ -2791,7 +2768,6 @@ func TestUpdatePerformedWithSyncPolicySync(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUpdatePerformedWithSyncPolicyCreateOnlyAndAllowPolicyOverrideFalse(t *testing.T) {
|
||||
|
||||
applicationsSyncPolicy := v1alpha1.ApplicationsSyncPolicyCreateOnly
|
||||
|
||||
app := applicationsUpdateSyncPolicyTest(t, applicationsSyncPolicy, 2, false)
|
||||
|
|
@ -2802,7 +2778,6 @@ func TestUpdatePerformedWithSyncPolicyCreateOnlyAndAllowPolicyOverrideFalse(t *t
|
|||
}
|
||||
|
||||
func applicationsDeleteSyncPolicyTest(t *testing.T, applicationsSyncPolicy v1alpha1.ApplicationsSyncPolicy, recordBuffer int, allowPolicyOverride bool) v1alpha1.ApplicationList {
|
||||
|
||||
scheme := runtime.NewScheme()
|
||||
err := v1alpha1.AddToScheme(scheme)
|
||||
assert.NoError(t, err)
|
||||
|
|
@ -2920,7 +2895,6 @@ func applicationsDeleteSyncPolicyTest(t *testing.T, applicationsSyncPolicy v1alp
|
|||
}
|
||||
|
||||
func TestDeleteNotPerformedWithSyncPolicyCreateOnly(t *testing.T) {
|
||||
|
||||
applicationsSyncPolicy := v1alpha1.ApplicationsSyncPolicyCreateOnly
|
||||
|
||||
apps := applicationsDeleteSyncPolicyTest(t, applicationsSyncPolicy, 1, true)
|
||||
|
|
@ -2929,7 +2903,6 @@ func TestDeleteNotPerformedWithSyncPolicyCreateOnly(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDeleteNotPerformedWithSyncPolicyCreateUpdate(t *testing.T) {
|
||||
|
||||
applicationsSyncPolicy := v1alpha1.ApplicationsSyncPolicyCreateUpdate
|
||||
|
||||
apps := applicationsDeleteSyncPolicyTest(t, applicationsSyncPolicy, 2, true)
|
||||
|
|
@ -2938,7 +2911,6 @@ func TestDeleteNotPerformedWithSyncPolicyCreateUpdate(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDeletePerformedWithSyncPolicyCreateDelete(t *testing.T) {
|
||||
|
||||
applicationsSyncPolicy := v1alpha1.ApplicationsSyncPolicyCreateDelete
|
||||
|
||||
apps := applicationsDeleteSyncPolicyTest(t, applicationsSyncPolicy, 3, true)
|
||||
|
|
@ -2947,7 +2919,6 @@ func TestDeletePerformedWithSyncPolicyCreateDelete(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDeletePerformedWithSyncPolicySync(t *testing.T) {
|
||||
|
||||
applicationsSyncPolicy := v1alpha1.ApplicationsSyncPolicySync
|
||||
|
||||
apps := applicationsDeleteSyncPolicyTest(t, applicationsSyncPolicy, 3, true)
|
||||
|
|
@ -2956,7 +2927,6 @@ func TestDeletePerformedWithSyncPolicySync(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDeletePerformedWithSyncPolicyCreateOnlyAndAllowPolicyOverrideFalse(t *testing.T) {
|
||||
|
||||
applicationsSyncPolicy := v1alpha1.ApplicationsSyncPolicyCreateOnly
|
||||
|
||||
apps := applicationsDeleteSyncPolicyTest(t, applicationsSyncPolicy, 3, false)
|
||||
|
|
@ -2977,16 +2947,18 @@ func TestGenerateAppsUsingPullRequestGenerator(t *testing.T) {
|
|||
}{
|
||||
{
|
||||
name: "Generate an application from a go template application set manifest using a pull request generator",
|
||||
params: []map[string]interface{}{{
|
||||
"number": "1",
|
||||
"branch": "branch1",
|
||||
"branch_slug": "branchSlug1",
|
||||
"head_sha": "089d92cbf9ff857a39e6feccd32798ca700fb958",
|
||||
"head_short_sha": "089d92cb",
|
||||
"branch_slugify_default": "feat/a_really+long_pull_request_name_to_test_argo_slugification_and_branch_name_shortening_feature",
|
||||
"branch_slugify_smarttruncate_disabled": "feat/areallylongpullrequestnametotestargoslugificationandbranchnameshorteningfeature",
|
||||
"branch_slugify_smarttruncate_enabled": "feat/testwithsmarttruncateenabledramdomlonglistofcharacters",
|
||||
"labels": []string{"label1"}},
|
||||
params: []map[string]interface{}{
|
||||
{
|
||||
"number": "1",
|
||||
"branch": "branch1",
|
||||
"branch_slug": "branchSlug1",
|
||||
"head_sha": "089d92cbf9ff857a39e6feccd32798ca700fb958",
|
||||
"head_short_sha": "089d92cb",
|
||||
"branch_slugify_default": "feat/a_really+long_pull_request_name_to_test_argo_slugification_and_branch_name_shortening_feature",
|
||||
"branch_slugify_smarttruncate_disabled": "feat/areallylongpullrequestnametotestargoslugificationandbranchnameshorteningfeature",
|
||||
"branch_slugify_smarttruncate_enabled": "feat/testwithsmarttruncateenabledramdomlonglistofcharacters",
|
||||
"labels": []string{"label1"},
|
||||
},
|
||||
},
|
||||
template: v1alpha1.ApplicationSetTemplate{
|
||||
ApplicationSetTemplateMeta: v1alpha1.ApplicationSetTemplateMeta{
|
||||
|
|
@ -3034,9 +3006,7 @@ func TestGenerateAppsUsingPullRequestGenerator(t *testing.T) {
|
|||
},
|
||||
},
|
||||
} {
|
||||
|
||||
t.Run(cases.name, func(t *testing.T) {
|
||||
|
||||
generatorMock := generatorMock{}
|
||||
generator := v1alpha1.ApplicationSetGenerator{
|
||||
PullRequest: &v1alpha1.PullRequestGenerator{},
|
||||
|
|
@ -3330,9 +3300,7 @@ func TestSetApplicationSetApplicationStatus(t *testing.T) {
|
|||
expectedAppStatuses: nil,
|
||||
},
|
||||
} {
|
||||
|
||||
t.Run(cc.name, func(t *testing.T) {
|
||||
|
||||
client := fake.NewClientBuilder().WithScheme(scheme).WithObjects(&cc.appSet).WithStatusSubresource(&cc.appSet).Build()
|
||||
|
||||
r := ApplicationSetReconciler{
|
||||
|
|
@ -3358,7 +3326,6 @@ func TestSetApplicationSetApplicationStatus(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestBuildAppDependencyList(t *testing.T) {
|
||||
|
||||
scheme := runtime.NewScheme()
|
||||
err := v1alpha1.AddToScheme(scheme)
|
||||
assert.NoError(t, err)
|
||||
|
|
@ -4094,9 +4061,7 @@ func TestBuildAppDependencyList(t *testing.T) {
|
|||
},
|
||||
},
|
||||
} {
|
||||
|
||||
t.Run(cc.name, func(t *testing.T) {
|
||||
|
||||
kubeclientset := kubefake.NewSimpleClientset([]runtime.Object{}...)
|
||||
argoDBMock := dbmocks.ArgoDB{}
|
||||
argoObjs := []runtime.Object{}
|
||||
|
|
@ -4121,7 +4086,6 @@ func TestBuildAppDependencyList(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestBuildAppSyncMap(t *testing.T) {
|
||||
|
||||
scheme := runtime.NewScheme()
|
||||
err := v1alpha1.AddToScheme(scheme)
|
||||
assert.NoError(t, err)
|
||||
|
|
@ -4688,9 +4652,7 @@ func TestBuildAppSyncMap(t *testing.T) {
|
|||
},
|
||||
},
|
||||
} {
|
||||
|
||||
t.Run(cc.name, func(t *testing.T) {
|
||||
|
||||
kubeclientset := kubefake.NewSimpleClientset([]runtime.Object{}...)
|
||||
argoDBMock := dbmocks.ArgoDB{}
|
||||
argoObjs := []runtime.Object{}
|
||||
|
|
@ -4714,7 +4676,6 @@ func TestBuildAppSyncMap(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUpdateApplicationSetApplicationStatus(t *testing.T) {
|
||||
|
||||
scheme := runtime.NewScheme()
|
||||
err := v1alpha1.AddToScheme(scheme)
|
||||
assert.NoError(t, err)
|
||||
|
|
@ -5416,9 +5377,7 @@ func TestUpdateApplicationSetApplicationStatus(t *testing.T) {
|
|||
},
|
||||
},
|
||||
} {
|
||||
|
||||
t.Run(cc.name, func(t *testing.T) {
|
||||
|
||||
kubeclientset := kubefake.NewSimpleClientset([]runtime.Object{}...)
|
||||
argoDBMock := dbmocks.ArgoDB{}
|
||||
argoObjs := []runtime.Object{}
|
||||
|
|
@ -5450,7 +5409,6 @@ func TestUpdateApplicationSetApplicationStatus(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUpdateApplicationSetApplicationStatusProgress(t *testing.T) {
|
||||
|
||||
scheme := runtime.NewScheme()
|
||||
err := v1alpha1.AddToScheme(scheme)
|
||||
assert.NoError(t, err)
|
||||
|
|
@ -6170,9 +6128,7 @@ func TestUpdateApplicationSetApplicationStatusProgress(t *testing.T) {
|
|||
},
|
||||
},
|
||||
} {
|
||||
|
||||
t.Run(cc.name, func(t *testing.T) {
|
||||
|
||||
kubeclientset := kubefake.NewSimpleClientset([]runtime.Object{}...)
|
||||
argoDBMock := dbmocks.ArgoDB{}
|
||||
argoObjs := []runtime.Object{}
|
||||
|
|
@ -6204,7 +6160,6 @@ func TestUpdateApplicationSetApplicationStatusProgress(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUpdateResourceStatus(t *testing.T) {
|
||||
|
||||
scheme := runtime.NewScheme()
|
||||
err := v1alpha1.AddToScheme(scheme)
|
||||
assert.NoError(t, err)
|
||||
|
|
@ -6388,9 +6343,7 @@ func TestUpdateResourceStatus(t *testing.T) {
|
|||
expectedResources: nil,
|
||||
},
|
||||
} {
|
||||
|
||||
t.Run(cc.name, func(t *testing.T) {
|
||||
|
||||
kubeclientset := kubefake.NewSimpleClientset([]runtime.Object{}...)
|
||||
argoDBMock := dbmocks.ArgoDB{}
|
||||
argoObjs := []runtime.Object{}
|
||||
|
|
@ -6449,60 +6402,64 @@ func TestOwnsHandler(t *testing.T) {
|
|||
ResourceVersion: "bar",
|
||||
}},
|
||||
}}, want: false},
|
||||
{name: "ApplicationHealthStatusDiff", args: args{e: event.UpdateEvent{
|
||||
ObjectOld: &v1alpha1.Application{Status: v1alpha1.ApplicationStatus{
|
||||
Health: v1alpha1.HealthStatus{
|
||||
Status: "Unknown",
|
||||
},
|
||||
}},
|
||||
ObjectNew: &v1alpha1.Application{Status: v1alpha1.ApplicationStatus{
|
||||
Health: v1alpha1.HealthStatus{
|
||||
Status: "Healthy",
|
||||
},
|
||||
}},
|
||||
},
|
||||
{name: "ApplicationHealthStatusDiff", args: args{
|
||||
e: event.UpdateEvent{
|
||||
ObjectOld: &v1alpha1.Application{Status: v1alpha1.ApplicationStatus{
|
||||
Health: v1alpha1.HealthStatus{
|
||||
Status: "Unknown",
|
||||
},
|
||||
}},
|
||||
ObjectNew: &v1alpha1.Application{Status: v1alpha1.ApplicationStatus{
|
||||
Health: v1alpha1.HealthStatus{
|
||||
Status: "Healthy",
|
||||
},
|
||||
}},
|
||||
},
|
||||
enableProgressiveSyncs: true,
|
||||
}, want: true},
|
||||
{name: "ApplicationSyncStatusDiff", args: args{e: event.UpdateEvent{
|
||||
ObjectOld: &v1alpha1.Application{Status: v1alpha1.ApplicationStatus{
|
||||
Sync: v1alpha1.SyncStatus{
|
||||
Status: "OutOfSync",
|
||||
},
|
||||
}},
|
||||
ObjectNew: &v1alpha1.Application{Status: v1alpha1.ApplicationStatus{
|
||||
Sync: v1alpha1.SyncStatus{
|
||||
Status: "Synced",
|
||||
},
|
||||
}},
|
||||
},
|
||||
{name: "ApplicationSyncStatusDiff", args: args{
|
||||
e: event.UpdateEvent{
|
||||
ObjectOld: &v1alpha1.Application{Status: v1alpha1.ApplicationStatus{
|
||||
Sync: v1alpha1.SyncStatus{
|
||||
Status: "OutOfSync",
|
||||
},
|
||||
}},
|
||||
ObjectNew: &v1alpha1.Application{Status: v1alpha1.ApplicationStatus{
|
||||
Sync: v1alpha1.SyncStatus{
|
||||
Status: "Synced",
|
||||
},
|
||||
}},
|
||||
},
|
||||
enableProgressiveSyncs: true,
|
||||
}, want: true},
|
||||
{name: "ApplicationOperationStateDiff", args: args{e: event.UpdateEvent{
|
||||
ObjectOld: &v1alpha1.Application{Status: v1alpha1.ApplicationStatus{
|
||||
OperationState: &v1alpha1.OperationState{
|
||||
Phase: "foo",
|
||||
},
|
||||
}},
|
||||
ObjectNew: &v1alpha1.Application{Status: v1alpha1.ApplicationStatus{
|
||||
OperationState: &v1alpha1.OperationState{
|
||||
Phase: "bar",
|
||||
},
|
||||
}},
|
||||
},
|
||||
{name: "ApplicationOperationStateDiff", args: args{
|
||||
e: event.UpdateEvent{
|
||||
ObjectOld: &v1alpha1.Application{Status: v1alpha1.ApplicationStatus{
|
||||
OperationState: &v1alpha1.OperationState{
|
||||
Phase: "foo",
|
||||
},
|
||||
}},
|
||||
ObjectNew: &v1alpha1.Application{Status: v1alpha1.ApplicationStatus{
|
||||
OperationState: &v1alpha1.OperationState{
|
||||
Phase: "bar",
|
||||
},
|
||||
}},
|
||||
},
|
||||
enableProgressiveSyncs: true,
|
||||
}, want: true},
|
||||
{name: "ApplicationOperationStartedAtDiff", args: args{e: event.UpdateEvent{
|
||||
ObjectOld: &v1alpha1.Application{Status: v1alpha1.ApplicationStatus{
|
||||
OperationState: &v1alpha1.OperationState{
|
||||
StartedAt: now,
|
||||
},
|
||||
}},
|
||||
ObjectNew: &v1alpha1.Application{Status: v1alpha1.ApplicationStatus{
|
||||
OperationState: &v1alpha1.OperationState{
|
||||
StartedAt: metav1.NewTime(now.Add(time.Minute * 1)),
|
||||
},
|
||||
}},
|
||||
},
|
||||
{name: "ApplicationOperationStartedAtDiff", args: args{
|
||||
e: event.UpdateEvent{
|
||||
ObjectOld: &v1alpha1.Application{Status: v1alpha1.ApplicationStatus{
|
||||
OperationState: &v1alpha1.OperationState{
|
||||
StartedAt: now,
|
||||
},
|
||||
}},
|
||||
ObjectNew: &v1alpha1.Application{Status: v1alpha1.ApplicationStatus{
|
||||
OperationState: &v1alpha1.OperationState{
|
||||
StartedAt: metav1.NewTime(now.Add(time.Minute * 1)),
|
||||
},
|
||||
}},
|
||||
},
|
||||
enableProgressiveSyncs: true,
|
||||
}, want: true},
|
||||
{name: "SameApplicationGeneration", args: args{e: event.UpdateEvent{
|
||||
|
|
@ -6541,48 +6498,50 @@ func TestOwnsHandler(t *testing.T) {
|
|||
ObjectOld: &v1alpha1.Application{ObjectMeta: metav1.ObjectMeta{Finalizers: []string{}}},
|
||||
ObjectNew: &v1alpha1.Application{ObjectMeta: metav1.ObjectMeta{Finalizers: nil}},
|
||||
}}, want: false},
|
||||
{name: "ApplicationDestinationSame", args: args{e: event.UpdateEvent{
|
||||
ObjectOld: &v1alpha1.Application{
|
||||
Spec: v1alpha1.ApplicationSpec{
|
||||
Destination: v1alpha1.ApplicationDestination{
|
||||
Server: "server",
|
||||
Namespace: "ns",
|
||||
Name: "name",
|
||||
{name: "ApplicationDestinationSame", args: args{
|
||||
e: event.UpdateEvent{
|
||||
ObjectOld: &v1alpha1.Application{
|
||||
Spec: v1alpha1.ApplicationSpec{
|
||||
Destination: v1alpha1.ApplicationDestination{
|
||||
Server: "server",
|
||||
Namespace: "ns",
|
||||
Name: "name",
|
||||
},
|
||||
},
|
||||
},
|
||||
ObjectNew: &v1alpha1.Application{
|
||||
Spec: v1alpha1.ApplicationSpec{
|
||||
Destination: v1alpha1.ApplicationDestination{
|
||||
Server: "server",
|
||||
Namespace: "ns",
|
||||
Name: "name",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
ObjectNew: &v1alpha1.Application{
|
||||
Spec: v1alpha1.ApplicationSpec{
|
||||
Destination: v1alpha1.ApplicationDestination{
|
||||
Server: "server",
|
||||
Namespace: "ns",
|
||||
Name: "name",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
enableProgressiveSyncs: true,
|
||||
}, want: false},
|
||||
{name: "ApplicationDestinationDiff", args: args{e: event.UpdateEvent{
|
||||
ObjectOld: &v1alpha1.Application{
|
||||
Spec: v1alpha1.ApplicationSpec{
|
||||
Destination: v1alpha1.ApplicationDestination{
|
||||
Server: "server",
|
||||
Namespace: "ns",
|
||||
Name: "name",
|
||||
{name: "ApplicationDestinationDiff", args: args{
|
||||
e: event.UpdateEvent{
|
||||
ObjectOld: &v1alpha1.Application{
|
||||
Spec: v1alpha1.ApplicationSpec{
|
||||
Destination: v1alpha1.ApplicationDestination{
|
||||
Server: "server",
|
||||
Namespace: "ns",
|
||||
Name: "name",
|
||||
},
|
||||
},
|
||||
},
|
||||
ObjectNew: &v1alpha1.Application{
|
||||
Spec: v1alpha1.ApplicationSpec{
|
||||
Destination: v1alpha1.ApplicationDestination{
|
||||
Server: "notSameServer",
|
||||
Namespace: "ns",
|
||||
Name: "name",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
ObjectNew: &v1alpha1.Application{
|
||||
Spec: v1alpha1.ApplicationSpec{
|
||||
Destination: v1alpha1.ApplicationDestination{
|
||||
Server: "notSameServer",
|
||||
Namespace: "ns",
|
||||
Name: "name",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
enableProgressiveSyncs: true,
|
||||
}, want: true},
|
||||
{name: "NotAnAppOld", args: args{e: event.UpdateEvent{
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import (
|
|||
// clusterSecretEventHandler is used when watching Secrets to check if they are ArgoCD Cluster Secrets, and if so
|
||||
// requeue any related ApplicationSets.
|
||||
type clusterSecretEventHandler struct {
|
||||
//handler.EnqueueRequestForOwner
|
||||
// handler.EnqueueRequestForOwner
|
||||
Log log.FieldLogger
|
||||
Client client.Client
|
||||
}
|
||||
|
|
@ -66,7 +66,6 @@ func (h *clusterSecretEventHandler) queueRelatedAppGenerators(ctx context.Contex
|
|||
|
||||
h.Log.WithField("count", len(appSetList.Items)).Info("listed ApplicationSets")
|
||||
for _, appSet := range appSetList.Items {
|
||||
|
||||
foundClusterGenerator := false
|
||||
for _, generator := range appSet.Spec.Generators {
|
||||
if generator.Clusters != nil {
|
||||
|
|
@ -109,7 +108,6 @@ func (h *clusterSecretEventHandler) queueRelatedAppGenerators(ctx context.Contex
|
|||
}
|
||||
}
|
||||
if foundClusterGenerator {
|
||||
|
||||
// TODO: only queue the AppGenerator if the labels match this cluster
|
||||
req := ctrl.Request{NamespacedName: types.NamespacedName{Namespace: appSet.Namespace, Name: appSet.Name}}
|
||||
q.Add(req)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import (
|
|||
)
|
||||
|
||||
func TestClusterEventHandler(t *testing.T) {
|
||||
|
||||
scheme := runtime.NewScheme()
|
||||
err := argov1alpha1.AddToScheme(scheme)
|
||||
assert.NoError(t, err)
|
||||
|
|
@ -535,9 +534,7 @@ func TestClusterEventHandler(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
|
||||
appSetList := argov1alpha1.ApplicationSetList{
|
||||
Items: test.items,
|
||||
}
|
||||
|
|
@ -555,10 +552,8 @@ func TestClusterEventHandler(t *testing.T) {
|
|||
|
||||
assert.False(t, mockAddRateLimitingInterface.errorOccurred)
|
||||
assert.ElementsMatch(t, mockAddRateLimitingInterface.addedItems, test.expectedRequests)
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Add checks the type, and adds it to the internal list of received additions
|
||||
|
|
|
|||
|
|
@ -11,14 +11,12 @@ import (
|
|||
)
|
||||
|
||||
func applyTemplatePatch(app *appv1.Application, templatePatch string) (*appv1.Application, error) {
|
||||
|
||||
appString, err := json.Marshal(app)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error while marhsalling Application %w", err)
|
||||
}
|
||||
|
||||
convertedTemplatePatch, err := utils.ConvertYAMLToJSON(templatePatch)
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error while converting template to json %q: %w", convertedTemplatePatch, err)
|
||||
}
|
||||
|
|
@ -28,7 +26,6 @@ func applyTemplatePatch(app *appv1.Application, templatePatch string) (*appv1.Ap
|
|||
}
|
||||
|
||||
data, err := strategicpatch.StrategicMergePatch(appString, []byte(convertedTemplatePatch), appv1.Application{})
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error while applying templatePatch template to json %q: %w", convertedTemplatePatch, err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ type ClusterGenerator struct {
|
|||
var render = &utils.Render{}
|
||||
|
||||
func NewClusterGenerator(c client.Client, ctx context.Context, clientset kubernetes.Interface, namespace string) Generator {
|
||||
|
||||
settingsManager := settings.NewSettingsManager(ctx, clientset, namespace)
|
||||
|
||||
g := &ClusterGenerator{
|
||||
|
|
@ -62,7 +61,6 @@ func (g *ClusterGenerator) GetTemplate(appSetGenerator *argoappsetv1alpha1.Appli
|
|||
}
|
||||
|
||||
func (g *ClusterGenerator) GenerateParams(appSetGenerator *argoappsetv1alpha1.ApplicationSetGenerator, appSet *argoappsetv1alpha1.ApplicationSet) ([]map[string]interface{}, error) {
|
||||
|
||||
if appSetGenerator == nil {
|
||||
return nil, EmptyAppSetGeneratorError
|
||||
}
|
||||
|
|
@ -95,12 +93,10 @@ func (g *ClusterGenerator) GenerateParams(appSetGenerator *argoappsetv1alpha1.Ap
|
|||
secretsFound := []corev1.Secret{}
|
||||
|
||||
for _, cluster := range clustersFromArgoCD.Items {
|
||||
|
||||
// If there is a secret for this cluster, then it's a non-local cluster, so it will be
|
||||
// handled by the next step.
|
||||
if secretForCluster, exists := clusterSecrets[cluster.Name]; exists {
|
||||
secretsFound = append(secretsFound, secretForCluster)
|
||||
|
||||
} else if !ignoreLocalClusters {
|
||||
// If there is no secret for the cluster, it's the local cluster, so handle it here.
|
||||
params := map[string]interface{}{}
|
||||
|
|
@ -185,5 +181,4 @@ func (g *ClusterGenerator) getSecretsByClusterName(appSetGenerator *argoappsetv1
|
|||
}
|
||||
|
||||
return res, nil
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,11 +104,15 @@ func TestGenerateParams(t *testing.T) {
|
|||
"aaa": "{{ server }}",
|
||||
"no-op": "{{ this-does-not-exist }}",
|
||||
}, expected: []map[string]interface{}{
|
||||
{"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"},
|
||||
{
|
||||
"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",
|
||||
},
|
||||
|
||||
{"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"},
|
||||
{
|
||||
"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",
|
||||
},
|
||||
|
||||
{"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"},
|
||||
},
|
||||
|
|
@ -124,11 +128,15 @@ func TestGenerateParams(t *testing.T) {
|
|||
},
|
||||
values: nil,
|
||||
expected: []map[string]interface{}{
|
||||
{"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"},
|
||||
{
|
||||
"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",
|
||||
},
|
||||
|
||||
{"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"},
|
||||
{
|
||||
"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",
|
||||
},
|
||||
},
|
||||
clientError: false,
|
||||
expectedError: nil,
|
||||
|
|
@ -144,8 +152,10 @@ func TestGenerateParams(t *testing.T) {
|
|||
"foo": "bar",
|
||||
},
|
||||
expected: []map[string]interface{}{
|
||||
{"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"},
|
||||
{
|
||||
"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",
|
||||
},
|
||||
},
|
||||
clientError: false,
|
||||
expectedError: nil,
|
||||
|
|
@ -168,10 +178,14 @@ func TestGenerateParams(t *testing.T) {
|
|||
"foo": "bar",
|
||||
},
|
||||
expected: []map[string]interface{}{
|
||||
{"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"},
|
||||
{"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"},
|
||||
{
|
||||
"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",
|
||||
},
|
||||
{
|
||||
"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",
|
||||
},
|
||||
},
|
||||
clientError: false,
|
||||
expectedError: nil,
|
||||
|
|
@ -197,8 +211,10 @@ func TestGenerateParams(t *testing.T) {
|
|||
"name": "baz",
|
||||
},
|
||||
expected: []map[string]interface{}{
|
||||
{"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"},
|
||||
{
|
||||
"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",
|
||||
},
|
||||
},
|
||||
clientError: false,
|
||||
expectedError: nil,
|
||||
|
|
@ -220,9 +236,7 @@ func TestGenerateParams(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
|
||||
appClientset := kubefake.NewSimpleClientset(runtimeClusters...)
|
||||
|
||||
fakeClient := fake.NewClientBuilder().WithObjects(clusters...).Build()
|
||||
|
|
@ -231,7 +245,7 @@ func TestGenerateParams(t *testing.T) {
|
|||
testCase.clientError,
|
||||
}
|
||||
|
||||
var clusterGenerator = NewClusterGenerator(cl, context.Background(), appClientset, "namespace")
|
||||
clusterGenerator := NewClusterGenerator(cl, context.Background(), appClientset, "namespace")
|
||||
|
||||
applicationSetInfo := argoprojiov1alpha1.ApplicationSet{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
|
|
@ -253,7 +267,6 @@ func TestGenerateParams(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
assert.ElementsMatch(t, testCase.expected, got)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -594,9 +607,7 @@ func TestGenerateParamsGoTemplate(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
|
||||
appClientset := kubefake.NewSimpleClientset(runtimeClusters...)
|
||||
|
||||
fakeClient := fake.NewClientBuilder().WithObjects(clusters...).Build()
|
||||
|
|
@ -605,7 +616,7 @@ func TestGenerateParamsGoTemplate(t *testing.T) {
|
|||
testCase.clientError,
|
||||
}
|
||||
|
||||
var clusterGenerator = NewClusterGenerator(cl, context.Background(), appClientset, "namespace")
|
||||
clusterGenerator := NewClusterGenerator(cl, context.Background(), appClientset, "namespace")
|
||||
|
||||
applicationSetInfo := argoprojiov1alpha1.ApplicationSet{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
|
|
@ -629,7 +640,6 @@ func TestGenerateParamsGoTemplate(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
assert.ElementsMatch(t, testCase.expected, got)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ type DuckTypeGenerator struct {
|
|||
}
|
||||
|
||||
func NewDuckTypeGenerator(ctx context.Context, dynClient dynamic.Interface, clientset kubernetes.Interface, namespace string) Generator {
|
||||
|
||||
settingsManager := settings.NewSettingsManager(ctx, clientset, namespace)
|
||||
|
||||
g := &DuckTypeGenerator{
|
||||
|
|
@ -46,7 +45,6 @@ func NewDuckTypeGenerator(ctx context.Context, dynClient dynamic.Interface, clie
|
|||
}
|
||||
|
||||
func (g *DuckTypeGenerator) GetRequeueAfter(appSetGenerator *argoprojiov1alpha1.ApplicationSetGenerator) time.Duration {
|
||||
|
||||
// Return a requeue default of 3 minutes, if no override is specified.
|
||||
|
||||
if appSetGenerator.ClusterDecisionResource.RequeueAfterSeconds != nil {
|
||||
|
|
@ -61,7 +59,6 @@ func (g *DuckTypeGenerator) GetTemplate(appSetGenerator *argoprojiov1alpha1.Appl
|
|||
}
|
||||
|
||||
func (g *DuckTypeGenerator) GenerateParams(appSetGenerator *argoprojiov1alpha1.ApplicationSetGenerator, appSet *argoprojiov1alpha1.ApplicationSet) ([]map[string]interface{}, error) {
|
||||
|
||||
if appSetGenerator == nil {
|
||||
return nil, EmptyAppSetGeneratorError
|
||||
}
|
||||
|
|
@ -83,7 +80,6 @@ func (g *DuckTypeGenerator) GenerateParams(appSetGenerator *argoprojiov1alpha1.A
|
|||
|
||||
// Read the configMapRef
|
||||
cm, err := g.clientset.CoreV1().ConfigMaps(g.namespace).Get(g.ctx, appSetGenerator.ClusterDecisionResource.ConfigMapRef, metav1.GetOptions{})
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error reading configMapRef: %w", err)
|
||||
}
|
||||
|
|
@ -104,7 +100,6 @@ func (g *DuckTypeGenerator) GenerateParams(appSetGenerator *argoprojiov1alpha1.A
|
|||
|
||||
if (resourceName == "" && labelSelector.MatchLabels == nil && labelSelector.MatchExpressions == nil) ||
|
||||
(resourceName != "" && (labelSelector.MatchExpressions != nil || labelSelector.MatchLabels != nil)) {
|
||||
|
||||
log.Warningf("You must choose either resourceName=%v, labelSelector.matchLabels=%v or labelSelect.matchExpressions=%v", resourceName, labelSelector.MatchLabels, labelSelector.MatchExpressions)
|
||||
return nil, fmt.Errorf("There is a problem with the definition of the ClusterDecisionResource generator")
|
||||
}
|
||||
|
|
@ -122,12 +117,11 @@ func (g *DuckTypeGenerator) GenerateParams(appSetGenerator *argoprojiov1alpha1.A
|
|||
log.WithField("listOptions.LabelSelector", listOptions.LabelSelector).Info("selection type")
|
||||
} else {
|
||||
listOptions.FieldSelector = fields.OneTermEqualSelector("metadata.name", resourceName).String()
|
||||
//metav1.Convert_fields_Selector_To_string(fields.).Sprintf("metadata.name=%s", resourceName)
|
||||
// metav1.Convert_fields_Selector_To_string(fields.).Sprintf("metadata.name=%s", resourceName)
|
||||
log.WithField("listOptions.FieldSelector", listOptions.FieldSelector).Info("selection type")
|
||||
}
|
||||
|
||||
duckResources, err := g.dynClient.Resource(duckGVR).Namespace(g.namespace).List(g.ctx, listOptions)
|
||||
|
||||
if err != nil {
|
||||
log.WithField("GVK", duckGVR).Warning("resources were not found")
|
||||
return nil, err
|
||||
|
|
@ -149,7 +143,6 @@ func (g *DuckTypeGenerator) GenerateParams(appSetGenerator *argoprojiov1alpha1.A
|
|||
if matchKey == "" {
|
||||
log.WithField("matchKey", matchKey).Warning("matchKey not found in " + cm.Name)
|
||||
return nil, nil
|
||||
|
||||
}
|
||||
|
||||
res := []map[string]interface{}{}
|
||||
|
|
@ -167,7 +160,6 @@ func (g *DuckTypeGenerator) GenerateParams(appSetGenerator *argoprojiov1alpha1.A
|
|||
log.WithField("duckResourceStatus", duckResource.Object["status"]).Debug("found resource")
|
||||
|
||||
clusterDecisions = append(clusterDecisions, duckResource.Object["status"].(map[string]interface{})[statusListKey].([]interface{})...)
|
||||
|
||||
}
|
||||
log.Infof("Number of decisions found: %v", len(clusterDecisions))
|
||||
|
||||
|
|
@ -176,7 +168,6 @@ func (g *DuckTypeGenerator) GenerateParams(appSetGenerator *argoprojiov1alpha1.A
|
|||
|
||||
if len(clusterDecisions) > 0 {
|
||||
for _, cluster := range clusterDecisions {
|
||||
|
||||
// generated instance of cluster params
|
||||
params := map[string]interface{}{}
|
||||
|
||||
|
|
@ -194,7 +185,6 @@ func (g *DuckTypeGenerator) GenerateParams(appSetGenerator *argoprojiov1alpha1.A
|
|||
|
||||
for _, argoCluster := range argoClusters {
|
||||
if argoCluster.Name == strMatchValue {
|
||||
|
||||
log.WithField(matchKey, argoCluster.Name).Info("matched cluster in ArgoCD")
|
||||
params["name"] = argoCluster.Name
|
||||
params["server"] = argoCluster.Server
|
||||
|
|
@ -202,7 +192,6 @@ func (g *DuckTypeGenerator) GenerateParams(appSetGenerator *argoprojiov1alpha1.A
|
|||
found = true
|
||||
break // Stop looking
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if !found {
|
||||
|
|
|
|||
|
|
@ -18,9 +18,11 @@ import (
|
|||
argoprojiov1alpha1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
|
||||
)
|
||||
|
||||
const resourceApiVersion = "mallard.io/v1"
|
||||
const resourceKind = "ducks"
|
||||
const resourceName = "quak"
|
||||
const (
|
||||
resourceApiVersion = "mallard.io/v1"
|
||||
resourceKind = "ducks"
|
||||
resourceName = "quak"
|
||||
)
|
||||
|
||||
func TestGenerateParamsForDuckType(t *testing.T) {
|
||||
clusters := []client.Object{
|
||||
|
|
@ -279,9 +281,7 @@ func TestGenerateParamsForDuckType(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
|
||||
appClientset := kubefake.NewSimpleClientset(append(runtimeClusters, configMap)...)
|
||||
|
||||
gvrToListKind := map[schema.GroupVersionResource]string{{
|
||||
|
|
@ -292,7 +292,7 @@ func TestGenerateParamsForDuckType(t *testing.T) {
|
|||
|
||||
fakeDynClient := dynfake.NewSimpleDynamicClientWithCustomListKinds(runtime.NewScheme(), gvrToListKind, testCase.resource)
|
||||
|
||||
var duckTypeGenerator = NewDuckTypeGenerator(context.Background(), fakeDynClient, appClientset, "namespace")
|
||||
duckTypeGenerator := NewDuckTypeGenerator(context.Background(), fakeDynClient, appClientset, "namespace")
|
||||
|
||||
applicationSetInfo := argoprojiov1alpha1.ApplicationSet{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
|
|
@ -577,9 +577,7 @@ func TestGenerateParamsForDuckTypeGoTemplate(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
|
||||
appClientset := kubefake.NewSimpleClientset(append(runtimeClusters, configMap)...)
|
||||
|
||||
gvrToListKind := map[schema.GroupVersionResource]string{{
|
||||
|
|
@ -590,7 +588,7 @@ func TestGenerateParamsForDuckTypeGoTemplate(t *testing.T) {
|
|||
|
||||
fakeDynClient := dynfake.NewSimpleDynamicClientWithCustomListKinds(runtime.NewScheme(), gvrToListKind, testCase.resource)
|
||||
|
||||
var duckTypeGenerator = NewDuckTypeGenerator(context.Background(), fakeDynClient, appClientset, "namespace")
|
||||
duckTypeGenerator := NewDuckTypeGenerator(context.Background(), fakeDynClient, appClientset, "namespace")
|
||||
|
||||
applicationSetInfo := argoprojiov1alpha1.ApplicationSet{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
|
|
|
|||
|
|
@ -65,8 +65,8 @@ func TestMatchValues(t *testing.T) {
|
|||
|
||||
for _, testCase := range testCases {
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
var listGenerator = NewListGenerator()
|
||||
var data = map[string]Generator{
|
||||
listGenerator := NewListGenerator()
|
||||
data := map[string]Generator{
|
||||
"List": listGenerator,
|
||||
}
|
||||
|
||||
|
|
@ -84,7 +84,8 @@ func TestMatchValues(t *testing.T) {
|
|||
List: &argov1alpha1.ListGenerator{
|
||||
Elements: testCase.elements,
|
||||
Template: emptyTemplate(),
|
||||
}},
|
||||
},
|
||||
},
|
||||
data,
|
||||
emptyTemplate(),
|
||||
&applicationSetInfo, nil)
|
||||
|
|
@ -148,8 +149,8 @@ func TestMatchValuesGoTemplate(t *testing.T) {
|
|||
|
||||
for _, testCase := range testCases {
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
var listGenerator = NewListGenerator()
|
||||
var data = map[string]Generator{
|
||||
listGenerator := NewListGenerator()
|
||||
data := map[string]Generator{
|
||||
"List": listGenerator,
|
||||
}
|
||||
|
||||
|
|
@ -167,7 +168,8 @@ func TestMatchValuesGoTemplate(t *testing.T) {
|
|||
List: &argov1alpha1.ListGenerator{
|
||||
Elements: testCase.elements,
|
||||
Template: emptyTemplate(),
|
||||
}},
|
||||
},
|
||||
},
|
||||
data,
|
||||
emptyTemplate(),
|
||||
&applicationSetInfo, nil)
|
||||
|
|
@ -236,7 +238,8 @@ func TestTransForm(t *testing.T) {
|
|||
Selector: metav1.LabelSelector{},
|
||||
Template: argov1alpha1.ApplicationSetTemplate{},
|
||||
Values: nil,
|
||||
}},
|
||||
},
|
||||
},
|
||||
testGenerators,
|
||||
emptyTemplate(),
|
||||
&applicationSetInfo, nil)
|
||||
|
|
@ -343,12 +346,11 @@ func getMockClusterGenerator() Generator {
|
|||
func getMockGitGenerator() Generator {
|
||||
argoCDServiceMock := mocks.Repos{}
|
||||
argoCDServiceMock.On("GetDirectories", mock.Anything, mock.Anything, mock.Anything).Return([]string{"app1", "app2", "app_3", "p1/app4"}, nil)
|
||||
var gitGenerator = NewGitGenerator(&argoCDServiceMock)
|
||||
gitGenerator := NewGitGenerator(&argoCDServiceMock)
|
||||
return gitGenerator
|
||||
}
|
||||
|
||||
func TestGetRelevantGenerators(t *testing.T) {
|
||||
|
||||
testGenerators := map[string]Generator{
|
||||
"Clusters": getMockClusterGenerator(),
|
||||
"Git": getMockGitGenerator(),
|
||||
|
|
@ -361,7 +363,8 @@ func TestGetRelevantGenerators(t *testing.T) {
|
|||
requestedGenerator := &argov1alpha1.ApplicationSetGenerator{
|
||||
List: &argov1alpha1.ListGenerator{
|
||||
Elements: []apiextensionsv1.JSON{{Raw: []byte(`{"cluster": "cluster","url": "url","values":{"foo":"bar"}}`)}},
|
||||
}}
|
||||
},
|
||||
}
|
||||
|
||||
relevantGenerators := GetRelevantGenerators(requestedGenerator, testGenerators)
|
||||
assert.Len(t, relevantGenerators, 1)
|
||||
|
|
@ -404,7 +407,8 @@ func TestInterpolateGenerator(t *testing.T) {
|
|||
"path-basename": "{{path.basename}}",
|
||||
"path-zero": "{{path[0]}}",
|
||||
"path-full": "{{path}}",
|
||||
}},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
gitGeneratorParams := map[string]interface{}{
|
||||
|
|
@ -458,7 +462,8 @@ func TestInterpolateGenerator_go(t *testing.T) {
|
|||
"path-zero": "{{index .path.segments 0}}",
|
||||
"path-full": "{{.path.path}}",
|
||||
"kubernetes.io/environment": `{{default "foo" .my_label}}`,
|
||||
}},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
gitGeneratorParams := map[string]interface{}{
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ func (g *GitGenerator) GetTemplate(appSetGenerator *argoprojiov1alpha1.Applicati
|
|||
}
|
||||
|
||||
func (g *GitGenerator) GetRequeueAfter(appSetGenerator *argoprojiov1alpha1.ApplicationSetGenerator) time.Duration {
|
||||
|
||||
// Return a requeue default of 3 minutes, if no default is specified.
|
||||
|
||||
if appSetGenerator.Git.RequeueAfterSeconds != nil {
|
||||
|
|
@ -47,7 +46,6 @@ func (g *GitGenerator) GetRequeueAfter(appSetGenerator *argoprojiov1alpha1.Appli
|
|||
}
|
||||
|
||||
func (g *GitGenerator) GenerateParams(appSetGenerator *argoprojiov1alpha1.ApplicationSetGenerator, appSet *argoprojiov1alpha1.ApplicationSet) ([]map[string]interface{}, error) {
|
||||
|
||||
if appSetGenerator == nil {
|
||||
return nil, EmptyAppSetGeneratorError
|
||||
}
|
||||
|
|
@ -75,7 +73,6 @@ func (g *GitGenerator) GenerateParams(appSetGenerator *argoprojiov1alpha1.Applic
|
|||
}
|
||||
|
||||
func (g *GitGenerator) generateParamsForGitDirectories(appSetGenerator *argoprojiov1alpha1.ApplicationSetGenerator, noRevisionCache bool, useGoTemplate bool, goTemplateOptions []string) ([]map[string]interface{}, error) {
|
||||
|
||||
// Directories, not files
|
||||
allPaths, err := g.repos.GetDirectories(context.TODO(), appSetGenerator.Git.RepoURL, appSetGenerator.Git.Revision, noRevisionCache)
|
||||
if err != nil {
|
||||
|
|
@ -101,7 +98,6 @@ func (g *GitGenerator) generateParamsForGitDirectories(appSetGenerator *argoproj
|
|||
}
|
||||
|
||||
func (g *GitGenerator) generateParamsForGitFiles(appSetGenerator *argoprojiov1alpha1.ApplicationSetGenerator, noRevisionCache bool, useGoTemplate bool, goTemplateOptions []string) ([]map[string]interface{}, error) {
|
||||
|
||||
// Get all files that match the requested path string, removing duplicates
|
||||
allFiles := make(map[string][]byte)
|
||||
for _, requestedPath := range appSetGenerator.Git.Files {
|
||||
|
|
@ -125,7 +121,6 @@ func (g *GitGenerator) generateParamsForGitFiles(appSetGenerator *argoprojiov1al
|
|||
// Generate params from each path, and return
|
||||
res := []map[string]interface{}{}
|
||||
for _, path := range allPaths {
|
||||
|
||||
// A JSON / YAML file path can contain multiple sets of parameters (ie it is an array)
|
||||
paramsArray, err := g.generateParamsFromGitFile(path, allFiles[path], appSetGenerator.Git.Values, useGoTemplate, goTemplateOptions, appSetGenerator.Git.PathParamPrefix)
|
||||
if err != nil {
|
||||
|
|
@ -158,7 +153,6 @@ func (g *GitGenerator) generateParamsFromGitFile(filePath string, fileContent []
|
|||
res := []map[string]interface{}{}
|
||||
|
||||
for _, objectFound := range objectsFound {
|
||||
|
||||
params := map[string]interface{}{}
|
||||
|
||||
if useGoTemplate {
|
||||
|
|
@ -245,7 +239,6 @@ func (g *GitGenerator) filterApps(Directories []argoprojiov1alpha1.GitDirectoryG
|
|||
func (g *GitGenerator) generateParamsFromApps(requestedApps []string, appSetGenerator *argoprojiov1alpha1.ApplicationSetGenerator, useGoTemplate bool, goTemplateOptions []string) ([]map[string]interface{}, error) {
|
||||
res := make([]map[string]interface{}, len(requestedApps))
|
||||
for i, a := range requestedApps {
|
||||
|
||||
params := make(map[string]interface{}, 5)
|
||||
|
||||
if useGoTemplate {
|
||||
|
|
|
|||
|
|
@ -175,7 +175,6 @@ foo:
|
|||
}
|
||||
|
||||
func TestGitGenerateParamsFromDirectories(t *testing.T) {
|
||||
|
||||
cases := []struct {
|
||||
name string
|
||||
directories []argoprojiov1alpha1.GitDirectoryGeneratorItem
|
||||
|
|
@ -320,7 +319,7 @@ func TestGitGenerateParamsFromDirectories(t *testing.T) {
|
|||
|
||||
argoCDServiceMock.On("GetDirectories", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(testCaseCopy.repoApps, testCaseCopy.repoError)
|
||||
|
||||
var gitGenerator = NewGitGenerator(&argoCDServiceMock)
|
||||
gitGenerator := NewGitGenerator(&argoCDServiceMock)
|
||||
applicationSetInfo := argoprojiov1alpha1.ApplicationSet{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "set",
|
||||
|
|
@ -353,7 +352,6 @@ func TestGitGenerateParamsFromDirectories(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGitGenerateParamsFromDirectoriesGoTemplate(t *testing.T) {
|
||||
|
||||
cases := []struct {
|
||||
name string
|
||||
directories []argoprojiov1alpha1.GitDirectoryGeneratorItem
|
||||
|
|
@ -553,7 +551,6 @@ func TestGitGenerateParamsFromDirectoriesGoTemplate(t *testing.T) {
|
|||
},
|
||||
repoError: nil,
|
||||
expected: []map[string]interface{}{
|
||||
|
||||
{
|
||||
"path": map[string]interface{}{
|
||||
"path": "app1",
|
||||
|
|
@ -616,7 +613,7 @@ func TestGitGenerateParamsFromDirectoriesGoTemplate(t *testing.T) {
|
|||
|
||||
argoCDServiceMock.On("GetDirectories", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(testCaseCopy.repoApps, testCaseCopy.repoError)
|
||||
|
||||
var gitGenerator = NewGitGenerator(&argoCDServiceMock)
|
||||
gitGenerator := NewGitGenerator(&argoCDServiceMock)
|
||||
applicationSetInfo := argoprojiov1alpha1.ApplicationSet{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "set",
|
||||
|
|
@ -646,11 +643,9 @@ func TestGitGenerateParamsFromDirectoriesGoTemplate(t *testing.T) {
|
|||
argoCDServiceMock.AssertExpectations(t)
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestGitGenerateParamsFromFiles(t *testing.T) {
|
||||
|
||||
cases := []struct {
|
||||
name string
|
||||
// files is the list of paths/globs to match
|
||||
|
|
@ -976,7 +971,7 @@ cluster:
|
|||
argoCDServiceMock.On("GetFiles", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
|
||||
Return(testCaseCopy.repoFileContents, testCaseCopy.repoPathsError)
|
||||
|
||||
var gitGenerator = NewGitGenerator(&argoCDServiceMock)
|
||||
gitGenerator := NewGitGenerator(&argoCDServiceMock)
|
||||
applicationSetInfo := argoprojiov1alpha1.ApplicationSet{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "set",
|
||||
|
|
@ -1009,7 +1004,6 @@ cluster:
|
|||
}
|
||||
|
||||
func TestGitGenerateParamsFromFilesGoTemplate(t *testing.T) {
|
||||
|
||||
cases := []struct {
|
||||
name string
|
||||
// files is the list of paths/globs to match
|
||||
|
|
@ -1326,7 +1320,7 @@ cluster:
|
|||
argoCDServiceMock.On("GetFiles", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
|
||||
Return(testCaseCopy.repoFileContents, testCaseCopy.repoPathsError)
|
||||
|
||||
var gitGenerator = NewGitGenerator(&argoCDServiceMock)
|
||||
gitGenerator := NewGitGenerator(&argoCDServiceMock)
|
||||
applicationSetInfo := argoprojiov1alpha1.ApplicationSet{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "set",
|
||||
|
|
|
|||
|
|
@ -23,8 +23,10 @@ type Generator interface {
|
|||
GetTemplate(appSetGenerator *argoprojiov1alpha1.ApplicationSetGenerator) *argoprojiov1alpha1.ApplicationSetTemplate
|
||||
}
|
||||
|
||||
var EmptyAppSetGeneratorError = fmt.Errorf("ApplicationSet is empty")
|
||||
var NoRequeueAfter time.Duration
|
||||
var (
|
||||
EmptyAppSetGeneratorError = fmt.Errorf("ApplicationSet is empty")
|
||||
NoRequeueAfter time.Duration
|
||||
)
|
||||
|
||||
// DefaultRequeueAfterSeconds is used when GetRequeueAfter is not specified, it is the default time to wait before the next reconcile loop
|
||||
const (
|
||||
|
|
|
|||
|
|
@ -12,8 +12,7 @@ import (
|
|||
|
||||
var _ Generator = (*ListGenerator)(nil)
|
||||
|
||||
type ListGenerator struct {
|
||||
}
|
||||
type ListGenerator struct{}
|
||||
|
||||
func NewListGenerator() Generator {
|
||||
g := &ListGenerator{}
|
||||
|
|
@ -77,7 +76,6 @@ func (g *ListGenerator) GenerateParams(appSetGenerator *argoprojiov1alpha1.Appli
|
|||
|
||||
// Append elements from ElementsYaml to the response
|
||||
if len(appSetGenerator.List.ElementsYaml) > 0 {
|
||||
|
||||
var yamlElements []map[string]interface{}
|
||||
err := yaml.Unmarshal([]byte(appSetGenerator.List.ElementsYaml), &yamlElements)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -25,8 +25,7 @@ func TestGenerateListParams(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
|
||||
var listGenerator = NewListGenerator()
|
||||
listGenerator := NewListGenerator()
|
||||
|
||||
applicationSetInfo := argoprojiov1alpha1.ApplicationSet{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
|
|
@ -38,11 +37,11 @@ func TestGenerateListParams(t *testing.T) {
|
|||
got, err := listGenerator.GenerateParams(&argoprojiov1alpha1.ApplicationSetGenerator{
|
||||
List: &argoprojiov1alpha1.ListGenerator{
|
||||
Elements: testCase.elements,
|
||||
}}, &applicationSetInfo)
|
||||
},
|
||||
}, &applicationSetInfo)
|
||||
|
||||
assert.NoError(t, err)
|
||||
assert.ElementsMatch(t, testCase.expected, got)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -61,8 +60,7 @@ func TestGenerateListParamsGoTemplate(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
|
||||
var listGenerator = NewListGenerator()
|
||||
listGenerator := NewListGenerator()
|
||||
|
||||
applicationSetInfo := argoprojiov1alpha1.ApplicationSet{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
|
|
@ -76,7 +74,8 @@ func TestGenerateListParamsGoTemplate(t *testing.T) {
|
|||
got, err := listGenerator.GenerateParams(&argoprojiov1alpha1.ApplicationSetGenerator{
|
||||
List: &argoprojiov1alpha1.ListGenerator{
|
||||
Elements: testCase.elements,
|
||||
}}, &applicationSetInfo)
|
||||
},
|
||||
}, &applicationSetInfo)
|
||||
|
||||
assert.NoError(t, err)
|
||||
assert.ElementsMatch(t, testCase.expected, got)
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ func NewMatrixGenerator(supportedGenerators map[string]Generator) Generator {
|
|||
}
|
||||
|
||||
func (m *MatrixGenerator) GenerateParams(appSetGenerator *argoprojiov1alpha1.ApplicationSetGenerator, appSet *argoprojiov1alpha1.ApplicationSet) ([]map[string]interface{}, error) {
|
||||
|
||||
if appSetGenerator.Matrix == nil {
|
||||
return nil, EmptyAppSetGeneratorError
|
||||
}
|
||||
|
|
@ -58,7 +57,6 @@ func (m *MatrixGenerator) GenerateParams(appSetGenerator *argoprojiov1alpha1.App
|
|||
return nil, fmt.Errorf("failed to get params for second generator in the matrix generator: %w", err)
|
||||
}
|
||||
for _, b := range g1 {
|
||||
|
||||
if appSet.Spec.GoTemplate {
|
||||
tmp := map[string]interface{}{}
|
||||
if err := mergo.Merge(&tmp, b, mergo.WithOverride); err != nil {
|
||||
|
|
@ -120,7 +118,6 @@ func (m *MatrixGenerator) getParams(appSetBaseGenerator argoprojiov1alpha1.Appli
|
|||
argoprojiov1alpha1.ApplicationSetTemplate{},
|
||||
appSet,
|
||||
params)
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("child generator returned an error on parameter generation: %v", err)
|
||||
}
|
||||
|
|
@ -172,7 +169,6 @@ func (m *MatrixGenerator) GetRequeueAfter(appSetGenerator *argoprojiov1alpha1.Ap
|
|||
} else {
|
||||
return NoRequeueAfter
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func getMatrixGenerator(r argoprojiov1alpha1.ApplicationSetNestedGenerator) (*argoprojiov1alpha1.MatrixGenerator, error) {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import (
|
|||
)
|
||||
|
||||
func TestMatrixGenerate(t *testing.T) {
|
||||
|
||||
gitGenerator := &argoprojiov1alpha1.GitGenerator{
|
||||
RepoURL: "RepoURL",
|
||||
Revision: "Revision",
|
||||
|
|
@ -147,7 +146,6 @@ func TestMatrixGenerate(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, g := range testCaseCopy.baseGenerators {
|
||||
|
||||
gitGeneratorSpec := argoprojiov1alpha1.ApplicationSetGenerator{
|
||||
Git: g.Git,
|
||||
List: g.List,
|
||||
|
|
@ -169,7 +167,7 @@ func TestMatrixGenerate(t *testing.T) {
|
|||
Return(&argoprojiov1alpha1.ApplicationSetTemplate{})
|
||||
}
|
||||
|
||||
var matrixGenerator = NewMatrixGenerator(
|
||||
matrixGenerator := NewMatrixGenerator(
|
||||
map[string]Generator{
|
||||
"Git": genMock,
|
||||
"List": &ListGenerator{},
|
||||
|
|
@ -189,14 +187,11 @@ func TestMatrixGenerate(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
assert.Equal(t, testCaseCopy.expected, got)
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func TestMatrixGenerateGoTemplate(t *testing.T) {
|
||||
|
||||
gitGenerator := &argoprojiov1alpha1.GitGenerator{
|
||||
RepoURL: "RepoURL",
|
||||
Revision: "Revision",
|
||||
|
|
@ -360,7 +355,6 @@ func TestMatrixGenerateGoTemplate(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, g := range testCaseCopy.baseGenerators {
|
||||
|
||||
gitGeneratorSpec := argoprojiov1alpha1.ApplicationSetGenerator{
|
||||
Git: g.Git,
|
||||
List: g.List,
|
||||
|
|
@ -386,7 +380,7 @@ func TestMatrixGenerateGoTemplate(t *testing.T) {
|
|||
Return(&argoprojiov1alpha1.ApplicationSetTemplate{})
|
||||
}
|
||||
|
||||
var matrixGenerator = NewMatrixGenerator(
|
||||
matrixGenerator := NewMatrixGenerator(
|
||||
map[string]Generator{
|
||||
"Git": genMock,
|
||||
"List": &ListGenerator{},
|
||||
|
|
@ -406,14 +400,11 @@ func TestMatrixGenerateGoTemplate(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
assert.Equal(t, testCaseCopy.expected, got)
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func TestMatrixGetRequeueAfter(t *testing.T) {
|
||||
|
||||
gitGenerator := &argoprojiov1alpha1.GitGenerator{
|
||||
RepoURL: "RepoURL",
|
||||
Revision: "Revision",
|
||||
|
|
@ -530,7 +521,7 @@ func TestMatrixGetRequeueAfter(t *testing.T) {
|
|||
mock.On("GetRequeueAfter", &gitGeneratorSpec).Return(testCaseCopy.gitGetRequeueAfter, nil)
|
||||
}
|
||||
|
||||
var matrixGenerator = NewMatrixGenerator(
|
||||
matrixGenerator := NewMatrixGenerator(
|
||||
map[string]Generator{
|
||||
"Git": mock,
|
||||
"List": &ListGenerator{},
|
||||
|
|
@ -548,9 +539,7 @@ func TestMatrixGetRequeueAfter(t *testing.T) {
|
|||
})
|
||||
|
||||
assert.Equal(t, testCaseCopy.expected, got)
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -655,10 +644,9 @@ func TestInterpolatedMatrixGenerate(t *testing.T) {
|
|||
fakeClient,
|
||||
testCase.clientError,
|
||||
}
|
||||
var clusterGenerator = NewClusterGenerator(cl, context.Background(), appClientset, "namespace")
|
||||
clusterGenerator := NewClusterGenerator(cl, context.Background(), appClientset, "namespace")
|
||||
|
||||
for _, g := range testCaseCopy.baseGenerators {
|
||||
|
||||
gitGeneratorSpec := argoprojiov1alpha1.ApplicationSetGenerator{
|
||||
Git: g.Git,
|
||||
Clusters: g.Clusters,
|
||||
|
|
@ -678,7 +666,7 @@ func TestInterpolatedMatrixGenerate(t *testing.T) {
|
|||
genMock.On("GetTemplate", &gitGeneratorSpec).
|
||||
Return(&argoprojiov1alpha1.ApplicationSetTemplate{})
|
||||
}
|
||||
var matrixGenerator = NewMatrixGenerator(
|
||||
matrixGenerator := NewMatrixGenerator(
|
||||
map[string]Generator{
|
||||
"Git": genMock,
|
||||
"Clusters": clusterGenerator,
|
||||
|
|
@ -698,7 +686,6 @@ func TestInterpolatedMatrixGenerate(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
assert.Equal(t, testCaseCopy.expected, got)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -838,16 +825,14 @@ func TestInterpolatedMatrixGenerateGoTemplate(t *testing.T) {
|
|||
fakeClient,
|
||||
testCase.clientError,
|
||||
}
|
||||
var clusterGenerator = NewClusterGenerator(cl, context.Background(), appClientset, "namespace")
|
||||
clusterGenerator := NewClusterGenerator(cl, context.Background(), appClientset, "namespace")
|
||||
|
||||
for _, g := range testCaseCopy.baseGenerators {
|
||||
|
||||
gitGeneratorSpec := argoprojiov1alpha1.ApplicationSetGenerator{
|
||||
Git: g.Git,
|
||||
Clusters: g.Clusters,
|
||||
}
|
||||
genMock.On("GenerateParams", mock.AnythingOfType("*v1alpha1.ApplicationSetGenerator"), appSet).Return([]map[string]interface{}{
|
||||
|
||||
{
|
||||
"path": map[string]string{
|
||||
"path": "examples/git-generator-files-discovery/cluster-config/dev/config.json",
|
||||
|
|
@ -866,7 +851,7 @@ func TestInterpolatedMatrixGenerateGoTemplate(t *testing.T) {
|
|||
genMock.On("GetTemplate", &gitGeneratorSpec).
|
||||
Return(&argoprojiov1alpha1.ApplicationSetTemplate{})
|
||||
}
|
||||
var matrixGenerator = NewMatrixGenerator(
|
||||
matrixGenerator := NewMatrixGenerator(
|
||||
map[string]Generator{
|
||||
"Git": genMock,
|
||||
"Clusters": clusterGenerator,
|
||||
|
|
@ -886,14 +871,11 @@ func TestInterpolatedMatrixGenerateGoTemplate(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
assert.Equal(t, testCaseCopy.expected, got)
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func TestMatrixGenerateListElementsYaml(t *testing.T) {
|
||||
|
||||
gitGenerator := &argoprojiov1alpha1.GitGenerator{
|
||||
RepoURL: "RepoURL",
|
||||
Revision: "Revision",
|
||||
|
|
@ -997,7 +979,6 @@ func TestMatrixGenerateListElementsYaml(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, g := range testCaseCopy.baseGenerators {
|
||||
|
||||
gitGeneratorSpec := argoprojiov1alpha1.ApplicationSetGenerator{
|
||||
Git: g.Git,
|
||||
List: g.List,
|
||||
|
|
@ -1029,10 +1010,9 @@ func TestMatrixGenerateListElementsYaml(t *testing.T) {
|
|||
}}, nil)
|
||||
genMock.On("GetTemplate", &gitGeneratorSpec).
|
||||
Return(&argoprojiov1alpha1.ApplicationSetTemplate{})
|
||||
|
||||
}
|
||||
|
||||
var matrixGenerator = NewMatrixGenerator(
|
||||
matrixGenerator := NewMatrixGenerator(
|
||||
map[string]Generator{
|
||||
"Git": genMock,
|
||||
"List": &ListGenerator{},
|
||||
|
|
@ -1052,9 +1032,7 @@ func TestMatrixGenerateListElementsYaml(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
assert.Equal(t, testCaseCopy.expected, got)
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1078,7 +1056,6 @@ func (g *generatorMock) GetRequeueAfter(appSetGenerator *argoprojiov1alpha1.Appl
|
|||
args := g.Called(appSetGenerator)
|
||||
|
||||
return args.Get(0).(time.Duration)
|
||||
|
||||
}
|
||||
|
||||
func TestGitGenerator_GenerateParams_list_x_git_matrix_generator(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -77,7 +77,6 @@ func (m *MergeGenerator) GenerateParams(appSetGenerator *argoprojiov1alpha1.Appl
|
|||
|
||||
for mergeKeyValue, baseParamSet := range baseParamSetsByMergeKey {
|
||||
if overrideParamSet, exists := paramSetsByMergeKey[mergeKeyValue]; exists {
|
||||
|
||||
if appSet.Spec.GoTemplate {
|
||||
if err := mergo.Merge(&baseParamSet, overrideParamSet, mergo.WithOverride); err != nil {
|
||||
return nil, fmt.Errorf("error merging base param set with override param set: %w", err)
|
||||
|
|
@ -95,7 +94,7 @@ func (m *MergeGenerator) GenerateParams(appSetGenerator *argoprojiov1alpha1.Appl
|
|||
}
|
||||
|
||||
mergedParamSets := make([]map[string]interface{}, len(baseParamSetsByMergeKey))
|
||||
var i = 0
|
||||
i := 0
|
||||
for _, mergedParamSet := range baseParamSetsByMergeKey {
|
||||
mergedParamSets[i] = mergedParamSet
|
||||
i += 1
|
||||
|
|
@ -177,7 +176,6 @@ func (m *MergeGenerator) getParams(appSetBaseGenerator argoprojiov1alpha1.Applic
|
|||
argoprojiov1alpha1.ApplicationSetTemplate{},
|
||||
appSet,
|
||||
map[string]interface{}{})
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("child generator returned an error on parameter generation: %v", err)
|
||||
}
|
||||
|
|
@ -227,7 +225,6 @@ func (m *MergeGenerator) GetRequeueAfter(appSetGenerator *argoprojiov1alpha1.App
|
|||
} else {
|
||||
return NoRequeueAfter
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func getMergeGenerator(r argoprojiov1alpha1.ApplicationSetNestedGenerator) (*argoprojiov1alpha1.MergeGenerator, error) {
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ func listOfMapsToSet(maps []map[string]interface{}) (map[string]bool, error) {
|
|||
}
|
||||
|
||||
func TestMergeGenerate(t *testing.T) {
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
baseGenerators []argoprojiov1alpha1.ApplicationSetNestedGenerator
|
||||
|
|
@ -156,7 +155,7 @@ func TestMergeGenerate(t *testing.T) {
|
|||
|
||||
appSet := &argoprojiov1alpha1.ApplicationSet{}
|
||||
|
||||
var mergeGenerator = NewMergeGenerator(
|
||||
mergeGenerator := NewMergeGenerator(
|
||||
map[string]Generator{
|
||||
"List": &ListGenerator{},
|
||||
"Matrix": &MatrixGenerator{
|
||||
|
|
@ -197,7 +196,6 @@ func TestMergeGenerate(t *testing.T) {
|
|||
}
|
||||
|
||||
func toAPIExtensionsJSON(t *testing.T, g interface{}) *apiextensionsv1.JSON {
|
||||
|
||||
resVal, err := json.Marshal(g)
|
||||
if err != nil {
|
||||
t.Error("unable to unmarshal json", g)
|
||||
|
|
@ -344,8 +342,6 @@ func TestParamSetsAreUniqueByMergeKeys(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
assert.Equal(t, testCaseCopy.expected, got)
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,6 @@ func (g *PluginGenerator) GetTemplate(appSetGenerator *argoprojiov1alpha1.Applic
|
|||
}
|
||||
|
||||
func (g *PluginGenerator) GenerateParams(appSetGenerator *argoprojiov1alpha1.ApplicationSetGenerator, applicationSetInfo *argoprojiov1alpha1.ApplicationSet) ([]map[string]interface{}, error) {
|
||||
|
||||
if appSetGenerator == nil {
|
||||
return nil, EmptyAppSetGeneratorError
|
||||
}
|
||||
|
|
@ -117,7 +116,6 @@ func (g *PluginGenerator) generateParams(appSetGenerator *argoprojiov1alpha1.App
|
|||
res := []map[string]interface{}{}
|
||||
|
||||
for _, objectFound := range objectsFound {
|
||||
|
||||
params := map[string]interface{}{}
|
||||
|
||||
if useGoTemplate {
|
||||
|
|
@ -152,7 +150,6 @@ func (g *PluginGenerator) generateParams(appSetGenerator *argoprojiov1alpha1.App
|
|||
}
|
||||
|
||||
func (g *PluginGenerator) getToken(ctx context.Context, tokenRef string) (string, error) {
|
||||
|
||||
if tokenRef == "" || !strings.HasPrefix(tokenRef, "$") {
|
||||
return "", fmt.Errorf("token is empty, or does not reference a secret key starting with '$': %v", tokenRef)
|
||||
}
|
||||
|
|
@ -167,7 +164,6 @@ func (g *PluginGenerator) getToken(ctx context.Context, tokenRef string) (string
|
|||
Namespace: g.namespace,
|
||||
},
|
||||
secret)
|
||||
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("error fetching secret %s/%s: %v", g.namespace, secretName, err)
|
||||
}
|
||||
|
|
@ -192,7 +188,6 @@ func (g *PluginGenerator) getConfigMap(ctx context.Context, configMapRef string)
|
|||
Namespace: g.namespace,
|
||||
},
|
||||
cm)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -631,9 +631,7 @@ func TestPluginGenerateParams(t *testing.T) {
|
|||
ctx := context.Background()
|
||||
|
||||
for _, testCase := range testCases {
|
||||
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
|
||||
generatorConfig := argoprojiov1alpha1.ApplicationSetGenerator{
|
||||
Plugin: &argoprojiov1alpha1.PluginGenerator{
|
||||
ConfigMapRef: argoprojiov1alpha1.PluginConfigMapRef{Name: testCase.configmap.Name},
|
||||
|
|
@ -645,7 +643,6 @@ func TestPluginGenerateParams(t *testing.T) {
|
|||
}
|
||||
|
||||
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
authHeader := r.Header.Get("Authorization")
|
||||
_, tokenKey := plugin.ParseSecretKey(testCase.configmap.Data["token"])
|
||||
expectedToken := testCase.secret.Data[strings.Replace(tokenKey, "$", "", -1)]
|
||||
|
|
@ -673,7 +670,7 @@ func TestPluginGenerateParams(t *testing.T) {
|
|||
|
||||
fakeClientWithCache := fake.NewClientBuilder().WithObjects([]client.Object{testCase.configmap, testCase.secret}...).Build()
|
||||
|
||||
var pluginGenerator = NewPluginGenerator(fakeClientWithCache, ctx, fakeClient, "default")
|
||||
pluginGenerator := NewPluginGenerator(fakeClientWithCache, ctx, fakeClient, "default")
|
||||
|
||||
applicationSetInfo := argoprojiov1alpha1.ApplicationSet{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
|
|
@ -685,7 +682,6 @@ func TestPluginGenerateParams(t *testing.T) {
|
|||
}
|
||||
|
||||
got, err := pluginGenerator.GenerateParams(&generatorConfig, &applicationSetInfo)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,6 @@ func TestSCMProviderGetSecretRef(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
}
|
||||
assert.Equal(t, c.token, token)
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -196,7 +195,6 @@ func TestSCMProviderGenerateParams(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
assert.Equal(t, testCaseCopy.expected, got)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ func appendTemplatedValues(values map[string]string, params map[string]interface
|
|||
|
||||
for key, value := range values {
|
||||
result, err := replaceTemplatedString(value, params, useGoTemplate, goTemplateOptions)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to replace templated string: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,6 @@ func TestValueInterpolation(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
err := appendTemplatedValues(testCase.values, testCase.params, false, nil)
|
||||
assert.NoError(t, err)
|
||||
|
|
@ -115,7 +114,6 @@ func TestValueInterpolationWithGoTemplating(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
err := appendTemplatedValues(testCase.values, testCase.params, true, nil)
|
||||
assert.NoError(t, err)
|
||||
|
|
|
|||
|
|
@ -66,7 +66,6 @@ func newClient(baseURL string, options ...ClientOptionFunc) (*Client, error) {
|
|||
}
|
||||
|
||||
func (c *Client) NewRequest(method, path string, body interface{}, options []ClientOptionFunc) (*http.Request, error) {
|
||||
|
||||
// Make sure the given URL end with a slash
|
||||
if !strings.HasSuffix(c.baseURL, "/") {
|
||||
c.baseURL += "/"
|
||||
|
|
@ -135,7 +134,6 @@ func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*htt
|
|||
|
||||
// CheckResponse checks the API response for errors, and returns them if present.
|
||||
func CheckResponse(resp *http.Response) error {
|
||||
|
||||
if c := resp.StatusCode; 200 <= c && c <= 299 {
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ func TestClient(t *testing.T) {
|
|||
|
||||
var clientOptionFns []ClientOptionFunc
|
||||
_, err := NewClient(server.URL, clientOptionFns...)
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create client: %v", err)
|
||||
}
|
||||
|
|
@ -119,13 +118,11 @@ func TestClientDo(t *testing.T) {
|
|||
defer cc.fakeServer.Close()
|
||||
|
||||
client, err := NewClient(cc.fakeServer.URL, cc.clientOptionFns...)
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("NewClient returned unexpected error: %v", err)
|
||||
}
|
||||
|
||||
req, err := client.NewRequest("POST", "", cc.params, nil)
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("NewRequest returned unexpected error: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,6 @@ func NewPluginService(ctx context.Context, appSetName string, baseURL string, to
|
|||
|
||||
func (p *Service) List(ctx context.Context, parameters v1alpha1.PluginParameters) (*ServiceResponse, error) {
|
||||
req, err := p.client.NewRequest(http.MethodPost, "api/v1/getparams.execute", ServiceRequest{ApplicationSetName: p.appSetName, Input: v1alpha1.PluginInput{Parameters: parameters}}, nil)
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("NewRequest returned unexpected error: %v", err)
|
||||
}
|
||||
|
|
@ -64,7 +63,6 @@ func (p *Service) List(ctx context.Context, parameters v1alpha1.PluginParameters
|
|||
var data ServiceResponse
|
||||
|
||||
_, err = p.client.Do(ctx, req, &data)
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error get api '%s': %v", p.appSetName, err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ func TestPlugin(t *testing.T) {
|
|||
return
|
||||
}
|
||||
_, err := w.Write([]byte(expectedJSON))
|
||||
|
||||
if err != nil {
|
||||
assert.NoError(t, fmt.Errorf("Error Write %v", err))
|
||||
}
|
||||
|
|
@ -32,13 +31,11 @@ func TestPlugin(t *testing.T) {
|
|||
defer ts.Close()
|
||||
|
||||
client, err := NewPluginService(context.Background(), "plugin-test", ts.URL, token, 0)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
data, err := client.List(context.Background(), nil)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,8 +36,10 @@ type AzureDevOpsService struct {
|
|||
labels []string
|
||||
}
|
||||
|
||||
var _ PullRequestService = (*AzureDevOpsService)(nil)
|
||||
var _ AzureDevOpsClientFactory = &devopsFactoryImpl{}
|
||||
var (
|
||||
_ PullRequestService = (*AzureDevOpsService)(nil)
|
||||
_ AzureDevOpsClientFactory = &devopsFactoryImpl{}
|
||||
)
|
||||
|
||||
func NewAzureDevOpsService(ctx context.Context, token, url, organization, project, repo string, labels []string) (PullRequestService, error) {
|
||||
organizationUrl := buildURL(url, organization)
|
||||
|
|
|
|||
|
|
@ -55,7 +55,6 @@ func NewGitLabService(ctx context.Context, token, url, project string, labels []
|
|||
}
|
||||
|
||||
func (g *GitLabService) List(ctx context.Context) ([]*PullRequest, error) {
|
||||
|
||||
// Filter the merge requests on labels, if they are specified.
|
||||
var labels *gitlab.Labels
|
||||
if len(g.labels) > 0 {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import (
|
|||
func strp(s string) *string {
|
||||
return &s
|
||||
}
|
||||
|
||||
func TestFilterBranchMatchBadRegexp(t *testing.T) {
|
||||
provider, _ := NewFakeService(
|
||||
context.Background(),
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ type argoCDService struct {
|
|||
//go:generate go run github.com/vektra/mockery/v2@v2.40.2 --name=Repos
|
||||
|
||||
type Repos interface {
|
||||
|
||||
// GetFiles returns content of files (not directories) within the target repo
|
||||
GetFiles(ctx context.Context, repoURL string, revision string, pattern string, noRevisionCache bool) (map[string][]byte, error)
|
||||
|
||||
|
|
@ -89,5 +88,4 @@ func (a *argoCDService) GetDirectories(ctx context.Context, repoURL string, revi
|
|||
return nil, fmt.Errorf("error retrieving Git Directories: %w", err)
|
||||
}
|
||||
return dirResponse.GetPaths(), nil
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ import (
|
|||
)
|
||||
|
||||
func TestGetDirectories(t *testing.T) {
|
||||
|
||||
type fields struct {
|
||||
storecreds git.CredsStore
|
||||
submoduleEnabled bool
|
||||
|
|
|
|||
|
|
@ -51,8 +51,10 @@ type AzureDevOpsProvider struct {
|
|||
allBranches bool
|
||||
}
|
||||
|
||||
var _ SCMProviderService = &AzureDevOpsProvider{}
|
||||
var _ AzureDevOpsClientFactory = &devopsFactoryImpl{}
|
||||
var (
|
||||
_ SCMProviderService = &AzureDevOpsProvider{}
|
||||
_ AzureDevOpsClientFactory = &devopsFactoryImpl{}
|
||||
)
|
||||
|
||||
func NewAzureDevOpsProvider(ctx context.Context, accessToken string, org string, url string, project string, allBranches bool) (*AzureDevOpsProvider, error) {
|
||||
if accessToken == "" {
|
||||
|
|
@ -60,7 +62,6 @@ func NewAzureDevOpsProvider(ctx context.Context, accessToken string, org string,
|
|||
}
|
||||
|
||||
devOpsURL, err := getValidDevOpsURL(url, org)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -77,7 +78,6 @@ func (g *AzureDevOpsProvider) ListRepos(ctx context.Context, cloneProtocol strin
|
|||
}
|
||||
getRepoArgs := azureGit.GetRepositoriesArgs{Project: &g.teamProject}
|
||||
azureRepos, err := gitClient.GetRepositories(ctx, getRepoArgs)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -106,7 +106,7 @@ func (g *AzureDevOpsProvider) RepoHasPath(ctx context.Context, repo *Repository,
|
|||
}
|
||||
|
||||
var repoId string
|
||||
if uuid, isUuid := repo.RepositoryId.(uuid.UUID); isUuid { //most likely an UUID, but do type-safe check anyway. Do %v fallback if not expected type.
|
||||
if uuid, isUuid := repo.RepositoryId.(uuid.UUID); isUuid { // most likely an UUID, but do type-safe check anyway. Do %v fallback if not expected type.
|
||||
repoId = uuid.String()
|
||||
} else {
|
||||
repoId = fmt.Sprintf("%v", repo.RepositoryId)
|
||||
|
|
@ -115,7 +115,6 @@ func (g *AzureDevOpsProvider) RepoHasPath(ctx context.Context, repo *Repository,
|
|||
branchName := repo.Branch
|
||||
getItemArgs := azureGit.GetItemArgs{RepositoryId: &repoId, Project: &g.teamProject, Path: &path, VersionDescriptor: &azureGit.GitVersionDescriptor{Version: &branchName}}
|
||||
_, err = gitClient.GetItem(ctx, getItemArgs)
|
||||
|
||||
if err != nil {
|
||||
if wrappedError, isWrappedError := err.(azuredevops.WrappedError); isWrappedError && wrappedError.TypeKey != nil {
|
||||
if *wrappedError.TypeKey == AzureDevOpsErrorsTypeKeyValues.GitItemNotFound {
|
||||
|
|
@ -138,7 +137,7 @@ func (g *AzureDevOpsProvider) GetBranches(ctx context.Context, repo *Repository)
|
|||
repos := []*Repository{}
|
||||
|
||||
if !g.allBranches {
|
||||
defaultBranchName := strings.Replace(repo.Branch, "refs/heads/", "", 1) //Azure DevOps returns default branch info like 'refs/heads/main', but does not support branch lookup of this format.
|
||||
defaultBranchName := strings.Replace(repo.Branch, "refs/heads/", "", 1) // Azure DevOps returns default branch info like 'refs/heads/main', but does not support branch lookup of this format.
|
||||
getBranchArgs := azureGit.GetBranchArgs{RepositoryId: &repo.Repository, Project: &g.teamProject, Name: &defaultBranchName}
|
||||
branchResult, err := gitClient.GetBranch(ctx, getBranchArgs)
|
||||
if err != nil {
|
||||
|
|
@ -209,7 +208,6 @@ func getValidDevOpsURL(url string, org string) (string, error) {
|
|||
devOpsURL := fmt.Sprintf("%s%s%s", url, separator, org)
|
||||
|
||||
urlCheck, err := netUrl.ParseRequestURI(devOpsURL)
|
||||
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("got an invalid URL for the Azure SCM generator: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,13 +105,11 @@ func TestAzureDevopsRepoHasPath(t *testing.T) {
|
|||
assert.Equal(t, testCase.pathFound, hasPath)
|
||||
|
||||
gitClientMock.AssertCalled(t, "GetItem", ctx, azureGit.GetItemArgs{Project: &teamProject, Path: &path, VersionDescriptor: &azureGit.GitVersionDescriptor{Version: &branchName}, RepositoryId: repoId})
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetDefaultBranchOnDisabledRepo(t *testing.T) {
|
||||
|
||||
organization := "myorg"
|
||||
teamProject := "myorg_project"
|
||||
repoName := "myorg_project_repo"
|
||||
|
|
@ -171,7 +169,6 @@ func TestGetDefaultBranchOnDisabledRepo(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetAllBranchesOnDisabledRepo(t *testing.T) {
|
||||
|
||||
organization := "myorg"
|
||||
teamProject := "myorg_project"
|
||||
repoName := "myorg_project_repo"
|
||||
|
|
@ -231,9 +228,7 @@ func TestGetAllBranchesOnDisabledRepo(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAzureDevOpsGetDefaultBranchStripsRefsName(t *testing.T) {
|
||||
|
||||
t.Run("Get branches only default branch removes characters before querying azure devops", func(t *testing.T) {
|
||||
|
||||
organization := "myorg"
|
||||
teamProject := "myorg_project"
|
||||
repoName := "myorg_project_repo"
|
||||
|
|
@ -406,7 +401,6 @@ func TestAzureDevopsGetBranches(t *testing.T) {
|
|||
assert.ErrorContains(t, err, testCase.clientError.Error())
|
||||
gitClientMock.AssertNotCalled(t, "GetBranches", ctx, azureGit.GetBranchesArgs{RepositoryId: &repoName, Project: &teamProject})
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
if testCase.getBranchesApiError != nil {
|
||||
|
|
@ -475,14 +469,14 @@ func TestGetAzureDevopsRepositories(t *testing.T) {
|
|||
{Name: s("missing_default_branch"), RemoteUrl: s("https://remoteurl.u"), Id: repoId},
|
||||
{DefaultBranch: s("missing_name"), RemoteUrl: s("https://remoteurl.u"), Id: repoId},
|
||||
{Name: s("missing_remote_url"), DefaultBranch: s("main"), Id: repoId},
|
||||
{Name: s("missing_id"), DefaultBranch: s("main"), RemoteUrl: s("https://remoteurl.u")}},
|
||||
{Name: s("missing_id"), DefaultBranch: s("main"), RemoteUrl: s("https://remoteurl.u")},
|
||||
},
|
||||
expectedNumberOfRepos: 1,
|
||||
},
|
||||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
|
||||
gitClientMock := azureMock.Client{}
|
||||
gitClientMock.On("GetRepositories", ctx, azureGit.GetRepositoriesArgs{Project: s(teamProject)}).Return(&testCase.repositories, testCase.getRepositoriesError)
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,6 @@ func (c *ExtendedClient) GetContents(repo *Repository, path string) (bool, error
|
|||
var _ SCMProviderService = &BitBucketCloudProvider{}
|
||||
|
||||
func NewBitBucketCloudProvider(ctx context.Context, owner string, user string, password string, allBranches bool) (*BitBucketCloudProvider, error) {
|
||||
|
||||
client := &ExtendedClient{
|
||||
bitbucket.NewBasicAuth(user, password),
|
||||
user,
|
||||
|
|
@ -151,11 +150,9 @@ func (g *BitBucketCloudProvider) listBranches(repo *Repository) ([]bitbucket.Rep
|
|||
return nil, err
|
||||
}
|
||||
return branches.Branches, nil
|
||||
|
||||
}
|
||||
|
||||
func findCloneURL(cloneProtocol string, repo *bitbucket.Repository) (*string, error) {
|
||||
|
||||
cloneLinks, ok := repo.Links["clone"].([]interface{})
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unknown type returned from repo links")
|
||||
|
|
|
|||
|
|
@ -258,6 +258,7 @@ func giteaMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGiteaListRepos(t *testing.T) {
|
||||
cases := []struct {
|
||||
name, proto, url string
|
||||
|
|
|
|||
|
|
@ -303,7 +303,7 @@ func TestGithubGetBranches(t *testing.T) {
|
|||
} else {
|
||||
assert.Equal(t, "master", repos[0].Branch)
|
||||
}
|
||||
//Branch Doesn't exists instead of error will return no error
|
||||
// Branch Doesn't exists instead of error will return no error
|
||||
repo2 := &Repository{
|
||||
Organization: "argoproj",
|
||||
Repository: "applicationset",
|
||||
|
|
|
|||
|
|
@ -1046,6 +1046,7 @@ func gitlabMockHandler(t *testing.T) func(http.ResponseWriter, *http.Request) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGitlabListRepos(t *testing.T) {
|
||||
cases := []struct {
|
||||
name, proto, url, topic string
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ func (m *MockProvider) GetBranches(_ context.Context, repo *Repository) ([]*Repo
|
|||
branchRepos = append(branchRepos, candidateRepo)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return branchRepos, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,6 +120,7 @@ func TestFilterPathDoesntExists(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
assert.Len(t, repos, 2)
|
||||
}
|
||||
|
||||
func TestFilterRepoMatchBadRegexp(t *testing.T) {
|
||||
provider := &MockProvider{
|
||||
Repos: []*Repository{
|
||||
|
|
@ -311,8 +312,10 @@ func TestApplicableFilterMap(t *testing.T) {
|
|||
BranchMatch: ®exp.Regexp{},
|
||||
FilterType: FilterTypeBranch,
|
||||
}
|
||||
filterMap := getApplicableFilters([]*Filter{&branchFilter, &repoFilter,
|
||||
&pathExistsFilter, &labelMatchFilter, &unsetFilter, &additionalBranchFilter, &pathDoesntExistsFilter})
|
||||
filterMap := getApplicableFilters([]*Filter{
|
||||
&branchFilter, &repoFilter,
|
||||
&pathExistsFilter, &labelMatchFilter, &unsetFilter, &additionalBranchFilter, &pathDoesntExistsFilter,
|
||||
})
|
||||
|
||||
assert.Len(t, filterMap[FilterTypeRepo], 2)
|
||||
assert.Len(t, filterMap[FilterTypeBranch], 4)
|
||||
|
|
|
|||
|
|
@ -93,7 +93,6 @@ func getDestinationServer(ctx context.Context, clusterName string, clientset kub
|
|||
}
|
||||
|
||||
func ListClusters(ctx context.Context, clientset kubernetes.Interface, namespace string) (*appv1.ClusterList, error) {
|
||||
|
||||
clusterSecretsList, err := clientset.CoreV1().Secrets(namespace).List(ctx,
|
||||
metav1.ListOptions{LabelSelector: common.LabelKeySecretType + "=" + common.LabelValueSecretTypeCluster})
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -64,7 +64,6 @@ func Test_secretToCluster_NoConfig(t *testing.T) {
|
|||
}
|
||||
|
||||
func createClusterSecret(secretName string, clusterName string, clusterServer string) *corev1.Secret {
|
||||
|
||||
secret := &corev1.Secret{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: secretName,
|
||||
|
|
@ -81,15 +80,12 @@ func createClusterSecret(secretName string, clusterName string, clusterServer st
|
|||
}
|
||||
|
||||
return secret
|
||||
|
||||
}
|
||||
|
||||
// From util/argo/argo_test.go
|
||||
// (ported to use kubeclientset)
|
||||
func TestValidateDestination(t *testing.T) {
|
||||
|
||||
t.Run("Validate destination with server url", func(t *testing.T) {
|
||||
|
||||
dest := argoappv1.ApplicationDestination{
|
||||
Server: "https://127.0.0.1:6443",
|
||||
Namespace: "default",
|
||||
|
|
@ -174,5 +170,4 @@ func TestValidateDestination(t *testing.T) {
|
|||
assert.Equal(t, "unable to find destination server: there are 2 clusters with the same name: [https://127.0.0.1:2443 https://127.0.0.1:8443]", err.Error())
|
||||
assert.False(t, dest.IsServerInferred())
|
||||
})
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ import (
|
|||
//
|
||||
// It returns the executed operation and an error.
|
||||
func CreateOrUpdate(ctx context.Context, logCtx *log.Entry, c client.Client, ignoreAppDifferences argov1alpha1.ApplicationSetIgnoreDifferences, ignoreNormalizerOpts normalizers.IgnoreNormalizerOpts, obj *argov1alpha1.Application, f controllerutil.MutateFn) (controllerutil.OperationResult, error) {
|
||||
|
||||
key := client.ObjectKeyFromObject(obj)
|
||||
if err := c.Get(ctx, key, obj); err != nil {
|
||||
if !errors.IsNotFound(err) {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ func ConvertToMapStringInterface(mapStringString map[string]string) map[string]i
|
|||
}
|
||||
|
||||
func CombineStringMaps(aSI map[string]interface{}, bSI map[string]interface{}) (map[string]string, error) {
|
||||
|
||||
a := ConvertToMapStringString(aSI)
|
||||
b := ConvertToMapStringString(bSI)
|
||||
|
||||
|
|
@ -49,7 +48,6 @@ func CombineStringMaps(aSI map[string]interface{}, bSI map[string]interface{}) (
|
|||
|
||||
// CombineStringMapsAllowDuplicates merges two maps. Where there are duplicates, take the latter map's value.
|
||||
func CombineStringMapsAllowDuplicates(aSI map[string]interface{}, bSI map[string]interface{}) (map[string]string, error) {
|
||||
|
||||
a := ConvertToMapStringString(aSI)
|
||||
b := ConvertToMapStringString(bSI)
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,6 @@ func TestCombineStringMaps(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
assert.Equal(t, testCaseCopy.expected, got)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,8 +44,7 @@ type Renderer interface {
|
|||
Replace(tmpl string, replaceMap map[string]interface{}, useGoTemplate bool, goTemplateOptions []string) (string, error)
|
||||
}
|
||||
|
||||
type Render struct {
|
||||
}
|
||||
type Render struct{}
|
||||
|
||||
func copyValueIntoUnexported(destination, value reflect.Value) {
|
||||
reflect.NewAt(destination.Type(), unsafe.Pointer(destination.UnsafeAddr())).
|
||||
|
|
@ -54,7 +53,7 @@ func copyValueIntoUnexported(destination, value reflect.Value) {
|
|||
}
|
||||
|
||||
func copyUnexported(copy, original reflect.Value) {
|
||||
var unexported = reflect.NewAt(original.Type(), unsafe.Pointer(original.UnsafeAddr())).Elem()
|
||||
unexported := reflect.NewAt(original.Type(), unsafe.Pointer(original.UnsafeAddr())).Elem()
|
||||
copyValueIntoUnexported(copy, unexported)
|
||||
}
|
||||
|
||||
|
|
@ -127,7 +126,7 @@ func (r *Render) deeplyReplace(copy, original reflect.Value, replaceMap map[stri
|
|||
// If it is a struct we translate each field
|
||||
case reflect.Struct:
|
||||
for i := 0; i < original.NumField(); i += 1 {
|
||||
var currentType = fmt.Sprintf("%s.%s", original.Type().Field(i).Name, original.Type().PkgPath())
|
||||
currentType := fmt.Sprintf("%s.%s", original.Type().Field(i).Name, original.Type().PkgPath())
|
||||
// specific case time
|
||||
if currentType == "time.Time" {
|
||||
copy.Field(i).Set(original.Field(i))
|
||||
|
|
@ -270,7 +269,6 @@ func (r *Render) RenderTemplateParams(tmpl *argoappsv1.Application, syncPolicy *
|
|||
// See TestRenderTemplateParamsFinalizers in util_test.go for test-based definition of behaviour
|
||||
if (syncPolicy == nil || !syncPolicy.PreserveResourcesOnDeletion) &&
|
||||
((*replacedTmpl).ObjectMeta.Finalizers == nil || len((*replacedTmpl).ObjectMeta.Finalizers) == 0) {
|
||||
|
||||
(*replacedTmpl).ObjectMeta.Finalizers = []string{"resources-finalizer.argocd.argoproj.io"}
|
||||
}
|
||||
|
||||
|
|
@ -486,7 +484,6 @@ func SlugifyName(args ...interface{}) string {
|
|||
}
|
||||
|
||||
func getTlsConfigWithCACert(scmRootCAPath string) *tls.Config {
|
||||
|
||||
tlsConfig := &tls.Config{}
|
||||
|
||||
if scmRootCAPath != "" {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import (
|
|||
)
|
||||
|
||||
func TestRenderTemplateParams(t *testing.T) {
|
||||
|
||||
// Believe it or not, this is actually less complex than the equivalent solution using reflection
|
||||
fieldMap := map[string]func(app *argoappsv1.Application) *string{}
|
||||
fieldMap["Path"] = func(app *argoappsv1.Application) *string { return &app.Spec.Source.Path }
|
||||
|
|
@ -165,11 +164,8 @@ func TestRenderTemplateParams(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
|
||||
for fieldName, getPtrFunc := range fieldMap {
|
||||
|
||||
// Clone the template application
|
||||
application := emptyApplication.DeepCopy()
|
||||
|
||||
|
|
@ -196,11 +192,9 @@ func TestRenderTemplateParams(t *testing.T) {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestRenderHelmValuesObjectJson(t *testing.T) {
|
||||
|
||||
params := map[string]interface{}{
|
||||
"test": "Hello world",
|
||||
}
|
||||
|
|
@ -251,11 +245,9 @@ func TestRenderHelmValuesObjectJson(t *testing.T) {
|
|||
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "Hello world", unmarshaled.(map[string]interface{})["some"].(map[string]interface{})["string"])
|
||||
|
||||
}
|
||||
|
||||
func TestRenderHelmValuesObjectYaml(t *testing.T) {
|
||||
|
||||
params := map[string]interface{}{
|
||||
"test": "Hello world",
|
||||
}
|
||||
|
|
@ -303,11 +295,9 @@ func TestRenderHelmValuesObjectYaml(t *testing.T) {
|
|||
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "Hello world", unmarshaled.(map[string]interface{})["some"].(map[string]interface{})["string"])
|
||||
|
||||
}
|
||||
|
||||
func TestRenderTemplateParamsGoTemplate(t *testing.T) {
|
||||
|
||||
// Believe it or not, this is actually less complex than the equivalent solution using reflection
|
||||
fieldMap := map[string]func(app *argoappsv1.Application) *string{}
|
||||
fieldMap["Path"] = func(app *argoappsv1.Application) *string { return &app.Spec.Source.Path }
|
||||
|
|
@ -616,11 +606,8 @@ func TestRenderTemplateParamsGoTemplate(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
|
||||
for fieldName, getPtrFunc := range fieldMap {
|
||||
|
||||
// Clone the template application
|
||||
application := emptyApplication.DeepCopy()
|
||||
|
||||
|
|
@ -734,7 +721,6 @@ func Test_Render_Replace_no_panic_on_missing_closing_brace(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRenderTemplateParamsFinalizers(t *testing.T) {
|
||||
|
||||
emptyApplication := &argoappsv1.Application{
|
||||
Spec: argoappsv1.ApplicationSpec{
|
||||
Source: &argoappsv1.ApplicationSource{
|
||||
|
|
@ -813,9 +799,7 @@ func TestRenderTemplateParamsFinalizers(t *testing.T) {
|
|||
expectedFinalizers: []string{"resources-finalizer.argocd.argoproj.io/background"},
|
||||
},
|
||||
} {
|
||||
|
||||
t.Run(c.testName, func(t *testing.T) {
|
||||
|
||||
// Clone the template application
|
||||
application := emptyApplication.DeepCopy()
|
||||
application.Finalizers = c.existingFinalizers
|
||||
|
|
@ -831,15 +815,11 @@ func TestRenderTemplateParamsFinalizers(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
|
||||
assert.ElementsMatch(t, res.Finalizers, c.expectedFinalizers)
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestCheckInvalidGenerators(t *testing.T) {
|
||||
|
||||
scheme := runtime.NewScheme()
|
||||
err := argoappsv1.AddToScheme(scheme)
|
||||
assert.NoError(t, err)
|
||||
|
|
@ -943,7 +923,6 @@ func TestCheckInvalidGenerators(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestInvalidGenerators(t *testing.T) {
|
||||
|
||||
scheme := runtime.NewScheme()
|
||||
err := argoappsv1.AddToScheme(scheme)
|
||||
assert.NoError(t, err)
|
||||
|
|
@ -1322,7 +1301,7 @@ xO7Tr5lAo74vNUkF2EHNaI28/RGnJPm2TIxZqy4rNH6L
|
|||
`
|
||||
|
||||
rootCAPath := path.Join(temppath, "foo.example.com")
|
||||
err := os.WriteFile(rootCAPath, []byte(cert), 0666)
|
||||
err := os.WriteFile(rootCAPath, []byte(cert), 0o666)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,9 +26,7 @@ import (
|
|||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var (
|
||||
errBasicAuthVerificationFailed = errors.New("basic auth verification failed")
|
||||
)
|
||||
var errBasicAuthVerificationFailed = errors.New("basic auth verification failed")
|
||||
|
||||
type WebhookHandler struct {
|
||||
namespace string
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ func NewCommand() *cobra.Command {
|
|||
serverSideDiff bool
|
||||
ignoreNormalizerOpts normalizers.IgnoreNormalizerOpts
|
||||
)
|
||||
var command = cobra.Command{
|
||||
command := cobra.Command{
|
||||
Use: cliName,
|
||||
Short: "Run ArgoCD Application Controller",
|
||||
Long: "ArgoCD application controller is a Kubernetes controller that continuously monitors running applications and compares the current, live state against the desired target state (as specified in the repo). This command runs Application Controller in the foreground. It can be configured by following options.",
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ func NewCommand() *cobra.Command {
|
|||
scheme := runtime.NewScheme()
|
||||
_ = clientgoscheme.AddToScheme(scheme)
|
||||
_ = appv1alpha1.AddToScheme(scheme)
|
||||
var command = cobra.Command{
|
||||
command := cobra.Command{
|
||||
Use: "controller",
|
||||
Short: "Starts Argo CD ApplicationSet controller",
|
||||
RunE: func(c *cobra.Command, args []string) error {
|
||||
|
|
@ -139,7 +139,6 @@ func NewCommand() *cobra.Command {
|
|||
DryRun: &dryRun,
|
||||
},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
log.Error(err, "unable to start manager")
|
||||
os.Exit(1)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ func NewCommand() *cobra.Command {
|
|||
otlpHeaders map[string]string
|
||||
otlpAttrs []string
|
||||
)
|
||||
var command = cobra.Command{
|
||||
command := cobra.Command{
|
||||
Use: cliName,
|
||||
Short: "Run ArgoCD ConfigManagementPlugin Server",
|
||||
Long: "ArgoCD ConfigManagementPlugin Server is an internal service which runs as sidecar container in reposerver deployment. The following configuration options are available:",
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ const (
|
|||
)
|
||||
|
||||
func NewCommand() *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: cliName,
|
||||
Short: "argocd-dex tools used by Argo CD",
|
||||
Long: "argocd-dex has internal utility tools used by Argo CD",
|
||||
|
|
@ -48,7 +48,7 @@ func NewRunDexCommand() *cobra.Command {
|
|||
clientConfig clientcmd.ClientConfig
|
||||
disableTLS bool
|
||||
)
|
||||
var command = cobra.Command{
|
||||
command := cobra.Command{
|
||||
Use: "rundex",
|
||||
Short: "Runs dex generating a config using settings from the Argo CD configmap and secret",
|
||||
RunE: func(c *cobra.Command, args []string) error {
|
||||
|
|
@ -79,11 +79,11 @@ func NewRunDexCommand() *cobra.Command {
|
|||
log.Fatalf("could not create TLS config: %v", err)
|
||||
}
|
||||
certPem, keyPem := tls.EncodeX509KeyPair(config.Certificates[0])
|
||||
err = os.WriteFile("/tmp/tls.crt", certPem, 0600)
|
||||
err = os.WriteFile("/tmp/tls.crt", certPem, 0o600)
|
||||
if err != nil {
|
||||
log.Fatalf("could not write TLS certificate: %v", err)
|
||||
}
|
||||
err = os.WriteFile("/tmp/tls.key", keyPem, 0600)
|
||||
err = os.WriteFile("/tmp/tls.key", keyPem, 0o600)
|
||||
if err != nil {
|
||||
log.Fatalf("could not write TLS key: %v", err)
|
||||
}
|
||||
|
|
@ -102,7 +102,7 @@ func NewRunDexCommand() *cobra.Command {
|
|||
if len(dexCfgBytes) == 0 {
|
||||
log.Infof("dex is not configured")
|
||||
} else {
|
||||
err = os.WriteFile("/tmp/dex.yaml", dexCfgBytes, 0644)
|
||||
err = os.WriteFile("/tmp/dex.yaml", dexCfgBytes, 0o644)
|
||||
errors.CheckError(err)
|
||||
log.Debug(redactor(string(dexCfgBytes)))
|
||||
cmd = exec.Command("dex", "serve", "/tmp/dex.yaml")
|
||||
|
|
@ -148,7 +148,7 @@ func NewGenDexConfigCommand() *cobra.Command {
|
|||
out string
|
||||
disableTLS bool
|
||||
)
|
||||
var command = cobra.Command{
|
||||
command := cobra.Command{
|
||||
Use: "gendexcfg",
|
||||
Short: "Generates a dex config from Argo CD settings",
|
||||
RunE: func(c *cobra.Command, args []string) error {
|
||||
|
|
@ -196,7 +196,7 @@ func NewGenDexConfigCommand() *cobra.Command {
|
|||
errors.CheckError(err)
|
||||
fmt.Print(string(maskedDexCfgBytes))
|
||||
} else {
|
||||
err = os.WriteFile(out, dexCfgBytes, 0644)
|
||||
err = os.WriteFile(out, dexCfgBytes, 0o644)
|
||||
errors.CheckError(err)
|
||||
}
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ const (
|
|||
)
|
||||
|
||||
func NewCommand() *cobra.Command {
|
||||
var command = cobra.Command{
|
||||
command := cobra.Command{
|
||||
Use: cliName,
|
||||
Short: "Argo CD git credential helper",
|
||||
DisableAutoGenTag: true,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ const (
|
|||
)
|
||||
|
||||
func NewCommand() *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: cliName,
|
||||
Short: "argocd-k8s-auth a set of commands to generate k8s auth token",
|
||||
DisableAutoGenTag: true,
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ func newAWSCommand() *cobra.Command {
|
|||
roleARN string
|
||||
profile string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "aws",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
ctx := c.Context()
|
||||
|
|
|
|||
|
|
@ -20,10 +20,10 @@ const (
|
|||
|
||||
func newAzureCommand() *cobra.Command {
|
||||
o := token.NewOptions()
|
||||
//we'll use default of WorkloadIdentityLogin for the login flow
|
||||
// we'll use default of WorkloadIdentityLogin for the login flow
|
||||
o.LoginMethod = token.WorkloadIdentityLogin
|
||||
o.ServerID = DEFAULT_AAD_SERVER_APPLICATION_ID
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "azure",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
o.UpdateFromEnv()
|
||||
|
|
|
|||
|
|
@ -10,20 +10,19 @@ import (
|
|||
"github.com/argoproj/argo-cd/v2/util/errors"
|
||||
)
|
||||
|
||||
var (
|
||||
// defaultGCPScopes:
|
||||
// - cloud-platform is the base scope to authenticate to GCP.
|
||||
// - userinfo.email is used to authenticate to GKE APIs with gserviceaccount
|
||||
// email instead of numeric uniqueID.
|
||||
// https://github.com/kubernetes/client-go/blob/be758edd136e61a1bffadf1c0235fceb8aee8e9e/plugin/pkg/client/auth/gcp/gcp.go#L59
|
||||
defaultGCPScopes = []string{
|
||||
"https://www.googleapis.com/auth/cloud-platform",
|
||||
"https://www.googleapis.com/auth/userinfo.email",
|
||||
}
|
||||
)
|
||||
// defaultGCPScopes:
|
||||
// - cloud-platform is the base scope to authenticate to GCP.
|
||||
// - userinfo.email is used to authenticate to GKE APIs with gserviceaccount
|
||||
// email instead of numeric uniqueID.
|
||||
//
|
||||
// https://github.com/kubernetes/client-go/blob/be758edd136e61a1bffadf1c0235fceb8aee8e9e/plugin/pkg/client/auth/gcp/gcp.go#L59
|
||||
var defaultGCPScopes = []string{
|
||||
"https://www.googleapis.com/auth/cloud-platform",
|
||||
"https://www.googleapis.com/auth/userinfo.email",
|
||||
}
|
||||
|
||||
func newGCPCommand() *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "gcp",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
ctx := c.Context()
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ func NewCommand() *cobra.Command {
|
|||
applicationNamespaces []string
|
||||
selfServiceNotificationEnabled bool
|
||||
)
|
||||
var command = cobra.Command{
|
||||
command := cobra.Command{
|
||||
Use: "controller",
|
||||
Short: "Starts Argo CD Notifications controller",
|
||||
RunE: func(c *cobra.Command, args []string) error {
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ func NewCommand() *cobra.Command {
|
|||
disableManifestMaxExtractedSize bool
|
||||
includeHiddenDirectories bool
|
||||
)
|
||||
var command = cobra.Command{
|
||||
command := cobra.Command{
|
||||
Use: cliName,
|
||||
Short: "Run ArgoCD Repository Server",
|
||||
Long: "ArgoCD Repository Server is an internal service which maintains a local cache of the Git repository holding the application manifests, and is responsible for generating and returning the Kubernetes manifests. This command runs Repository Server in the foreground. It can be configured by following options.",
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ func NewCommand() *cobra.Command {
|
|||
applicationNamespaces []string
|
||||
enableProxyExtension bool
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: cliName,
|
||||
Short: "Run the ArgoCD API server",
|
||||
Long: "The API server is a gRPC/REST server which exposes the API consumed by the Web UI, CLI, and CI/CD systems. This command runs API server in the foreground. It can be configured by following options.",
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import (
|
|||
)
|
||||
|
||||
func NewAccountCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "account",
|
||||
Short: "Manage account settings",
|
||||
Example: templates.Examples(`
|
||||
|
|
@ -68,7 +68,7 @@ func NewAccountUpdatePasswordCommand(clientOpts *argocdclient.ClientOptions) *co
|
|||
currentPassword string
|
||||
newPassword string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "update-password",
|
||||
Short: "Update an account's password",
|
||||
Long: `
|
||||
|
|
@ -151,10 +151,8 @@ has appropriate RBAC permissions to change other accounts.
|
|||
}
|
||||
|
||||
func NewAccountGetUserInfoCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var (
|
||||
output string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
var output string
|
||||
command := &cobra.Command{
|
||||
Use: "get-user-info",
|
||||
Short: "Get user info",
|
||||
Example: templates.Examples(`
|
||||
|
|
@ -258,9 +256,7 @@ func printAccountsTable(items []*accountpkg.Account) {
|
|||
}
|
||||
|
||||
func NewAccountListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var (
|
||||
output string
|
||||
)
|
||||
var output string
|
||||
cmd := &cobra.Command{
|
||||
Use: "list",
|
||||
Short: "List accounts",
|
||||
|
|
@ -412,9 +408,7 @@ argocd account generate-token --account <account-name>`,
|
|||
}
|
||||
|
||||
func NewAccountDeleteTokenCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var (
|
||||
account string
|
||||
)
|
||||
var account string
|
||||
cmd := &cobra.Command{
|
||||
Use: "delete-token",
|
||||
Short: "Deletes account token",
|
||||
|
|
|
|||
|
|
@ -37,11 +37,9 @@ var (
|
|||
|
||||
// NewAdminCommand returns a new instance of an argocd command
|
||||
func NewAdminCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var (
|
||||
pathOpts = clientcmd.NewDefaultPathOptions()
|
||||
)
|
||||
pathOpts := clientcmd.NewDefaultPathOptions()
|
||||
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "admin",
|
||||
Short: "Contains a set of commands useful for Argo CD administrators and requires direct Kubernetes access",
|
||||
DisableAutoGenTag: true,
|
||||
|
|
@ -183,7 +181,6 @@ func isArgoCDConfigMap(name string) bool {
|
|||
return true
|
||||
}
|
||||
return false
|
||||
|
||||
}
|
||||
|
||||
// specsEqual returns if the spec, data, labels, annotations, and finalizers of the two
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ import (
|
|||
)
|
||||
|
||||
func NewAppCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "app",
|
||||
Short: "Manage applications configuration",
|
||||
Example: `
|
||||
|
|
@ -79,7 +79,7 @@ func NewGenAppSpecCommand() *cobra.Command {
|
|||
annotations []string
|
||||
inline bool
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "generate-spec APPNAME",
|
||||
Short: "Generate declarative config for an application",
|
||||
Example: `
|
||||
|
|
@ -159,7 +159,7 @@ func printLine(format string, a ...interface{}) {
|
|||
}
|
||||
|
||||
func NewDiffReconcileResults() *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "diff-reconcile-results PATH1 PATH2",
|
||||
Short: "Compare results of two reconciliations and print diff.",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
|
|
@ -249,7 +249,7 @@ func NewReconcileCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command
|
|||
ignoreNormalizerOpts normalizers.IgnoreNormalizerOpts
|
||||
)
|
||||
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "get-reconcile-results PATH",
|
||||
Short: "Reconcile all applications and stores reconciliation summary in the specified file.",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
|
|
@ -328,7 +328,7 @@ func saveToFile(err error, outputFormat string, result reconcileResults, outputP
|
|||
return fmt.Errorf("format %s is not supported", outputFormat)
|
||||
}
|
||||
|
||||
return os.WriteFile(outputPath, data, 0644)
|
||||
return os.WriteFile(outputPath, data, 0o644)
|
||||
}
|
||||
|
||||
func getReconcileResults(ctx context.Context, appClientset appclientset.Interface, namespace string, selector string) ([]appReconcileResult, error) {
|
||||
|
|
@ -384,7 +384,6 @@ func reconcileApplications(
|
|||
}, func(r *http.Request) error {
|
||||
return nil
|
||||
}, []string{})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ func NewExportCommand() *cobra.Command {
|
|||
clientConfig clientcmd.ClientConfig
|
||||
out string
|
||||
)
|
||||
var command = cobra.Command{
|
||||
command := cobra.Command{
|
||||
Use: "export",
|
||||
Short: "Export all Argo CD data to stdout (default) or a file",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
|
|
@ -118,7 +118,7 @@ func NewImportCommand() *cobra.Command {
|
|||
verbose bool
|
||||
stopOperation bool
|
||||
)
|
||||
var command = cobra.Command{
|
||||
command := cobra.Command{
|
||||
Use: "import SOURCE",
|
||||
Short: "Import Argo CD data from stdin (specify `-') or a file",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
|
|
@ -230,7 +230,6 @@ func NewImportCommand() *cobra.Command {
|
|||
if !isForbidden {
|
||||
fmt.Printf("%s/%s %s created%s\n", gvk.Group, gvk.Kind, bakObj.GetName(), dryRunMsg)
|
||||
}
|
||||
|
||||
} else if specsEqual(*bakObj, liveObj) && checkAppHasNoNeedToStopOperation(liveObj, stopOperation) {
|
||||
if verbose {
|
||||
fmt.Printf("%s/%s %s unchanged%s\n", gvk.Group, gvk.Kind, bakObj.GetName(), dryRunMsg)
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ import (
|
|||
)
|
||||
|
||||
func NewClusterCommand(clientOpts *argocdclient.ClientOptions, pathOpts *clientcmd.PathOptions) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "cluster",
|
||||
Short: "Manage clusters configuration",
|
||||
Example: `
|
||||
|
|
@ -168,7 +168,8 @@ func loadClusters(ctx context.Context, kubeClient *kubernetes.Clientset, appClie
|
|||
func getControllerReplicas(ctx context.Context, kubeClient *kubernetes.Clientset, namespace string, appControllerName string) (int, error) {
|
||||
appControllerPodLabelSelector := common.LabelKeyAppName + "=" + appControllerName
|
||||
controllerPods, err := kubeClient.CoreV1().Pods(namespace).List(ctx, v1.ListOptions{
|
||||
LabelSelector: appControllerPodLabelSelector})
|
||||
LabelSelector: appControllerPodLabelSelector,
|
||||
})
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
|
@ -185,7 +186,7 @@ func NewClusterShardsCommand(clientOpts *argocdclient.ClientOptions) *cobra.Comm
|
|||
portForwardRedis bool
|
||||
redisCompressionStr string
|
||||
)
|
||||
var command = cobra.Command{
|
||||
command := cobra.Command{
|
||||
Use: "shards",
|
||||
Short: "Print information about each controller shard and the estimated portion of Kubernetes resources it is responsible for.",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
|
|
@ -311,10 +312,8 @@ func runClusterNamespacesCommand(ctx context.Context, clientConfig clientcmd.Cli
|
|||
}
|
||||
|
||||
func NewClusterNamespacesCommand() *cobra.Command {
|
||||
var (
|
||||
clientConfig clientcmd.ClientConfig
|
||||
)
|
||||
var command = cobra.Command{
|
||||
var clientConfig clientcmd.ClientConfig
|
||||
command := cobra.Command{
|
||||
Use: "namespaces",
|
||||
Short: "Print information namespaces which Argo CD manages in each cluster.",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
|
|
@ -357,7 +356,7 @@ func NewClusterEnableNamespacedMode() *cobra.Command {
|
|||
clusterResources bool
|
||||
namespacesCount int
|
||||
)
|
||||
var command = cobra.Command{
|
||||
command := cobra.Command{
|
||||
Use: "enable-namespaced-mode PATTERN",
|
||||
Short: "Enable namespaced mode for clusters which name matches to the specified pattern.",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
|
|
@ -392,7 +391,6 @@ func NewClusterEnableNamespacedMode() *cobra.Command {
|
|||
} else {
|
||||
fmt.Println("done (dry run)")
|
||||
}
|
||||
|
||||
}
|
||||
return nil
|
||||
}))
|
||||
|
|
@ -411,7 +409,7 @@ func NewClusterDisableNamespacedMode() *cobra.Command {
|
|||
clientConfig clientcmd.ClientConfig
|
||||
dryRun bool
|
||||
)
|
||||
var command = cobra.Command{
|
||||
command := cobra.Command{
|
||||
Use: "disable-namespaced-mode PATTERN",
|
||||
Short: "Disable namespaced mode for clusters which name matches to the specified pattern.",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
|
|
@ -451,7 +449,6 @@ func NewClusterDisableNamespacedMode() *cobra.Command {
|
|||
} else {
|
||||
fmt.Println("done (dry run)")
|
||||
}
|
||||
|
||||
}
|
||||
return nil
|
||||
}))
|
||||
|
|
@ -472,7 +469,7 @@ func NewClusterStatsCommand(clientOpts *argocdclient.ClientOptions) *cobra.Comma
|
|||
portForwardRedis bool
|
||||
redisCompressionStr string
|
||||
)
|
||||
var command = cobra.Command{
|
||||
command := cobra.Command{
|
||||
Use: "stats",
|
||||
Short: "Prints information cluster statistics and inferred shard number",
|
||||
Example: `
|
||||
|
|
@ -528,10 +525,8 @@ argocd admin cluster stats target-cluster`,
|
|||
|
||||
// NewClusterConfig returns a new instance of `argocd admin kubeconfig` command
|
||||
func NewClusterConfig() *cobra.Command {
|
||||
var (
|
||||
clientConfig clientcmd.ClientConfig
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
var clientConfig clientcmd.ClientConfig
|
||||
command := &cobra.Command{
|
||||
Use: "kubeconfig CLUSTER_URL OUTPUT_PATH",
|
||||
Short: "Generates kubeconfig for the specified cluster",
|
||||
DisableAutoGenTag: true,
|
||||
|
|
@ -582,7 +577,7 @@ func NewGenClusterConfigCommand(pathOpts *clientcmd.PathOptions) *cobra.Command
|
|||
labels []string
|
||||
annotations []string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "generate-spec CONTEXT",
|
||||
Short: "Generate declarative config for a cluster",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
|
|
|
|||
|
|
@ -17,14 +17,11 @@ const initialPasswordSecretName = "argocd-initial-admin-secret"
|
|||
|
||||
// NewInitialPasswordCommand defines a new command to retrieve Argo CD initial password.
|
||||
func NewInitialPasswordCommand() *cobra.Command {
|
||||
var (
|
||||
clientConfig clientcmd.ClientConfig
|
||||
)
|
||||
var command = cobra.Command{
|
||||
var clientConfig clientcmd.ClientConfig
|
||||
command := cobra.Command{
|
||||
Use: "initial-password",
|
||||
Short: "Prints initial password to log in to Argo CD for the first time",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
|
||||
config, err := clientConfig.ClientConfig()
|
||||
errors.CheckError(err)
|
||||
namespace, _, err := clientConfig.Namespace()
|
||||
|
|
|
|||
|
|
@ -21,9 +21,7 @@ import (
|
|||
"github.com/argoproj/argo-cd/v2/pkg/apis/application"
|
||||
)
|
||||
|
||||
var (
|
||||
applications = schema.GroupVersionResource{Group: application.Group, Version: "v1alpha1", Resource: application.ApplicationPlural}
|
||||
)
|
||||
var applications = schema.GroupVersionResource{Group: application.Group, Version: "v1alpha1", Resource: application.ApplicationPlural}
|
||||
|
||||
func NewNotificationsCommand() *cobra.Command {
|
||||
var (
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import (
|
|||
)
|
||||
|
||||
func NewProjectsCommand() *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "proj",
|
||||
Short: "Manage projects configuration",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
|
|
@ -45,7 +45,7 @@ func NewGenProjectSpecCommand() *cobra.Command {
|
|||
outputFormat string
|
||||
inline bool
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "generate-spec PROJECT",
|
||||
Short: "Generate declarative config for a project",
|
||||
Example: templates.Examples(`
|
||||
|
|
@ -151,7 +151,7 @@ func NewUpdatePolicyRuleCommand() *cobra.Command {
|
|||
permission string
|
||||
dryRun bool
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
command := &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
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ func NewProjectAllowListGenCommand() *cobra.Command {
|
|||
clientConfig clientcmd.ClientConfig
|
||||
out string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
command := &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
|
||||
|
|
|
|||
|
|
@ -22,8 +22,10 @@ import (
|
|||
corev1 "k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
const defaulRedisInitialPasswordSecretName = "argocd-redis"
|
||||
const defaultResisInitialPasswordKey = "auth"
|
||||
const (
|
||||
defaulRedisInitialPasswordSecretName = "argocd-redis"
|
||||
defaultResisInitialPasswordKey = "auth"
|
||||
)
|
||||
|
||||
func generateRandomPassword() (string, error) {
|
||||
const initialPasswordLength = 16
|
||||
|
|
@ -42,10 +44,8 @@ func generateRandomPassword() (string, error) {
|
|||
|
||||
// NewRedisInitialPasswordCommand defines a new command to ensure Argo CD Redis password secret exists.
|
||||
func NewRedisInitialPasswordCommand() *cobra.Command {
|
||||
var (
|
||||
clientConfig clientcmd.ClientConfig
|
||||
)
|
||||
var command = cobra.Command{
|
||||
var clientConfig clientcmd.ClientConfig
|
||||
command := cobra.Command{
|
||||
Use: "redis-initial-password",
|
||||
Short: "Ensure the Redis password exists, creating a new one if necessary.",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ const (
|
|||
)
|
||||
|
||||
func NewRepoCommand() *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "repo",
|
||||
Short: "Manage repositories configuration",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
|
|
@ -44,7 +44,7 @@ func NewGenRepoSpecCommand() *cobra.Command {
|
|||
)
|
||||
|
||||
// For better readability and easier formatting
|
||||
var repoAddExamples = `
|
||||
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
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ func NewGenRepoSpecCommand() *cobra.Command {
|
|||
argocd admin repo generate-spec helm-oci-registry.cn-zhangjiakou.cr.aliyuncs.com --type helm --name stable --enable-oci --username test --password test
|
||||
`
|
||||
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "generate-spec REPOURL",
|
||||
Short: "Generate declarative config for a repo",
|
||||
Example: repoAddExamples,
|
||||
|
|
|
|||
|
|
@ -146,11 +146,9 @@ func (opts *settingsOpts) getK8sClient() (*kubernetes.Clientset, string, error)
|
|||
}
|
||||
|
||||
func NewSettingsCommand() *cobra.Command {
|
||||
var (
|
||||
opts settingsOpts
|
||||
)
|
||||
var opts settingsOpts
|
||||
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "settings",
|
||||
Short: "Provides set of commands for settings validation and troubleshooting",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
|
|
@ -218,7 +216,6 @@ var validatorsByGroup = map[string]settingValidator{
|
|||
summary = summary + " ('url' field is missing)"
|
||||
}
|
||||
} else if ssoProvider != "" && general.URL != "" {
|
||||
|
||||
} else {
|
||||
summary = "SSO is not configured"
|
||||
}
|
||||
|
|
@ -277,9 +274,7 @@ var validatorsByGroup = map[string]settingValidator{
|
|||
}
|
||||
|
||||
func NewValidateSettingsCommand(cmdCtx commandContext) *cobra.Command {
|
||||
var (
|
||||
groups []string
|
||||
)
|
||||
var groups []string
|
||||
|
||||
var allGroups []string
|
||||
for k := range validatorsByGroup {
|
||||
|
|
@ -289,7 +284,7 @@ func NewValidateSettingsCommand(cmdCtx commandContext) *cobra.Command {
|
|||
return allGroups[i] < allGroups[j]
|
||||
})
|
||||
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "validate",
|
||||
Short: "Validate settings",
|
||||
Long: "Validates settings specified in 'argocd-cm' ConfigMap and 'argocd-secret' Secret",
|
||||
|
|
@ -341,7 +336,7 @@ argocd admin settings validate --group accounts --group plugins --load-cluster-s
|
|||
}
|
||||
|
||||
func NewResourceOverridesCommand(cmdCtx commandContext) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "resource-overrides",
|
||||
Short: "Troubleshoot resource overrides",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
|
|
@ -403,7 +398,7 @@ func executeIgnoreResourceUpdatesOverrideCommand(ctx context.Context, cmdCtx com
|
|||
}
|
||||
|
||||
func NewResourceIgnoreDifferencesCommand(cmdCtx commandContext) *cobra.Command {
|
||||
var command = &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",
|
||||
|
|
@ -453,10 +448,8 @@ argocd admin settings resource-overrides ignore-differences ./deploy.yaml --argo
|
|||
}
|
||||
|
||||
func NewResourceIgnoreResourceUpdatesCommand(cmdCtx commandContext) *cobra.Command {
|
||||
var (
|
||||
ignoreNormalizerOpts normalizers.IgnoreNormalizerOpts
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
var ignoreNormalizerOpts normalizers.IgnoreNormalizerOpts
|
||||
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",
|
||||
|
|
@ -503,7 +496,7 @@ argocd admin settings resource-overrides ignore-resource-updates ./deploy.yaml -
|
|||
}
|
||||
|
||||
func NewResourceHealthCommand(cmdCtx commandContext) *cobra.Command {
|
||||
var command = &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",
|
||||
|
|
@ -536,7 +529,7 @@ argocd admin settings resource-overrides health ./deploy.yaml --argocd-cm-path .
|
|||
}
|
||||
|
||||
func NewResourceActionListCommand(cmdCtx commandContext) *cobra.Command {
|
||||
var command = &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",
|
||||
|
|
@ -580,7 +573,7 @@ argocd admin settings resource-overrides action list /tmp/deploy.yaml --argocd-c
|
|||
}
|
||||
|
||||
func NewResourceActionRunCommand(cmdCtx commandContext) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "run-action RESOURCE_YAML_PATH ACTION",
|
||||
Aliases: []string{"action"},
|
||||
Short: "Executes resource action",
|
||||
|
|
@ -629,7 +622,6 @@ argocd admin settings resource-overrides action run /tmp/deploy.yaml restart --a
|
|||
fmt.Println(bytes.NewBuffer(yamlBytes).String())
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,11 +74,13 @@ var defaultCRUDActions = actionTraitMap{
|
|||
rbacpolicy.ActionUpdate: rbacTrait{},
|
||||
rbacpolicy.ActionDelete: rbacTrait{},
|
||||
}
|
||||
|
||||
var defaultCRDActions = actionTraitMap{
|
||||
rbacpolicy.ActionCreate: rbacTrait{},
|
||||
rbacpolicy.ActionGet: rbacTrait{},
|
||||
rbacpolicy.ActionDelete: rbacTrait{},
|
||||
}
|
||||
|
||||
var applicationsActions = actionTraitMap{
|
||||
rbacpolicy.ActionCreate: rbacTrait{},
|
||||
rbacpolicy.ActionGet: rbacTrait{},
|
||||
|
|
@ -88,23 +90,27 @@ var applicationsActions = actionTraitMap{
|
|||
rbacpolicy.ActionOverride: rbacTrait{},
|
||||
rbacpolicy.ActionSync: rbacTrait{},
|
||||
}
|
||||
|
||||
var accountsActions = actionTraitMap{
|
||||
rbacpolicy.ActionCreate: rbacTrait{},
|
||||
rbacpolicy.ActionUpdate: rbacTrait{},
|
||||
}
|
||||
|
||||
var execActions = actionTraitMap{
|
||||
rbacpolicy.ActionCreate: rbacTrait{},
|
||||
}
|
||||
|
||||
var logsActions = actionTraitMap{
|
||||
rbacpolicy.ActionGet: rbacTrait{},
|
||||
}
|
||||
|
||||
var extensionActions = actionTraitMap{
|
||||
rbacpolicy.ActionInvoke: rbacTrait{},
|
||||
}
|
||||
|
||||
// NewRBACCommand is the command for 'rbac'
|
||||
func NewRBACCommand() *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "rbac",
|
||||
Short: "Validate and test RBAC configuration",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
|
|
@ -130,7 +136,7 @@ func NewRBACCanCommand() *cobra.Command {
|
|||
subResource string
|
||||
clientConfig clientcmd.ClientConfig
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "can ROLE/SUBJECT ACTION RESOURCE [SUB-RESOURCE]",
|
||||
Short: "Check RBAC permissions for a role or subject",
|
||||
Long: `
|
||||
|
|
@ -238,7 +244,7 @@ func NewRBACValidateCommand() *cobra.Command {
|
|||
clientConfig clientcmd.ClientConfig
|
||||
)
|
||||
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "validate [--policy-file POLICYFILE] [--namespace NAMESPACE]",
|
||||
Short: "Validate RBAC policy",
|
||||
Long: `
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ func captureStdout(callback func()) (string, error) {
|
|||
utils.Close(w)
|
||||
|
||||
data, err := io.ReadAll(r)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -305,7 +304,8 @@ func TestResourceOverrideIgnoreDifferences(t *testing.T) {
|
|||
"resource.customizations": `apps/Deployment:
|
||||
ignoreDifferences: |
|
||||
jsonPointers:
|
||||
- /spec`}))
|
||||
- /spec`,
|
||||
}))
|
||||
out, err := captureStdout(func() {
|
||||
cmd.SetArgs([]string{"ignore-differences", f})
|
||||
err := cmd.Execute()
|
||||
|
|
@ -325,7 +325,8 @@ func TestResourceOverrideHealth(t *testing.T) {
|
|||
|
||||
t.Run("NoHealthAssessment", func(t *testing.T) {
|
||||
cmd := NewResourceOverridesCommand(newCmdContext(map[string]string{
|
||||
"resource.customizations": `example.com/ExampleResource: {}`}))
|
||||
"resource.customizations": `example.com/ExampleResource: {}`,
|
||||
}))
|
||||
out, err := captureStdout(func() {
|
||||
cmd.SetArgs([]string{"health", f})
|
||||
err := cmd.Execute()
|
||||
|
|
@ -340,7 +341,8 @@ func TestResourceOverrideHealth(t *testing.T) {
|
|||
"resource.customizations": `example.com/ExampleResource:
|
||||
health.lua: |
|
||||
return { status = "Progressing" }
|
||||
`}))
|
||||
`,
|
||||
}))
|
||||
out, err := captureStdout(func() {
|
||||
cmd.SetArgs([]string{"health", f})
|
||||
err := cmd.Execute()
|
||||
|
|
@ -355,7 +357,8 @@ func TestResourceOverrideHealth(t *testing.T) {
|
|||
"resource.customizations": `example.com/*:
|
||||
health.lua: |
|
||||
return { status = "Progressing" }
|
||||
`}))
|
||||
`,
|
||||
}))
|
||||
out, err := captureStdout(func() {
|
||||
cmd.SetArgs([]string{"health", f})
|
||||
err := cmd.Execute()
|
||||
|
|
@ -381,7 +384,8 @@ func TestResourceOverrideAction(t *testing.T) {
|
|||
|
||||
t.Run("NoActions", func(t *testing.T) {
|
||||
cmd := NewResourceOverridesCommand(newCmdContext(map[string]string{
|
||||
"resource.customizations": `apps/Deployment: {}`}))
|
||||
"resource.customizations": `apps/Deployment: {}`,
|
||||
}))
|
||||
out, err := captureStdout(func() {
|
||||
cmd.SetArgs([]string{"run-action", f, "test"})
|
||||
err := cmd.Execute()
|
||||
|
|
@ -405,7 +409,8 @@ func TestResourceOverrideAction(t *testing.T) {
|
|||
action.lua: |
|
||||
obj.metadata.labels["test"] = 'updated'
|
||||
return obj
|
||||
`}))
|
||||
`,
|
||||
}))
|
||||
out, err := captureStdout(func() {
|
||||
cmd.SetArgs([]string{"run-action", f, "test"})
|
||||
err := cmd.Execute()
|
||||
|
|
@ -449,7 +454,8 @@ resume false
|
|||
result = {}
|
||||
result[1] = impactedResource1
|
||||
return result
|
||||
`}))
|
||||
`,
|
||||
}))
|
||||
out, err := captureStdout(func() {
|
||||
cmd.SetArgs([]string{"run-action", cronJobFile, "test"})
|
||||
err := cmd.Execute()
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ import (
|
|||
|
||||
// NewApplicationCommand returns a new instance of an `argocd app` command
|
||||
func NewApplicationCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "app",
|
||||
Short: "Manage applications",
|
||||
Example: ` # List all the applications.
|
||||
|
|
@ -122,7 +122,7 @@ func NewApplicationCreateCommand(clientOpts *argocdclient.ClientOptions) *cobra.
|
|||
setFinalizer bool
|
||||
appNamespace string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "create APPNAME",
|
||||
Short: "Create an application",
|
||||
Example: ` # Create a directory app
|
||||
|
|
@ -270,7 +270,6 @@ func hasAppChanged(appReq, appRes *argoappv1.Application, upsert bool) bool {
|
|||
}
|
||||
|
||||
func parentChildDetails(appIf application.ApplicationServiceClient, ctx context.Context, appName string, appNs string) (map[string]argoappv1.ResourceNode, map[string][]string, map[string]struct{}) {
|
||||
|
||||
mapUidToNode := make(map[string]argoappv1.ResourceNode)
|
||||
mapParentToChild := make(map[string][]string)
|
||||
parentNode := make(map[string]struct{})
|
||||
|
|
@ -325,7 +324,7 @@ func NewApplicationGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Com
|
|||
showOperation bool
|
||||
appNamespace string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "get APPNAME",
|
||||
Short: "Get application details",
|
||||
Example: templates.Examples(`
|
||||
|
|
@ -439,7 +438,7 @@ func NewApplicationLogsCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
|
|||
container string
|
||||
previous bool
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "logs APPNAME",
|
||||
Short: "Get logs of application pods",
|
||||
Example: templates.Examples(`
|
||||
|
|
@ -737,7 +736,7 @@ func NewApplicationSetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Com
|
|||
appNamespace string
|
||||
sourcePosition int
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "set APPNAME",
|
||||
Short: "Set application parameters",
|
||||
Example: templates.Examples(`
|
||||
|
|
@ -838,13 +837,11 @@ func (o *unsetOpts) KustomizeIsZero() bool {
|
|||
|
||||
// NewApplicationUnsetCommand returns a new instance of an `argocd app unset` command
|
||||
func NewApplicationUnsetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var (
|
||||
sourcePosition int
|
||||
)
|
||||
var sourcePosition int
|
||||
appOpts := cmdutil.AppOptions{}
|
||||
opts := unsetOpts{}
|
||||
var appNamespace string
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "unset APPNAME parameters",
|
||||
Short: "Unset application parameters",
|
||||
Example: ` # Unset kustomize override kustomize image
|
||||
|
|
@ -1047,7 +1044,8 @@ func targetObjects(resources []*argoappv1.ResourceDiff) ([]*unstructured.Unstruc
|
|||
}
|
||||
|
||||
func getLocalObjects(ctx context.Context, app *argoappv1.Application, proj *argoappv1.AppProject, local, localRepoRoot, appLabelKey, kubeVersion string, apiVersions []string, kustomizeOptions *argoappv1.KustomizeOptions,
|
||||
trackingMethod string) []*unstructured.Unstructured {
|
||||
trackingMethod string,
|
||||
) []*unstructured.Unstructured {
|
||||
manifestStrings := getLocalObjectsString(ctx, app, proj, local, localRepoRoot, appLabelKey, kubeVersion, apiVersions, kustomizeOptions, trackingMethod)
|
||||
objs := make([]*unstructured.Unstructured, len(manifestStrings))
|
||||
for i := range manifestStrings {
|
||||
|
|
@ -1060,7 +1058,8 @@ func getLocalObjects(ctx context.Context, app *argoappv1.Application, proj *argo
|
|||
}
|
||||
|
||||
func getLocalObjectsString(ctx context.Context, app *argoappv1.Application, proj *argoappv1.AppProject, local, localRepoRoot, appLabelKey, kubeVersion string, apiVersions []string, kustomizeOptions *argoappv1.KustomizeOptions,
|
||||
trackingMethod string) []string {
|
||||
trackingMethod string,
|
||||
) []string {
|
||||
source := app.Spec.GetSource()
|
||||
res, err := repository.GenerateManifests(ctx, local, localRepoRoot, source.TargetRevision, &repoapiclient.ManifestRequest{
|
||||
Repo: &argoappv1.Repository{Repo: source.RepoURL},
|
||||
|
|
@ -1133,7 +1132,7 @@ func NewApplicationDiffCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
|
|||
ignoreNormalizerOpts normalizers.IgnoreNormalizerOpts
|
||||
)
|
||||
shortDesc := "Perform a diff against the target and live state."
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "diff APPNAME",
|
||||
Short: shortDesc,
|
||||
Long: shortDesc + "\nUses 'diff' to render the difference. KUBECTL_EXTERNAL_DIFF environment variable can be used to select your own diff tool.\nReturns the following exit codes: 2 on general errors, 1 when a diff is found, and 0 when no diff is found\nKubernetes Secrets are ignored from this diff.",
|
||||
|
|
@ -1285,11 +1284,11 @@ func findandPrintDiff(ctx context.Context, app *argoappv1.Application, proj *arg
|
|||
} else {
|
||||
for i := range resources.Items {
|
||||
res := resources.Items[i]
|
||||
var live = &unstructured.Unstructured{}
|
||||
live := &unstructured.Unstructured{}
|
||||
err := json.Unmarshal([]byte(res.NormalizedLiveState), &live)
|
||||
errors.CheckError(err)
|
||||
|
||||
var target = &unstructured.Unstructured{}
|
||||
target := &unstructured.Unstructured{}
|
||||
err = json.Unmarshal([]byte(res.TargetState), &target)
|
||||
errors.CheckError(err)
|
||||
|
||||
|
|
@ -1345,7 +1344,7 @@ func findandPrintDiff(ctx context.Context, app *argoappv1.Application, proj *arg
|
|||
func groupObjsForDiff(resources *application.ManagedResourcesResponse, objs map[kube.ResourceKey]*unstructured.Unstructured, items []objKeyLiveTarget, argoSettings *settings.Settings, appName, namespace string) []objKeyLiveTarget {
|
||||
resourceTracking := argo.NewResourceTracking()
|
||||
for _, res := range resources.Items {
|
||||
var live = &unstructured.Unstructured{}
|
||||
live := &unstructured.Unstructured{}
|
||||
err := json.Unmarshal([]byte(res.NormalizedLiveState), &live)
|
||||
errors.CheckError(err)
|
||||
|
||||
|
|
@ -1386,7 +1385,7 @@ func NewApplicationDeleteCommand(clientOpts *argocdclient.ClientOptions) *cobra.
|
|||
wait bool
|
||||
appNamespace string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "delete APPNAME",
|
||||
Short: "Delete an application",
|
||||
Example: ` # Delete an app
|
||||
|
|
@ -1413,8 +1412,8 @@ func NewApplicationDeleteCommand(clientOpts *argocdclient.ClientOptions) *cobra.
|
|||
defer argoio.Close(conn)
|
||||
var isTerminal bool = isatty.IsTerminal(os.Stdout.Fd()) || isatty.IsCygwinTerminal(os.Stdout.Fd())
|
||||
var isConfirmAll bool = false
|
||||
var numOfApps = len(args)
|
||||
var promptFlag = c.Flag("yes")
|
||||
numOfApps := len(args)
|
||||
promptFlag := c.Flag("yes")
|
||||
if promptFlag.Changed && promptFlag.Value.String() == "true" {
|
||||
noPrompt = true
|
||||
}
|
||||
|
|
@ -1540,7 +1539,7 @@ func NewApplicationListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
|
|||
appNamespace string
|
||||
cluster string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "list",
|
||||
Short: "List applications",
|
||||
Example: ` # List all apps
|
||||
|
|
@ -1710,7 +1709,7 @@ func NewApplicationWaitCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
|
|||
output string
|
||||
appNamespace string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "wait [APPNAME.. | -l selector]",
|
||||
Short: "Wait for an application to reach a synced and healthy state",
|
||||
Example: ` # Wait for an app
|
||||
|
|
@ -1838,7 +1837,7 @@ func NewApplicationSyncCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
|
|||
appNamespace string
|
||||
ignoreNormalizerOpts normalizers.IgnoreNormalizerOpts
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "sync [APPNAME... | -l selector | --project project-name]",
|
||||
Short: "Sync an application to its target state",
|
||||
Example: ` # Sync an app
|
||||
|
|
@ -1902,7 +1901,8 @@ func NewApplicationSyncCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
|
|||
list, err := appIf.List(ctx, &application.ApplicationQuery{
|
||||
Selector: ptr.To(selector),
|
||||
AppNamespace: &appNamespace,
|
||||
Projects: projects})
|
||||
Projects: projects,
|
||||
})
|
||||
errors.CheckError(err)
|
||||
|
||||
// unlike list, we'd want to fail if nothing was found
|
||||
|
|
@ -2237,7 +2237,8 @@ func getResourceStates(app *argoappv1.Application, selectedResources []*argoappv
|
|||
sync = string(resource.Status)
|
||||
}
|
||||
states = append(states, &resourceState{
|
||||
Group: res.Group, Kind: res.Kind, Namespace: res.Namespace, Name: res.Name, Status: sync, Health: health, Hook: string(res.HookType), Message: res.Message})
|
||||
Group: res.Group, Kind: res.Kind, Namespace: res.Namespace, Name: res.Name, Status: sync, Health: health, Hook: string(res.HookType), Message: res.Message,
|
||||
})
|
||||
delete(resourceByKey, kube.NewResourceKey(res.Group, res.Kind, res.Namespace, res.Name))
|
||||
}
|
||||
}
|
||||
|
|
@ -2256,7 +2257,8 @@ func getResourceStates(app *argoappv1.Application, selectedResources []*argoappv
|
|||
health = string(res.Health.Status)
|
||||
}
|
||||
states = append(states, &resourceState{
|
||||
Group: res.Group, Kind: res.Kind, Namespace: res.Namespace, Name: res.Name, Status: string(res.Status), Health: health, Hook: "", Message: ""})
|
||||
Group: res.Group, Kind: res.Kind, Namespace: res.Namespace, Name: res.Name, Status: string(res.Status), Health: health, Hook: "", Message: "",
|
||||
})
|
||||
}
|
||||
// filter out not selected resources
|
||||
if len(selectedResources) > 0 {
|
||||
|
|
@ -2635,7 +2637,7 @@ func NewApplicationHistoryCommand(clientOpts *argocdclient.ClientOptions) *cobra
|
|||
output string
|
||||
appNamespace string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "history APPNAME",
|
||||
Short: "Show application deployment history",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
|
|
@ -2691,7 +2693,7 @@ func NewApplicationRollbackCommand(clientOpts *argocdclient.ClientOptions) *cobr
|
|||
output string
|
||||
appNamespace string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "rollback APPNAME [ID]",
|
||||
Short: "Rollback application to a previous deployed version by History ID, omitted will Rollback to the previous version",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
|
|
@ -2740,8 +2742,10 @@ func NewApplicationRollbackCommand(clientOpts *argocdclient.ClientOptions) *cobr
|
|||
return command
|
||||
}
|
||||
|
||||
const printOpFmtStr = "%-20s%s\n"
|
||||
const defaultCheckTimeoutSeconds = 0
|
||||
const (
|
||||
printOpFmtStr = "%-20s%s\n"
|
||||
defaultCheckTimeoutSeconds = 0
|
||||
)
|
||||
|
||||
func printOperationResult(opState *argoappv1.OperationState) {
|
||||
if opState == nil {
|
||||
|
|
@ -2780,7 +2784,7 @@ func NewApplicationManifestsCommand(clientOpts *argocdclient.ClientOptions) *cob
|
|||
local string
|
||||
localRepoRoot string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "manifests APPNAME",
|
||||
Short: "Print manifests of an application",
|
||||
Example: templates.Examples(`
|
||||
|
|
@ -2842,7 +2846,6 @@ func NewApplicationManifestsCommand(clientOpts *argocdclient.ClientOptions) *cob
|
|||
proj := getProject(c, clientOpts, ctx, app.Spec.Project)
|
||||
unstructureds = getLocalObjects(context.Background(), app, proj.Project, local, localRepoRoot, argoSettings.AppLabelKey, cluster.ServerVersion, cluster.Info.APIVersions, argoSettings.KustomizeOptions, argoSettings.TrackingMethod)
|
||||
} else if len(revisions) > 0 && len(sourcePositions) > 0 {
|
||||
|
||||
q := application.ApplicationManifestQuery{
|
||||
Name: &appName,
|
||||
AppNamespace: &appNs,
|
||||
|
|
@ -2904,7 +2907,7 @@ func NewApplicationManifestsCommand(clientOpts *argocdclient.ClientOptions) *cob
|
|||
|
||||
// NewApplicationTerminateOpCommand returns a new instance of an `argocd app terminate-op` command
|
||||
func NewApplicationTerminateOpCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "terminate-op APPNAME",
|
||||
Short: "Terminate running operation of an application",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
|
|
@ -2929,10 +2932,8 @@ func NewApplicationTerminateOpCommand(clientOpts *argocdclient.ClientOptions) *c
|
|||
}
|
||||
|
||||
func NewApplicationEditCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var (
|
||||
appNamespace string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
var appNamespace string
|
||||
command := &cobra.Command{
|
||||
Use: "edit APPNAME",
|
||||
Short: "Edit application",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
|
|
@ -3043,7 +3044,7 @@ func NewApplicationAddSourceCommand(clientOpts *argocdclient.ClientOptions) *cob
|
|||
appOpts cmdutil.AppOptions
|
||||
appNamespace string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
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
|
||||
|
|
|
|||
|
|
@ -35,19 +35,17 @@ type DisplayedAction struct {
|
|||
Disabled bool
|
||||
}
|
||||
|
||||
var (
|
||||
appActionExample = templates.Examples(`
|
||||
var appActionExample = templates.Examples(`
|
||||
# List all the available actions for an application
|
||||
argocd 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]
|
||||
`)
|
||||
)
|
||||
|
||||
// NewApplicationResourceActionsCommand returns a new instance of an `argocd app actions` command
|
||||
func NewApplicationResourceActionsCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "actions",
|
||||
Short: "Manage Resource actions",
|
||||
Example: appActionExample,
|
||||
|
|
@ -68,7 +66,7 @@ func NewApplicationResourceActionsListCommand(clientOpts *argocdclient.ClientOpt
|
|||
var group string
|
||||
var resourceName string
|
||||
var output string
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "list APPNAME",
|
||||
Short: "Lists available actions on a resource",
|
||||
Example: templates.Examples(`
|
||||
|
|
@ -150,7 +148,7 @@ func NewApplicationResourceActionsRunCommand(clientOpts *argocdclient.ClientOpti
|
|||
var kind string
|
||||
var group string
|
||||
var all bool
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "run APPNAME ACTION",
|
||||
Short: "Runs an available action on resource(s)",
|
||||
Example: templates.Examples(`
|
||||
|
|
@ -182,7 +180,7 @@ func NewApplicationResourceActionsRunCommand(clientOpts *argocdclient.ClientOpti
|
|||
errors.CheckError(err)
|
||||
filteredObjects, err := util.FilterResources(command.Flags().Changed("group"), resources, group, kind, namespace, resourceName, all)
|
||||
errors.CheckError(err)
|
||||
var resGroup = filteredObjects[0].GroupVersionKind().Group
|
||||
resGroup := filteredObjects[0].GroupVersionKind().Group
|
||||
for i := range filteredObjects[1:] {
|
||||
if filteredObjects[i].GroupVersionKind().Group != resGroup {
|
||||
log.Fatal("Ambiguous resource group. Use flag --group to specify resource group explicitly.")
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ func TestPrintTreeViewAppResources(t *testing.T) {
|
|||
nodes[1].ResourceRef = v1alpha1.ResourceRef{Group: "apps", Version: "v1", Kind: "ReplicaSet", Namespace: "sandbox-rollout-numalogic-demo", Name: "numalogic-rollout-demo-5dcd5457d5", UID: "75c30dce-1b66-414f-a86c-573a74be0f40"}
|
||||
nodes[1].ParentRefs = []v1alpha1.ResourceRef{{Group: "argoproj.io", Version: "", Kind: "Rollout", Namespace: "sandbox-rollout-numalogic-demo", Name: "numalogic-rollout-demo", UID: "87f3aab0-f634-4b2c-959a-7ddd30675ed0"}}
|
||||
nodes[2].ResourceRef = v1alpha1.ResourceRef{Group: "argoproj.io", Version: "", Kind: "Rollout", Namespace: "sandbox-rollout-numalogic-demo", Name: "numalogic-rollout-demo", UID: "87f3aab0-f634-4b2c-959a-7ddd30675ed0"}
|
||||
var nodeMapping = make(map[string]v1alpha1.ResourceNode)
|
||||
var mapParentToChild = make(map[string][]string)
|
||||
var parentNode = make(map[string]struct{})
|
||||
nodeMapping := make(map[string]v1alpha1.ResourceNode)
|
||||
mapParentToChild := make(map[string][]string)
|
||||
parentNode := make(map[string]struct{})
|
||||
for _, node := range nodes {
|
||||
nodeMapping[node.UID] = node
|
||||
if len(node.ParentRefs) > 0 {
|
||||
|
|
@ -58,9 +58,9 @@ func TestPrintTreeViewDetailedAppResources(t *testing.T) {
|
|||
Message: "Readiness Gate failed",
|
||||
}
|
||||
|
||||
var nodeMapping = make(map[string]v1alpha1.ResourceNode)
|
||||
var mapParentToChild = make(map[string][]string)
|
||||
var parentNode = make(map[string]struct{})
|
||||
nodeMapping := make(map[string]v1alpha1.ResourceNode)
|
||||
mapParentToChild := make(map[string][]string)
|
||||
parentNode := make(map[string]struct{})
|
||||
for _, node := range nodes {
|
||||
nodeMapping[node.UID] = node
|
||||
if len(node.ParentRefs) > 0 {
|
||||
|
|
|
|||
|
|
@ -179,7 +179,6 @@ func printDetailedTreeViewAppResourcesNotOrphaned(nodeMapping map[string]v1alpha
|
|||
for uid := range parentNodes {
|
||||
detailedTreeViewAppResourcesNotOrphaned("", nodeMapping, parentChildMapping, nodeMapping[uid], w)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func printDetailedTreeViewAppResourcesOrphaned(nodeMapping map[string]v1alpha1.ResourceNode, parentChildMapping map[string][]string, parentNodes map[string]struct{}, orphaned bool, listAll bool, w *tabwriter.Writer) {
|
||||
|
|
@ -192,7 +191,6 @@ func printTreeViewAppResourcesNotOrphaned(nodeMapping map[string]v1alpha1.Resour
|
|||
for uid := range parentNodes {
|
||||
treeViewAppResourcesNotOrphaned("", nodeMapping, parentChildMapping, nodeMapping[uid], w)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func printTreeViewAppResourcesOrphaned(nodeMapping map[string]v1alpha1.ResourceNode, parentChildMapping map[string][]string, parentNodes map[string]struct{}, orphaned bool, listAll bool, w *tabwriter.Writer) {
|
||||
|
|
@ -215,7 +213,6 @@ func printResources(listAll bool, orphaned bool, appResourceTree *v1alpha1.Appli
|
|||
mapUidToNode, mapParentToChild, parentNode := parentChildInfo(appResourceTree.OrphanedNodes)
|
||||
printDetailedTreeViewAppResourcesOrphaned(mapUidToNode, mapParentToChild, parentNode, orphaned, listAll, w)
|
||||
}
|
||||
|
||||
} else if output == "tree" {
|
||||
fmt.Fprintf(w, "GROUP\tKIND\tNAMESPACE\tNAME\tORPHANED\n")
|
||||
|
||||
|
|
@ -228,9 +225,7 @@ func printResources(listAll bool, orphaned bool, appResourceTree *v1alpha1.Appli
|
|||
mapUidToNode, mapParentToChild, parentNode := parentChildInfo(appResourceTree.OrphanedNodes)
|
||||
printTreeViewAppResourcesOrphaned(mapUidToNode, mapParentToChild, parentNode, orphaned, listAll, w)
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
headers := []interface{}{"GROUP", "KIND", "NAMESPACE", "NAME", "ORPHANED"}
|
||||
fmtStr := "%s\t%s\t%s\t%s\t%s\n"
|
||||
_, _ = fmt.Fprintf(w, fmtStr, headers...)
|
||||
|
|
@ -246,17 +241,15 @@ func printResources(listAll bool, orphaned bool, appResourceTree *v1alpha1.Appli
|
|||
_, _ = fmt.Fprintf(w, fmtStr, res.Group, res.Kind, res.Namespace, res.Name, "Yes")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
_ = w.Flush()
|
||||
|
||||
}
|
||||
|
||||
func NewApplicationListResourcesCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var orphaned bool
|
||||
var output string
|
||||
var project string
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "resources APPNAME",
|
||||
Short: "List resource of application",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
|
|
|
|||
|
|
@ -99,7 +99,6 @@ func Test_getRefreshType(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestFindRevisionHistoryWithoutPassedId(t *testing.T) {
|
||||
|
||||
histories := v1alpha1.RevisionHistories{}
|
||||
|
||||
histories = append(histories, v1alpha1.RevisionHistory{ID: 1})
|
||||
|
|
@ -124,7 +123,6 @@ func TestFindRevisionHistoryWithoutPassedId(t *testing.T) {
|
|||
}
|
||||
|
||||
history, err := findRevisionHistory(&application, -1)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal("Find revision history should fail without errors")
|
||||
}
|
||||
|
|
@ -132,7 +130,6 @@ func TestFindRevisionHistoryWithoutPassedId(t *testing.T) {
|
|||
if history == nil {
|
||||
t.Fatal("History should be found")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestPrintTreeViewAppGet(t *testing.T) {
|
||||
|
|
@ -143,9 +140,9 @@ func TestPrintTreeViewAppGet(t *testing.T) {
|
|||
nodes[1].ParentRefs = []v1alpha1.ResourceRef{{Group: "argoproj.io", Version: "", Kind: "Rollout", Namespace: "sandbox-rollout-numalogic-demo", Name: "numalogic-rollout-demo", UID: "87f3aab0-f634-4b2c-959a-7ddd30675ed0"}}
|
||||
nodes[2].ResourceRef = v1alpha1.ResourceRef{Group: "argoproj.io", Version: "", Kind: "Rollout", Namespace: "sandbox-rollout-numalogic-demo", Name: "numalogic-rollout-demo", UID: "87f3aab0-f634-4b2c-959a-7ddd30675ed0"}
|
||||
|
||||
var nodeMapping = make(map[string]v1alpha1.ResourceNode)
|
||||
var mapParentToChild = make(map[string][]string)
|
||||
var parentNode = make(map[string]struct{})
|
||||
nodeMapping := make(map[string]v1alpha1.ResourceNode)
|
||||
mapParentToChild := make(map[string][]string)
|
||||
parentNode := make(map[string]struct{})
|
||||
|
||||
for _, node := range nodes {
|
||||
nodeMapping[node.UID] = node
|
||||
|
|
@ -182,9 +179,9 @@ func TestPrintTreeViewDetailedAppGet(t *testing.T) {
|
|||
nodes[1].ParentRefs = []v1alpha1.ResourceRef{{Group: "argoproj.io", Version: "", Kind: "Rollout", Namespace: "sandbox-rollout-numalogic-demo", Name: "numalogic-rollout-demo", UID: "87f3aab0-f634-4b2c-959a-7ddd30675ed0"}}
|
||||
nodes[2].ResourceRef = v1alpha1.ResourceRef{Group: "argoproj.io", Version: "", Kind: "Rollout", Namespace: "sandbox-rollout-numalogic-demo", Name: "numalogic-rollout-demo", UID: "87f3aab0-f634-4b2c-959a-7ddd30675ed0"}
|
||||
|
||||
var nodeMapping = make(map[string]v1alpha1.ResourceNode)
|
||||
var mapParentToChild = make(map[string][]string)
|
||||
var parentNode = make(map[string]struct{})
|
||||
nodeMapping := make(map[string]v1alpha1.ResourceNode)
|
||||
mapParentToChild := make(map[string][]string)
|
||||
parentNode := make(map[string]struct{})
|
||||
|
||||
for _, node := range nodes {
|
||||
nodeMapping[node.UID] = node
|
||||
|
|
@ -215,7 +212,6 @@ func TestPrintTreeViewDetailedAppGet(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestFindRevisionHistoryWithoutPassedIdWithMultipleSources(t *testing.T) {
|
||||
|
||||
histories := v1alpha1.RevisionHistories{}
|
||||
|
||||
histories = append(histories, v1alpha1.RevisionHistory{ID: 1})
|
||||
|
|
@ -240,7 +236,6 @@ func TestFindRevisionHistoryWithoutPassedIdWithMultipleSources(t *testing.T) {
|
|||
}
|
||||
|
||||
history, err := findRevisionHistory(&application, -1)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal("Find revision history should fail without errors")
|
||||
}
|
||||
|
|
@ -248,7 +243,6 @@ func TestFindRevisionHistoryWithoutPassedIdWithMultipleSources(t *testing.T) {
|
|||
if history == nil {
|
||||
t.Fatal("History should be found")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestDefaultWaitOptions(t *testing.T) {
|
||||
|
|
@ -280,7 +274,6 @@ func TestOverrideWaitOptions(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestFindRevisionHistoryWithoutPassedIdAndEmptyHistoryList(t *testing.T) {
|
||||
|
||||
histories := v1alpha1.RevisionHistories{}
|
||||
|
||||
status := v1alpha1.ApplicationStatus{
|
||||
|
|
@ -313,11 +306,9 @@ func TestFindRevisionHistoryWithoutPassedIdAndEmptyHistoryList(t *testing.T) {
|
|||
if err.Error() != "Application '' should have at least two successful deployments" {
|
||||
t.Fatal("Find revision history should fail with correct error message")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestFindRevisionHistoryWithPassedId(t *testing.T) {
|
||||
|
||||
histories := v1alpha1.RevisionHistories{}
|
||||
|
||||
histories = append(histories, v1alpha1.RevisionHistory{ID: 1})
|
||||
|
|
@ -342,7 +333,6 @@ func TestFindRevisionHistoryWithPassedId(t *testing.T) {
|
|||
}
|
||||
|
||||
history, err := findRevisionHistory(&application, 3)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal("Find revision history should fail without errors")
|
||||
}
|
||||
|
|
@ -354,11 +344,9 @@ func TestFindRevisionHistoryWithPassedId(t *testing.T) {
|
|||
if history.Revision != "123" {
|
||||
t.Fatal("Failed to find correct history with correct revision")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestFindRevisionHistoryWithPassedIdThatNotExist(t *testing.T) {
|
||||
|
||||
histories := v1alpha1.RevisionHistories{}
|
||||
|
||||
histories = append(histories, v1alpha1.RevisionHistory{ID: 1})
|
||||
|
|
@ -395,7 +383,6 @@ func TestFindRevisionHistoryWithPassedIdThatNotExist(t *testing.T) {
|
|||
if err.Error() != "Application '' does not have deployment id '4' in history\n" {
|
||||
t.Fatal("Find revision history should fail with correct error message")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func Test_groupObjsByKey(t *testing.T) {
|
||||
|
|
@ -452,7 +439,6 @@ func Test_groupObjsByKey(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestFormatSyncPolicy(t *testing.T) {
|
||||
|
||||
t.Run("Policy not defined", func(t *testing.T) {
|
||||
app := v1alpha1.Application{}
|
||||
|
||||
|
|
@ -496,7 +482,6 @@ func TestFormatSyncPolicy(t *testing.T) {
|
|||
t.Fatalf("Incorrect policy %q, should be Auto-Prune", policy)
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
func TestFormatConditionSummary(t *testing.T) {
|
||||
|
|
@ -639,7 +624,7 @@ func TestPrintApplicationHistoryTableWithMultipleSources(t *testing.T) {
|
|||
"1a",
|
||||
"1b",
|
||||
},
|
||||
//added Source just for testing the fuction
|
||||
// added Source just for testing the fuction
|
||||
Source: v1alpha1.ApplicationSource{
|
||||
TargetRevision: "-1",
|
||||
RepoURL: "ignore",
|
||||
|
|
@ -1044,7 +1029,6 @@ func TestTargetObjects_invalid(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCheckForDeleteEvent(t *testing.T) {
|
||||
|
||||
ctx := context.Background()
|
||||
fakeClient := new(fakeAcdClient)
|
||||
|
||||
|
|
@ -1293,7 +1277,8 @@ func TestFilterAppResources(t *testing.T) {
|
|||
app := v1alpha1.Application{
|
||||
Status: v1alpha1.ApplicationStatus{
|
||||
Resources: []v1alpha1.ResourceStatus{
|
||||
appReplicaSet1, appReplicaSet2, appJob, appService1, appService2, appDeployment},
|
||||
appReplicaSet1, appReplicaSet2, appJob, appService1, appService2, appDeployment,
|
||||
},
|
||||
},
|
||||
}
|
||||
// Resource filters
|
||||
|
|
@ -1303,49 +1288,56 @@ func TestFilterAppResources(t *testing.T) {
|
|||
Kind: "",
|
||||
Name: "",
|
||||
Namespace: "",
|
||||
Exclude: false}
|
||||
Exclude: false,
|
||||
}
|
||||
// *:*:*
|
||||
includeAllResources = v1alpha1.SyncOperationResource{
|
||||
Group: "*",
|
||||
Kind: "*",
|
||||
Name: "*",
|
||||
Namespace: "",
|
||||
Exclude: false}
|
||||
Exclude: false,
|
||||
}
|
||||
// !*:*:*
|
||||
excludeAllResources = v1alpha1.SyncOperationResource{
|
||||
Group: "*",
|
||||
Kind: "*",
|
||||
Name: "*",
|
||||
Namespace: "",
|
||||
Exclude: true}
|
||||
Exclude: true,
|
||||
}
|
||||
// *:Service:*
|
||||
includeAllServiceResources = v1alpha1.SyncOperationResource{
|
||||
Group: "*",
|
||||
Kind: "Service",
|
||||
Name: "*",
|
||||
Namespace: "",
|
||||
Exclude: false}
|
||||
Exclude: false,
|
||||
}
|
||||
// !*:Service:*
|
||||
excludeAllServiceResources = v1alpha1.SyncOperationResource{
|
||||
Group: "*",
|
||||
Kind: "Service",
|
||||
Name: "*",
|
||||
Namespace: "",
|
||||
Exclude: true}
|
||||
Exclude: true,
|
||||
}
|
||||
// apps:ReplicaSet:replicaSet-name1
|
||||
includeReplicaSet1Resource = v1alpha1.SyncOperationResource{
|
||||
Group: "apps",
|
||||
Kind: "ReplicaSet",
|
||||
Name: "replicaSet-name1",
|
||||
Namespace: "",
|
||||
Exclude: false}
|
||||
Exclude: false,
|
||||
}
|
||||
// !apps:ReplicaSet:replicaSet-name2
|
||||
excludeReplicaSet2Resource = v1alpha1.SyncOperationResource{
|
||||
Group: "apps",
|
||||
Kind: "ReplicaSet",
|
||||
Name: "replicaSet-name2",
|
||||
Namespace: "",
|
||||
Exclude: true}
|
||||
Exclude: true,
|
||||
}
|
||||
)
|
||||
|
||||
// Filtered resources
|
||||
|
|
@ -1393,55 +1385,66 @@ func TestFilterAppResources(t *testing.T) {
|
|||
expectedResult []*v1alpha1.SyncOperationResource
|
||||
}{
|
||||
// --resource apps:ReplicaSet:replicaSet-name1 --resource *:Service:*
|
||||
{testName: "Include ReplicaSet replicaSet-name1 resource and all service resources",
|
||||
{
|
||||
testName: "Include ReplicaSet replicaSet-name1 resource and all service resources",
|
||||
selectedResources: []*v1alpha1.SyncOperationResource{&includeAllServiceResources, &includeReplicaSet1Resource},
|
||||
expectedResult: []*v1alpha1.SyncOperationResource{&replicaSet1, &service1, &service2},
|
||||
},
|
||||
// --resource apps:ReplicaSet:replicaSet-name1 --resource !*:Service:*
|
||||
{testName: "Include ReplicaSet replicaSet-name1 resource and exclude all service resources",
|
||||
{
|
||||
testName: "Include ReplicaSet replicaSet-name1 resource and exclude all service resources",
|
||||
selectedResources: []*v1alpha1.SyncOperationResource{&excludeAllServiceResources, &includeReplicaSet1Resource},
|
||||
expectedResult: []*v1alpha1.SyncOperationResource{&replicaSet1, &replicaSet2, &job, &deployment},
|
||||
},
|
||||
// --resource !apps:ReplicaSet:replicaSet-name2 --resource !*:Service:*
|
||||
{testName: "Exclude ReplicaSet replicaSet-name2 resource and all service resources",
|
||||
{
|
||||
testName: "Exclude ReplicaSet replicaSet-name2 resource and all service resources",
|
||||
selectedResources: []*v1alpha1.SyncOperationResource{&excludeReplicaSet2Resource, &excludeAllServiceResources},
|
||||
expectedResult: []*v1alpha1.SyncOperationResource{&replicaSet1, &replicaSet2, &job, &service1, &service2, &deployment},
|
||||
},
|
||||
// --resource !apps:ReplicaSet:replicaSet-name2
|
||||
{testName: "Exclude ReplicaSet replicaSet-name2 resource",
|
||||
{
|
||||
testName: "Exclude ReplicaSet replicaSet-name2 resource",
|
||||
selectedResources: []*v1alpha1.SyncOperationResource{&excludeReplicaSet2Resource},
|
||||
expectedResult: []*v1alpha1.SyncOperationResource{&replicaSet1, &job, &service1, &service2, &deployment},
|
||||
},
|
||||
// --resource apps:ReplicaSet:replicaSet-name1
|
||||
{testName: "Include ReplicaSet replicaSet-name1 resource",
|
||||
{
|
||||
testName: "Include ReplicaSet replicaSet-name1 resource",
|
||||
selectedResources: []*v1alpha1.SyncOperationResource{&includeReplicaSet1Resource},
|
||||
expectedResult: []*v1alpha1.SyncOperationResource{&replicaSet1},
|
||||
},
|
||||
// --resource !*:Service:*
|
||||
{testName: "Exclude Service resources",
|
||||
{
|
||||
testName: "Exclude Service resources",
|
||||
selectedResources: []*v1alpha1.SyncOperationResource{&excludeAllServiceResources},
|
||||
expectedResult: []*v1alpha1.SyncOperationResource{&replicaSet1, &replicaSet2, &job, &deployment},
|
||||
},
|
||||
// --resource *:Service:*
|
||||
{testName: "Include Service resources",
|
||||
{
|
||||
testName: "Include Service resources",
|
||||
selectedResources: []*v1alpha1.SyncOperationResource{&includeAllServiceResources},
|
||||
expectedResult: []*v1alpha1.SyncOperationResource{&service1, &service2},
|
||||
},
|
||||
// --resource !*:*:*
|
||||
{testName: "Exclude all resources",
|
||||
{
|
||||
testName: "Exclude all resources",
|
||||
selectedResources: []*v1alpha1.SyncOperationResource{&excludeAllResources},
|
||||
expectedResult: nil,
|
||||
},
|
||||
// --resource *:*:*
|
||||
{testName: "Include all resources",
|
||||
{
|
||||
testName: "Include all resources",
|
||||
selectedResources: []*v1alpha1.SyncOperationResource{&includeAllResources},
|
||||
expectedResult: []*v1alpha1.SyncOperationResource{&replicaSet1, &replicaSet2, &job, &service1, &service2, &deployment},
|
||||
},
|
||||
{testName: "No Filters",
|
||||
{
|
||||
testName: "No Filters",
|
||||
selectedResources: []*v1alpha1.SyncOperationResource{&blankValues},
|
||||
expectedResult: nil,
|
||||
},
|
||||
{testName: "Empty Filter",
|
||||
{
|
||||
testName: "Empty Filter",
|
||||
selectedResources: []*v1alpha1.SyncOperationResource{},
|
||||
expectedResult: nil,
|
||||
},
|
||||
|
|
@ -1456,11 +1459,13 @@ func TestFilterAppResources(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestParseSelectedResources(t *testing.T) {
|
||||
resources := []string{"v1alpha:Application:test",
|
||||
resources := []string{
|
||||
"v1alpha:Application:test",
|
||||
"v1alpha:Application:namespace/test",
|
||||
"!v1alpha:Application:test",
|
||||
"apps:Deployment:default/test",
|
||||
"!*:*:*"}
|
||||
"!*:*:*",
|
||||
}
|
||||
operationResources, err := parseSelectedResources(resources)
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, operationResources, 5)
|
||||
|
|
@ -1509,7 +1514,6 @@ func TestParseSelectedResourcesIncorrectNamespace(t *testing.T) {
|
|||
resources := []string{"v1alpha:Application:namespace/test/unknown"}
|
||||
_, err := parseSelectedResources(resources)
|
||||
assert.ErrorContains(t, err, "v1alpha:Application:namespace/test/unknown")
|
||||
|
||||
}
|
||||
|
||||
func TestParseSelectedResourcesEmptyList(t *testing.T) {
|
||||
|
|
@ -1618,7 +1622,6 @@ func TestFormatItems(t *testing.T) {
|
|||
assert.Equal(t, "health", items[6])
|
||||
assert.Equal(t, "hook", items[7])
|
||||
assert.Equal(t, "message", items[8])
|
||||
|
||||
}
|
||||
|
||||
func TestMerge(t *testing.T) {
|
||||
|
|
@ -1854,84 +1857,111 @@ func (c *fakeAcdClient) HTTPClient() (*http.Client, error) { return nil, nil }
|
|||
func (c *fakeAcdClient) OIDCConfig(context.Context, *settingspkg.Settings) (*oauth2.Config, *oidc.Provider, error) {
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
func (c *fakeAcdClient) NewRepoClient() (io.Closer, repositorypkg.RepositoryServiceClient, error) {
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
func (c *fakeAcdClient) NewRepoClientOrDie() (io.Closer, repositorypkg.RepositoryServiceClient) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *fakeAcdClient) NewRepoCredsClient() (io.Closer, repocredspkg.RepoCredsServiceClient, error) {
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
func (c *fakeAcdClient) NewRepoCredsClientOrDie() (io.Closer, repocredspkg.RepoCredsServiceClient) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *fakeAcdClient) NewCertClient() (io.Closer, certificatepkg.CertificateServiceClient, error) {
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
func (c *fakeAcdClient) NewCertClientOrDie() (io.Closer, certificatepkg.CertificateServiceClient) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *fakeAcdClient) NewClusterClient() (io.Closer, clusterpkg.ClusterServiceClient, error) {
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
func (c *fakeAcdClient) NewClusterClientOrDie() (io.Closer, clusterpkg.ClusterServiceClient) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *fakeAcdClient) NewGPGKeyClient() (io.Closer, gpgkeypkg.GPGKeyServiceClient, error) {
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
func (c *fakeAcdClient) NewGPGKeyClientOrDie() (io.Closer, gpgkeypkg.GPGKeyServiceClient) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *fakeAcdClient) NewApplicationClient() (io.Closer, applicationpkg.ApplicationServiceClient, error) {
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
func (c *fakeAcdClient) NewApplicationSetClient() (io.Closer, applicationsetpkg.ApplicationSetServiceClient, error) {
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
func (c *fakeAcdClient) NewApplicationClientOrDie() (io.Closer, applicationpkg.ApplicationServiceClient) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *fakeAcdClient) NewApplicationSetClientOrDie() (io.Closer, applicationsetpkg.ApplicationSetServiceClient) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *fakeAcdClient) NewNotificationClient() (io.Closer, notificationpkg.NotificationServiceClient, error) {
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
func (c *fakeAcdClient) NewNotificationClientOrDie() (io.Closer, notificationpkg.NotificationServiceClient) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *fakeAcdClient) NewSessionClient() (io.Closer, sessionpkg.SessionServiceClient, error) {
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
func (c *fakeAcdClient) NewSessionClientOrDie() (io.Closer, sessionpkg.SessionServiceClient) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *fakeAcdClient) NewSettingsClient() (io.Closer, settingspkg.SettingsServiceClient, error) {
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
func (c *fakeAcdClient) NewSettingsClientOrDie() (io.Closer, settingspkg.SettingsServiceClient) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *fakeAcdClient) NewVersionClient() (io.Closer, versionpkg.VersionServiceClient, error) {
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
func (c *fakeAcdClient) NewVersionClientOrDie() (io.Closer, versionpkg.VersionServiceClient) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *fakeAcdClient) NewProjectClient() (io.Closer, projectpkg.ProjectServiceClient, error) {
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
func (c *fakeAcdClient) NewProjectClientOrDie() (io.Closer, projectpkg.ProjectServiceClient) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *fakeAcdClient) NewAccountClient() (io.Closer, accountpkg.AccountServiceClient, error) {
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
func (c *fakeAcdClient) NewAccountClientOrDie() (io.Closer, accountpkg.AccountServiceClient) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *fakeAcdClient) WatchApplicationWithRetry(ctx context.Context, appName string, revision string) chan *v1alpha1.ApplicationWatchEvent {
|
||||
appEventsCh := make(chan *v1alpha1.ApplicationWatchEvent)
|
||||
|
||||
|
|
|
|||
|
|
@ -24,8 +24,7 @@ import (
|
|||
"github.com/argoproj/argo-cd/v2/util/templates"
|
||||
)
|
||||
|
||||
var (
|
||||
appSetExample = templates.Examples(`
|
||||
var appSetExample = templates.Examples(`
|
||||
# Get an ApplicationSet.
|
||||
argocd appset get APPSETNAME
|
||||
|
||||
|
|
@ -38,11 +37,10 @@ var (
|
|||
# Delete an ApplicationSet
|
||||
argocd appset delete APPSETNAME (APPSETNAME...)
|
||||
`)
|
||||
)
|
||||
|
||||
// NewAppSetCommand returns a new instance of an `argocd appset` command
|
||||
func NewAppSetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "appset",
|
||||
Short: "Manage ApplicationSets",
|
||||
Example: appSetExample,
|
||||
|
|
@ -64,7 +62,7 @@ func NewApplicationSetGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.
|
|||
output string
|
||||
showParams bool
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "get APPSETNAME",
|
||||
Short: "Get ApplicationSet details",
|
||||
Example: templates.Examples(`
|
||||
|
|
@ -117,7 +115,7 @@ func NewApplicationSetGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.
|
|||
// NewApplicationSetCreateCommand returns a new instance of an `argocd appset create` command
|
||||
func NewApplicationSetCreateCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var upsert bool
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "create",
|
||||
Short: "Create one or more ApplicationSets",
|
||||
Example: templates.Examples(`
|
||||
|
|
@ -188,7 +186,7 @@ func NewApplicationSetListCommand(clientOpts *argocdclient.ClientOptions) *cobra
|
|||
projects []string
|
||||
appSetNamespace string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "list",
|
||||
Short: "List ApplicationSets",
|
||||
Example: templates.Examples(`
|
||||
|
|
@ -228,10 +226,8 @@ func NewApplicationSetListCommand(clientOpts *argocdclient.ClientOptions) *cobra
|
|||
|
||||
// NewApplicationSetDeleteCommand returns a new instance of an `argocd appset delete` command
|
||||
func NewApplicationSetDeleteCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var (
|
||||
noPrompt bool
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
var noPrompt bool
|
||||
command := &cobra.Command{
|
||||
Use: "delete",
|
||||
Short: "Delete one or more ApplicationSets",
|
||||
Example: templates.Examples(`
|
||||
|
|
@ -249,13 +245,12 @@ func NewApplicationSetDeleteCommand(clientOpts *argocdclient.ClientOptions) *cob
|
|||
defer argoio.Close(conn)
|
||||
var isTerminal bool = isatty.IsTerminal(os.Stdout.Fd()) || isatty.IsCygwinTerminal(os.Stdout.Fd())
|
||||
var isConfirmAll bool = false
|
||||
var numOfApps = len(args)
|
||||
var promptFlag = c.Flag("yes")
|
||||
numOfApps := len(args)
|
||||
promptFlag := c.Flag("yes")
|
||||
if promptFlag.Changed && promptFlag.Value.String() == "true" {
|
||||
noPrompt = true
|
||||
}
|
||||
for _, appSetQualifiedName := range args {
|
||||
|
||||
appSetName, appSetNs := argo.ParseFromQualifiedName(appSetQualifiedName, "")
|
||||
|
||||
appsetDeleteReq := applicationset.ApplicationSetDeleteRequest{
|
||||
|
|
@ -370,7 +365,6 @@ func printAppSetSummaryTable(appSet *arogappsetv1.ApplicationSet) {
|
|||
syncPolicyStr = "<none>"
|
||||
}
|
||||
fmt.Printf(printOpFmtStr, "SyncPolicy:", syncPolicyStr)
|
||||
|
||||
}
|
||||
|
||||
func printAppSetConditions(w io.Writer, appSet *arogappsetv1.ApplicationSet) {
|
||||
|
|
|
|||
|
|
@ -10,10 +10,8 @@ import (
|
|||
|
||||
// NewBcryptCmd represents the bcrypt command
|
||||
func NewBcryptCmd() *cobra.Command {
|
||||
var (
|
||||
password string
|
||||
)
|
||||
var bcryptCmd = &cobra.Command{
|
||||
var password string
|
||||
bcryptCmd := &cobra.Command{
|
||||
Use: "bcrypt",
|
||||
Short: "Generate bcrypt hash for any password",
|
||||
Example: `# Generate bcrypt hash for any password
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import (
|
|||
|
||||
// NewCertCommand returns a new instance of an `argocd repo` command
|
||||
func NewCertCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "cert",
|
||||
Short: "Manage repository certificates and SSH known hosts entries",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
|
|
@ -60,7 +60,7 @@ func NewCertAddTLSCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command
|
|||
fromFile string
|
||||
upsert bool
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "add-tls SERVERNAME",
|
||||
Short: "Add TLS certificate data for connecting to repository server SERVERNAME",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
|
|
@ -144,7 +144,7 @@ func NewCertAddSSHCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command
|
|||
certificates []appsv1.RepositoryCertificate
|
||||
)
|
||||
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "add-ssh --batch",
|
||||
Short: "Add SSH known host entries for repository servers",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
|
|
@ -214,7 +214,7 @@ func NewCertRemoveCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command
|
|||
certSubType string
|
||||
certQuery certificatepkg.RepositoryCertificateQuery
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "rm REPOSERVER",
|
||||
Short: "Remove certificate of TYPE for REPOSERVER",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
|
|
@ -265,7 +265,7 @@ func NewCertListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
|||
sortOrder string
|
||||
output string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "list",
|
||||
Short: "List configured certificates",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
|
|
@ -295,7 +295,6 @@ func NewCertListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
|||
default:
|
||||
errors.CheckError(fmt.Errorf("unknown output format: %s", output))
|
||||
}
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ const (
|
|||
|
||||
// NewClusterCommand returns a new instance of an `argocd cluster` command
|
||||
func NewClusterCommand(clientOpts *argocdclient.ClientOptions, pathOpts *clientcmd.PathOptions) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "cluster",
|
||||
Short: "Manage cluster credentials",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
|
|
@ -81,7 +81,7 @@ func NewClusterAddCommand(clientOpts *argocdclient.ClientOptions, pathOpts *clie
|
|||
labels []string
|
||||
annotations []string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "add CONTEXT",
|
||||
Short: fmt.Sprintf("%s cluster add CONTEXT", cliName),
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
|
|
@ -221,7 +221,7 @@ func NewClusterSetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command
|
|||
clusterOptions cmdutil.ClusterOptions
|
||||
clusterName string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "set NAME",
|
||||
Short: "Set cluster information",
|
||||
Example: ` # Set cluster information
|
||||
|
|
@ -283,10 +283,8 @@ func checkFieldsToUpdate(clusterOptions cmdutil.ClusterOptions) []string {
|
|||
|
||||
// NewClusterGetCommand returns a new instance of an `argocd cluster get` command
|
||||
func NewClusterGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var (
|
||||
output string
|
||||
)
|
||||
var command = &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
|
||||
|
|
@ -359,7 +357,7 @@ 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 {
|
||||
var noPrompt bool
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "rm SERVER/NAME",
|
||||
Short: "Remove cluster credentials",
|
||||
Example: `argocd cluster rm https://12.34.567.89
|
||||
|
|
@ -373,7 +371,7 @@ argocd cluster rm cluster-name`,
|
|||
}
|
||||
conn, clusterIf := headless.NewClientOrDie(clientOpts, c).NewClusterClientOrDie()
|
||||
defer io.Close(conn)
|
||||
var numOfClusters = len(args)
|
||||
numOfClusters := len(args)
|
||||
var isConfirmAll bool = false
|
||||
|
||||
for _, clusterSelector := range args {
|
||||
|
|
@ -461,10 +459,8 @@ func printClusterServers(clusters []argoappv1.Cluster) {
|
|||
|
||||
// NewClusterListCommand returns a new instance of an `argocd cluster rm` command
|
||||
func NewClusterListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var (
|
||||
output string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
var output string
|
||||
command := &cobra.Command{
|
||||
Use: "list",
|
||||
Short: "List configured clusters",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
|
|
@ -510,7 +506,7 @@ argocd cluster list -o server <ARGOCD_SERVER_ADDRESS>
|
|||
|
||||
// NewClusterRotateAuthCommand returns a new instance of an `argocd cluster rotate-auth` command
|
||||
func NewClusterRotateAuthCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "rotate-auth SERVER/NAME",
|
||||
Short: fmt.Sprintf("%s cluster rotate-auth SERVER/NAME", cliName),
|
||||
Example: `argocd cluster rotate-auth https://12.34.567.89
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ const expectJsonSingle = `{
|
|||
"foo": "bar"
|
||||
}
|
||||
`
|
||||
|
||||
const expectYamlList = `one:
|
||||
bar: ""
|
||||
baz: foo
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ __argocd_custom_func() {
|
|||
)
|
||||
|
||||
func NewCompletionCommand() *cobra.Command {
|
||||
var command = &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.
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import (
|
|||
// NewContextCommand returns a new instance of an `argocd ctx` command
|
||||
func NewContextCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var delete bool
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "context [CONTEXT]",
|
||||
Aliases: []string{"ctx"},
|
||||
Short: "Switch between contexts",
|
||||
|
|
@ -31,7 +31,6 @@ argocd context cd.argoproj.io
|
|||
# Delete Argo CD context
|
||||
argocd context cd.argoproj.io --delete`,
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
|
||||
localCfg, err := localconfig.ReadLocalConfig(clientOpts.ConfigPath)
|
||||
errors.CheckError(err)
|
||||
|
||||
|
|
@ -73,7 +72,7 @@ argocd context cd.argoproj.io --delete`,
|
|||
|
||||
err = localconfig.WriteLocalConfig(*localCfg, clientOpts.ConfigPath)
|
||||
errors.CheckError(err)
|
||||
err = os.WriteFile(prevCtxFile, []byte(prevCtx), 0644)
|
||||
err = os.WriteFile(prevCtxFile, []byte(prevCtx), 0o644)
|
||||
errors.CheckError(err)
|
||||
fmt.Printf("Switched to context '%s'\n", localCfg.CurrentContext)
|
||||
},
|
||||
|
|
@ -83,7 +82,6 @@ argocd context cd.argoproj.io --delete`,
|
|||
}
|
||||
|
||||
func deleteContext(context, configPath string) error {
|
||||
|
||||
localCfg, err := localconfig.ReadLocalConfig(configPath)
|
||||
errors.CheckError(err)
|
||||
if localCfg == nil {
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ func TestContextDelete(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
defer os.Remove(testConfigFilePath)
|
||||
|
||||
err = os.Chmod(testConfigFilePath, 0600)
|
||||
err = os.Chmod(testConfigFilePath, 0o600)
|
||||
require.NoError(t, err, "Could not change the file permission to 0600 %v", err)
|
||||
localConfig, err := localconfig.ReadLocalConfig(testConfigFilePath)
|
||||
assert.NoError(t, err)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import (
|
|||
|
||||
// NewGPGCommand returns a new instance of an `argocd repo` command
|
||||
func NewGPGCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "gpg",
|
||||
Short: "Manage GPG keys used for signature verification",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
|
|
@ -37,10 +37,8 @@ func NewGPGCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
|||
|
||||
// NewGPGListCommand lists all configured public keys from the server
|
||||
func NewGPGListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var (
|
||||
output string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
var output string
|
||||
command := &cobra.Command{
|
||||
Use: "list",
|
||||
Short: "List configured GPG public keys",
|
||||
Example: templates.Examples(`
|
||||
|
|
@ -78,10 +76,8 @@ func NewGPGListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
|||
|
||||
// NewGPGGetCommand retrieves a single public key from the server
|
||||
func NewGPGGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var (
|
||||
output string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
var output string
|
||||
command := &cobra.Command{
|
||||
Use: "get KEYID",
|
||||
Short: "Get the GPG public key with ID <KEYID> from the server",
|
||||
Example: templates.Examples(`
|
||||
|
|
@ -126,10 +122,8 @@ func NewGPGGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
|||
|
||||
// NewGPGAddCommand adds a public key to the server's configuration
|
||||
func NewGPGAddCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var (
|
||||
fromFile string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
var fromFile string
|
||||
command := &cobra.Command{
|
||||
Use: "add",
|
||||
Short: "Adds a GPG public key to the server's keyring",
|
||||
Example: templates.Examples(`
|
||||
|
|
@ -160,12 +154,11 @@ func NewGPGAddCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
|||
}
|
||||
command.Flags().StringVarP(&fromFile, "from", "f", "", "Path to the file that contains the GPG public key to import")
|
||||
return command
|
||||
|
||||
}
|
||||
|
||||
// NewGPGDeleteCommand removes a key from the server's keyring
|
||||
func NewGPGDeleteCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "rm KEYID",
|
||||
Short: "Removes a GPG public key from the server's keyring",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
|
|
@ -182,7 +175,6 @@ func NewGPGDeleteCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command
|
|||
},
|
||||
}
|
||||
return command
|
||||
|
||||
}
|
||||
|
||||
// Print table of certificate info
|
||||
|
|
|
|||
|
|
@ -143,7 +143,8 @@ func (c *forwardRepoClientset) NewRepoServerClient() (io.Closer, repoapiclient.R
|
|||
return
|
||||
}
|
||||
c.repoClientset = repoapiclient.NewRepoServerClientset(fmt.Sprintf("localhost:%d", repoServerPort), 60, repoapiclient.TLSConfiguration{
|
||||
DisableTLS: false, StrictValidation: false})
|
||||
DisableTLS: false, StrictValidation: false,
|
||||
})
|
||||
})
|
||||
if c.err != nil {
|
||||
return nil, nil, c.err
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ func NewLoginCommand(globalClientOpts *argocdclient.ClientOptions) *cobra.Comman
|
|||
ssoPort int
|
||||
skipTestTLS bool
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "login SERVER",
|
||||
Short: "Log in to Argo CD",
|
||||
Long: "Log in to Argo CD",
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import (
|
|||
|
||||
// NewLogoutCommand returns a new instance of `argocd logout` command
|
||||
func NewLogoutCommand(globalClientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "logout CONTEXT",
|
||||
Short: "Log out from Argo CD",
|
||||
Long: "Log out from Argo CD",
|
||||
|
|
|
|||
|
|
@ -12,13 +12,12 @@ import (
|
|||
)
|
||||
|
||||
func TestLogout(t *testing.T) {
|
||||
|
||||
// Write the test config file
|
||||
err := os.WriteFile(testConfigFilePath, []byte(testConfig), os.ModePerm)
|
||||
assert.NoError(t, err)
|
||||
defer os.Remove(testConfigFilePath)
|
||||
|
||||
err = os.Chmod(testConfigFilePath, 0600)
|
||||
err = os.Chmod(testConfigFilePath, 0o600)
|
||||
require.NoError(t, err)
|
||||
|
||||
localConfig, err := localconfig.ReadLocalConfig(testConfigFilePath)
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ type policyOpts struct {
|
|||
|
||||
// NewProjectCommand returns a new instance of an `argocd proj` command
|
||||
func NewProjectCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "proj",
|
||||
Short: "Manage projects",
|
||||
Example: templates.Examples(`
|
||||
|
|
@ -101,7 +101,7 @@ func NewProjectCreateCommand(clientOpts *argocdclient.ClientOptions) *cobra.Comm
|
|||
fileURL string
|
||||
upsert bool
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "create PROJECT",
|
||||
Short: "Create a project",
|
||||
Example: templates.Examples(`
|
||||
|
|
@ -135,10 +135,8 @@ func NewProjectCreateCommand(clientOpts *argocdclient.ClientOptions) *cobra.Comm
|
|||
|
||||
// NewProjectSetCommand returns a new instance of an `argocd proj set` command
|
||||
func NewProjectSetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var (
|
||||
opts cmdutil.ProjectOpts
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
var opts cmdutil.ProjectOpts
|
||||
command := &cobra.Command{
|
||||
Use: "set PROJECT",
|
||||
Short: "Set project parameters",
|
||||
Example: templates.Examples(`
|
||||
|
|
@ -178,7 +176,7 @@ func NewProjectSetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command
|
|||
|
||||
// NewProjectAddSignatureKeyCommand returns a new instance of an `argocd proj add-signature-key` command
|
||||
func NewProjectAddSignatureKeyCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "add-signature-key PROJECT KEY-ID",
|
||||
Short: "Add GnuPG signature key to project",
|
||||
Example: templates.Examples(`
|
||||
|
|
@ -220,7 +218,7 @@ func NewProjectAddSignatureKeyCommand(clientOpts *argocdclient.ClientOptions) *c
|
|||
|
||||
// NewProjectRemoveSignatureKeyCommand returns a new instance of an `argocd proj remove-signature-key` command
|
||||
func NewProjectRemoveSignatureKeyCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "remove-signature-key PROJECT KEY-ID",
|
||||
Short: "Remove GnuPG signature key from project",
|
||||
Example: templates.Examples(`
|
||||
|
|
@ -274,7 +272,7 @@ func NewProjectAddDestinationCommand(clientOpts *argocdclient.ClientOptions) *co
|
|||
return v1alpha1.ApplicationDestination{Server: destination, Namespace: namespace}
|
||||
}
|
||||
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "add-destination PROJECT SERVER/NAME NAMESPACE",
|
||||
Short: "Add project destination",
|
||||
Example: templates.Examples(`
|
||||
|
|
@ -318,7 +316,7 @@ func NewProjectAddDestinationCommand(clientOpts *argocdclient.ClientOptions) *co
|
|||
|
||||
// NewProjectRemoveDestinationCommand returns a new instance of an `argocd proj remove-destination` command
|
||||
func NewProjectRemoveDestinationCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "remove-destination PROJECT SERVER NAMESPACE",
|
||||
Short: "Remove project destination",
|
||||
Example: templates.Examples(`
|
||||
|
|
@ -363,10 +361,8 @@ func NewProjectRemoveDestinationCommand(clientOpts *argocdclient.ClientOptions)
|
|||
|
||||
// NewProjectAddOrphanedIgnoreCommand returns a new instance of an `argocd proj add-orphaned-ignore` command
|
||||
func NewProjectAddOrphanedIgnoreCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var (
|
||||
name string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
var name string
|
||||
command := &cobra.Command{
|
||||
Use: "add-orphaned-ignore PROJECT GROUP KIND",
|
||||
Short: "Add a resource to orphaned ignore list",
|
||||
Example: templates.Examples(`
|
||||
|
|
@ -415,10 +411,8 @@ func NewProjectAddOrphanedIgnoreCommand(clientOpts *argocdclient.ClientOptions)
|
|||
|
||||
// NewProjectRemoveOrphanedIgnoreCommand returns a new instance of an `argocd proj remove-orphaned-ignore` command
|
||||
func NewProjectRemoveOrphanedIgnoreCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var (
|
||||
name string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
var name string
|
||||
command := &cobra.Command{
|
||||
Use: "remove-orphaned-ignore PROJECT GROUP KIND",
|
||||
Short: "Remove a resource from orphaned ignore list",
|
||||
Example: templates.Examples(`
|
||||
|
|
@ -471,7 +465,7 @@ func NewProjectRemoveOrphanedIgnoreCommand(clientOpts *argocdclient.ClientOption
|
|||
|
||||
// NewProjectAddSourceCommand returns a new instance of an `argocd proj add-src` command
|
||||
func NewProjectAddSourceCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "add-source PROJECT URL",
|
||||
Short: "Add project source repository",
|
||||
Example: templates.Examples(`
|
||||
|
|
@ -513,7 +507,7 @@ func NewProjectAddSourceCommand(clientOpts *argocdclient.ClientOptions) *cobra.C
|
|||
|
||||
// NewProjectAddSourceNamespace returns a new instance of an `argocd proj add-source-namespace` command
|
||||
func NewProjectAddSourceNamespace(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "add-source-namespace PROJECT NAMESPACE",
|
||||
Short: "Add source namespace to the AppProject",
|
||||
Example: templates.Examples(`
|
||||
|
|
@ -551,7 +545,7 @@ func NewProjectAddSourceNamespace(clientOpts *argocdclient.ClientOptions) *cobra
|
|||
|
||||
// NewProjectRemoveSourceNamespace returns a new instance of an `argocd proj remove-source-namespace` command
|
||||
func NewProjectRemoveSourceNamespace(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "remove-source-namespace PROJECT NAMESPACE",
|
||||
Short: "Removes the source namespace from the AppProject",
|
||||
Example: templates.Examples(`
|
||||
|
|
@ -632,7 +626,7 @@ func modifyResourceListCmd(cmdUse, cmdDesc, examples string, clientOpts *argocdc
|
|||
} else {
|
||||
defaultList = "allow"
|
||||
}
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: cmdUse,
|
||||
Short: cmdDesc,
|
||||
Example: templates.Examples(examples),
|
||||
|
|
@ -726,7 +720,7 @@ func NewProjectAllowClusterResourceCommand(clientOpts *argocdclient.ClientOption
|
|||
|
||||
// NewProjectRemoveSourceCommand returns a new instance of an `argocd proj remove-src` command
|
||||
func NewProjectRemoveSourceCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "remove-source PROJECT URL",
|
||||
Short: "Remove project source repository",
|
||||
Example: templates.Examples(`
|
||||
|
|
@ -770,7 +764,7 @@ func NewProjectRemoveSourceCommand(clientOpts *argocdclient.ClientOptions) *cobr
|
|||
|
||||
// NewProjectDeleteCommand returns a new instance of an `argocd proj delete` command
|
||||
func NewProjectDeleteCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "delete PROJECT",
|
||||
Short: "Delete project",
|
||||
Example: templates.Examples(`
|
||||
|
|
@ -814,10 +808,8 @@ func printProjectTable(projects []v1alpha1.AppProject) {
|
|||
|
||||
// NewProjectListCommand returns a new instance of an `argocd proj list` command
|
||||
func NewProjectListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var (
|
||||
output string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
var output string
|
||||
command := &cobra.Command{
|
||||
Use: "list",
|
||||
Short: "List projects",
|
||||
Example: templates.Examples(`
|
||||
|
|
@ -929,7 +921,7 @@ func printProject(p *v1alpha1.AppProject, scopedRepositories []*v1alpha1.Reposit
|
|||
fmt.Printf(printProjFmtStr, "", p.Spec.SourceRepos[i])
|
||||
}
|
||||
|
||||
//Print scoped repositories
|
||||
// Print scoped repositories
|
||||
scr0 := "<none>"
|
||||
if len(scopedRepositories) > 0 {
|
||||
scr0 = scopedRepositories[0].Repo
|
||||
|
|
@ -949,7 +941,7 @@ func printProject(p *v1alpha1.AppProject, scopedRepositories []*v1alpha1.Reposit
|
|||
fmt.Printf(printProjFmtStr, "", fmt.Sprintf("%s/%s", p.Spec.ClusterResourceWhitelist[i].Group, p.Spec.ClusterResourceWhitelist[i].Kind))
|
||||
}
|
||||
|
||||
//Print scoped clusters
|
||||
// Print scoped clusters
|
||||
scc0 := "<none>"
|
||||
if len(scopedClusters) > 0 {
|
||||
scc0 = scopedClusters[0].Server
|
||||
|
|
@ -981,15 +973,12 @@ func printProject(p *v1alpha1.AppProject, scopedRepositories []*v1alpha1.Reposit
|
|||
fmt.Printf(printProjFmtStr, "Signature keys:", signatureKeysStr)
|
||||
|
||||
fmt.Printf(printProjFmtStr, "Orphaned Resources:", formatOrphanedResources(p))
|
||||
|
||||
}
|
||||
|
||||
// NewProjectGetCommand returns a new instance of an `argocd proj get` command
|
||||
func NewProjectGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var (
|
||||
output string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
var output string
|
||||
command := &cobra.Command{
|
||||
Use: "get PROJECT",
|
||||
Short: "Get project details",
|
||||
Example: templates.Examples(`
|
||||
|
|
@ -1034,7 +1023,7 @@ func getProject(c *cobra.Command, clientOpts *argocdclient.ClientOptions, ctx co
|
|||
}
|
||||
|
||||
func NewProjectEditCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "edit PROJECT",
|
||||
Short: "Edit project",
|
||||
Example: templates.Examples(`
|
||||
|
|
|
|||
|
|
@ -51,10 +51,8 @@ func NewProjectRoleCommand(clientOpts *argocdclient.ClientOptions) *cobra.Comman
|
|||
|
||||
// NewProjectRoleAddPolicyCommand returns a new instance of an `argocd proj role add-policy` command
|
||||
func NewProjectRoleAddPolicyCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var (
|
||||
opts policyOpts
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
var opts policyOpts
|
||||
command := &cobra.Command{
|
||||
Use: "add-policy PROJECT ROLE-NAME",
|
||||
Short: "Add a policy to a project role",
|
||||
Example: `# Before adding new policy
|
||||
|
|
@ -112,10 +110,8 @@ ID ISSUED-AT EXPIRES-AT
|
|||
|
||||
// NewProjectRoleRemovePolicyCommand returns a new instance of an `argocd proj role remove-policy` command
|
||||
func NewProjectRoleRemovePolicyCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var (
|
||||
opts policyOpts
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
var opts policyOpts
|
||||
command := &cobra.Command{
|
||||
Use: "remove-policy PROJECT ROLE-NAME",
|
||||
Short: "Remove a policy from a role within a project",
|
||||
Example: `List the policy of the test-role before removing a policy
|
||||
|
|
@ -183,10 +179,8 @@ ID ISSUED-AT EXPIRES-AT
|
|||
|
||||
// NewProjectRoleCreateCommand returns a new instance of an `argocd proj role create` command
|
||||
func NewProjectRoleCreateCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var (
|
||||
description string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
var description string
|
||||
command := &cobra.Command{
|
||||
Use: "create PROJECT ROLE-NAME",
|
||||
Short: "Create a project role",
|
||||
Example: templates.Examples(`
|
||||
|
|
@ -227,7 +221,7 @@ func NewProjectRoleCreateCommand(clientOpts *argocdclient.ClientOptions) *cobra.
|
|||
|
||||
// NewProjectRoleDeleteCommand returns a new instance of an `argocd proj role delete` command
|
||||
func NewProjectRoleDeleteCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "delete PROJECT ROLE-NAME",
|
||||
Short: "Delete a project role",
|
||||
Example: `$ argocd proj role delete test-project test-role`,
|
||||
|
|
@ -277,7 +271,7 @@ func NewProjectRoleCreateTokenCommand(clientOpts *argocdclient.ClientOptions) *c
|
|||
outputTokenOnly bool
|
||||
tokenID string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "create-token PROJECT ROLE-NAME",
|
||||
Short: "Create a project token",
|
||||
Example: `$ argocd proj role create-token test-project test-role
|
||||
|
|
@ -346,10 +340,8 @@ Create token succeeded for proj:test-project:test-role.
|
|||
}
|
||||
|
||||
func NewProjectRoleListTokensCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var (
|
||||
useUnixTime bool
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
var useUnixTime bool
|
||||
command := &cobra.Command{
|
||||
Use: "list-tokens PROJECT ROLE-NAME",
|
||||
Short: "List tokens for a given role.",
|
||||
Example: `$ argocd proj role list-tokens test-project test-role
|
||||
|
|
@ -405,7 +397,7 @@ fa9d3517-c52d-434c-9bff-215b38508842 2023-10-08T11:08:18+01:00 Never
|
|||
|
||||
// NewProjectRoleDeleteTokenCommand returns a new instance of an `argocd proj role delete-token` command
|
||||
func NewProjectRoleDeleteTokenCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "delete-token PROJECT ROLE-NAME ISSUED-AT",
|
||||
Short: "Delete a project token",
|
||||
Example: `#Create project test-project
|
||||
|
|
@ -477,10 +469,8 @@ func printProjectRoleListTable(roles []v1alpha1.ProjectRole) {
|
|||
|
||||
// NewProjectRoleListCommand returns a new instance of an `argocd proj roles list` command
|
||||
func NewProjectRoleListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var (
|
||||
output string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
var output string
|
||||
command := &cobra.Command{
|
||||
Use: "list PROJECT",
|
||||
Short: "List all the roles in a project",
|
||||
Example: templates.Examples(`
|
||||
|
|
@ -524,7 +514,7 @@ func NewProjectRoleListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
|
|||
|
||||
// NewProjectRoleGetCommand returns a new instance of an `argocd proj roles get` command
|
||||
func NewProjectRoleGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "get PROJECT ROLE-NAME",
|
||||
Short: "Get the details of a specific role",
|
||||
Example: `$ argocd proj role get test-project test-role
|
||||
|
|
@ -579,7 +569,7 @@ ID ISSUED-AT EXPIRES-AT
|
|||
|
||||
// NewProjectRoleAddGroupCommand returns a new instance of an `argocd proj role add-group` command
|
||||
func NewProjectRoleAddGroupCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "add-group PROJECT ROLE-NAME GROUP-CLAIM",
|
||||
Short: "Add a group claim to a project role",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
|
|
@ -610,7 +600,7 @@ func NewProjectRoleAddGroupCommand(clientOpts *argocdclient.ClientOptions) *cobr
|
|||
|
||||
// NewProjectRoleRemoveGroupCommand returns a new instance of an `argocd proj role remove-group` command
|
||||
func NewProjectRoleRemoveGroupCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "remove-group PROJECT ROLE-NAME GROUP-CLAIM",
|
||||
Short: "Remove a group claim from a role within a project",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ argocd proj windows list <project-name>`,
|
|||
|
||||
// NewProjectWindowsDisableManualSyncCommand returns a new instance of an `argocd proj windows disable-manual-sync` command
|
||||
func NewProjectWindowsDisableManualSyncCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "disable-manual-sync PROJECT ID",
|
||||
Short: "Disable manual sync for a sync window",
|
||||
Long: "Disable manual sync for a sync window. Requires ID which can be found by running \"argocd proj windows list PROJECT\"",
|
||||
|
|
@ -93,7 +93,7 @@ argocd proj windows disable-manual-sync default 0`,
|
|||
|
||||
// NewProjectWindowsEnableManualSyncCommand returns a new instance of an `argocd proj windows enable-manual-sync` command
|
||||
func NewProjectWindowsEnableManualSyncCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "enable-manual-sync PROJECT ID",
|
||||
Short: "Enable manual sync for a sync window",
|
||||
Long: "Enable manual sync for a sync window. Requires ID which can be found by running \"argocd proj windows list PROJECT\"",
|
||||
|
|
@ -149,7 +149,7 @@ func NewProjectWindowsAddWindowCommand(clientOpts *argocdclient.ClientOptions) *
|
|||
manualSync bool
|
||||
timeZone string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "add PROJECT",
|
||||
Short: "Add a sync window to a project",
|
||||
Example: `
|
||||
|
|
@ -205,7 +205,7 @@ argocd proj windows add PROJECT \
|
|||
|
||||
// NewProjectWindowsDeleteCommand returns a new instance of an `argocd proj windows delete` command
|
||||
func NewProjectWindowsDeleteCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "delete PROJECT ID",
|
||||
Short: "Delete a sync window from a project. Requires ID which can be found by running \"argocd proj windows list PROJECT\"",
|
||||
Example: `
|
||||
|
|
@ -252,7 +252,7 @@ func NewProjectWindowsUpdateCommand(clientOpts *argocdclient.ClientOptions) *cob
|
|||
clusters []string
|
||||
timeZone string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "update PROJECT ID",
|
||||
Short: "Update a project sync window",
|
||||
Long: "Update a project sync window. Requires ID which can be found by running \"argocd proj windows list PROJECT\"",
|
||||
|
|
@ -302,10 +302,8 @@ argocd proj windows update PROJECT ID \
|
|||
|
||||
// NewProjectWindowsListCommand returns a new instance of an `argocd proj windows list` command
|
||||
func NewProjectWindowsListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var (
|
||||
output string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
var output string
|
||||
command := &cobra.Command{
|
||||
Use: "list PROJECT",
|
||||
Short: "List project sync windows",
|
||||
Example: `
|
||||
|
|
@ -381,6 +379,7 @@ func formatListOutput(list []string) string {
|
|||
}
|
||||
return o
|
||||
}
|
||||
|
||||
func formatBoolOutput(active bool) string {
|
||||
var o string
|
||||
if active {
|
||||
|
|
@ -390,6 +389,7 @@ func formatBoolOutput(active bool) string {
|
|||
}
|
||||
return o
|
||||
}
|
||||
|
||||
func formatManualOutput(active bool) string {
|
||||
var o string
|
||||
if active {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ func NewReloginCommand(globalClientOpts *argocdclient.ClientOptions) *cobra.Comm
|
|||
password string
|
||||
ssoPort int
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "relogin",
|
||||
Short: "Refresh an expired authenticate token",
|
||||
Long: "Refresh an expired authenticate token",
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import (
|
|||
|
||||
// NewRepoCommand returns a new instance of an `argocd repo` command
|
||||
func NewRepoCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "repo",
|
||||
Short: "Manage repository connection parameters",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
|
|
@ -53,12 +53,10 @@ argocd repo rm https://github.com/yourusername/your-repo.git
|
|||
|
||||
// NewRepoAddCommand returns a new instance of an `argocd repo add` command
|
||||
func NewRepoAddCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var (
|
||||
repoOpts cmdutil.RepoOptions
|
||||
)
|
||||
var repoOpts cmdutil.RepoOptions
|
||||
|
||||
// For better readability and easier formatting
|
||||
var repoAddExamples = ` # Add a Git repository via SSH using a private key for authentication, ignoring the server's host key:
|
||||
repoAddExamples := ` # Add a Git repository via SSH using a private key for authentication, ignoring the server's host key:
|
||||
argocd repo add 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
|
||||
|
|
@ -95,7 +93,7 @@ func NewRepoAddCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
|||
argocd repo add https://source.developers.google.com/p/my-google-cloud-project/r/my-repo --gcp-service-account-key-path service-account-key.json
|
||||
`
|
||||
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "add REPOURL",
|
||||
Short: "Add git repository connection parameters",
|
||||
Example: repoAddExamples,
|
||||
|
|
@ -242,10 +240,8 @@ func NewRepoAddCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
|||
|
||||
// NewRepoRemoveCommand returns a new instance of an `argocd repo remove` command
|
||||
func NewRepoRemoveCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var (
|
||||
project string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
var project string
|
||||
command := &cobra.Command{
|
||||
Use: "rm REPO",
|
||||
Short: "Remove repository credentials",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
|
|
@ -298,7 +294,7 @@ func NewRepoListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
|||
output string
|
||||
refresh string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "list",
|
||||
Short: "List configured repositories",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
|
|
@ -343,7 +339,7 @@ func NewRepoGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
|||
refresh string
|
||||
project string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "get",
|
||||
Short: "Get a configured repository by URL",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import (
|
|||
|
||||
// NewRepoCredsCommand returns a new instance of an `argocd repocreds` command
|
||||
func NewRepoCredsCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "repocreds",
|
||||
Short: "Manage repository connection parameters",
|
||||
Example: templates.Examples(`
|
||||
|
|
@ -60,7 +60,7 @@ func NewRepoCredsAddCommand(clientOpts *argocdclient.ClientOptions) *cobra.Comma
|
|||
)
|
||||
|
||||
// For better readability and easier formatting
|
||||
var repocredsAddExamples = ` # Add credentials with user/pass authentication to use for all repositories under https://git.example.com/repos
|
||||
repocredsAddExamples := ` # Add credentials with user/pass authentication to use for all repositories under https://git.example.com/repos
|
||||
argocd repocreds add https://git.example.com/repos/ --username git --password secret
|
||||
|
||||
# Add credentials with SSH private key authentication to use for all repositories under ssh://git@git.example.com/repos
|
||||
|
|
@ -79,7 +79,7 @@ func NewRepoCredsAddCommand(clientOpts *argocdclient.ClientOptions) *cobra.Comma
|
|||
argocd repocreds add https://source.developers.google.com/p/my-google-cloud-project/r/ --gcp-service-account-key-path service-account-key.json
|
||||
`
|
||||
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "add REPOURL",
|
||||
Short: "Add git repository connection parameters",
|
||||
Example: repocredsAddExamples,
|
||||
|
|
@ -192,7 +192,7 @@ func NewRepoCredsAddCommand(clientOpts *argocdclient.ClientOptions) *cobra.Comma
|
|||
|
||||
// NewRepoCredsRemoveCommand returns a new instance of an `argocd repocreds rm` command
|
||||
func NewRepoCredsRemoveCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
command := &cobra.Command{
|
||||
Use: "rm CREDSURL",
|
||||
Short: "Remove repository credentials",
|
||||
Example: templates.Examples(`
|
||||
|
|
@ -240,10 +240,8 @@ func printRepoCredsUrls(repos []appsv1.RepoCreds) {
|
|||
|
||||
// NewRepoCredsListCommand returns a new instance of an `argocd repo list` command
|
||||
func NewRepoCredsListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var (
|
||||
output string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
var output string
|
||||
command := &cobra.Command{
|
||||
Use: "list",
|
||||
Short: "List configured repository credentials",
|
||||
Example: templates.Examples(`
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue