xorpaul/g10k

-branch should include the repository prefix

Closed this issue · 6 comments

The branch parameter should honor the prefix if one is configured for a given source. Otherwise if two sources use the same branch name, it is impossible to specify which one is ment. For example if there are two sources, "devel" and "staging", and both have a branch "branchname", I would like to run g10k with -branch devel_branchname to exactly specify which branch is ment.

I don't understand how you're talking about the -puppetfile mode in the subject and then about the prefix setting inside a source YAML config, but I guess you meant to write -branch mode instead.

For me the -branch parameter should only specify the Git branch that g10k should try to resolve, bot the Puppet environment.

How about I'll add a -puppetenv parameter to g10k which would support the behavior you expect?
Would that be OK for you?

Sorry, you are right, I got a bit confused, I mixed up updating only a single environment with using -puppetfile mode. And yes, if you want to keep the -branch parameter as it is, having a -puppetenv parameter that includes the repository prefix would would be very useful.

I've not added an extra parameter for this, but simply added the possibility to match the branch and the prefix+branch combination here: 48c3303#diff-df78fe67e2c9bffdb3673a5fd14d2bb7R84

Now with v.0.7.0 you should be able to specify the exact branch/environment with -branch devel_branchname

Awesome. If I have one repo with a prefix and one without a prefix and both contain the same branch, does g10k guarantee that when run with -branch <branchname>, always the one from the repo without the prefix is used?

Ah, now I understand.

I've just tested it and g10k would sync both sources currently as anything else involving the -branch parameter would break current behavior.

As written previously I'm thinking about adding an additional parameter called -environment which can be used just like like the environment parameter of r10k.

r10k always uses the source name + "_" + the branch name of the repository.

An example:

sources:
  example:
    remote: 'https://github.com/xorpaul/g10k-environment.git'
    basedir: '/tmp/out/'
    prefix: true
  full:
    remote: 'https://github.com/xorpaul/g10k-fullworking-env.git'
    basedir: '/tmp/out/'
    prefix: false
  another:
    remote: 'https://github.com/xorpaul/g10k-fullworking-env.git'
    basedir: '/tmp/out/'
    prefix: 'foobar'
  • calling -environment with master does nothing.
  • calling -environment with foobar_master does nothing.
  • calling -environment with example_master deploys only the master branch of the example source.
  • calling -environment with another_master deploys only the master branch of the another source.

This way you should also be able to control which branch of which source you want to deploy.

How does this sound to you?