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

Skip 'name' validation when in a controlrepo context #1352

Merged
merged 3 commits into from
Jul 9, 2024

Conversation

garrettrowell
Copy link
Contributor

Summary

Control repos can effectively be named whatever the end user wants. The pdk should not do it's validation on 'modulename' when in a control-repo context

Current Behavior

$ git clone git@github.com:puppetlabs/control-repo.git my-awesome-control-repo
$ cd my-awesome-control-repo
$ PDK_FEATURE_FLAGS=controlrepo pdk convert
pdk (ERROR): Invalid 'name' field in metadata.json: Module name must contain only alphanumeric or underscore characters.

This happens because in this example the module name is being resolved as garrettrowell-awesome-control-repo which as the error explains does not follow our module naming conventions

Expected Behavior

$ git clone git@github.com:puppetlabs/control-repo.git my-awesome-control-repo
$ cd my-awesome-control-repo
$ PDK_FEATURE_FLAGS=controlrepo pdk convert

We need to create the metadata.json file for this module, so we're going to ask you 4 questions.
If the question is not applicable to this module, accept the default option shown after each question. You can modify any answers at any time by manually updating the metadata.json file.

[Q 1/4] If you have a Puppet Forge username, add it here.
We can use this to upload your module to the Forge when it's complete.
--> garrettrowell

[Q 2/4] Who wrote this module?
This is used to credit the module's author.
--> Garrett Rowell

[Q 3/4] What license does this module code fall under?
This should be an identifier from https://spdx.org/licenses/. Common values are "Apache-2.0", "MIT", or "proprietary".
--> Apache-2.0

[Q 4/4] What operating systems does this module support?
Use the up and down keys to move between the choices, space to select and enter to continue.
--> RedHat based Linux, Debian based Linux, Windows


------------Files to be added-----------
/Users/garrett.rowell/workspace/control-repo/metadata.json
/Users/garrett.rowell/workspace/control-repo/.gitattributes
/Users/garrett.rowell/workspace/control-repo/.pdkignore
/Users/garrett.rowell/workspace/control-repo/.puppet-lint.rc
/Users/garrett.rowell/workspace/control-repo/.rspec
/Users/garrett.rowell/workspace/control-repo/.rubocop.yml
/Users/garrett.rowell/workspace/control-repo/.vscode/extensions.json
/Users/garrett.rowell/workspace/control-repo/.yardopts
/Users/garrett.rowell/workspace/control-repo/Gemfile
/Users/garrett.rowell/workspace/control-repo/Rakefile
/Users/garrett.rowell/workspace/control-repo/spec/default_facts.yml
/Users/garrett.rowell/workspace/control-repo/spec/spec_helper.rb
/Users/garrett.rowell/workspace/control-repo/.fixtures.yml
/Users/garrett.rowell/workspace/control-repo/.sync.yml
/Users/garrett.rowell/workspace/control-repo/CHANGELOG.md

----------Files to be modified----------
/Users/garrett.rowell/workspace/control-repo/.gitignore

----------------------------------------

You can find a report of differences in convert_report.txt.

pdk (INFO): Module conversion is a potentially destructive action. Ensure that you have committed your module to a version control system or have a backup, and review the changes above before continuing.
Do you want to continue and make these changes to your module? yes

$ head -n 4 metadata.json
{
  "name": "garrettrowell-my-awesome-control-repo",
  "version": "0.1.0",
  "author": "Garrett Rowell",

@garrettrowell garrettrowell requested a review from a team as a code owner May 8, 2024 19:35
Copy link

codecov bot commented May 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.81%. Comparing base (35ea7d6) to head (b128e55).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1352   +/-   ##
=======================================
  Coverage   87.81%   87.81%           
=======================================
  Files         129      129           
  Lines        5489     5489           
=======================================
  Hits         4820     4820           
  Misses        669      669           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jordanbreen28
Copy link
Contributor

@garrettrowell We like this change, thanks for submitting it! Could you update the PR title to be a bit more descriptive of the change, and rebase the PR off the current main and I can revisit this to get it merged.

@garrettrowell garrettrowell changed the title Control-repo Name Validation Skip 'name' validation when in a controlrepo context Jul 8, 2024
@garrettrowell
Copy link
Contributor Author

@jordanbreen28 I rebased off of current main and updated the PR title.

Copy link
Contributor

@jordanbreen28 jordanbreen28 left a comment

Choose a reason for hiding this comment

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

Thanks @garrettrowell! Failures unrelated

@jordanbreen28 jordanbreen28 merged commit 3f0ca66 into puppetlabs:main Jul 9, 2024
6 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants