Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Add labels to VMs #516

Merged
merged 1 commit into from
Feb 3, 2020
Merged

Add labels to VMs #516

merged 1 commit into from
Feb 3, 2020

Conversation

darkowlzz
Copy link
Contributor

@darkowlzz darkowlzz commented Feb 2, 2020

Adds a new flag --label to VM create command for setting label on the VM
object. The flag is of StringArray type and can be used multiple times
to set more than one label.

# ignite create weaveworks/ignite-ubuntu --name my-vm1 -l label1=val1 -l label2=val2

vm inspect result:

# ignite inspect vm my-vm1
{
  "kind": "VM",
  "apiVersion": "ignite.weave.works/v1alpha2",
  "metadata": {
    "name": "my-vm1",
    "uid": "70d265ddaaa92462",
    "created": "2020-02-02T12:37:21Z",
    "labels": {
      "label1": "val1",
      "label2": "val2"
    }
...

@chanwit chanwit requested review from chanwit and removed request for twelho February 2, 2020 16:47
Copy link
Member

@chanwit chanwit left a comment

Choose a reason for hiding this comment

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

Thank you for submitting this PR, @darkowlzz :-)
Not sure if you think my comment to change Split to SplitN is making sense?

Other than this small nit, it LGTM

}

for _, label := range labels {
kv := strings.Split(label, "=")
Copy link
Member

Choose a reason for hiding this comment

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

should we use SplitN(label, "=", 2), wdyt?
if so, the value could also be possible to contain other = chars too.

Copy link
Contributor Author

@darkowlzz darkowlzz Feb 3, 2020

Choose a reason for hiding this comment

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

Yes, that's a good idea. I checked what happens if I pass "k1=v1,k2=v2" as label to docker, and it splits at first separator and accepts the rest of the string as the value.

            "Labels": {
                "k1": "v1,k2=v2"
            }

Updating the test to not fail for this case.
Thanks!

@chanwit chanwit added the kind/enhancement Categorizes issue or PR as related to improving an existing feature. label Feb 2, 2020
@chanwit chanwit self-assigned this Feb 2, 2020
Adds a new flag --label to VM create command for setting label on the VM
object. The flag is of StringArray type and can be used multiple times
to set more than one label.

```
$ ignite create weaveworks/ignite-ubuntu --name vm -l k1=v1 -l k2=v2
```
@darkowlzz
Copy link
Contributor Author

Added another check to ensure that the label name isn't empty. Updated the test with this case.

Copy link
Member

@chanwit chanwit left a comment

Choose a reason for hiding this comment

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

LGTM

@chanwit chanwit merged commit b88dce6 into weaveworks:master Feb 3, 2020
@darkowlzz darkowlzz deleted the vm-labels branch February 3, 2020 11:04
@chanwit
Copy link
Member

chanwit commented Feb 3, 2020

Thank you @darkowlzz for this wonderful PR!!

@luxas luxas added this to the v0.7.0 milestone Jun 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/enhancement Categorizes issue or PR as related to improving an existing feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants