Skip to content

Commit

Permalink
Change endpoint name and verbose flag
Browse files Browse the repository at this point in the history
Signed-off-by: Weiqiang TANG <[email protected]>
  • Loading branch information
weiqiangt committed Dec 18, 2019
1 parent b510c32 commit 93bc175
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 26 deletions.
8 changes: 4 additions & 4 deletions build/yamls/antrea.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ rules:
verbs:
- create
- nonResourceURLs:
- /apis/antctl.antrea.tanzu.vmware.com/v1
- /apis/antctl.antrea.tanzu.vmware.com/v1/*
- /apis/clusterinfo.antrea.tanzu.vmware.com/v1
- /apis/clusterinfo.antrea.tanzu.vmware.com/v1/*
verbs:
- get
---
Expand Down Expand Up @@ -334,9 +334,9 @@ kind: APIService
metadata:
labels:
app: antrea
name: v1.antctl.antrea.tanzu.vmware.com
name: v1.clusterinfo.antrea.tanzu.vmware.com
spec:
group: antctl.antrea.tanzu.vmware.com
group: clusterinfo.antrea.tanzu.vmware.com
groupPriorityMinimum: 1000
insecureSkipTLSVerify: true
service:
Expand Down
4 changes: 2 additions & 2 deletions build/yamls/base/antctl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ metadata:
name: antctl
rules:
- nonResourceURLs:
- /apis/antctl.antrea.tanzu.vmware.com/v1
- /apis/antctl.antrea.tanzu.vmware.com/v1/*
- /apis/clusterinfo.antrea.tanzu.vmware.com/v1
- /apis/clusterinfo.antrea.tanzu.vmware.com/v1/*
verbs:
- get
---
Expand Down
4 changes: 2 additions & 2 deletions build/yamls/base/controller-rbac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ rules:
verbs:
- create
- nonResourceURLs:
- /apis/antctl.antrea.tanzu.vmware.com/v1
- /apis/antctl.antrea.tanzu.vmware.com/v1/*
- /apis/clusterinfo.antrea.tanzu.vmware.com/v1
- /apis/clusterinfo.antrea.tanzu.vmware.com/v1/*
verbs:
- get
---
Expand Down
4 changes: 2 additions & 2 deletions build/yamls/base/controller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ spec:
apiVersion: apiregistration.k8s.io/v1
kind: APIService
metadata:
name: v1.antctl.antrea.tanzu.vmware.com
name: v1.clusterinfo.antrea.tanzu.vmware.com
spec:
insecureSkipTLSVerify: true
group: antctl.antrea.tanzu.vmware.com
group: clusterinfo.antrea.tanzu.vmware.com
groupPriorityMinimum: 1000
versionPriority: 15
service:
Expand Down
10 changes: 5 additions & 5 deletions pkg/antctl/commandbundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ func (b *CommandBundle) ApplyToRootCommand(root *cobra.Command, client *Client,

func (b *CommandBundle) applyToRootCommand(root *cobra.Command, isAgent bool) {
defaultPath := filepath.Join(homedir.HomeDir(), ".kube", "config")
root.PersistentFlags().BoolP("debug", "d", false, "enable debug mode")
root.PersistentFlags().BoolP("verbose", "v", false, "enable verbose output")
root.PersistentFlags().StringP("kubeconfig", "k", defaultPath, "absolute path to the kubeconfig file")
root.PersistentPreRun = func(cmd *cobra.Command, args []string) {
enableDebug, _ := root.PersistentFlags().GetBool("debug")
flag.Set("logtostderr", fmt.Sprint(enableDebug))
flag.Set("alsologtostderr", fmt.Sprint(enableDebug))
if enableDebug {
enableVerbose, _ := root.PersistentFlags().GetBool("verbose")
flag.Set("logtostderr", fmt.Sprint(enableVerbose))
flag.Set("alsologtostderr", fmt.Sprint(enableVerbose))
if enableVerbose {
flag.Set("v", "0")
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/antctl/commandbundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ var TestBundle = &CommandBundle{
},
},
GroupVersion: &schema.GroupVersion{
Group: "test-antctl.antrea.tanzu.vmware.com",
Group: "test-clusterinfo.antrea.tanzu.vmware.com",
Version: "v1",
},
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/antctl/definitions.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import (
)

type VersionResponse struct {
handlers.ComponentVersionResponse
AntctlVersion string `json:"antctlVersion,omitempty" yaml:"antctlVersion,omitempty"`
handlers.ComponentVersionResponse `json:",inline" yaml:",inline"`
AntctlVersion string `json:"antctlVersion,omitempty" yaml:"antctlVersion,omitempty"`
}

func versionTransform(reader io.Reader, single bool) (interface{}, error) {
Expand Down Expand Up @@ -65,6 +65,6 @@ var Definition = &CommandBundle{
AddonTransform: versionTransform,
},
},
GroupVersion: &schema.GroupVersion{Group: "antctl.antrea.tanzu.vmware.com", Version: "v1"},
GroupVersion: &schema.GroupVersion{Group: "clusterinfo.antrea.tanzu.vmware.com", Version: "v1"},
Codec: scheme.Codecs,
}
14 changes: 7 additions & 7 deletions test/e2e/antctl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
)

func antctlOutput(stdout, stderr string, tb testing.TB) {
tb.Logf("`antctl version` stdout:\n%s", stdout)
tb.Logf("`antctl version` stderr:\n%s", stderr)
tb.Logf("antctl stdout:\n%s", stdout)
tb.Logf("antctl stderr:\n%s", stderr)
}

func runAntctl(podName string, subCmds []string, data *TestData, tb testing.TB) (string, string, error) {
Expand All @@ -21,7 +21,7 @@ func runAntctl(podName string, subCmds []string, data *TestData, tb testing.TB)
containerName = "antrea-controller"
}

cmds := []string{"antctl", "-d"}
cmds := []string{"antctl", "-v"}
stdout, stderr, err := data.runCommandFromPod(AntreaNamespace, podName, containerName, append(cmds, subCmds...))
antctlOutput(stdout, stderr, tb)

Expand Down Expand Up @@ -72,7 +72,7 @@ func TestAntctlControllerRemoteAccess(t *testing.T) {
_, _, _, err = RunCommandOnNode(masterNodeName(), cmd)
assert.Nil(t, err, "Error when copying antctl from %s", podName)

_, stdout, stderr, err := RunCommandOnNode(masterNodeName(), "~/antctl -d version")
_, stdout, stderr, err := RunCommandOnNode(masterNodeName(), "~/antctl -v version")
antctlOutput(stdout, stderr, t)
if err != nil {
t.Fatalf("Error when running `antctl version` from %s: %v", masterNodeName(), err)
Expand All @@ -92,10 +92,10 @@ func TestAntctlDebugMode(t *testing.T) {
commands []string
}{
{name: "RootNonDebug", hasStderr: false, commands: []string{"antctl"}},
{name: "RootDebug", hasStderr: false, commands: []string{"antctl", "-d"}},
{name: "RootDebug", hasStderr: false, commands: []string{"antctl", "-v"}},
{name: "CommandNonDebug", hasStderr: false, commands: []string{"antctl", "version"}},
{name: "CommandDebug", hasStderr: true, commands: []string{"antctl", "-d", "version"}},
{name: "CommandDebug", hasStderr: true, commands: []string{"antctl", "version", "-d"}},
{name: "CommandDebug", hasStderr: true, commands: []string{"antctl", "-v", "version"}},
{name: "CommandDebug", hasStderr: true, commands: []string{"antctl", "version", "-v"}},
} {
t.Run(tc.name, func(t *testing.T) {
podName, err := data.getAntreaController()
Expand Down

0 comments on commit 93bc175

Please sign in to comment.