Skip to content

Commit

Permalink
changes after review
Browse files Browse the repository at this point in the history
Signed-off-by: schakrad <58915923+schakrad@users.noreply.github.com>
  • Loading branch information
schakrad committed Sep 14, 2023
1 parent f6f97a7 commit 0468990
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 58 deletions.
82 changes: 27 additions & 55 deletions cmd/argocd/commands/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,27 @@ func parentChildDetails(appIf application.ApplicationServiceClient, ctx context.
}

}
return
return mapUidToNode, mapParentToChild, parentNode
}

func commonOutputFunctionality(acdClient argocdclient.Client, app *argoappv1.Application, ctx context.Context, windows *argoappv1.SyncWindows, showOperation bool, showParams bool) {
aURL := appURL(ctx, acdClient, app.Name)
printAppSummaryTable(app, aURL, windows)

if len(app.Status.Conditions) > 0 {
fmt.Println()
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
printAppConditions(w, app)
_ = w.Flush()
fmt.Println()
}
if showOperation && app.Status.OperationState != nil {
fmt.Println()
printOperationResult(app.Status.OperationState)
}
if showParams {
printParams(app)
}
}

// NewApplicationGetCommand returns a new instance of an `argocd app get` command
Expand Down Expand Up @@ -333,74 +353,26 @@ func NewApplicationGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Com
err := PrintResource(app, output)
errors.CheckError(err)
case "wide", "":
aURL := appURL(ctx, acdClient, app.Name)
printAppSummaryTable(app, aURL, windows)

if len(app.Status.Conditions) > 0 {
fmt.Println()
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
printAppConditions(w, app)
_ = w.Flush()
fmt.Println()
}
if showOperation && app.Status.OperationState != nil {
fmt.Println()
printOperationResult(app.Status.OperationState)
}
if showParams {
printParams(app)
}

commonOutputFunctionality(acdClient, app, ctx, windows, showOperation, showParams)
if len(app.Status.Resources) > 0 {
fmt.Println()
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
printAppResources(w, app)
_ = w.Flush()
}
case "tree":
aURL := appURL(ctx, acdClient, app.Name)
printAppSummaryTable(app, aURL, windows)

if len(app.Status.Conditions) > 0 {
fmt.Println()
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
printAppConditions(w, app)
_ = w.Flush()
fmt.Println()
}
if showOperation && app.Status.OperationState != nil {
fmt.Println()
printOperationResult(app.Status.OperationState)
}
if showParams {
printParams(app)
}
commonOutputFunctionality(acdClient, app, ctx, windows, showOperation, showParams)
mapUidToNode, mapParentToChild, parentNode := parentChildDetails(appIf, ctx, appName, appNs)
mapNodeNameToResourceState := make(map[string]*resourceState)
for _, res := range getResourceStates(app, nil) {
mapNodeNameToResourceState[res.Kind+"/"+res.Name] = res
}
if len(mapUidToNode) > 0 {
fmt.Println()
printTreeView(mapUidToNode, mapParentToChild, parentNode, mapNodeNameToResourceState)
}
case "tree=detailed":
aURL := appURL(ctx, acdClient, app.Name)
printAppSummaryTable(app, aURL, windows)

if len(app.Status.Conditions) > 0 {
fmt.Println()
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
printAppConditions(w, app)
_ = w.Flush()
fmt.Println()
}
if showOperation && app.Status.OperationState != nil {
fmt.Println()
printOperationResult(app.Status.OperationState)
}
if showParams {
printParams(app)
}
commonOutputFunctionality(acdClient, app, ctx, windows, showOperation, showParams)
mapUidToNode, mapParentToChild, parentNode := parentChildDetails(appIf, ctx, appName, appNs)
mapNodeNameToResourceState := make(map[string]*resourceState)
for _, res := range getResourceStates(app, nil) {
Expand Down Expand Up @@ -505,12 +477,12 @@ func NewApplicationLogsCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
command.Flags().StringVar(&kind, "kind", "", "Resource kind")
command.Flags().StringVar(&namespace, "namespace", "", "Resource namespace")
command.Flags().StringVar(&resourceName, "name", "", "Resource name")
command.Flags().BoolVar(&follow, "follow", false, "Specify if the logs should be streamed")
command.Flags().BoolVarP(&follow, "follow", "f", false, "Specify if the logs should be streamed")
command.Flags().Int64Var(&tail, "tail", 0, "The number of lines from the end of the logs to show")
command.Flags().Int64Var(&sinceSeconds, "since-seconds", 0, "A relative time in seconds before the current time from which to show logs")
command.Flags().StringVar(&untilTime, "until-time", "", "Show logs until this time")
command.Flags().StringVar(&filter, "filter", "", "Show logs contain this string")
command.Flags().StringVar(&container, "container", "", "Optional container name")
command.Flags().StringVarP(&container, "container", "c", "", "Optional container name")
command.Flags().BoolVarP(&previous, "previous", "p", false, "Specify if the previously terminated container logs should be returned")

return command
Expand Down
2 changes: 1 addition & 1 deletion cmd/argocd/commands/app_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func parentChildInfo(nodes []v1alpha1.ResourceNode) (mapUidToNode map[string]v1a
parentNode[node.UID] = struct{}{}
}
}
return
return mapUidToNode, mapParentToChild, parentNode
}

func printDetailedTreeViewAppResourcesNotOrphaned(nodeMapping map[string]v1alpha1.ResourceNode, parentChildMapping map[string][]string, parentNodes map[string]struct{}, orphaned bool, listAll bool, w *tabwriter.Writer) {
Expand Down
4 changes: 2 additions & 2 deletions docs/user-guide/commands/argocd_app_logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ argocd app logs APPNAME [flags]
### Options

```
--container string Optional container name
-c, --container string Optional container name
--filter string Show logs contain this string
--follow Specify if the logs should be streamed
-f, --follow Specify if the logs should be streamed
--group string Resource group
-h, --help help for logs
--kind string Resource kind
Expand Down

0 comments on commit 0468990

Please sign in to comment.