-
Notifications
You must be signed in to change notification settings - Fork 502
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
Track branch with -n Option #10844
Track branch with -n Option #10844
Conversation
This is a naive attempt at adding a tracking branch option to track the number of units in stages. It's naive in the fact that it doesn't validate if you just pass a unit type or if you pass multiple types. So it doesn't accumulate across applications and units. That requires some additional feedback to track the number of items that it has tracked.
The following just ensures that we correctly validate and guard against wrong cases when running track branch with the -n flag. This helps reduce a lot of complexity with in the state package, as we know that certain scenarios can't happen.
The following bumps the model generation version for the facade, this means that we can still support older version of model generations with out breaking.
The following ensures that we correctly handle no operations when attempting to get some units.
cmd/juju/model/trackbranch.go
Outdated
} | ||
|
||
// Init implements part of the cmd.Command interface. | ||
func (c *trackBranchCommand) Init(args []string) error { | ||
if len(args) == 0 { | ||
return errors.Errorf("expected a branch name plus unit and/or application names(s)") | ||
} | ||
if c.numUnits < 0 { |
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 we should detect somehow if the user actually passed -n 0
and return as invalid.
It would violate user expectation to pass that and have all units assigned.
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.
Ok, that makes sense.
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. Just a couple of tweaks around operator feedback.
To ensure operators correctly enter valid values for the tracking of a branch, ensure we can verify when they do or don't enter a valid -n value. This complication arises because we want to ensure that we don't accidently allow them to track all branches when they don't want to. Also the rise in complexity is shown when we want the inverse of track all things as a non-value. Most things in juju the default value is track 1 as the default. Not the case here.
|
|
Description of change
Track branch with -n allows us to specify the number of units to
track when tracking a branch.
The -n can only be used when tracking application tags, as unit
tags only track 1 thing, so it's not valid to do so. I've added some
validation around this to ensure we don't accidentally allow this to
happen.
QA steps