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 custom tags to machines #158

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Add custom tags to machines #158

wants to merge 6 commits into from

Conversation

mcbenjemaa
Copy link
Member

@mcbenjemaa mcbenjemaa commented Mar 27, 2024

This PR add Custom Tags to VM while preserving the current tags.

Copy link

tags = append(tags, tag)
}
}
if len(tags) > length {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this check does not account for removal of tags. is this intended?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, so we don't delete existing tags.
The IP tag i mean.
Which means tags are also immutable as per the machine.

Copy link
Collaborator

Choose a reason for hiding this comment

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

then you need to add this to the webhook or a CRD kubebuilder annotation

@@ -131,3 +144,14 @@ func validateNetworkDeviceMTU(device *infrav1.NetworkDevice) error {

return nil
}

func validateTags(tags []string) error {
re := regexp.MustCompile(`^[a-zA-Z0-9-_]*$`)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should be + not * to prevent empty string. Also, have you tried +kubebuilder:validation:Pattern?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmmm,

Let me check

Copy link

github-actions bot commented Feb 6, 2025

External PR

Test runs on external PRs require manual approval.

Note: This PR changes the following non-go, non-docs files:
config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxclusters.yaml
config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxclustertemplates.yaml
config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxmachines.yaml
config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxmachinetemplates.yaml
go.mod

Copy link

github-actions bot commented Feb 6, 2025

External PR

Test runs on external PRs require manual approval.

Note: This PR changes the following non-go, non-docs files:
config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxclusters.yaml
config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxclustertemplates.yaml
config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxmachines.yaml
config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxmachinetemplates.yaml

@@ -427,6 +430,27 @@ func TestReconcileVirtualMachineConfig_ApplyConfig(t *testing.T) {
require.EqualValues(t, task.UPID, *machineScope.ProxmoxMachine.Status.TaskRef)
}

func TestReconcileVirtualMachineConfigTags(t *testing.T) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add a test case for multiple tags and for zero/empty tags?

Copy link
Member Author

Choose a reason for hiding this comment

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

all the cases are included,

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 have added an empty case in the function

// +immutable
// +listType=set
// +kubebuilder:validation:MinItems=1
// +kubebuilder:validation:items:Pattern=`^[a-zA-Z0-9-_+]+$`
Copy link
Contributor

@pborn-ionos pborn-ionos Feb 11, 2025

Choose a reason for hiding this comment

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

Might need some more refinement.

https://github.com/proxmox/pve-common/blob/master/src/PVE/JSONSchema.pm#L706

our $PVE_TAG_RE = qr/[a-z0-9_][a-z0-9_\-\+\.]*/i;

i.e.

// +kubebuilder:validation:items:Pattern=`^(?i)[a-z0-9_][a-z0-9_\-\+\.]*$`

to be true to upstream :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point

Copy link

External PR

Test runs on external PRs require manual approval.

Note: This PR changes the following non-go, non-docs files:
config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxclusters.yaml
config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxclustertemplates.yaml
config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxmachines.yaml
config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxmachinetemplates.yaml

@mcbenjemaa
Copy link
Member Author

Ready

Copy link

External PR

Test runs on external PRs require manual approval.

Copy link

External PR

Test runs on external PRs require manual approval.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants