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

Support --sort-by flag for "antctl get networkpolicy" for Agent #2604

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
4 changes: 2 additions & 2 deletions pkg/antctl/antctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ var CommandList = &commandList{
agentEndpoint: &endpoint{
nonResourceEndpoint: &nonResourceEndpoint{
path: "/networkpolicies",
params: []flagInfo{
params: append([]flagInfo{
{
name: "name",
usage: "Get NetworkPolicy by name.",
Expand All @@ -161,7 +161,7 @@ var CommandList = &commandList{
usage: "Get NetworkPolicies with specific type. Type means the type of its source network policy: K8sNP, ACNP, ANP",
shorthand: "T",
},
},
}, getSortByFlag()),
outputType: multiple,
},
addonTransform: networkpolicy.Transform,
Expand Down
16 changes: 10 additions & 6 deletions pkg/antctl/command_definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,20 @@ func (e *resourceEndpoint) flags() []flagInfo {
})
}
if e.groupVersionResource == &v1beta2.NetworkPolicyVersionResource {
flags = append(flags, flagInfo{
name: "sort-by",
defaultValue: "",
supportedValues: []string{sortByEffectivePriority},
usage: "Get NetworkPolicies in specific order. Current supported value is effectivePriority.",
})
flags = append(flags, getSortByFlag())
}
return flags
}

func getSortByFlag() flagInfo {
return flagInfo{
name: "sort-by",
defaultValue: "",
supportedValues: []string{sortByEffectivePriority},
usage: "Get NetworkPolicies in specific order. Current supported value is effectivePriority.",
}
}

type nonResourceEndpoint struct {
path string
params []flagInfo
Expand Down