forked from helm/helm
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(get deployed): Add subcommand "get deployed"
The command to print the list of resources under a named release: helm get deployed <RELEASE_NAME> Optional flags: -o / --output <format> - Prints the output in the specified format. Allowed values: table, json, yaml (default table) Signed-off-by: Bhargav Ravuri <[email protected]>
- Loading branch information
1 parent
c5698e5
commit 66b48d3
Showing
8 changed files
with
399 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
Copyright The Helm Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package main | ||
|
||
import ( | ||
"io" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"helm.sh/helm/v3/cmd/helm/require" | ||
"helm.sh/helm/v3/pkg/action" | ||
"helm.sh/helm/v3/pkg/cli/output" | ||
) | ||
|
||
var getDeployedHelp = ` | ||
This command prints list of resources deployed under a release. | ||
` | ||
|
||
// newGetDeployedCmd creates a command for listing the resources deployed under a named release | ||
func newGetDeployedCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { | ||
// Output format for the command output. This will be set by input flag -o (or --output). | ||
var outfmt output.Format | ||
|
||
// Create get-deployed action's client | ||
client := action.NewGetDeployed(cfg) | ||
|
||
cmd := &cobra.Command{ | ||
Use: "deployed RELEASE_NAME", | ||
Short: "list resources deployed under a named release", | ||
Long: getDeployedHelp, | ||
Args: require.ExactArgs(1), | ||
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { | ||
if len(args) != 0 { | ||
return nil, cobra.ShellCompDirectiveNoFileComp | ||
} | ||
|
||
return compListReleases(toComplete, args, cfg) | ||
}, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
// Run the client to list resources under the release | ||
resourceList, err := client.Run(args[0]) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// Create an output writer with resources listed | ||
writer := action.NewResourceListWriter(resourceList, false) | ||
|
||
// Write the resources list with output format provided with input flag | ||
return outfmt.Write(out, writer) | ||
}, | ||
} | ||
|
||
// Add flag for specifying the output format | ||
bindOutputFlag(cmd, &outfmt) | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.