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

Instance ls/inspect/tag CLI #352

Conversation

divolgin
Copy link
Member

@divolgin divolgin commented Jan 5, 2024

replicated instance ls/inspect/tag commands

replicated instance ls

$ ./bin/replicated instance ls --customer 2ULcKDT6snYYy5Zsdx3xuc3fffl 
ID                                      NAME      LAST ACTIVE                          VERSION    TAGS
7e5503f2-ba45-429f-8c94-6476d6d66fe5              2023-09-18 16:49:49.314 +0000 UTC    1.0.11     
2VOkWCw0nNp87r5qN6zcujzitm7             fozzy     2023-09-15 19:46:25.083 +0000 UTC    0.0.1      name=fozzy
1b1c5325-d06c-4ab3-8078-eafd07516b52    kermit    2023-09-11 15:08:00.138 +0000 UTC               manager=jim,name=kermit,type=frog
53359c21-0f94-4378-b0f1-2687fd8098d3              2023-08-23 17:36:15.531 +0000 UTC    0.1.2      
2ULcb51hPujG1L3bBcljP0avtCy             rolf      2023-08-22 16:55:08.013 +0000 UTC    0.1.2      manager=jim,name=rolf,type=dog,ui=yes2
$ ./bin/replicated instance ls --customer 2ULcKDT6snYYy5Zsdx3xuc3fffl --tag manager=jim
ID                                      NAME      LAST ACTIVE                          VERSION    TAGS
1b1c5325-d06c-4ab3-8078-eafd07516b52    kermit    2023-09-11 15:08:00.138 +0000 UTC               manager=jim,name=kermit,type=frog
2ULcb51hPujG1L3bBcljP0avtCy             rolf      2023-08-22 16:55:08.013 +0000 UTC    0.1.2      manager=jim,name=rolf,type=dog,ui=yes2
$ ./bin/replicated instance ls --customer 2ULcKDT6snYYy5Zsdx3xuc3fffl --tag manager=jim --tag name=fozzy
ID                                      NAME      LAST ACTIVE                          VERSION    TAGS
2VOkWCw0nNp87r5qN6zcujzitm7             fozzy     2023-09-15 19:46:25.083 +0000 UTC    0.0.1      name=fozzy
1b1c5325-d06c-4ab3-8078-eafd07516b52    kermit    2023-09-11 15:08:00.138 +0000 UTC               manager=jim,name=kermit,type=frog
2ULcb51hPujG1L3bBcljP0avtCy             rolf      2023-08-22 16:55:08.013 +0000 UTC    0.1.2      manager=jim,name=rolf,type=dog,ui=yes2

replicated instance inspect

$ ./bin/replicated instance inspect --customer 2ULcKDT6snYYy5Zsdx3xuc3fffl --instance 2ULcb51hPujG1L3bBcljP0avtCy
ID                             NAME    LAST ACTIVE                          VERSION    TAGS
2ULcb51hPujG1L3bBcljP0avtCy    rolf    2023-08-22 16:55:08.013 +0000 UTC    0.1.2      manager=jim,name=rolf,type=dog,ui=yes2

VERSION LABEL    CHANNEL ID                     RELEASE SEQUENCE    FIRST SEEN                           LAST SEEN
0.1.2            2ULZURFgOKVpjtpWG4xJUBKL8Rc    3                   2023-08-22 16:54:39.051 +0000 UTC    2023-08-22 16:55:08.013 +0000 UTC
0.1.1            2ULZURFgOKVpjtpWG4xJUBKL8Rc    2                   2023-08-22 16:44:33.786 +0000 UTC    2023-08-22 16:54:35.341 +0000 UTC
0.1.0            2ULZURFgOKVpjtpWG4xJUBKL8Rc    1                   2023-08-22 16:40:39.881 +0000 UTC    2023-08-22 16:44:32.642 +0000 UTC

replicated instance tag

$ ./bin/replicated instance tag --customer 2ULcKDT6snYYy5Zsdx3xuc3fffl --instance 2ULcb51hPujG1L3bBcljP0avtCy --tag ui= --tag cli=yes
ID                             NAME    LAST ACTIVE                          VERSION    TAGS
2ULcb51hPujG1L3bBcljP0avtCy    rolf    2023-08-22 16:55:08.013 +0000 UTC               cli=yes,manager=jim,name=rolf,type=dog

@divolgin divolgin force-pushed the divolgin/sc-95417/instance-tags-replicated-cli-supports-instance branch 4 times, most recently from a70b54f to 6b1ea40 Compare January 5, 2024 00:48
return instance, nil
}

func findInstancesByTags(tags []types.Tag, instances []types.Instance) []types.Instance {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably have an API endpoint for this feature in the near future.


instances := customer.Instances
if len(r.args.instanceListTags) > 0 {
tags, err := parseTags(r.args.instanceListTags)
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment applies to all instances of parseTags. What is your opinion on case sensitive of tags? Is Name=hello same as Name=HELLO

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated the name logic to be case insensitive to match FE. But everywhere else tags are case sensitive right now.

Copy link
Contributor

Choose a reason for hiding this comment

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

It the same way in CMX. We should probably come up with constraints for this feature in another story.

@FourSigma
Copy link
Contributor

Nice!

FourSigma
FourSigma previously approved these changes Jan 5, 2024
@FourSigma
Copy link
Contributor

Just one thought, I am assuming the JSON output works as well for this feature? In that String() string interface on Tag doesn't interfere with the JSON marshaling.

@divolgin divolgin force-pushed the divolgin/sc-95417/instance-tags-replicated-cli-supports-instance branch from 6b1ea40 to 68b89d9 Compare January 5, 2024 16:31
@divolgin
Copy link
Member Author

divolgin commented Jan 5, 2024

Just one thought, I am assuming the JSON output works as well for this feature? In that String() string interface on Tag doesn't interfere with the JSON marshaling.

It works. That affects printf functions but json package uses MarshalJSON function.

@divolgin divolgin merged commit 163e97c into main Jan 5, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants