Skip to content

Augment components with version and images from OCM component descriptors#87

Open
MartinWeindel wants to merge 14 commits intogardener:mainfrom
MartinWeindel:enh/ocm-component-vector-resources2
Open

Augment components with version and images from OCM component descriptors#87
MartinWeindel wants to merge 14 commits intogardener:mainfrom
MartinWeindel:enh/ocm-component-vector-resources2

Conversation

@MartinWeindel
Copy link
Member

@MartinWeindel MartinWeindel commented Jan 30, 2026

How to categorize this PR?

/area control-plane
/kind enhancement

What this PR does / why we need it:
The resolve-ocm-components command now writes a ocm-components.yaml containing component vectors with resources, image overwrites, and component image overwrites.
These additional information is then used during the generate landscape command to update the helm chart, images references and overwrites in the templates.
Additional processing of custom compoments with OCM component descriptors are supported, too. (See docs/usage/custom-ocm-components.md for details.)

Which issue(s) this PR fixes:
Fixes #67, #68, and #74

Special notes for your reviewer:

Release note:

Augment components with version and images from OCM component descriptors.
Support templating custom compoments with OCM component descriptors.

@gardener-prow gardener-prow bot added area/control-plane Control plane related kind/enhancement Enhancement, improvement, extension cla: yes Indicates the PR's author has signed the cla-assistant.io CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jan 30, 2026
@MartinWeindel MartinWeindel force-pushed the enh/ocm-component-vector-resources2 branch from f0204f2 to 5d7316f Compare January 30, 2026 16:41
@MartinWeindel MartinWeindel force-pushed the enh/ocm-component-vector-resources2 branch from 5d7316f to cbea833 Compare January 30, 2026 16:46
Copy link
Member

@LucaBernstein LucaBernstein left a comment

Choose a reason for hiding this comment

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

Thank you very much, also for structuring the commits so well. A few preliminary comments from my side.

@timuthy
Copy link
Member

timuthy commented Feb 4, 2026

/assign

@gardener-prow gardener-prow bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 10, 2026
@gardener-prow
Copy link

gardener-prow bot commented Feb 10, 2026

PR needs rebase.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link
Member

@timuthy timuthy left a comment

Choose a reason for hiding this comment

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

Thanks for integrating the OCM image processing into GLK 👏

if err := os.MkdirAll(baseDir, 0700); err != nil {
return fmt.Errorf("failed to create output base directory %s: %w", baseDir, err)
}
if err := os.WriteFile(path.Join(baseDir, ".gitignore"), []byte("/*"), 0600); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Is there a strong reason for not checking in the generated file? I'd say it's important to keep this state in the repository, so that glk generate can easily be invoked again w/o re-resolving the OCM image vector.

The debug files can still be written into a separate, ignored debug directory.

// Name is the name of the resource.
Name string `json:"name"`
// Alias is an optional alias name of the resource.
Alias string `json:"alias,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

Consider using a pointer if it's optional.

// Resources is an optional list of values representing resources of the component.
Resources map[string]any `json:"resources,omitempty"`
// ImageVectorOverwrite is an optional image vector overwrite for the component.
ImageVectorOverwrite string `json:"imageVectorOverwrite,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

Do we really have to use string here, can we be more precise?

SourceRepository string `json:"sourceRepository"`
// Version is the version of the component.
Version string `json:"version"`
// Resources is an optional list of values representing resources of the component.
Copy link
Member

Choose a reason for hiding this comment

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

I think this needs further clarification, as the definition of a resource is not clear in this context. Please enhance the docstring by stating that a resource is usually an OCI image produced by a component.

// Version is the version of the component.
Version string `json:"version"`
// Resources is an optional list of values representing resources of the component.
Resources map[string]any `json:"resources,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

Do we really have to use any here, can we be more precise?

Copy link
Member

Choose a reason for hiding this comment

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

Move to pkg/utils/test.

Copy link
Member

Choose a reason for hiding this comment

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

Move to pkg/utils/test.

"sigs.k8s.io/yaml"
)

type ComponentVectorFactory func() (componentvector.ComponentVector, error)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
type ComponentVectorFactory func() (componentvector.ComponentVector, error)
type BuildComponentVectorFn func() (componentvector.ComponentVector, error)

type ComponentVectorFactory func() (componentvector.ComponentVector, error)

// CreateComponentsVectorFile creates a components vector YAML file in the given filesystem.
func CreateComponentsVectorFile(fs afero.Afero, cvf ComponentVectorFactory) (string, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func CreateComponentsVectorFile(fs afero.Afero, cvf ComponentVectorFactory) (string, error) {
func CreateComponentsVectorFile(fs afero.Afero, build BuildComponentVectorFn) (string, error) {

}

// ComponentVector creates a new ComponentVectorFactoryBuilder with the given name and version.
func ComponentVector(name, version string) *ComponentVectorFactoryBuilder {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func ComponentVector(name, version string) *ComponentVectorFactoryBuilder {
func NewComponentVectorBuilder(name, version string) *ComponentVectorFactoryBuilder {

@gardener-prow
Copy link

gardener-prow bot commented Feb 10, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from timuthy. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

Copy link
Member

@LucaBernstein LucaBernstein left a comment

Choose a reason for hiding this comment

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

Apart from what has already been remarked, I have some additional concerns about the imageVectorOverride templating, mainly w.r.t. indentations.

{{- end }}
{{- if .imageVectorOverwrite }}
imageVectorOverwrite: |
{{ indent 10 .imageVectorOverwrite }}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
{{ indent 10 .imageVectorOverwrite }}
{{ indent 10 .imageVectorOverwrite }}

Seems to make a difference. Tried it out:

apiVersion: operator.gardener.cloud/v1alpha1
kind: Extension
metadata:
  name: networking-calico
spec:
  deployment:
    extension:
      values:
        imageVectorOverwrite: |
            images:                       // <-- wrong indentation!
          - name: bird-exporter
            repository: ghcr.io/czerwonk/bird_exporter
            tag: v1.4.5

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure, though, why it doesn't show in the unit test with imageVectorOverwriteContent. 🤔
To me it seems that in the source ocm-components.yaml, there are <TAB> chars used instead of spaces.

→ Maybe we want to add some kind of strings.TrimSpace(...) to the image vector overwrite inserted?

{{- end }}
{{- if .imageVectorOverwrite }}
imageVectorOverwrite: |
{{ indent 10 .imageVectorOverwrite }}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
{{ indent 10 .imageVectorOverwrite }}
{{ indent 10 .imageVectorOverwrite }}

Comment on lines +72 to +77
if cv.ImageVectorOverwrite != "" {
m["imageVectorOverwrite"] = cv.ImageVectorOverwrite
}
if cv.ComponentImageVectorOverwrites != "" {
m["componentImageVectorOverwrites"] = cv.ComponentImageVectorOverwrites
}
Copy link
Member

Choose a reason for hiding this comment

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

W.r.t. my previous comment: Maybe some pruning is required here?
Reproducibility of the indentation issues pointed out earlier would be nice though.

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

Labels

area/control-plane Control plane related cla: yes Indicates the PR's author has signed the cla-assistant.io CLA. kind/enhancement Enhancement, improvement, extension needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generate Image Vectors

3 participants