Skip to content

Commit

Permalink
Merge pull request #10112 from juanvallejo/jvallejo_update-hardcoded-…
Browse files Browse the repository at this point in the history
…oc-cmd

Merged by openshift-bot
  • Loading branch information
OpenShift Bot authored Aug 2, 2016
2 parents 14c1a78 + bcf8d9b commit 2dee2ff
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
10 changes: 8 additions & 2 deletions pkg/cmd/cli/cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func NewCmdStatus(name, baseCLIName, fullName string, f *clientcmd.Factory, out
Long: fmt.Sprintf(statusLong, baseCLIName),
Example: fmt.Sprintf(statusExample, fullName),
Run: func(cmd *cobra.Command, args []string) {
err := opts.Complete(f, cmd, args, out)
err := opts.Complete(f, cmd, baseCLIName, args, out)
kcmdutil.CheckErr(err)

if err := opts.Validate(); err != nil {
Expand All @@ -87,7 +87,7 @@ func NewCmdStatus(name, baseCLIName, fullName string, f *clientcmd.Factory, out
}

// Complete completes the options for the Openshift cli status command.
func (o *StatusOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, args []string, out io.Writer) error {
func (o *StatusOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, baseCLIName string, args []string, out io.Writer) error {
if len(args) > 0 {
return kcmdutil.UsageError(cmd, "no arguments should be provided")
}
Expand Down Expand Up @@ -116,12 +116,18 @@ func (o *StatusOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, args
o.namespace = namespace
}

if baseCLIName == "" {
baseCLIName = "oc"
}

o.describer = &describe.ProjectStatusDescriber{
K: kclient,
C: client,
Server: config.Host,
Suggest: o.verbose,

CommandBaseName: baseCLIName,

// TODO: Remove these and reference them inside the markers using constants.
LogsCommandName: o.logsCommandName,
SecurityPolicyCommandFormat: o.securityPolicyCommandFormat,
Expand Down
13 changes: 8 additions & 5 deletions pkg/cmd/cli/describe/projectstatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ type ProjectStatusDescriber struct {
Server string
Suggest bool

// root command used when calling this command
CommandBaseName string

LogsCommandName string
SecurityPolicyCommandFormat string
SetProbeCommandName string
Expand Down Expand Up @@ -311,20 +314,20 @@ func (d *ProjectStatusDescriber) Describe(namespace, name string) (string, error

switch {
case !d.Suggest && len(errorMarkers) > 0 && len(warningMarkers) > 0:
fmt.Fprintf(out, "%s and %s identified, use 'oc status -v' to see details.\n", errors, warnings)
fmt.Fprintf(out, "%s and %s identified, use '%[3]s status -v' to see details.\n", errors, warnings, d.CommandBaseName)

case !d.Suggest && len(errorMarkers) > 0 && errorSuggestions > 0:
fmt.Fprintf(out, "%s identified, use 'oc status -v' to see details.\n", errors)
fmt.Fprintf(out, "%s identified, use '%[2]s status -v' to see details.\n", errors, d.CommandBaseName)

case !d.Suggest && len(warningMarkers) > 0:
fmt.Fprintf(out, "%s identified, use 'oc status -v' to see details.\n", warnings)
fmt.Fprintf(out, "%s identified, use '%[2]s status -v' to see details.\n", warnings, d.CommandBaseName)

case (len(services) == 0) && (len(standaloneDCs) == 0) && (len(standaloneImages) == 0):
fmt.Fprintln(out, "You have no services, deployment configs, or build configs.")
fmt.Fprintln(out, "Run 'oc new-app' to create an application.")
fmt.Fprintf(out, "Run '%[1]s new-app' to create an application.\n", d.CommandBaseName)

default:
fmt.Fprintln(out, "View details with 'oc describe <resource>/<name>' or list everything with 'oc get all'.")
fmt.Fprintf(out, "View details with '%[1]s describe <resource>/<name>' or list everything with '%[1]s get all'.\n", d.CommandBaseName)
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/cli/describe/projectstatus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ func TestProjectStatus(t *testing.T) {
o.Add(obj)
}
oc, kc := testclient.NewFixtureClients(o)
d := ProjectStatusDescriber{C: oc, K: kc, Server: "https://example.com:8443", Suggest: true, LogsCommandName: "oc logs -p", SecurityPolicyCommandFormat: "policycommand %s %s"}
d := ProjectStatusDescriber{C: oc, K: kc, Server: "https://example.com:8443", Suggest: true, CommandBaseName: "oc", LogsCommandName: "oc logs -p", SecurityPolicyCommandFormat: "policycommand %s %s"}
out, err := d.Describe("example", "")
if !test.ErrFn(err) {
t.Errorf("%s: unexpected error: %v", k, err)
Expand Down
2 changes: 2 additions & 0 deletions test/cmd/basicresources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ os::test::junit::declare_suite_end
os::test::junit::declare_suite_start "cmd/basicresources/status"
os::cmd::expect_success_and_text 'openshift cli status -h' 'openshift cli describe buildConfig'
os::cmd::expect_success_and_text 'oc status -h' 'oc describe buildConfig'
os::cmd::expect_success_and_text 'oc status' 'oc new-app'
os::cmd::expect_success_and_text 'openshift cli status' 'openshift cli new-app'
echo "status help output: ok"
os::test::junit::declare_suite_end

Expand Down

0 comments on commit 2dee2ff

Please sign in to comment.