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

virtctl: Apply --namespace to created manifests #10167

Merged
merged 4 commits into from Sep 6, 2023

Conversation

0xFelix
Copy link
Member

@0xFelix 0xFelix commented Jul 25, 2023

What this PR does / why we need it:

With this PR virtctl applies the namespace passed with the
--namespace flag to the following created manifests:

  • VirtualMachine
  • VirtualMachinePreferences
  • VirtualMachineInstancetype
  • VirtualMachineClone

Release note:

virtctl: Apply namespace to created manifests

With this change virtctl applies the namespace passed with the
--namespace flag to the created VirtualMachine manifest.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
With this change virtctl applies the namespace passed with the
--namespace flag to the created VirtualMachinePreference manifest.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
With this change virtctl applies the namespace passed with the
--namespace flag to the created VirtualMachineInstancetype manifest.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
With this change virtctl applies the namespace passed with the
--namespace flag to the created VirtualMachineClone manifest.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
@kubevirt-bot kubevirt-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. size/L labels Jul 25, 2023
@0xFelix
Copy link
Member Author

0xFelix commented Jul 25, 2023

/area instancetype

@0xFelix
Copy link
Member Author

0xFelix commented Jul 25, 2023

/cc @lyarwood

@0xFelix
Copy link
Member Author

0xFelix commented Jul 25, 2023

/cc @opokornyy

@0xFelix 0xFelix changed the title Virtctl create ns virtctl: Apply --namespace to created manifests Jul 25, 2023
@0xFelix
Copy link
Member Author

0xFelix commented Jul 26, 2023

/retest-required

Copy link
Member

@lyarwood lyarwood left a comment

Choose a reason for hiding this comment

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

/lgtm

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Jul 26, 2023
@0xFelix
Copy link
Member Author

0xFelix commented Jul 26, 2023

/cc @alicefr Could you take a look please? :)

}
if overridden {
c.namespace = namespace
c.namespaced = true
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still need the namespaced flag? We could by default create VirtualMachineClusterInstancetype and based on namespace flag decide if we want the VirtualMachineInstancetype instead. What do you think about that?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd keep the namespaced flag so it is still possible to create a VirtualMachineInstancetype that does not have the namespace set.

}
if overridden {
c.namespace = namespace
c.namespaced = true
Copy link
Contributor

Choose a reason for hiding this comment

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

Same question like for VirtualMachineInstancetype.

Copy link
Contributor

@jcanocan jcanocan left a comment

Choose a reason for hiding this comment

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

Nice job. Looks good to me! Just a couple small comments.

@@ -23,14 +23,15 @@ import (
"fmt"
"strings"

"kubevirt.io/kubevirt/pkg/pointer"

"github.com/spf13/cobra"
Copy link
Contributor

Choose a reason for hiding this comment

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

it's not related with this PR but, newline?

Copy link
Member Author

Choose a reason for hiding this comment

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

I moved this local import to the bottom of the imports on purpose.

Copy link
Contributor

@jcanocan jcanocan Jul 27, 2023

Choose a reason for hiding this comment

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

Sorry, I didn't explain myself properly. I meant between:

"github.com/spf13/cobra"v1

"k8s.io/api/core/v1"

Copy link
Member Author

Choose a reason for hiding this comment

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

Those are all remote imports, so AFAIK we don't separate them further.

@@ -21,9 +21,9 @@ package create

import (
"github.com/spf13/cobra"
Copy link
Contributor

Choose a reason for hiding this comment

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

newline?

Copy link
Member Author

Choose a reason for hiding this comment

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

Basically the same as the other comment: First stdlib imports, then remote packages, then local packages. I did this on purpose while touching the imports anyways.

@0xFelix
Copy link
Member Author

0xFelix commented Aug 8, 2023

@alicefr Ping :)

@alicefr
Copy link
Member

alicefr commented Sep 5, 2023

It looks good, the only super nit I have, if we should put the common field in a struct instead of adding them to every types. Like:

type createCommon {
     name string
     namespace string
     clientConfig clientcmd.ClientConfig
}

(not sure about the name) and a common function to set the defaults for those values.

@alicefr
Copy link
Member

alicefr commented Sep 5, 2023

/approve
/hold
if you want to address the comments.

@kubevirt-bot kubevirt-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 5, 2023
@kubevirt-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alicefr

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

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubevirt-bot kubevirt-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 5, 2023
@0xFelix
Copy link
Member Author

0xFelix commented Sep 5, 2023

I have looked at your suggestions and I don't think they necessarily make things any easier. It would require public fields, which I'd like to avoid and a common defaults setter for the namespace is not possible, because they all require slightly different logic.

Maybe in a follow up?

@alicefr
Copy link
Member

alicefr commented Sep 6, 2023

I have looked at your suggestions and I don't think they necessarily make things any easier. It would require public fields, which I'd like to avoid and a common defaults setter for the namespace is not possible, because they all require slightly different logic.

Maybe in a follow up?

That's ok, thanks for your work!
/unhold

@kubevirt-bot kubevirt-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 6, 2023
@0xFelix
Copy link
Member Author

0xFelix commented Sep 6, 2023

/retest-required

@kubevirt-bot kubevirt-bot merged commit ce2b4ce into kubevirt:main Sep 6, 2023
42 checks passed
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. area/instancetype dco-signoff: yes Indicates the PR's author has DCO signed all their commits. lgtm 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants