Skip to content

Commit

Permalink
feat: argocd app manifests --local option
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Ninon <simon.ninon@gmail.com>
  • Loading branch information
Cylix committed Feb 13, 2022
1 parent 131eea6 commit 4102f81
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
1 change: 1 addition & 0 deletions USERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ Currently, the following organizations are **officially** using Argo CD:
1. [Optoro](https://www.optoro.com/)
1. [Orbital Insight](https://orbitalinsight.com/)
1. [Packlink](https://www.packlink.com/)
1. [PagerDuty](https://www.pagerduty.com/)
1. [PayPay](https://paypay.ne.jp/)
1. [Peloton Interactive](https://www.onepeloton.com/)
1. [Pipefy](https://www.pipefy.com/)
Expand Down
28 changes: 24 additions & 4 deletions cmd/argocd/commands/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1951,8 +1951,10 @@ func printOperationResult(opState *argoappv1.OperationState) {
// NewApplicationManifestsCommand returns a new instance of an `argocd app manifests` command
func NewApplicationManifestsCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var (
source string
revision string
source string
revision string
local string
localRepoRoot string
)
var command = &cobra.Command{
Use: "manifests APPNAME",
Expand All @@ -1963,7 +1965,8 @@ func NewApplicationManifestsCommand(clientOpts *argocdclient.ClientOptions) *cob
os.Exit(1)
}
appName := args[0]
conn, appIf := headless.NewClientOrDie(clientOpts, c).NewApplicationClientOrDie()
clientset := headless.NewClientOrDie(clientOpts, c)
conn, appIf := clientset.NewApplicationClientOrDie()
defer argoio.Close(conn)
ctx := context.Background()
resources, err := appIf.ManagedResources(context.Background(), &applicationpkg.ResourcesQuery{ApplicationName: &appName})
Expand All @@ -1972,7 +1975,22 @@ func NewApplicationManifestsCommand(clientOpts *argocdclient.ClientOptions) *cob
var unstructureds []*unstructured.Unstructured
switch source {
case "git":
if revision != "" {
if local != "" {
app, err := appIf.Get(context.Background(), &applicationpkg.ApplicationQuery{Name: &appName})
errors.CheckError(err)

settingsConn, settingsIf := clientset.NewSettingsClientOrDie()
defer argoio.Close(settingsConn)
argoSettings, err := settingsIf.Get(context.Background(), &settingspkg.SettingsQuery{})
errors.CheckError(err)

clusterConn, clusterIf := clientset.NewClusterClientOrDie()
defer argoio.Close(clusterConn)
cluster, err := clusterIf.Get(context.Background(), &clusterpkg.ClusterQuery{Name: app.Spec.Destination.Name, Server: app.Spec.Destination.Server})
errors.CheckError(err)

unstructureds = getLocalObjects(app, local, localRepoRoot, argoSettings.AppLabelKey, cluster.ServerVersion, cluster.Info.APIVersions, argoSettings.KustomizeOptions, argoSettings.ConfigManagementPlugins, argoSettings.TrackingMethod)
} else if revision != "" {
q := applicationpkg.ApplicationManifestQuery{
Name: &appName,
Revision: revision,
Expand Down Expand Up @@ -2007,6 +2025,8 @@ func NewApplicationManifestsCommand(clientOpts *argocdclient.ClientOptions) *cob
}
command.Flags().StringVar(&source, "source", "git", "Source of manifests. One of: live|git")
command.Flags().StringVar(&revision, "revision", "", "Show manifests at a specific revision")
command.Flags().StringVar(&local, "local", "", "Show local manifests")
command.Flags().StringVar(&localRepoRoot, "local-repo-root", "/", "Path to the repository root. Used together with --local allows setting the repository root")
return command
}

Expand Down
8 changes: 5 additions & 3 deletions docs/user-guide/commands/argocd_app_manifests.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ argocd app manifests APPNAME [flags]
### Options

```
-h, --help help for manifests
--revision string Show manifests at a specific revision
--source string Source of manifests. One of: live|git (default "git")
-h, --help help for manifests
--local string Show local manifests
--local-repo-root string Path to the repository root. Used together with --local allows setting the repository root (default "/")
--revision string Show manifests at a specific revision
--source string Source of manifests. One of: live|git (default "git")
```

### Options inherited from parent commands
Expand Down

0 comments on commit 4102f81

Please sign in to comment.