-
Notifications
You must be signed in to change notification settings - Fork 39.8k
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
add create subcommand for priorityclass #54858
Conversation
Hi @wackxu. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
/assign @brendandburns |
/ok-to-test |
/test pull-kubernetes-verify |
|
||
pcExample = templates.Examples(i18n.T(` | ||
# Create a priorityclass named high-priority | ||
kubectl create priorityclass default-priority --value=1000 --descroption="high priority" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
kubectl create priorityclass default-priority --value=1000 --descroption="high priority" | ||
|
||
# Create a priorityclass named default-priority that considered as the global default priority | ||
kubectl create priorityclass default-priority --value=1000 --globalDefault=true --descroption="default priority"`)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
@@ -498,6 +498,7 @@ const ( | |||
ClusterV1Beta1GeneratorName = "cluster/v1beta1" | |||
PodDisruptionBudgetV1GeneratorName = "poddisruptionbudget/v1beta1" | |||
PodDisruptionBudgetV2GeneratorName = "poddisruptionbudget/v1beta1/v2" | |||
PriorityClassV1GeneratorName = "priorityclass/v1alpha1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this generator name should be PriorityClassV1Alpha1GeneratorName
pkg/kubectl/priorityclass.go
Outdated
|
||
// StructuredGenerate outputs a priorityClass object using the configured fields. | ||
func (s *PriorityClassV1Generator) StructuredGenerate() (runtime.Object, error) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be get remove
restclient "k8s.io/client-go/rest" | ||
"k8s.io/client-go/rest/fake" | ||
"k8s.io/kubernetes/pkg/api/legacyscheme" | ||
"k8s.io/kubernetes/pkg/apis/scheduling" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use "k8s.io/api/scheduling/......"
pcName := "my-pc" | ||
f, tf, _, ns := cmdtesting.NewAPIFactory() | ||
tf.Client = &fake.RESTClient{ | ||
GroupVersion: legacyscheme.Registry.GroupOrDie(scheduling.GroupName).GroupVersion, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
legacyscheme
have removed from create command
@zjj2wry Thanks for your review, I have addressed all comments, PTAL |
pkg/kubectl/priorityclass.go
Outdated
@@ -0,0 +1,90 @@ | |||
/* | |||
Copyright 2016 The Kubernetes Authors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: it's 2017
pkg/kubectl/priorityclass.go
Outdated
|
||
func (s PriorityClassV1Generator) Generate(params map[string]interface{}) (runtime.Object, error) { | ||
err := ValidateParams(s.ParamNames(), params) | ||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: inline if check:
if err := ... ; err != nil {
...
}
cmdutil.AddGeneratorFlags(cmd, cmdutil.PriorityClassV1Alpha1GeneratorName) | ||
|
||
cmd.Flags().Int32("value", 0, i18n.T("the value of this priority class.")) | ||
cmd.Flags().Bool("globalDefault", false, i18n.T("globalDefault specifies whether this PriorityClass should be considered as the default priority.")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
conventions are that flags are dashed not camel case, so this should be
`cmd.Flags().Bool("global-default", ...)
b3ab4fa
to
0ee4803
Compare
@brendandburns Thanks for your review, I have addressed all comments, PTAL |
Example: pcExample, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
err := CreatePriorityClass(f, cmdOut, cmd, args) | ||
cmdutil.CheckErr(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cmdutil.CheckErr(CreatePriorityClass(f, cmdOut, cmd, args)) will better
@zjj2wry addressed, PTAL |
/test pull-kubernetes-verify |
1 similar comment
/test pull-kubernetes-verify |
@wackxu hack/make-rules/../../hack/verify-generated-docs.sh |
/test pull-kubernetes-unit |
1 similar comment
/test pull-kubernetes-unit |
@zjj2wry Thanks for you tips and all test has passed, PATL |
Kindly ping @zjj2wry @brendandburns @dshulyak for approval |
pkg/kubectl/priorityclass.go
Outdated
return nil, err | ||
} | ||
|
||
name, ok := params["name"].(string) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: preference for found
rather than ok
pkg/kubectl/priorityclass.go
Outdated
|
||
// StructuredGenerate outputs a priorityClass object using the configured fields. | ||
func (s *PriorityClassV1Generator) StructuredGenerate() (runtime.Object, error) { | ||
if s.Value <= 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not move this validation up to the 'Generate' call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brendandburns StructuredGenerate
and Generate
is two different function that can be used to generate object, StructuredGenerate
is using pre-configured parameters and Generate
is using input parameters. we check if exist in Generate
and check if reasonable in StructuredGenerate
so that we can reuse the code. I have delete the check because I find that it can be small than zero from the api validation
Small comments, basically LGTM. |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: brendandburns, wackxu Associated issue: 54857 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
/retest Review the full test history for this PR. |
Automatic merge from submit-queue (batch tested with PRs 54460, 55258, 54858, 55506, 55510). If you want to cherry-pick this change to another branch, please follow the instructions here. |
What this PR does / why we need it:
add
create priorityclass
sub commandWhich issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #54857Special notes for your reviewer:
Release note: