← Back to Pull requests

Add a kubectl command to set the HNC configuration of a specific type #595

Merged
sophieliu15 merged 3 files (91 lines) on Apr 08, 2020 15:37 UTC
View on GitHub
sophieliu15 sophieliu15 commented on Apr 02, 2020 18:06 UTC
Author

This PR adds a kubectl command to set the HNC configuration of a specific type. Specifically it implements the following features:

  • If the type exists in the spec, it will update the configuration of the type.

  • If the type does not exist in the spec, it will add the configuration in the spec.
  • Example usage: kubectl hns config --apiVersion v1 --kind Secret ignore

    Issue: #454

    Diff: 91 lines (+87 / -4) across 3 files Reviewer: adrianludwin Review duration: 8491m
    All Vouch review confidence checks passed
    Residual risk 0.05 = Change Risk (0.56) × (1 − Review Confidence (0.91)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.56 · 91 lines diff across 3 files
    0.56
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.89 · 5 substantive comment(s)
    0.89
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    90%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.271
    Sensitive Paths sensitive_paths
    0.056
    Real PR Conversation Timeline
    31 items
    sophieliu15 sophieliu15 commented on Apr 02, 2020 18:07 UTC
    Author

    /hold

    Will make this PR on hold till #592 is merged.

    sophieliu15 sophieliu15 commented on Apr 02, 2020 18:09 UTC
    Author

    /assign @adrianludwin
    /assign @yiqigao217
    @adrianchung

    Thanks for reviewing my previous PR. I will resolve comments in that PR first and ping you again once that one is merged.

    k8s-ci-robot k8s-ci-robot commented on Apr 02, 2020 18:09 UTC
    Contributor

    @sophieliu15: GitHub didn't allow me to request PR reviews from the following users: adrianchung.

    Note that only kubernetes-sigs members and repo collaborators can review this PR, and authors cannot review their own PRs.

    <details>

    In response to this:

    >/assign @adrianludwin
    >/assign @yiqigao217
    >/cc @adrianchung

    >Thanks for reviewing my previous PR. I will resolve comments in that PR first and ping you again once that one is merged.

    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.
    </details>

    adrianludwin adrianludwin commented on code on Apr 02, 2020 20:08 UTC
    Code Review
    incubator/hnc/pkg/kubectl/configset.go:1
    @@ -0,0 +1,65 @@
    +/*
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package kubectl
    +
    +import (
    +	"fmt"
    +
    +	"github.com/spf13/cobra"
    +
    +	api "github.com/kubernetes-sigs/multi-tenancy/incubator/hnc/api/v1alpha1"
    +)
    +
    +var setTypeCmd = &cobra.Command{
    +	Use: fmt.Sprintf("set-type <%s|%s|%s>", string(api.Propagate), string(api.Remove),

    Is the string(x) cast really needed?

    Also, the usage should be something more like set-type --kind X --apiVersion Y <propagate|remove|ignore>, right?

    adrianludwin adrianludwin commented on code on Apr 02, 2020 20:11 UTC
    Code Review
    incubator/hnc/pkg/kubectl/configset.go:1
    @@ -0,0 +1,65 @@
    +/*
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package kubectl
    +
    +import (
    +	"fmt"
    +
    +	"github.com/spf13/cobra"
    +
    +	api "github.com/kubernetes-sigs/multi-tenancy/incubator/hnc/api/v1alpha1"
    +)
    +
    +var setTypeCmd = &cobra.Command{
    +	Use: fmt.Sprintf("set-type <%s|%s|%s>", string(api.Propagate), string(api.Remove),
    +		string(api.Ignore)),
    +	Short: "Sets the HNC configuration of a specific type",
    +	Args:  cobra.ExactArgs(1),
    +	Run: func(cmd *cobra.Command, args []string) {
    +		mode := api.SynchronizationMode(args[0])
    +		flags := cmd.Flags()
    +		apiVersion, _ := flags.GetString("apiVersion")
    +		kind, _ := flags.GetString("kind")
    +		config := client.getHNCConfig()
    +
    +		exist := false
    +		for i := 0; i < len(config.Spec.Types); i++ {
    +			t := &config.Spec.Types[i]
    +			if t.APIVersion == apiVersion && t.Kind == kind {
    +				t.Mode = mode
    +				exist = true
    +				break
    +			}
    +		}
    +
    +		if !exist {
    +			config.Spec.Types = append(config.Spec.Types,
    +				api.TypeSynchronizationSpec{
    +					APIVersion: apiVersion,
    +					Kind:       kind,
    +					Mode:       mode,
    +				})
    +		}
    +
    +		client.updateHNCConfig(config)
    +	},
    +}
    +
    +func newSetTypeCmd() *cobra.Command {
    +	setTypeCmd.Flags().String("apiVersion", "", "API version of the kind")

    Some examples here might be nice, e.g. "v1" for core objects or "example.com/v1beta1" for a contributed type.

    sophieliu15 sophieliu15 commented on code on Apr 03, 2020 14:41 UTC
    Code Review
    incubator/hnc/pkg/kubectl/configset.go:1
    @@ -0,0 +1,65 @@
    +/*
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package kubectl
    +
    +import (
    +	"fmt"
    +
    +	"github.com/spf13/cobra"
    +
    +	api "github.com/kubernetes-sigs/multi-tenancy/incubator/hnc/api/v1alpha1"
    +)
    +
    +var setTypeCmd = &cobra.Command{
    +	Use: fmt.Sprintf("set-type <%s|%s|%s>", string(api.Propagate), string(api.Remove),

    It doesn't look like we need the string(x) cast. Removed them. Changed to the usage to contain the flags.

    sophieliu15 sophieliu15 commented on code on Apr 03, 2020 14:41 UTC
    Code Review
    incubator/hnc/pkg/kubectl/configset.go:1
    @@ -0,0 +1,65 @@
    +/*
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package kubectl
    +
    +import (
    +	"fmt"
    +
    +	"github.com/spf13/cobra"
    +
    +	api "github.com/kubernetes-sigs/multi-tenancy/incubator/hnc/api/v1alpha1"
    +)
    +
    +var setTypeCmd = &cobra.Command{
    +	Use: fmt.Sprintf("set-type <%s|%s|%s>", string(api.Propagate), string(api.Remove),
    +		string(api.Ignore)),
    +	Short: "Sets the HNC configuration of a specific type",
    +	Args:  cobra.ExactArgs(1),
    +	Run: func(cmd *cobra.Command, args []string) {
    +		mode := api.SynchronizationMode(args[0])
    +		flags := cmd.Flags()
    +		apiVersion, _ := flags.GetString("apiVersion")
    +		kind, _ := flags.GetString("kind")
    +		config := client.getHNCConfig()
    +
    +		exist := false
    +		for i := 0; i < len(config.Spec.Types); i++ {
    +			t := &config.Spec.Types[i]
    +			if t.APIVersion == apiVersion && t.Kind == kind {
    +				t.Mode = mode
    +				exist = true
    +				break
    +			}
    +		}
    +
    +		if !exist {
    +			config.Spec.Types = append(config.Spec.Types,
    +				api.TypeSynchronizationSpec{
    +					APIVersion: apiVersion,
    +					Kind:       kind,
    +					Mode:       mode,
    +				})
    +		}
    +
    +		client.updateHNCConfig(config)
    +	},
    +}
    +
    +func newSetTypeCmd() *cobra.Command {
    +	setTypeCmd.Flags().String("apiVersion", "", "API version of the kind")

    Thanks for the suggestion! Done. PTAL.

    adrianludwin adrianludwin commented on code on Apr 03, 2020 14:47 UTC
    Code Review
    incubator/hnc/pkg/validators/hierarchy.go:1
    @@ -382,13 +382,16 @@ func deny(reason metav1.StatusReason, msg string) admission.Response {
     			},
     		}}
     	} else {
    -		// metav1.StatusReasonInvalid shows the custom message in the Details field instead of
    -		// Message field of metav1.Status.
    +		// We need to set the custom message in both Message and Details fields.
    +		// When interacting via the kutectl plugin, the custom message
    +		// in the Message field will be shown when an error occurs. When interacting
    +		// without the kubectl plugin, the custom message in the Details field will be shown.

    Eh? That's odd. Is this behaviour documented anywhere? Or is our plugin not treating the Details field properly?

    adrianludwin adrianludwin commented on code on Apr 03, 2020 14:48 UTC
    Code Review
    incubator/hnc/pkg/kubectl/configset.go:1
    @@ -0,0 +1,67 @@
    +/*
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package kubectl
    +
    +import (
    +	"fmt"
    +
    +	"github.com/spf13/cobra"
    +
    +	api "github.com/kubernetes-sigs/multi-tenancy/incubator/hnc/api/v1alpha1"
    +)
    +
    +var setTypeCmd = &cobra.Command{
    +	Use: fmt.Sprintf("set-type --apiVersion X --kind Y <%s|%s|%s>",
    +		api.Propagate, api.Remove, api.Ignore),
    +	Short: "Sets the HNC configuration of a specific type",
    +	Args:  cobra.ExactArgs(1),
    +	Run: func(cmd *cobra.Command, args []string) {

    If you type in kubectl help create role, you get a lot of examples. Can we add some examples here as well? I don't know if they belong in the "Use" field or somewhere else (e.g., is ther a "Long" help field?).

    sophieliu15 sophieliu15 commented on code on Apr 03, 2020 17:48 UTC
    Code Review
    incubator/hnc/pkg/validators/hierarchy.go:1
    @@ -382,13 +382,16 @@ func deny(reason metav1.StatusReason, msg string) admission.Response {
     			},
     		}}
     	} else {
    -		// metav1.StatusReasonInvalid shows the custom message in the Details field instead of
    -		// Message field of metav1.Status.
    +		// We need to set the custom message in both Message and Details fields.
    +		// When interacting via the kutectl plugin, the custom message
    +		// in the Message field will be shown when an error occurs. When interacting
    +		// without the kubectl plugin, the custom message in the Details field will be shown.

    I don't think it is related to our plugin. When tracing back the call tree of Error(), it calls FromObject, which generates a StatusError from metav1.Status (this is the type of AdmissionResponse.Result). The StatusError implements the Error interface using Message field from the status. IIUC, that's why when we print Error() it only prints the Message field.

    sophieliu15 sophieliu15 commented on code on Apr 03, 2020 17:48 UTC
    Code Review
    incubator/hnc/pkg/kubectl/configset.go:1
    @@ -0,0 +1,67 @@
    +/*
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package kubectl
    +
    +import (
    +	"fmt"
    +
    +	"github.com/spf13/cobra"
    +
    +	api "github.com/kubernetes-sigs/multi-tenancy/incubator/hnc/api/v1alpha1"
    +)
    +
    +var setTypeCmd = &cobra.Command{
    +	Use: fmt.Sprintf("set-type --apiVersion X --kind Y <%s|%s|%s>",
    +		api.Propagate, api.Remove, api.Ignore),
    +	Short: "Sets the HNC configuration of a specific type",
    +	Args:  cobra.ExactArgs(1),
    +	Run: func(cmd *cobra.Command, args []string) {

    Sure! I added two examples in the Example field and removed the examples in the flag definitions. Feel free to take a look.

    sophieliu15 sophieliu15 commented on Apr 03, 2020 18:30 UTC
    Author

    /hold cancel

    #592 was merged and this PR was rebased.

    adrianludwin adrianludwin commented on code on Apr 03, 2020 18:45 UTC
    Code Review
    incubator/hnc/pkg/kubectl/configset.go:1
    @@ -0,0 +1,69 @@
    +/*
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package kubectl
    +
    +import (
    +	"fmt"
    +
    +	"github.com/spf13/cobra"
    +
    +	api "github.com/kubernetes-sigs/multi-tenancy/incubator/hnc/api/v1alpha1"
    +)
    +
    +var setTypeCmd = &cobra.Command{
    +	Use: fmt.Sprintf("set-type --apiVersion X --kind Y <%s|%s|%s>",
    +		api.Propagate, api.Remove, api.Ignore),
    +	Short: "Sets the HNC configuration of a specific type",
    +	Example: fmt.Sprintf("  # Set configuration of a core type\n" +

    You need to manually indent like this? That's annoying :P

    adrianludwin adrianludwin commented on code on Apr 03, 2020 18:51 UTC
    Code Review
    incubator/hnc/pkg/validators/hierarchy.go:1
    @@ -382,13 +382,16 @@ func deny(reason metav1.StatusReason, msg string) admission.Response {
     			},
     		}}
     	} else {
    -		// metav1.StatusReasonInvalid shows the custom message in the Details field instead of
    -		// Message field of metav1.Status.
    +		// We need to set the custom message in both Message and Details fields.
    +		// When interacting via the kutectl plugin, the custom message
    +		// in the Message field will be shown when an error occurs. When interacting
    +		// without the kubectl plugin, the custom message in the Details field will be shown.

    Ah, but that _is_ our plugin then. We're the ones calling Error(), which is only based on the Message field below.

    By contrast, it sounds like kubectl ignores Message and only displays Details instead?

    sophieliu15 sophieliu15 commented on code on Apr 03, 2020 19:19 UTC
    Code Review
    incubator/hnc/pkg/validators/hierarchy.go:1
    @@ -382,13 +382,16 @@ func deny(reason metav1.StatusReason, msg string) admission.Response {
     			},
     		}}
     	} else {
    -		// metav1.StatusReasonInvalid shows the custom message in the Details field instead of
    -		// Message field of metav1.Status.
    +		// We need to set the custom message in both Message and Details fields.
    +		// When interacting via the kutectl plugin, the custom message
    +		// in the Message field will be shown when an error occurs. When interacting
    +		// without the kubectl plugin, the custom message in the Details field will be shown.

    Looks like kubectl ignores Message and prints out Details if the error is Invalid (see implementation here). Do you think we should do something similar in our plugin?

    sophieliu15 sophieliu15 commented on code on Apr 03, 2020 19:23 UTC
    Code Review
    incubator/hnc/pkg/kubectl/configset.go:1
    @@ -0,0 +1,69 @@
    +/*
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package kubectl
    +
    +import (
    +	"fmt"
    +
    +	"github.com/spf13/cobra"
    +
    +	api "github.com/kubernetes-sigs/multi-tenancy/incubator/hnc/api/v1alpha1"
    +)
    +
    +var setTypeCmd = &cobra.Command{
    +	Use: fmt.Sprintf("set-type --apiVersion X --kind Y <%s|%s|%s>",
    +		api.Propagate, api.Remove, api.Ignore),
    +	Short: "Sets the HNC configuration of a specific type",
    +	Example: fmt.Sprintf("  # Set configuration of a core type\n" +

    I haven't found a good way to format space. :( Looks like rest of the code in the directory is doing something similar (eg1, eg2). Feel free to let me know if there are any better ways to format indent!

    adrianludwin adrianludwin commented on code on Apr 03, 2020 20:31 UTC
    Code Review
    incubator/hnc/pkg/kubectl/configset.go:1
    @@ -0,0 +1,69 @@
    +/*
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package kubectl
    +
    +import (
    +	"fmt"
    +
    +	"github.com/spf13/cobra"
    +
    +	api "github.com/kubernetes-sigs/multi-tenancy/incubator/hnc/api/v1alpha1"
    +)
    +
    +var setTypeCmd = &cobra.Command{
    +	Use: fmt.Sprintf("set-type --apiVersion X --kind Y <%s|%s|%s>",
    +		api.Propagate, api.Remove, api.Ignore),
    +	Short: "Sets the HNC configuration of a specific type",
    +	Example: fmt.Sprintf("  # Set configuration of a core type\n" +

    Oh, I just thought there might be something special for Example because it's a builtin feature of Cobra. But that's fine, thanks!

    adrianludwin adrianludwin commented on code on Apr 03, 2020 20:35 UTC
    Code Review
    incubator/hnc/pkg/validators/hierarchy.go:1
    @@ -382,13 +382,16 @@ func deny(reason metav1.StatusReason, msg string) admission.Response {
     			},
     		}}
     	} else {
    -		// metav1.StatusReasonInvalid shows the custom message in the Details field instead of
    -		// Message field of metav1.Status.
    +		// We need to set the custom message in both Message and Details fields.
    +		// When interacting via the kutectl plugin, the custom message
    +		// in the Message field will be shown when an error occurs. When interacting
    +		// without the kubectl plugin, the custom message in the Details field will be shown.

    No, I don't think that's needed, but can you please update this comment to include everything we've discussed? Because it is super-confusing. And don't try to write a short comment, make it as long and rambling as you like (e.g. https://github.com/kubernetes-sigs/multi-tenancy/blob/master/incubator/hnc/pkg/reconcilers/hierarchy_config.go#L306) - give any future reader as much of a chance as you can that they'll be able to figure out why we did this.

    sophieliu15 sophieliu15 commented on code on Apr 06, 2020 14:36 UTC
    Code Review
    incubator/hnc/pkg/validators/hierarchy.go:1
    @@ -382,13 +382,16 @@ func deny(reason metav1.StatusReason, msg string) admission.Response {
     			},
     		}}
     	} else {
    -		// metav1.StatusReasonInvalid shows the custom message in the Details field instead of
    -		// Message field of metav1.Status.
    +		// We need to set the custom message in both Message and Details fields.
    +		// When interacting via the kutectl plugin, the custom message
    +		// in the Message field will be shown when an error occurs. When interacting
    +		// without the kubectl plugin, the custom message in the Details field will be shown.

    Thanks for the suggestion! I added a detailed the comment here. PTAL. I also added code links in the comment, feel free to let me know if it makes the comment less readable or any suggestions to improve the readability. Thank you!

    adrianludwin adrianludwin commented on code on Apr 06, 2020 16:55 UTC
    Code Review
    incubator/hnc/pkg/validators/hierarchy.go:1
    @@ -382,13 +382,16 @@ func deny(reason metav1.StatusReason, msg string) admission.Response {
     			},
     		}}
     	} else {
    -		// metav1.StatusReasonInvalid shows the custom message in the Details field instead of
    -		// Message field of metav1.Status.
    +		// We need to set the custom message in both Message and Details fields.
    +		// When interacting via the kutectl plugin, the custom message
    +		// in the Message field will be shown when an error occurs. When interacting
    +		// without the kubectl plugin, the custom message in the Details field will be shown.

    Perfect :)

    adrianludwin adrianludwin commented on Apr 06, 2020 16:56 UTC
    Contributor

    /approve
    /lgtm
    /hold
    /assign @rjbez17

    sophieliu15 sophieliu15 commented on Apr 06, 2020 19:14 UTC
    Author

    I changed the commit and PR message to refer to the correct issue (454 instead of 545).

    rjbez17 rjbez17 commented on code on Apr 06, 2020 19:52 UTC
    Code Review
    incubator/hnc/pkg/kubectl/configset.go:1
    @@ -0,0 +1,69 @@
    +/*
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package kubectl
    +
    +import (
    +	"fmt"
    +
    +	"github.com/spf13/cobra"
    +
    +	api "github.com/kubernetes-sigs/multi-tenancy/incubator/hnc/api/v1alpha1"
    +)
    +
    +var setTypeCmd = &cobra.Command{
    +	Use: fmt.Sprintf("set-type --apiVersion X --kind Y <%s|%s|%s>",
    +		api.Propagate, api.Remove, api.Ignore),
    +	Short: "Sets the HNC configuration of a specific type",

    type in this context isn't that obvious IMO. Maybe resources type is better? Thoughts?

    rjbez17 rjbez17 commented on Apr 06, 2020 20:38 UTC
    Contributor

    /lgtm
    /approve

    k8s-ci-robot k8s-ci-robot commented on Apr 06, 2020 20:38 UTC
    Contributor

    [APPROVALNOTIFIER] This PR is APPROVED

    This pull-request has been approved by: <a href="https://github.com/kubernetes-sigs/multi-tenancy/pull/595#issuecomment-609914130" title="LGTM">adrianludwin</a>, <a href="https://github.com/kubernetes-sigs/multi-tenancy/pull/595#issuecomment-610024069" title="Approved">rjbez17</a>, <a href="https://github.com/kubernetes-sigs/multi-tenancy/pull/595#" title="Author self-approved">sophieliu15</a>

    The full list of commands accepted by this bot can be found here.

    The pull request process is described here

    <details >
    Needs approval from an approver in each of these files:

  • ~~OWNERS~~ [adrianludwin,rjbez17]
  • Approvers can indicate their approval by writing /approve in a comment
    Approvers can cancel approval by writing /approve cancel in a comment
    </details>
    <!-- META={"approvers":[]} -->

    sophieliu15 sophieliu15 commented on code on Apr 06, 2020 21:31 UTC
    Code Review
    incubator/hnc/pkg/kubectl/configset.go:1
    @@ -0,0 +1,69 @@
    +/*
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package kubectl
    +
    +import (
    +	"fmt"
    +
    +	"github.com/spf13/cobra"
    +
    +	api "github.com/kubernetes-sigs/multi-tenancy/incubator/hnc/api/v1alpha1"
    +)
    +
    +var setTypeCmd = &cobra.Command{
    +	Use: fmt.Sprintf("set-type --apiVersion X --kind Y <%s|%s|%s>",
    +		api.Propagate, api.Remove, api.Ignore),
    +	Short: "Sets the HNC configuration of a specific type",

    Hi Ryan!

    Thanks for the suggestion! I feel set-resources-type might be a little bit long (e.g., the whole command will be like kubectl hns config set-resources-type [flags] propagate) but I don't have a better suggestion about the naming. Are there other kinds of "types" that users might be confused with "resource types"?

    I don't have preference between type and resources-type. If you think resources-type is not too long, we can go for it. :)

    @adrianludwin WDYT?

    rjbez17 rjbez17 commented on code on Apr 06, 2020 21:38 UTC
    Code Review
    incubator/hnc/pkg/kubectl/configset.go:1
    @@ -0,0 +1,69 @@
    +/*
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package kubectl
    +
    +import (
    +	"fmt"
    +
    +	"github.com/spf13/cobra"
    +
    +	api "github.com/kubernetes-sigs/multi-tenancy/incubator/hnc/api/v1alpha1"
    +)
    +
    +var setTypeCmd = &cobra.Command{
    +	Use: fmt.Sprintf("set-type --apiVersion X --kind Y <%s|%s|%s>",
    +		api.Propagate, api.Remove, api.Ignore),
    +	Short: "Sets the HNC configuration of a specific type",

    I was referring just to the short description, not the actual command names. I agree it'd be too long for the name.

    sophieliu15 sophieliu15 commented on code on Apr 07, 2020 13:50 UTC
    Code Review
    incubator/hnc/pkg/kubectl/configset.go:1
    @@ -0,0 +1,69 @@
    +/*
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package kubectl
    +
    +import (
    +	"fmt"
    +
    +	"github.com/spf13/cobra"
    +
    +	api "github.com/kubernetes-sigs/multi-tenancy/incubator/hnc/api/v1alpha1"
    +)
    +
    +var setTypeCmd = &cobra.Command{
    +	Use: fmt.Sprintf("set-type --apiVersion X --kind Y <%s|%s|%s>",
    +		api.Propagate, api.Remove, api.Ignore),
    +	Short: "Sets the HNC configuration of a specific type",

    Cool! Thanks for the clarification. Changed to "resources type" in the short description.

    adrianludwin adrianludwin commented on Apr 08, 2020 15:33 UTC
    Contributor

    /lgtm
    /hold cancel

    adrianludwin adrianludwin commented on code on Apr 08, 2020 15:33 UTC
    Code Review
    incubator/hnc/pkg/kubectl/configset.go:1
    @@ -0,0 +1,69 @@
    +/*
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package kubectl
    +
    +import (
    +	"fmt"
    +
    +	"github.com/spf13/cobra"
    +
    +	api "github.com/kubernetes-sigs/multi-tenancy/incubator/hnc/api/v1alpha1"
    +)
    +
    +var setTypeCmd = &cobra.Command{
    +	Use: fmt.Sprintf("set-type --apiVersion X --kind Y <%s|%s|%s>",
    +		api.Propagate, api.Remove, api.Ignore),
    +	Short: "Sets the HNC configuration of a specific type",

    This lgtm!

    Reviewers
    Assignees
    sophieliu15 sophieliu15
    Labels
    risk: low confidence: 90.6% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 56.1% (MEDIUM) · Higher = larger blast radius
    56.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 90.6% · Lower = rushed or shallow review
    90.6%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 5.3% · Safe to merge
    5.3%