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

add create subcommand for priorityclass #54858

Merged
merged 1 commit into from
Nov 11, 2017

Conversation

wackxu
Copy link
Contributor

@wackxu wackxu commented Oct 31, 2017

What this PR does / why we need it:

add create priorityclass sub command

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):Fixes #54857

Special notes for your reviewer:

Release note:

add create priorityclass sub command

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 31, 2017
@k8s-ci-robot
Copy link
Contributor

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

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.

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 31, 2017
@wackxu
Copy link
Contributor Author

wackxu commented Oct 31, 2017

/assign @brendandburns

@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 31, 2017
@zjj2wry
Copy link
Contributor

zjj2wry commented Oct 31, 2017

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Oct 31, 2017
@wackxu
Copy link
Contributor Author

wackxu commented Nov 1, 2017

/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"
Copy link
Contributor

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"`))
Copy link
Contributor

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"
Copy link
Contributor

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


// StructuredGenerate outputs a priorityClass object using the configured fields.
func (s *PriorityClassV1Generator) StructuredGenerate() (runtime.Object, error) {

Copy link
Contributor

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"
Copy link
Contributor

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,
Copy link
Contributor

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

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 1, 2017
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 1, 2017
@wackxu
Copy link
Contributor Author

wackxu commented Nov 1, 2017

@zjj2wry Thanks for your review, I have addressed all comments, PTAL

@@ -0,0 +1,90 @@
/*
Copyright 2016 The Kubernetes Authors.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it's 2017


func (s PriorityClassV1Generator) Generate(params map[string]interface{}) (runtime.Object, error) {
err := ValidateParams(s.ParamNames(), params)
if err != nil {
Copy link
Contributor

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."))
Copy link
Contributor

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", ...)

@wackxu wackxu force-pushed the createpri branch 2 times, most recently from b3ab4fa to 0ee4803 Compare November 1, 2017 05:56
@wackxu
Copy link
Contributor Author

wackxu commented Nov 1, 2017

@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)
Copy link
Contributor

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

@wackxu
Copy link
Contributor Author

wackxu commented Nov 1, 2017

@zjj2wry addressed, PTAL

@wackxu
Copy link
Contributor Author

wackxu commented Nov 1, 2017

/test pull-kubernetes-verify

1 similar comment
@wackxu
Copy link
Contributor Author

wackxu commented Nov 1, 2017

/test pull-kubernetes-verify

@zjj2wry
Copy link
Contributor

zjj2wry commented Nov 1, 2017

@wackxu hack/make-rules/../../hack/verify-generated-docs.sh

@wackxu
Copy link
Contributor Author

wackxu commented Nov 1, 2017

/test pull-kubernetes-unit

1 similar comment
@wackxu
Copy link
Contributor Author

wackxu commented Nov 1, 2017

/test pull-kubernetes-unit

@wackxu
Copy link
Contributor Author

wackxu commented Nov 2, 2017

@zjj2wry Thanks for you tips and all test has passed, PATL

@wackxu
Copy link
Contributor Author

wackxu commented Nov 6, 2017

Kindly ping @zjj2wry @brendandburns @dshulyak for approval

return nil, err
}

name, ok := params["name"].(string)
Copy link
Contributor

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


// StructuredGenerate outputs a priorityClass object using the configured fields.
func (s *PriorityClassV1Generator) StructuredGenerate() (runtime.Object, error) {
if s.Value <= 0 {
Copy link
Contributor

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?

Copy link
Contributor Author

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

@brendandburns
Copy link
Contributor

Small comments, basically LGTM.

@brendandburns
Copy link
Contributor

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 10, 2017
@k8s-github-robot
Copy link

[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 /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 10, 2017
@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to @fejta).

Review the full test history for this PR.

@k8s-github-robot
Copy link

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.

@k8s-github-robot k8s-github-robot merged commit 0ca74ef into kubernetes:master Nov 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add create priorityclass sub command
8 participants