Skip to content

Render :tag in PuppetFile.toText for git modules - #5

Open
dennisboege-devoba wants to merge 2 commits into
dodevops:mainfrom
dennisboege-devoba:fix/puppetfile-tag-roundtrip
Open

dennisboege-devoba wants to merge 2 commits into
dodevops:mainfrom
dennisboege-devoba:fix/puppetfile-tag-roundtrip

Conversation

@dennisboege-devoba

@dennisboege-devoba dennisboege-devoba commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Follow-up to #4. The parser accepts :tag on git modules now, but PuppetFile.toText() only knows :ref. A Puppetfile that pins a module with :tag => 'v1.0.0' comes back as :ref => 'v1.0.0' after a round-trip. r10k treats both the same, but the generated file no longer matches the input.

Change

  • lib/ModuleDeclaration.ts: new tag field, set alongside ref when the module uses :tag. ref stays populated, so the checkout in fetchGitMetadata() does not change.
  • lib/PuppetFile.ts: the git module template renders :tag when tag is set and falls back to :ref otherwise.
  • test/puppetfile.test.ts: new round-trip test with a :tag module. It fails on current main (:ref => 'test' instead of :tag => 'test') and passes with this change.

If a module declares both :ref and :tag, :ref still wins, same as in the parser.

Version as a proposal: v0.4.1

Since :tag is parsed as an alias for :ref, toText() rendered every
git module with :ref, so a Puppetfile that pinned a module by tag
came back with :ref after a round-trip.

Remember the tag on the module declaration and render :tag when it
is set. ref stays populated so the checkout in fetchGitMetadata() is
unchanged.
Comment thread lib/ModuleDeclaration.ts
this.ref = parameters[':ref']
} else if (':tag' in parameters) {
this.ref = parameters[':tag']
this.ref = this.tag = parameters[':tag']

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please only set this.tag here and not this.ref because it makes no sense to set it here IMHO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants