Skip to content

Commit b1f47bf

Browse files
Merge pull request #20412 from soltysh/issue20097
Restore -v in set deploymenthook and status
2 parents 10b4e5e + b059191 commit b1f47bf

File tree

10 files changed

+67
-54
lines changed

10 files changed

+67
-54
lines changed

pkg/oc/cli/cli.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
"runtime"
99
"strings"
1010

11-
"github.com/openshift/origin/pkg/oc/util/ocscheme"
1211
"github.com/spf13/cobra"
12+
1313
kubecmd "k8s.io/kubernetes/pkg/kubectl/cmd"
1414
ktemplates "k8s.io/kubernetes/pkg/kubectl/cmd/templates"
1515
kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
@@ -68,6 +68,7 @@ import (
6868
"github.com/openshift/origin/pkg/oc/cli/types"
6969
"github.com/openshift/origin/pkg/oc/cli/version"
7070
"github.com/openshift/origin/pkg/oc/cli/whoami"
71+
"github.com/openshift/origin/pkg/oc/util/ocscheme"
7172
)
7273

7374
const productName = `OpenShift`

pkg/oc/cli/set/deploymenthook.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,12 @@ func NewCmdDeploymentHook(fullName string, f kcmdutil.Factory, streams genericcl
122122
cmd.Flags().BoolVar(&o.Mid, "mid", o.Mid, "Set or remove a mid deployment hook")
123123
cmd.Flags().BoolVar(&o.Post, "post", o.Post, "Set or remove a post deployment hook")
124124
cmd.Flags().StringArrayVarP(&o.Environment, "environment", "e", o.Environment, "Environment variable to use in the deployment hook pod")
125-
// FIXME: https://github.com/openshift/origin/issues/20097
126-
// cmd.Flags().StringSliceVarP(&o.Volumes, "volumes", "v", o.Volumes, "Volumes from the pod template to use in the deployment hook pod")
125+
// TODO: remove shorthand 'v' in 3.12
126+
// this is done to trick pflag into allowing the duplicate registration. The local value here wins
127+
cmd.Flags().StringSliceVarP(&o.Volumes, "v", "v", o.Volumes, "Volumes from the pod template to use in the deployment hook pod")
128+
cmd.Flags().MarkDeprecated("v", "Use --volumes instead. Will be dropped in a future release")
129+
cmd.Flags().MarkShorthandDeprecated("v", "Use --volumes instead.")
127130
cmd.Flags().StringSliceVar(&o.Volumes, "volumes", o.Volumes, "Volumes from the pod template to use in the deployment hook pod")
128-
cmd.Flags().MarkShorthandDeprecated("volumes", "Use --volumes instead.")
129131
cmd.Flags().StringVar(&o.FailurePolicyStr, "failure-policy", o.FailurePolicyStr, "The failure policy for the deployment hook. Valid values are: abort,retry,ignore")
130132
cmd.Flags().BoolVar(&o.Local, "local", o.Local, "If true, set deployment hook will NOT contact api-server but run locally.")
131133

pkg/oc/cli/status/status.go

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ var (
4646
%[1]s -o dot | dot -T svg -o project.svg
4747
4848
# See an overview of the current project including details for any identified issues.
49-
%[1]s -v`)
49+
%[1]s --sugest`)
5050
)
5151

