-
Notifications
You must be signed in to change notification settings - Fork 324
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
Extract http flags from consul/command pkg #259
Conversation
e6286a1
to
82aebfd
Compare
@hashicorp/consul-eco-platform this is a draft of what it looks like to remove our dependency on |
82aebfd
to
bfa7f46
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for taking so long to review this, Luke!
This looks really good! I left a couple of comments/questions inline.
// This was done so we don't depend on internal Consul implementation. | ||
|
||
// DurationValue provides a flag value that's aware if it has been set. | ||
type DurationValue struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This type is currently only used by the sync-catalog command. I've also found that you could just use time.Duration
and the flags would parse correctly (see this example in the lifecycle-sidecar command). I'm wondering if we can replace the type of the flagConsulWritePeriod
with time.Duration
, then maybe we don't need this at all?
I have tried it out quickly, and it seems to be working (branch). This I think would also be fine to refactor afterward as it seems like it's expanding the scope of this task.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine to include, thanks for doing the leg work. Done.
subcommand/flags/flag_map_value.go
Outdated
|
||
// FlagMapValue is a flag implementation used to provide key=value semantics | ||
// multiple times. | ||
type FlagMapValue map[string]string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't find how this type is used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
subcommand/flags/flag_slice_value.go
Outdated
|
||
import "strings" | ||
|
||
// Taken from https://github.com/hashicorp/consul/blob/master/command/flags/flag_slice_value.go |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make all the links tied to a specific git sha? If this code is moved or deleted, then we'd lose this reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good call, done!
subcommand/flags/usage.go
Outdated
"io" | ||
"strings" | ||
|
||
text "github.com/kr/text" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to alias it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, was just copied. removed.
Flags *flag.FlagSet | ||
} | ||
|
||
func (u *Usager) String() string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to test this 😬 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a test!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙏
This decouples us from an internal Consul package. We've removed flags that we aren't using.
bfa7f46
to
3c87e52
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!! thanks so much for making the changes 🎉
Flags *flag.FlagSet | ||
} | ||
|
||
func (u *Usager) String() string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙏
Run `helm test` in acceptance tests
Extract flags from
consul/command
into our own package:subcommand/flags
. Remove the flags we weren't using, that leaves:-http-addr
CONSUL_HTTP_ADDR
everywhere so this flag matches. We do use it in our tests.-token
CONSUL_HTTP_TOKEN
in a lot of locations so this flag matches.-token-file
-ca-file
CONSUL_CACERT
is used by almost all of our components.-ca-path
-tls-server-name
Testing: Use
lkysow/consul-k8s-dev:may27-flags
. Test with all of our components, they'll crash if a flag isn't supported. Note, I've tested this myself.