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

enable global flags for deploy command #634

Conversation

fmoehler
Copy link
Contributor

No description provided.

@fmoehler fmoehler changed the title move global flags coding to deploy.go enabel global flags for deploy command Nov 2, 2023
@jpalermo jpalermo requested review from bgandon, a team and danielfor and removed request for a team November 2, 2023 15:45
@bgandon bgandon changed the title enabel global flags for deploy command enable global flags for deploy command Nov 2, 2023
@fmoehler fmoehler force-pushed the add-global-flags-from-deploy-config-in-deploy-go branch from 0d38221 to cfbabbb Compare November 8, 2023 10:14
Copy link

@anshrupani anshrupani left a comment

Choose a reason for hiding this comment

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

looks good in general, but having ExcludeDeployments would be good. thanks!

cmd/deploy.go Show resolved Hide resolved
cmd/deploy.go Outdated

yaml.Unmarshal([]byte(config.Content), &conf)
if conf.IncludeDeployments == nil || includeContains(conf.IncludeDeployments, c.deployment.Name()) {
c.ui.PrintLinef("Using deployment flags from config of type '%s' (name: '%s')", config.Type, config.Name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make that information more prominent in the cli logs (e.g. color it, or add !!! a line before and afterwards) otherwise it can be overseen to easy.

Additionally maybe the better message would be:
NOTE: The deploy command execution will use parameters that are globally configured in the director's %s config.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, we can make it more prominent. I tried to have the text similar to what comes up in the deploy command anyway e.g.

Using deployment 'foo'

So I thought it would be nice to stick to the same sentence "structure"

@fmoehler
Copy link
Contributor Author

fmoehler commented Nov 9, 2023

Documentation PR: cloudfoundry/docs-bosh#811

@fmoehler fmoehler force-pushed the add-global-flags-from-deploy-config-in-deploy-go branch from 74a3741 to 2e7bb37 Compare November 9, 2023 15:18
@fmoehler fmoehler force-pushed the add-global-flags-from-deploy-config-in-deploy-go branch from 2e7bb37 to 55961e4 Compare November 9, 2023 15:20
Copy link
Member

@danielfor danielfor left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +53 to +59
if conf.ExcludeDeployments != nil &&
conf.IncludeDeployments != nil {
c.ui.PrintLinef("Ignoring deployment flags from config of type '%s' (name: '%s'). Please use only 'include'- OR 'exclude'-property in the config.", config.Type, config.Name)
} else {
if (conf.IncludeDeployments == nil && conf.ExcludeDeployments == nil) ||
deploymentIncluded ||
(!deploymentExcluded && conf.ExcludeDeployments != nil) {
Copy link

Choose a reason for hiding this comment

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

I first thought of such pseudo-code instead:

decision=NO
IF includeList == null OR includeList contains deploymentName THEN decision=YES
IF excludeList != null AND excludeList contains deploymentName THEN decision=NO

Then, inspired by the director’s code for addons, here is a better version (see other commend below), which is equivalent:

decision = applies(includeList, deploymentName) && !applies(excludeList, deploymentName)

This is easier to understand, and consistent with what we already have for other include/exclude mechanisms in Bosh.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bgandon thanks for the review. I agree that would be easier to understand, however only having the check
decision = applies(includeList, deploymentName) && !applies(excludeList, deploymentName)

would not apply to the following cases, that are currently taking care of:

  1. No warning/ignoring of the flags in case both include and exclude properties are maintained.
  2. If the exclude property is empty, it will always be a NO decision (considering that the containsDeployment() -> applies() method gets rewritten to return true if list == null OR list contains deploymentName)

So I am not sure about that...

Copy link

Choose a reason for hiding this comment

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

That’s right, my second suggestion is not equivalent to the first one, and i didn’t take into account the ambiguous case where both include and exclude are specified.

The idea with my first suggestion, was to skip the ambiguity and just le the exclude win when both are contradictory concerning a given deployment name.

I think we can go ahead with the code as is.

cmd/deploy.go Outdated
(!deploymentExcluded && conf.ExcludeDeployments != nil) {
c.ui.PrintLinef("!!!!!!!")
c.ui.PrintLinef("Using deployment flags from config of type '%s' (name: '%s')", config.Type, config.Name)
c.ui.PrintLinef("!!!!!!!")
Copy link

Choose a reason for hiding this comment

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

Message should be improved to be similar to other Bosh CLI outputs and still raise the relevant attention from human operators

cmd/deploy.go Outdated
return opts
}

func containsDeployment(slice []string, value string) bool {
Copy link

Choose a reason for hiding this comment

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

Thinking of the implementation done in Director for addons, I think that applies() would be better name for this function, with this pseudo code as implementation:

list == null OR list contains deploymentName

@beyhan
Copy link
Member

beyhan commented Nov 24, 2023

The lint issues are fixed now and I'm going to merge this as discussed during the FI WG meeting.

@beyhan beyhan merged commit d00df5a into cloudfoundry:main Nov 24, 2023
3 checks passed
@jpalermo
Copy link
Member

This was released in 7.5.0

achrinza added a commit to achrinzafork/schemastore that referenced this pull request Oct 17, 2024
achrinza added a commit to achrinzafork/schemastore that referenced this pull request Oct 17, 2024
achrinza added a commit to achrinzafork/schemastore that referenced this pull request Oct 17, 2024
achrinza added a commit to achrinzafork/schemastore that referenced this pull request Oct 17, 2024
achrinza added a commit to achrinzafork/schemastore that referenced this pull request Oct 17, 2024
madskristensen pushed a commit to SchemaStore/schemastore that referenced this pull request Oct 17, 2024
benpops89 pushed a commit to benpops89/schemastore that referenced this pull request Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

7 participants