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

(PDK-1096, PDK-1097, PDK-1098) Add puppet-dev flag to validate and test unit #559

Merged
merged 7 commits into from
Aug 10, 2018

Conversation

bmjen
Copy link
Contributor

@bmjen bmjen commented Aug 3, 2018

Adds the --puppet-dev flag to validate and test unit. This flag will allow users to get Puppet from github source.

@bmjen bmjen requested review from scotje and rodjek August 3, 2018 18:59
@coveralls
Copy link

coveralls commented Aug 3, 2018

Coverage Status

Coverage increased (+0.07%) to 92.882% when pulling db1a57f on bmjen:puppet-dev into a87c8e1 on puppetlabs:master.

@bmjen bmjen force-pushed the puppet-dev branch 2 times, most recently from b90cad1 to 2c60a29 Compare August 3, 2018 20:06
expect {
PDK::CLI.run(['validate', '--puppet-dev'])
}.to exit_zero
end
Copy link
Contributor

Choose a reason for hiding this comment

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

This test isn't actually asserting anything about activating the right puppet version yet, I assume this that part hasn't been implemented in this PR. But maybe it would be better to leave this out or mark it as pending so that we don't accidentally leave it this way later?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, good point. I was going to address it in the next PR when I do get the puppet-version selection parts tested.

@bmjen bmjen changed the title (PDK-1096) Add puppet-dev flag to CLI (PDK-1096, PDK-1097, PDK-1098) Add puppet-dev flag to validate and test unit Aug 7, 2018
@@ -16,6 +17,19 @@ def instance
end

PE_VERSIONS_URL = 'https://forgeapi.puppet.com/private/versions/pe'.freeze
DEFAULT_PUPPET_DEV_URL = 'https://github.com/puppetlabs/puppet'
Copy link
Contributor

Choose a reason for hiding this comment

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

.freeze the dev URL as well?

end

def puppet_dev_path
'%{cache}/src/puppet' % { cache: PDK::Util.cachedir }
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this use File.join?

PDK.logger.error clone_result[:stdout]
PDK.logger.error clone_result[:stderr]
raise PDK::CLI::FatalError, _("Unable to clone git repository at '%{repo}'.") % { repo: DEFAULT_PUPPET_DEV_URL }
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be worth returning early after the clone since the subsequent fetch is unlikely to bring in any new commits.

desired_puppet_version = (opts || {})[:'puppet-version'] || ENV['PDK_PUPPET_VERSION']
desired_pe_version = (opts || {})[:'pe-version'] || ENV['PDK_PE_VERSION']

begin
puppet_env =
if desired_puppet_version
if use_puppet_dev
PDK::Util::PuppetVersion.fetch_puppet_dev
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it's optimal for puppet_from_opts_or_env to have the side effect of cloning/fetching the repo every time it's called. Could this be exposed separately and maybe this method can raise if the local repo doesn't exist?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm. I figured it would be appropriate because puppet_from_opts_or_env is called on 3 occasions: pdk validate, pdk test unit, and pdk bundle and the clone or fetch is only performed if --puppet-dev or PDK_PUPPET_DEV is true.

I can abstract the call that clones/fetch the git repo elsewhere, but it would still be called every time puppet-dev is true in order to get the latest from github.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, it currently is a 1-1 correlation with the places you want to call it, but I think it's just unclear that calling that method will have that side effect, so I'd rather see explicit calls in those places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, that's fair. I can make that change and at this part, I'll just call .puppet_dev_env to get the hash.

@bmjen bmjen force-pushed the puppet-dev branch 3 times, most recently from 5cccaa1 to e13dcc5 Compare August 9, 2018 06:12
Copy link
Contributor

@rodjek rodjek left a comment

Choose a reason for hiding this comment

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

It'd be good to get coverage of the of the changes in PDK::CLI::Util up to 100% - PDK::CLI::Util.puppet_from_opts_or_env in particular (also some acceptance tests). Other than that, 👍 nice!

Copy link
Contributor

@rodjek rodjek 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 to me!

@bmjen bmjen merged commit 599aafa into puppetlabs:master Aug 10, 2018
@bmjen bmjen deleted the puppet-dev branch August 10, 2018 15:45
@bmjen bmjen added the feature label Aug 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants