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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ define run-in-test-server
-e ARGOCD_TLS_DATA_PATH=${ARGOCD_TLS_DATA_PATH:-/tmp/argocd-local/tls} \
-e ARGOCD_SSH_DATA_PATH=${ARGOCD_SSH_DATA_PATH:-/tmp/argocd-local/ssh} \
-e ARGOCD_GPG_DATA_PATH=${ARGOCD_GPG_DATA_PATH:-/tmp/argocd-local/gpg/source} \
-e ARGOCD_E2E_RECORD=${ARGOCD_E2E_RECORD} \
-v ${DOCKER_SRC_MOUNT} \
-v ${GOPATH}/pkg/mod:/go/pkg/mod${VOLUME_MOUNT} \
-v ${GOCACHE}:/tmp/go-build-cache${VOLUME_MOUNT} \
Expand All @@ -100,6 +101,7 @@ define run-in-test-client
-e HOME=/home/user \
-e GOPATH=/go \
-e ARGOCD_E2E_K3S=$(ARGOCD_E2E_K3S) \
-e ARGOCD_E2E_RECORD=$(ARGOCD_E2E_RECORD) \
-e GOCACHE=/tmp/go-build-cache \
-e ARGOCD_LINT_GOGC=$(ARGOCD_LINT_GOGC) \
-v ${DOCKER_SRC_MOUNT} \
Expand All @@ -112,9 +114,13 @@ define run-in-test-client
bash -c "$(1)"
endef

#
define exec-in-test-server
docker exec -it -u $(shell id -u):$(shell id -g) -e ARGOCD_E2E_K3S=$(ARGOCD_E2E_K3S) argocd-test-server $(1)
docker exec -it -u $(shell id -u):$(shell id -g) \
-e ARGOCD_E2E_K3S=$(ARGOCD_E2E_K3S) \
-e ARGOCD_E2E_RECORD=$(ARGOCD_E2E_RECORD) \
-e ARGOCD_E2E_APP_NAMESPACE=$(ARGOCD_E2E_APP_NAMESPACE) \
-e ARGOCD_E2E_TEST_TIMEOUT=$(ARGOCD_E2E_TEST_TIMEOUT) \
argocd-test-server $(1)
endef

PATH:=$(PATH):$(PWD)/hack
Expand Down
7 changes: 7 additions & 0 deletions assets/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -4637,6 +4637,13 @@
"$ref": "#/definitions/v1alpha1SignatureKey"
}
},
"sourceNamespaces": {
"type": "array",
"title": "SourceNamespaces contains list of allowed Application namespaces",
"items": {
"type": "string"
}
},
"sourceRepos": {
"type": "array",
"title": "SourceRepos contains list of repository URLs which can be used for deployment",
Expand Down
1 change: 1 addition & 0 deletions cmd/argocd-server/commands/argocd_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ func NewCommand() *cobra.Command {
Cache: cache,
XFrameOptions: frameOptions,
RedisClient: redisClient,
WatchAllNamespaces: true,
}

stats.RegisterStackDumper()
Expand Down
33 changes: 16 additions & 17 deletions cmd/argocd/commands/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ func NewApplicationLogsCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
}

func printAppSummaryTable(app *argoappv1.Application, appURL string, windows *argoappv1.SyncWindows) {
fmt.Printf(printOpFmtStr, "Name:", app.Name)
fmt.Printf(printOpFmtStr, "Name:", app.QualifiedName())
fmt.Printf(printOpFmtStr, "Project:", app.Spec.GetProject())
fmt.Printf(printOpFmtStr, "Server:", app.Spec.Destination.Server)
fmt.Printf(printOpFmtStr, "Namespace:", app.Spec.Destination.Namespace)
Expand Down Expand Up @@ -537,7 +537,7 @@ func NewApplicationSetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Com
}
setParameterOverrides(app, appOpts.Parameters)
_, err = appIf.UpdateSpec(ctx, &applicationpkg.ApplicationUpdateSpecRequest{
Name: &app.Name,
Name: &appName,
Spec: app.Spec,
Validate: &appOpts.Validate,
})
Expand Down Expand Up @@ -685,7 +685,7 @@ func NewApplicationUnsetCommand(clientOpts *argocdclient.ClientOptions) *cobra.C

cmdutil.SetAppSpecOptions(c.Flags(), &app.Spec, &appOpts)
_, err = appIf.UpdateSpec(context.Background(), &applicationpkg.ApplicationUpdateSpecRequest{
Name: &app.Name,
Name: pointer.StringPtr(app.QualifiedName()),
Spec: app.Spec,
Validate: &appOpts.Validate,
})
Expand Down Expand Up @@ -748,7 +748,7 @@ func getLocalObjectsString(app *argoappv1.Application, local, localRepoRoot, app
res, err := repository.GenerateManifests(local, localRepoRoot, app.Spec.Source.TargetRevision, &repoapiclient.ManifestRequest{
Repo: &argoappv1.Repository{Repo: app.Spec.Source.RepoURL},
AppLabelKey: appLabelKey,
AppName: app.Name,
AppName: app.InstanceName(),
Namespace: app.Spec.Destination.Namespace,
ApplicationSource: &app.Spec.Source,
KustomizeOptions: kustomizeOptions,
Expand Down Expand Up @@ -840,7 +840,7 @@ func NewApplicationDiffCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
cluster, err := clusterIf.Get(context.Background(), &clusterpkg.ClusterQuery{Name: app.Spec.Destination.Name, Server: app.Spec.Destination.Server})
errors.CheckError(err)
localObjs := groupObjsByKey(getLocalObjects(app, local, localRepoRoot, argoSettings.AppLabelKey, cluster.ServerVersion, argoSettings.KustomizeOptions, argoSettings.ConfigManagementPlugins), liveObjs, app.Spec.Destination.Namespace)
items = groupObjsForDiff(resources, localObjs, items, argoSettings, appName)
items = groupObjsForDiff(resources, localObjs, items, argoSettings, app.InstanceName())
} else if revision != "" {
var unstructureds []*unstructured.Unstructured
q := applicationpkg.ApplicationManifestQuery{
Expand All @@ -855,7 +855,7 @@ func NewApplicationDiffCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
unstructureds = append(unstructureds, obj)
}
groupedObjs := groupObjsByKey(unstructureds, liveObjs, app.Spec.Destination.Namespace)
items = groupObjsForDiff(resources, groupedObjs, items, argoSettings, appName)
items = groupObjsForDiff(resources, groupedObjs, items, argoSettings, app.InstanceName())
} else {
for i := range resources.Items {
res := resources.Items[i]
Expand Down Expand Up @@ -1029,7 +1029,7 @@ func NewApplicationDeleteCommand(clientOpts *argocdclient.ClientOptions) *cobra.
// Print simple list of application names
func printApplicationNames(apps []argoappv1.Application) {
for _, app := range apps {
fmt.Println(app.Name)
fmt.Println(app.QualifiedName())
}
}

Expand All @@ -1047,7 +1047,7 @@ func printApplicationTable(apps []argoappv1.Application, output *string) {
_, _ = fmt.Fprintf(w, fmtStr, headers...)
for _, app := range apps {
vals := []interface{}{
app.Name,
app.QualifiedName(),
app.Spec.Destination.Server,
app.Spec.Destination.Namespace,
app.Spec.GetProject(),
Expand All @@ -1067,10 +1067,11 @@ func printApplicationTable(apps []argoappv1.Application, output *string) {
// NewApplicationListCommand returns a new instance of an `argocd app list` command
func NewApplicationListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var (
output string
selector string
projects []string
repo string
output string
selector string
projects []string
repo string
namespace string
)
var command = &cobra.Command{
Use: "list",
Expand Down Expand Up @@ -1109,6 +1110,7 @@ func NewApplicationListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
command.Flags().StringVarP(&selector, "selector", "l", "", "List apps by label")
command.Flags().StringArrayVarP(&projects, "project", "p", []string{}, "Filter by project name")
command.Flags().StringVarP(&repo, "repo", "r", "", "List apps by source repo URL")
command.Flags().StringVarP(&namespace, "namespace", "n", "", "List only apps in given namespace")
return command
}

Expand Down Expand Up @@ -1228,7 +1230,7 @@ func NewApplicationWaitCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
list, err := appIf.List(context.Background(), &applicationpkg.ApplicationQuery{Selector: selector})
errors.CheckError(err)
for _, i := range list.Items {
appNames = append(appNames, i.Name)
appNames = append(appNames, i.Namespace+"/"+i.Name)
}
}
for _, appName := range appNames {
Expand Down Expand Up @@ -1315,7 +1317,7 @@ func NewApplicationSyncCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
log.Fatalf("no apps match selector %v", selector)
}
for _, i := range list.Items {
appNames = append(appNames, i.Name)
appNames = append(appNames, i.QualifiedName())
}
}

Expand Down Expand Up @@ -1413,7 +1415,6 @@ func NewApplicationSyncCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
if !async {
app, err := waitOnApplicationStatus(acdClient, appName, timeout, false, false, true, false, selectedResources)
errors.CheckError(err)

if !dryRun {
if !app.Status.OperationState.Phase.Successful() {
log.Fatalf("Operation has completed with phase: %s", app.Status.OperationState.Phase)
Expand Down Expand Up @@ -1662,12 +1663,10 @@ func waitOnApplicationStatus(acdClient apiclient.Client, appName string, timeout
// Wait on the application as a whole
selectedResourcesAreReady = checkResourceStatus(watchSync, watchHealth, watchOperation, watchSuspended, string(app.Status.Health.Status), string(app.Status.Sync.Status), appEvent.Application.Operation)
}

if selectedResourcesAreReady && (!operationInProgress || !watchOperation) {
app = printFinalStatus(app)
return app, nil
}

newStates := groupResourceStates(app, selectedResources)
for _, newState := range newStates {
var doPrint bool
Expand Down
5 changes: 5 additions & 0 deletions cmd/util/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type AppOptions struct {
allowEmpty bool
namePrefix string
nameSuffix string
namespace string
directoryRecurse bool
configManagementPlugin string
jsonnetTlaStr []string
Expand Down Expand Up @@ -118,6 +119,7 @@ func AddAppFlags(command *cobra.Command, opts *AppOptions) {
command.Flags().DurationVar(&opts.retryBackoffDuration, "sync-retry-backoff-duration", argoappv1.DefaultSyncRetryDuration, "Sync retry backoff base duration. Input needs to be a duration (e.g. 2m, 1h)")
command.Flags().DurationVar(&opts.retryBackoffMaxDuration, "sync-retry-backoff-max-duration", argoappv1.DefaultSyncRetryMaxDuration, "Max sync retry backoff duration. Input needs to be a duration (e.g. 2m, 1h)")
command.Flags().Int64Var(&opts.retryBackoffFactor, "sync-retry-backoff-factor", argoappv1.DefaultSyncRetryFactor, "Factor multiplies the base duration after each failed sync retry")
command.Flags().StringVar(&opts.namespace, "app-namespace", "", "create application in given namespace instead of the default one")
}

func SetAppSpecOptions(flags *pflag.FlagSet, spec *argoappv1.ApplicationSpec, appOpts *AppOptions) int {
Expand Down Expand Up @@ -584,6 +586,9 @@ func ConstructApp(fileURL, appName string, labels, args []string, appOpts AppOpt
SetParameterOverrides(&app, appOpts.Parameters)
mergeLabels(&app, labels)
}
if appOpts.namespace != "" {
app.Namespace = appOpts.namespace
}
return &app, nil
}

Expand Down
Loading