Skip to content

fix: various cli fixes on transfer and construction behavior#1807

Merged
jakobmoellerdev merged 8 commits into
open-component-model:mainfrom
jakobmoellerdev:expansion-constructor
Feb 20, 2026
Merged

fix: various cli fixes on transfer and construction behavior#1807
jakobmoellerdev merged 8 commits into
open-component-model:mainfrom
jakobmoellerdev:expansion-constructor

Conversation

@jakobmoellerdev

@jakobmoellerdev jakobmoellerdev commented Feb 19, 2026

Copy link
Copy Markdown
Member

What this PR does / why we need it

  • It fixes a resource leak by ensuring the stream used to read a component constructor is always closed, and it adds environment-variable expansion so constructor content can be parameterized at runtime.
  • It reduces normal log noise by downgrading “transformation started/completed” messages from info to debug in the progress output.
  • It makes credential lookup more tolerant by treating “credentials not found” as a non-fatal case when resolving optional credentials during resource download.
  • It adjusts a resource download success message to be logged via defer, preventing “success” from being printed before later work can still fail.
  • It improves OCI/CTF transformation handling by instantiating repository objects based on the destination type and selecting the correct upload transformation (with clearer errors for unsupported types).

Which issue(s) this PR fixes

part of my sovereign scenario testing (open-component-model/ocm-project#842)

…sitories

#### What this commit does
- Implemented repository type-specific logic for handling resource transformations.
- Introduced a check to instantiate repository objects based on the `toSpec.GetType()` dynamically.
- Updated `ociUploadAsArtifact` and `ociUploadAsLocalResource` transformations to correctly handle both OCI and CTF repository types.
- Added error handling for unsupported repository types for better robustness.

#### Why this is needed
This change ensures resource transformations can dynamically adapt to the repository type, providing greater flexibility and extensibility for handling both OCI and CTF repository schemes in component versions. Fixes edge cases where incorrect repository handling could occur.

Signed-off-by: Jakob Möller <jakob.moeller@sap.com>
### What this commit does
- Updated the resource download logging statement to use a `defer` construct for consistent logging behavior, ensuring it executes after all operations complete.

### Why this is needed
This change ensures better readability and avoids premature logging of success before all related operations and error checks have concluded.

Signed-off-by: Jakob Möller <jakob.moeller@sap.com>
### What this commit does
- Added handling for `credentials.ErrNotFound` during credential resolution to prevent unnecessary errors when credentials are missing but non-critical.
- Introduced the `errors` package to enable error comparison for better accuracy.

### Why this is needed
This change ensures the CLI behaves gracefully when certain credentials are not required, improving overall robustness and user experience.

Signed-off-by: Jakob Möller <jakob.moeller@sap.com>
### What this commit does
- Replaced references to `OCM_CONFIG_PATH` with `OCM_CONFIG` across all CLI documentation files for consistency.
- Updated the `RegisterConfigFlag` function and associated CLI configuration documentation.

### Why this is needed
This change reflects the correct environment variable name (`OCM_CONFIG`) and avoids confusion in configuration flag usage. Aligns documentation with the current implementation.

Signed-off-by: Jakob Möller <jakob.moeller@sap.com>
…ualizer

### What this commit does
- Updated log levels for "transformation started" and "transformation completed" events in `simpleVisualizer` from `Info` to `Debug`.

### Why this is needed
This change reduces unnecessary log noise during normal CLI operation by aligning the log levels to better reflect the intended granularity, improving the developer debugging experience.

Signed-off-by: Jakob Möller <jakob.moeller@sap.com>
### What this commit does
- Added a `defer` statement to close the `constructorStream` after it is opened, preventing potential file descriptor leaks.
- Expanded the constructor data with environment variable substitution using `os.Expand`.

### Why this is needed
This change ensures that file handles are properly closed, improving resource management and preventing system issues caused by unclosed streams. It also enhances component constructor functionality by substituting environment variables, adding flexibility for runtime configurations.

Signed-off-by: Jakob Möller <jakob.moeller@sap.com>
@jakobmoellerdev jakobmoellerdev requested a review from a team as a code owner February 19, 2026 16:34
Comment thread cli/cmd/add/component-version/cmd.go
piotrjanik
piotrjanik previously approved these changes Feb 19, 2026
frewilhelm
frewilhelm previously approved these changes Feb 20, 2026

@frewilhelm frewilhelm left a comment

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.

lgtm

matthiasbruns
matthiasbruns previously approved these changes Feb 20, 2026
@github-actions github-actions Bot added area/documentation Documentation related size/m Medium labels Feb 20, 2026
… constructor files

### What this commit does
- Introduced environment variable substitution in component constructor files using `${VAR_NAME}` or `$VAR_NAME` syntax.
- Updated processing logic to expand environment variables during file reading.
- Extended CLI documentation to include examples and use cases for environment variable substitution.
- Added explanation of dynamic configuration scenarios in relevant ADR and reference documentation.

### Why this is needed
This change enhances flexibility by enabling dynamic configuration of component constructor files. It supports use cases like CI/CD pipeline integrations, registry-specific configurations, and runtime-dependent metadata injection.

Signed-off-by: Jakob Möller <jakob.moeller@sap.com>
@github-actions github-actions Bot added the component/github-actions Changes on GitHub Actions or within `.github/` directory label Feb 20, 2026
@jakobmoellerdev jakobmoellerdev enabled auto-merge (squash) February 20, 2026 09:05
@jakobmoellerdev jakobmoellerdev merged commit eaddbf3 into open-component-model:main Feb 20, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/documentation Documentation related component/github-actions Changes on GitHub Actions or within `.github/` directory kind/bugfix Bug size/m Medium size/s Small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants