Skip to content

Add CPE label and RHEL version placeholder in Dockerfile generator#791

Merged
openshift-merge-bot[bot] merged 4 commits into
openshift-knative:mainfrom
Kaustubh-pande:add-cpe-label-fix-name
Oct 8, 2025
Merged

Add CPE label and RHEL version placeholder in Dockerfile generator#791
openshift-merge-bot[bot] merged 4 commits into
openshift-knative:mainfrom
Kaustubh-pande:add-cpe-label-fix-name

Conversation

@Kaustubh-pande
Copy link
Copy Markdown
Collaborator

  • Introduce CPE label support for images
  • Add placeholder for RHEL version to dynamically set OS version in Dockerfiles

cc @dsimansk

@openshift-ci openshift-ci Bot requested review from matzew and pierDipi October 7, 2025 13:32
@openshift-ci openshift-ci Bot added the approved label Oct 7, 2025
@dsimansk
Copy link
Copy Markdown
Contributor

dsimansk commented Oct 8, 2025

 2025/10/07 18:44:55 🔥 Error: bad template: Parsing failed: template: pattern matches no files: `dockerfile-templates/rhel-9/*.tmpl`

 - bad template

 - template: pattern matches no files: `dockerfile-templates/rhel-9/*.tmpl`

Should we rather include a specific template files into embed, I still see a lot of error in the generator tests.

@dsimansk
Copy link
Copy Markdown
Contributor

dsimansk commented Oct 8, 2025

Comment thread pkg/dockerfilegen/templates.go Outdated
import "embed"

//go:embed dockerfile-templates/Default.dockerfile.tmpl
//go:embed dockerfile-templates/Default.dockerfile.tmpl dockerfile-templates/rhel-9/*.tmpl
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
//go:embed dockerfile-templates/Default.dockerfile.tmpl dockerfile-templates/rhel-9/*.tmpl
//go:embed dockerfile-templates/Default.dockerfile.tmpl dockerfile-templates/rhel-9/*

It should be dir input, otherwise pattern match with suffix doesn't work.

Comment thread pkg/dockerfilegen/generator.go Outdated
Comment on lines +306 to +310
if rhelVersion == RHEL9 {
templateFile = "dockerfile-templates/rhel-9/Default.dockerfile.tmpl"
} else {
templateFile = "dockerfile-templates/Default.dockerfile.tmpl"
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's enough to fix embed directive to either wildcard dir. We don't need to have full path everywhere.

Comment on lines -296 to -300
templateFiles := "dockerfile-templates/*.tmpl"
if rhelVersion == "rhel-9" {
templateFiles = "dockerfile-templates/rhel-9/*.tmpl"
}
t, err := template.ParseFS(dockerfileTemplate, templateFiles)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

With correct embed this will work as expected.

Comment on lines +455 to +475
// Pick proper template FS file and RPM lock file
templateFile := "dockerfile-templates/rhel-9/*.tmpl" // RHEL9 default
if rhelVersion == RHEL9 {
rpmsLockTemplate = &RPMsLockTemplateUbi9
} else {
templateFile = "dockerfile-templates/*.tmpl"
rpmsLockTemplate = &RPMsLockTemplateUbi8
}

t, err := template.ParseFS(DockerfileMustGatherTemplate, templateFile)
if err != nil {
return fmt.Errorf("%w: Parsing failed: %w",
ErrBadTemplate, errors.WithStack(err))
}

bf := new(bytes.Buffer)
if err := t.Execute(bf, d); err != nil {
return fmt.Errorf("%w: executing failed: %w",
ErrBadTemplate, errors.WithStack(err))
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

IMO, this whole part is still extra and not needed.

@dsimansk
Copy link
Copy Markdown
Contributor

dsimansk commented Oct 8, 2025

/approve
/lgtm

@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Oct 8, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dsimansk, Kaustubh-pande

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot Bot merged commit f0ba683 into openshift-knative:main Oct 8, 2025
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants