Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

accept diagnostics as args #6634

Merged
merged 3 commits into from
Jan 23, 2016
Merged
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
208 changes: 0 additions & 208 deletions contrib/completions/bash/openshift
Original file line number Diff line number Diff line change
Expand Up @@ -13435,209 +13435,6 @@ _openshift_kube()
must_have_one_noun=()
}

_openshift_ex_validate_master-config()
{
last_command="openshift_ex_validate_master-config"
commands=()

flags=()
two_word_flags=()
flags_with_completion=()
flags_completion=()

flags+=("--alsologtostderr")
flags+=("--api-version=")
flags+=("--boot-id-file=")
flags+=("--certificate-authority=")
flags_with_completion+=("--certificate-authority")
flags_completion+=("_filedir")
flags+=("--client-certificate=")
flags_with_completion+=("--client-certificate")
flags_completion+=("_filedir")
flags+=("--client-key=")
flags_with_completion+=("--client-key")
flags_completion+=("_filedir")
flags+=("--cluster=")
flags+=("--config=")
flags_with_completion+=("--config")
flags_completion+=("_filedir")
flags+=("--container-hints=")
flags+=("--context=")
flags+=("--docker=")
flags+=("--docker-only")
flags+=("--docker-root=")
flags+=("--docker-run=")
flags+=("--enable-load-reader")
flags+=("--event-storage-age-limit=")
flags+=("--event-storage-event-limit=")
flags+=("--global-housekeeping-interval=")
flags+=("--google-json-key=")
flags+=("--housekeeping-interval=")
flags+=("--httptest.serve=")
flags+=("--insecure-skip-tls-verify")
flags+=("--ir-data-source=")
flags+=("--ir-dbname=")
flags+=("--ir-influxdb-host=")
flags+=("--ir-namespace-only")
flags+=("--ir-password=")
flags+=("--ir-percentile=")
flags+=("--ir-user=")
flags+=("--log-backtrace-at=")
flags+=("--log-cadvisor-usage")
flags+=("--log-dir=")
flags+=("--log-flush-frequency=")
flags+=("--logtostderr")
flags+=("--machine-id-file=")
flags+=("--match-server-version")
flags+=("--namespace=")
two_word_flags+=("-n")
flags+=("--server=")
flags+=("--stderrthreshold=")
flags+=("--token=")
flags+=("--user=")
flags+=("--v=")
flags+=("--vmodule=")

must_have_one_flag=()
must_have_one_noun=()
}

_openshift_ex_validate_node-config()
{
last_command="openshift_ex_validate_node-config"
commands=()

flags=()
two_word_flags=()
flags_with_completion=()
flags_completion=()

flags+=("--alsologtostderr")
flags+=("--api-version=")
flags+=("--boot-id-file=")
flags+=("--certificate-authority=")
flags_with_completion+=("--certificate-authority")
flags_completion+=("_filedir")
flags+=("--client-certificate=")
flags_with_completion+=("--client-certificate")
flags_completion+=("_filedir")
flags+=("--client-key=")
flags_with_completion+=("--client-key")
flags_completion+=("_filedir")
flags+=("--cluster=")
flags+=("--config=")
flags_with_completion+=("--config")
flags_completion+=("_filedir")
flags+=("--container-hints=")
flags+=("--context=")
flags+=("--docker=")
flags+=("--docker-only")
flags+=("--docker-root=")
flags+=("--docker-run=")
flags+=("--enable-load-reader")
flags+=("--event-storage-age-limit=")
flags+=("--event-storage-event-limit=")
flags+=("--global-housekeeping-interval=")
flags+=("--google-json-key=")
flags+=("--housekeeping-interval=")
flags+=("--httptest.serve=")
flags+=("--insecure-skip-tls-verify")
flags+=("--ir-data-source=")
flags+=("--ir-dbname=")
flags+=("--ir-influxdb-host=")
flags+=("--ir-namespace-only")
flags+=("--ir-password=")
flags+=("--ir-percentile=")
flags+=("--ir-user=")
flags+=("--log-backtrace-at=")
flags+=("--log-cadvisor-usage")
flags+=("--log-dir=")
flags+=("--log-flush-frequency=")
flags+=("--logtostderr")
flags+=("--machine-id-file=")
flags+=("--match-server-version")
flags+=("--namespace=")
two_word_flags+=("-n")
flags+=("--server=")
flags+=("--stderrthreshold=")
flags+=("--token=")
flags+=("--user=")
flags+=("--v=")
flags+=("--vmodule=")

must_have_one_flag=()
must_have_one_noun=()
}

_openshift_ex_validate()
{
last_command="openshift_ex_validate"
commands=()
commands+=("master-config")
commands+=("node-config")

flags=()
two_word_flags=()
flags_with_completion=()
flags_completion=()

flags+=("--alsologtostderr")
flags+=("--api-version=")
flags+=("--boot-id-file=")
flags+=("--certificate-authority=")
flags_with_completion+=("--certificate-authority")
flags_completion+=("_filedir")
flags+=("--client-certificate=")
flags_with_completion+=("--client-certificate")
flags_completion+=("_filedir")
flags+=("--client-key=")
flags_with_completion+=("--client-key")
flags_completion+=("_filedir")
flags+=("--cluster=")
flags+=("--config=")
flags_with_completion+=("--config")
flags_completion+=("_filedir")
flags+=("--container-hints=")
flags+=("--context=")
flags+=("--docker=")
flags+=("--docker-only")
flags+=("--docker-root=")
flags+=("--docker-run=")
flags+=("--enable-load-reader")
flags+=("--event-storage-age-limit=")
flags+=("--event-storage-event-limit=")
flags+=("--global-housekeeping-interval=")
flags+=("--google-json-key=")
flags+=("--housekeeping-interval=")
flags+=("--httptest.serve=")
flags+=("--insecure-skip-tls-verify")
flags+=("--ir-data-source=")
flags+=("--ir-dbname=")
flags+=("--ir-influxdb-host=")
flags+=("--ir-namespace-only")
flags+=("--ir-password=")
flags+=("--ir-percentile=")
flags+=("--ir-user=")
flags+=("--log-backtrace-at=")
flags+=("--log-cadvisor-usage")
flags+=("--log-dir=")
flags+=("--log-flush-frequency=")
flags+=("--logtostderr")
flags+=("--machine-id-file=")
flags+=("--match-server-version")
flags+=("--namespace=")
two_word_flags+=("-n")
flags+=("--server=")
flags+=("--stderrthreshold=")
flags+=("--token=")
flags+=("--user=")
flags+=("--v=")
flags+=("--vmodule=")

must_have_one_flag=()
must_have_one_noun=()
}