5252
// StatusOptions contains all the necessary options for the Openshift cli status command.
@@ -74,31 +74,29 @@ func NewStatusOptions(streams genericclioptions.IOStreams) *StatusOptions {
7474
// NewCmdStatus implements the OpenShift cli status command.
7575
// baseCLIName is the path from root cmd to the parent of this cmd.
7676
func NewCmdStatus(name, baseCLIName, fullName string, f kcmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {
77-
opts := NewStatusOptions(streams)
78-
77+
o := NewStatusOptions(streams)
7978
cmd := &cobra.Command{
80-
Use: fmt.Sprintf("%s [-o dot | -s ]", StatusRecommendedName),
79+
Use: fmt.Sprintf("%s [-o dot | --sugest ]", StatusRecommendedName),
8180
Short: "Show an overview of the current project",
8281
Long: fmt.Sprintf(statusLong, baseCLIName),
8382
Example: fmt.Sprintf(statusExample, fullName),
8483
Run: func(cmd *cobra.Command, args []string) {
85-
err := opts.Complete(f, cmd, baseCLIName, args)
86-
kcmdutil.CheckErr(err)
87-
88-
if err := opts.Validate(); err != nil {
89-
kcmdutil.CheckErr(kcmdutil.UsageErrorf(cmd, err.Error()))
90-
}
91-
92-
err = opts.RunStatus()
93-
kcmdutil.CheckErr(err)
84+
kcmdutil.CheckErr(o.Complete(f, cmd, baseCLIName, args))
85+
kcmdutil.CheckErr(o.Validate())
86+
kcmdutil.CheckErr(o.RunStatus())
9487
},
9588
}
96-
97-
cmd.Flags().StringVarP(&opts.outputFormat, "output", "o", opts.outputFormat, "Output format. One of: dot.")
98-
cmd.Flags().BoolVar(&opts.suggest, "verbose", opts.suggest, "See details for resolving issues.")
89+
cmd.Flags().StringVarP(&o.outputFormat, "output", "o", o.outputFormat, "Output format. One of: dot.")
90+
// TODO: remove verbose in 3.12
91+
// this is done to trick pflag into allowing the duplicate registration. The local value here wins
92+
cmd.Flags().BoolVarP(&o.suggest, "v", "v", o.suggest, "See details for resolving issues.")
93+
cmd.Flags().MarkDeprecated("v", "Use --suggest instead. Will be dropped in a future release")
94+
cmd.Flags().MarkShorthandDeprecated("v", "Use --suggest instead. Will be dropped in a future release")
95+
cmd.Flags().BoolVar(&o.suggest, "verbose", o.suggest, "See details for resolving issues.")
96+
cmd.Flags().MarkDeprecated("verbose", "Use --suggest instead.")
9997
cmd.Flags().MarkHidden("verbose")
100-
cmd.Flags().BoolVar(&opts.suggest, "suggest", opts.suggest, "See details for resolving issues.")
101-
cmd.Flags().BoolVar(&opts.allNamespaces, "all-namespaces", false, "If true, display status for all namespaces (must have cluster admin)")
98+
cmd.Flags().BoolVar(&o.suggest, "suggest", o.suggest, "See details for resolving issues.")
99+
cmd.Flags().BoolVar(&o.allNamespaces, "all-namespaces", o.allNamespaces, "If true, display status for all namespaces (must have cluster admin)")
102100

103101
return cmd
104102
}

pkg/oc/lib/describe/projectstatus.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ func (d *ProjectStatusDescriber) Describe(namespace, name string) (string, error
518518

519519
switch {
520520
case !d.Suggest && ((len(errorMarkers) > 0 && errorSuggestions > 0) || len(warningMarkers) > 0 || len(infoMarkers) > 0):
521-
fmt.Fprintf(out, "%s identified, use '%s status -v' to see details.\n", markerString, d.CommandBaseName)
521+
fmt.Fprintf(out, "%s identified, use '%s status --sugest' to see details.\n", markerString, d.CommandBaseName)
522522

523523
case (len(services) == 0) && (len(standaloneDCs) == 0) && (len(standaloneImages) == 0):
524524
fmt.Fprintln(out, "You have no services, deployment configs, or build configs.")

pkg/router/template/configmanager/haproxy/client_test.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package haproxy
22

33
import (
44
"testing"
5+
6+
haproxytesting "github.com/openshift/origin/pkg/router/template/configmanager/haproxy/testing"
57
)
68

79
type infoEntry struct {
@@ -37,7 +39,7 @@ func TestNewClient(t *testing.T) {
3739

3840
// TestClientRunCommand tests client command execution.
3941
func TestClientRunCommand(t *testing.T) {
40-
server := startFakeServerForTest(t)
42+
server := haproxytesting.StartFakeServerForTest(t)
4143
defer server.Stop()
4244

4345
testCases := []struct {
@@ -121,7 +123,7 @@ func TestClientRunInfoCommandConverter(t *testing.T) {
121123
},
122124
}
123125

124-
server := startFakeServerForTest(t)
126+
server := haproxytesting.StartFakeServerForTest(t)
125127
defer server.Stop()
126128

127129
for _, tc := range testCases {
@@ -157,7 +159,7 @@ func TestClientRunBackendCommandConverter(t *testing.T) {
157159
},
158160
}
159161

160-
server := startFakeServerForTest(t)
162+
server := haproxytesting.StartFakeServerForTest(t)
161163
defer server.Stop()
162164

163165
for _, tc := range testCases {
@@ -200,7 +202,7 @@ func TestClientRunMapCommandConverter(t *testing.T) {
200202
},
201203
}
202204

203-
server := startFakeServerForTest(t)
205+
server := haproxytesting.StartFakeServerForTest(t)
204206
defer server.Stop()
205207

206208
for _, tc := range testCases {
@@ -243,7 +245,7 @@ func TestClientRunServerCommandConverter(t *testing.T) {
243245
},
244246
}
245247

246-
server := startFakeServerForTest(t)
248+
server := haproxytesting.StartFakeServerForTest(t)
247249
defer server.Stop()
248250

249251
for _, tc := range testCases {
@@ -315,7 +317,7 @@ func TestClientExecute(t *testing.T) {
315317
},
316318
}
317319

318-
server := startFakeServerForTest(t)
320+
server := haproxytesting.StartFakeServerForTest(t)
319321
defer server.Stop()
320322

321323
for _, tc := range testCases {
@@ -333,7 +335,7 @@ func TestClientExecute(t *testing.T) {
333335

334336
// TestClientReset tests client state reset.
335337
func TestClientReset(t *testing.T) {
336-
server := startFakeServerForTest(t)
338+
server := haproxytesting.StartFakeServerForTest(t)
337339
defer server.Stop()
338340

339341
client := NewClient(server.SocketFile(), 1)
@@ -375,7 +377,7 @@ func TestClientReset(t *testing.T) {
375377

376378
// TestClientCommit tests client state commit.
377379
func TestClientCommit(t *testing.T) {
378-
server := startFakeServerForTest(t)
380+
server := haproxytesting.StartFakeServerForTest(t)
379381
defer server.Stop()
380382

381383
client := NewClient(server.SocketFile(), 1)
@@ -439,7 +441,7 @@ func TestClientCommit(t *testing.T) {
439441

440442
// TestClientBackends tests client backends.
441443
func TestClientBackends(t *testing.T) {
442-
server := startFakeServerForTest(t)
444+
server := haproxytesting.StartFakeServerForTest(t)
443445
defer server.Stop()
444446

445447
client := NewClient(server.SocketFile(), 1)
@@ -501,7 +503,7 @@ func TestClientFindBackend(t *testing.T) {
501503
},
502504
}
503505

504-
server := startFakeServerForTest(t)
506+
server := haproxytesting.StartFakeServerForTest(t)
505507
defer server.Stop()
506508

507509
for _, tc := range testCases {
@@ -527,7 +529,7 @@ func TestClientFindBackend(t *testing.T) {
527529

528530
// TestClientMaps tests client haproxy maps.
529531
func TestClientMaps(t *testing.T) {
530-
server := startFakeServerForTest(t)
532+
server := haproxytesting.StartFakeServerForTest(t)
531533
defer server.Stop()
532534

533535
client := NewClient(server.SocketFile(), 1)
@@ -584,7 +586,7 @@ func TestClientFindMap(t *testing.T) {
584586
},
585587
}
586588

587-
server := startFakeServerForTest(t)
589+
server := haproxytesting.StartFakeServerForTest(t)
588590
defer server.Stop()
589591

590592
for _, tc := range testCases {

pkg/router/template/configmanager/haproxy/converter_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"bytes"
55
"fmt"
66
"testing"
7+
8+
haproxytesting "github.com/openshift/origin/pkg/router/template/configmanager/haproxy/testing"
79
)
810

911
// TestNewConverter tests a new converter.
@@ -352,35 +354,35 @@ func TestShowServerStateOutputConverter(t *testing.T) {
352354
}{
353355
{
354356
name: "show servers state",
355-
commandOutput: onePodAndOneDynamicServerBackendTemplate,
357+
commandOutput: haproxytesting.OnePodAndOneDynamicServerBackendTemplate,
356358
header: serversStateHeader,
357359
converter: stripVersionNumber,
358360
failureExpected: false,
359361
},
360362
{
361363
name: "show servers state without a converter",
362-
commandOutput: onePodAndOneDynamicServerBackendTemplate,
364+
commandOutput: haproxytesting.OnePodAndOneDynamicServerBackendTemplate,
363365
header: serversStateHeader,
364366
converter: nil,
365367
failureExpected: true,
366368
},
367369
{
368370
name: "show servers state without removing version number",
369-
commandOutput: onePodAndOneDynamicServerBackendTemplate,
371+
commandOutput: haproxytesting.OnePodAndOneDynamicServerBackendTemplate,
370372
header: serversStateHeader,
371373
converter: removeLeadingHashConverter,
372374
failureExpected: true,
373375
},
374376
{
375377
name: "show servers state removing first line with version number",
376-
commandOutput: onePodAndOneDynamicServerBackendTemplate,
378+
commandOutput: haproxytesting.OnePodAndOneDynamicServerBackendTemplate,
377379
header: serversStateHeader,
378380
converter: removeFirstLineConverter,
379381
failureExpected: false,
380382
},
381383
{
382384
name: "show servers state with error converter",
383-
commandOutput: onePodAndOneDynamicServerBackendTemplate,
385+
commandOutput: haproxytesting.OnePodAndOneDynamicServerBackendTemplate,
384386
header: serversStateHeader,
385387
converter: errorConverter,
386388
failureExpected: true,

pkg/router/template/configmanager/haproxy/map_test.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ package haproxy
22

33
import (
44
"testing"
5+
6+
haproxytesting "github.com/openshift/origin/pkg/router/template/configmanager/haproxy/testing"
57
)
68

79
// TestBuildHAProxyMaps tests haproxy maps.
810
func TestBuildHAProxyMaps(t *testing.T) {
9-
server := startFakeServerForTest(t)
11+
server := haproxytesting.StartFakeServerForTest(t)
1012
defer server.Stop()
1113

1214
testCases := []struct {
@@ -56,7 +58,7 @@ func TestBuildHAProxyMaps(t *testing.T) {
5658

5759
// TestNewHAProxyMap tests a new haproxy map.
5860
func TestNewHAProxyMap(t *testing.T) {
59-
server := startFakeServerForTest(t)
61+
server := haproxytesting.StartFakeServerForTest(t)
6062
defer server.Stop()
6163

6264
testCases := []struct {
@@ -91,7 +93,7 @@ func TestNewHAProxyMap(t *testing.T) {
9193

9294
// TestHAProxyMapRefresh tests haproxy map refresh.
9395
func TestHAProxyMapRefresh(t *testing.T) {
94-
server := startFakeServerForTest(t)
96+
server := haproxytesting.StartFakeServerForTest(t)
9597
defer server.Stop()
9698

9799
testCases := []struct {
@@ -167,7 +169,7 @@ func TestHAProxyMapRefresh(t *testing.T) {
167169

168170
// TestHAProxyMapCommit tests haproxy map commit.
169171
func TestHAProxyMapCommit(t *testing.T) {
170-
server := startFakeServerForTest(t)
172+
server := haproxytesting.StartFakeServerForTest(t)
171173
defer server.Stop()
172174

173175
testCases := []struct {
@@ -227,7 +229,7 @@ func TestHAProxyMapCommit(t *testing.T) {
227229

228230
// TestHAProxyMapName tests haproxy map returns its name.
229231
func TestHAProxyMapName(t *testing.T) {
230-
server := startFakeServerForTest(t)
232+
server := haproxytesting.StartFakeServerForTest(t)
231233
defer server.Stop()
232234

233235
testCases := []struct {
@@ -303,7 +305,7 @@ func TestHAProxyMapName(t *testing.T) {
303305

304306
// TestHAProxyMapFind tests finding an entry in a haproxy map.
305307
func TestHAProxyMapFind(t *testing.T) {
306-
server := startFakeServerForTest(t)
308+
server := haproxytesting.StartFakeServerForTest(t)
307309
defer server.Stop()
308310

309311
testCases := []struct {
@@ -441,7 +443,7 @@ func TestHAProxyMapFind(t *testing.T) {
441443

442444
// TestHAProxyMapAdd tests adding an entry in a haproxy map.
443445
func TestHAProxyMapAdd(t *testing.T) {
444-
server := startFakeServerForTest(t)
446+
server := haproxytesting.StartFakeServerForTest(t)
445447
defer server.Stop()
446448

447449
testCases := []struct {
@@ -598,7 +600,7 @@ func TestHAProxyMapAdd(t *testing.T) {
598600

599601
// TestHAProxyMapDelete tests deleting entries in a haproxy map.
600602
func TestHAProxyMapDelete(t *testing.T) {
601-
server := startFakeServerForTest(t)
603+
server := haproxytesting.StartFakeServerForTest(t)
602604
defer server.Stop()
603605

604606
testCases := []struct {
@@ -720,7 +722,7 @@ func TestHAProxyMapDelete(t *testing.T) {
720722

721723
// TestHAProxyMapDeleteEntry tests deleting an entry in a haproxy map.
722724
func TestHAProxyMapDeleteEntry(t *testing.T) {
723-
server := startFakeServerForTest(t)
725+
server := haproxytesting.StartFakeServerForTest(t)
724726
defer server.Stop()
725727

726728
testCases := []struct {

pkg/router/template/configmanager/haproxy/fake_haproxy.go renamed to pkg/router/template/configmanager/haproxy/testing/haproxy.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package haproxy
1+
package testing
22

33
import (
44
"bytes"
@@ -18,7 +18,7 @@ const (
1818

1919
serverName = "_dynamic-pod-1"
2020

21-
onePodAndOneDynamicServerBackendTemplate = `1
21+
OnePodAndOneDynamicServerBackendTemplate = `1
2222
# be_id be_name srv_id srv_name srv_addr srv_op_state srv_admin_state srv_uweight srv_iweight srv_time_since_last_change srv_check_status srv_check_result srv_check_health srv_check_state srv_agent_state bk_f_forced_id srv_f_forced_id srv_fqdn srv_port
2323
9 %s 1 pod:test-1-l8x8w:test-service:172.17.0.3:1234 172.17.0.3 2 4 256 1 8117 6 3 4 6 0 0 0 - 1234
2424
9 %s 2 _dynamic-pod-1 172.4.0.4 2 4 256 1 8117 6 3 4 6 0 0 0 - 1234
@@ -50,7 +50,7 @@ func startFakeHAProxyServer(prefix string) (*fakeHAProxy, error) {
5050
return server, nil
5151
}
5252

53-
func startFakeServerForTest(t *testing.T) *fakeHAProxy {
53+
func StartFakeServerForTest(t *testing.T) *fakeHAProxy {
5454
name := fmt.Sprintf("fake-haproxy-%s", t.Name())
5555
server, err := startFakeHAProxyServer(name)
5656
if err != nil {
@@ -356,7 +356,7 @@ func (p *fakeHAProxy) showServers(name string) string {
356356

357357
if name != p.backendName {
358358
if _, ok := onePodAndOneDynamicServerBackends[name]; ok {
359-
return fmt.Sprintf(onePodAndOneDynamicServerBackendTemplate, name, name)
359+
return fmt.Sprintf(OnePodAndOneDynamicServerBackendTemplate, name, name)
360360
}
361361
if len(name) > 0 {
362362
return fmt.Sprintf("Can't find backend.\n")

0 commit comments

Comments
 (0)