_openshift_ex_tokens_validate-token()
{
last_command="openshift_ex_tokens_validate-token"
Expand Down Expand Up @@ -14022,8 +13819,6 @@ _openshift_ex_diagnostics()
flags+=("--context=")
flags+=("--diaglevel=")
two_word_flags+=("-l")
flags+=("--diagnostics=")
two_word_flags+=("-d")
flags+=("--host")
flags+=("--images=")
flags+=("--latest-images")
Expand Down Expand Up @@ -14319,7 +14114,6 @@ _openshift_ex()
{
last_command="openshift_ex"
commands=()
commands+=("validate")
commands+=("tokens")
commands+=("ipfailover")
commands+=("build-chain")
Expand Down Expand Up @@ -14680,8 +14474,6 @@ _openshift_infra_diagnostic-pod()

flags+=("--diaglevel=")
two_word_flags+=("-l")
flags+=("--diagnostics=")
two_word_flags+=("-d")
flags+=("--google-json-key=")
flags+=("--log-flush-frequency=")

Expand Down
11 changes: 7 additions & 4 deletions pkg/cmd/admin/validate/master.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ This command validates that a configuration file intended to be used for a maste

validateMasterConfigExample = ` // Validate master server configuration file
$ %s openshift.local.config/master/master-config.yaml`

validateMasterConfigDeprecationMessage = `This command is deprecated and will be removed. Use 'openshift ex diagnostics MasterConfigCheck --master-config=path/to/config.yaml' instead.`
)

type ValidateMasterConfigOptions struct {
Expand All @@ -44,10 +46,11 @@ func NewCommandValidateMasterConfig(name, fullName string, out io.Writer) *cobra
}

cmd := &cobra.Command{
Use: fmt.Sprintf("%s SOURCE", name),
Short: "Validate the configuration file for a master server",
Long: validateMasterConfigLong,
Example: fmt.Sprintf(validateMasterConfigExample, fullName),
Use: fmt.Sprintf("%s SOURCE", name),
Short: "Validate the configuration file for a master server",
Long: validateMasterConfigLong,
Example: fmt.Sprintf(validateMasterConfigExample, fullName),
Deprecated: validateMasterConfigDeprecationMessage,
Run: func(c *cobra.Command, args []string) {
if err := options.Complete(args); err != nil {
cmdutil.CheckErr(cmdutil.UsageError(c, err.Error()))
Expand Down
11 changes: 7 additions & 4 deletions pkg/cmd/admin/validate/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ This command validates that a configuration file intended to be used for a node

valiateNodeConfigExample = ` // Validate node configuration file
$ %s openshift.local.config/master/node-config.yaml`

validateNodeConfigDeprecationMessage = `This command is deprecated and will be removed. Use 'openshift ex diagnostics NodeConfigCheck --node-config=path/to/config.yaml' instead.`
)

type ValidateNodeConfigOptions struct {
Expand All @@ -43,10 +45,11 @@ func NewCommandValidateNodeConfig(name, fullName string, out io.Writer) *cobra.C
}

cmd := &cobra.Command{
Use: fmt.Sprintf("%s SOURCE", name),
Short: "Validate the configuration file for a node",
Long: validateNodeConfigLong,
Example: fmt.Sprintf(valiateNodeConfigExample, fullName),
Use: fmt.Sprintf("%s SOURCE", name),
Short: "Validate the configuration file for a node",
Long: validateNodeConfigLong,
Example: fmt.Sprintf(valiateNodeConfigExample, fullName),
Deprecated: validateNodeConfigDeprecationMessage,
Run: func(c *cobra.Command, args []string) {
if err := options.Complete(args); err != nil {
cmdutil.CheckErr(cmdutil.UsageError(c, err.Error()))
Expand Down
18 changes: 12 additions & 6 deletions pkg/cmd/admin/validate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,26 @@ import (
cmdutil "github.com/openshift/origin/pkg/cmd/util"
)

const ValidateRecommendedName = "validate"
const (
ValidateRecommendedName = "validate"

const validateLong = `Validate configuration file integrity
validateLong = `Validate configuration file integrity

The commands here allow administrators to validate the integrity of configuration files.
`

validateDeprecationMessage = `The commands here are deprecated and will be removed. Use 'openshift ex diagnostics' to run configuration validations instead.
See sub-command help text for specific instructions with 'openshift ex diagnostics'.`
)

func NewCommandValidate(name, fullName string, out io.Writer) *cobra.Command {
// Parent command to which all subcommands are added.
cmds := &cobra.Command{
Use: name,
Short: "Validate configuration file integrity",
Long: validateLong,
Run: cmdutil.DefaultSubCommandRun(out),
Use: name,
Short: "Validate configuration file integrity",
Long: validateLong,
Deprecated: validateDeprecationMessage,
Run: cmdutil.DefaultSubCommandRun(out),
}

cmds.AddCommand(NewCommandValidateMasterConfig(ValidateMasterConfigRecommendedName,
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/experimental/diagnostics/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (o DiagnosticsOptions) buildClientDiagnostics(rawConfig *clientcmdapi.Confi
}

diagnostics := []types.Diagnostic{}
requestedDiagnostics := intersection(sets.NewString(o.RequestedDiagnostics...), available).List()
requestedDiagnostics := available.Intersection(sets.NewString(o.RequestedDiagnostics...)).List()
for _, diagnosticName := range requestedDiagnostics {
switch diagnosticName {
case clientdiags.ConfigContextsName:
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/experimental/diagnostics/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var (
// buildClusterDiagnostics builds cluster Diagnostic objects if a cluster-admin client can be extracted from the rawConfig passed in.
// Returns the Diagnostics built, "ok" bool for whether to proceed or abort, and an error if any was encountered during the building of diagnostics.) {
func (o DiagnosticsOptions) buildClusterDiagnostics(rawConfig *clientcmdapi.Config) ([]types.Diagnostic, bool, error) {
requestedDiagnostics := intersection(sets.NewString(o.RequestedDiagnostics...), availableClusterDiagnostics).List()
requestedDiagnostics := availableClusterDiagnostics.Intersection(sets.NewString(o.RequestedDiagnostics...)).List()
if len(requestedDiagnostics) == 0 { // no diagnostics to run here
return nil, true, nil // don't waste time on discovery
}
Expand Down
Loading