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

Support different versions per instance of a component #559

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

simu
Copy link
Member

@simu simu commented Jul 19, 2022

This PR changes Commodore to

  • Create separate worktrees for each component alias
  • Create class symlinks for each component alias
  • Create each alias target with only the defaults and component class symlinked from the alias worktree
  • Read instance versions from parameters.components.<instance-name>

Note that per-instance versions only work correctly only for components which use ${_base_directory} in their config when specifying Jsonnet files or Helm chart/YAML locations in kapitan.compile and kapitan.dependencies. Note, that components should use ${_base_directory} anyway, and new components created from the template use ${_base_directory} out of the box.

TODO:

  • Implement support for overriding the URL or path for individual component instances
  • Test cases which cover new features

Resolves #563

Checklist

  • Keep pull requests small so they can be easily reviewed.
  • Update the documentation.
  • Update tests.
  • Categorize the PR by setting a good title and adding one of the labels:
    bug, enhancement, documentation, change, breaking, dependency
    as they show up in the changelog

@simu simu changed the title Suppor different versions per instance of a component Support different versions per instance of a component Jul 19, 2022
@simu simu added the enhancement New feature or request label Jul 19, 2022
simu added 2 commits July 19, 2022 17:00
Recent pylint (or Python+pylint) versions can deal with `Optional[str]`
and similar type annotations without requiring the pylint annotation
`# pylint: disable=unsubscriptable-object`.
Implemented:
* Create separate worktrees for each component alias
* Create class symlinks for each component alias
* Create each alias target with only the defaults and component class
  for the alias worktree
* Works only for components which use `${_base_directory}` in their
  config (kapitan.compile and kapitan.dependencies mainly)

TODO:
* Actually allow users to specify version for each alias separately
* Cleanup changes
* Add tests
* Update docs
@simu simu force-pushed the feat/per-alias-versions branch from cd837a7 to 7322392 Compare July 19, 2022 15:00
simu added 3 commits July 19, 2022 17:04
We add support for specifying instance versions in
`parameters.components`. Commodore falls back to the version/url/path
specified for the component when the keys are not provided for component
aliases.

Note that the actual dependency handling doesn't yet support overriding
URL/path for aliases.
- Fix compile tests by falling back to old component path if no
  dependencies object is present
- Fix git tree tests by allowing dependency repos with no Author
  information on components
- Fix using the correct path for rendering aliased targets
@HappyTetrahedron HappyTetrahedron force-pushed the feat/per-alias-versions branch from 0e6e4cd to a588aea Compare January 8, 2025 09:28
@HappyTetrahedron HappyTetrahedron requested a review from a team January 21, 2025 19:19
@simu simu marked this pull request as ready for review January 22, 2025 15:16
@simu simu requested a review from a team as a code owner January 22, 2025 15:16
commodore/config.py Outdated Show resolved Hide resolved
commodore/dependency_mgmt/__init__.py Outdated Show resolved Hide resolved
commodore/dependency_mgmt/version_parsing.py Outdated Show resolved Hide resolved
commodore/component/__init__.py Outdated Show resolved Hide resolved
commodore/dependency_mgmt/__init__.py Outdated Show resolved Hide resolved
tests/test_component.py Outdated Show resolved Hide resolved
Comment on lines 210 to +214
for c in sorted(components):
if inv.defaults_file(c).is_file():
classes.append(f"defaults.{c}")
defaults_file = inv.defaults_file(c)
if c == component and target != component:
# Special case alias defaults symlink
defaults_file = inv.defaults_file(target)
Copy link
Member Author

Choose a reason for hiding this comment

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

We've not really thought about this in the design doc, but this snippet makes the implicit decision to only provide the class/defaults.yml of the unaliased instance of other components to each component instance.

This is probably fine for the same reasons as it's fine to only provide the unaliased component library, since I can't really imagine a sensible usecase where a component would want to read configuration from multiple instances of another component.

commodore/dependency_mgmt/__init__.py Outdated Show resolved Hide resolved
commodore/dependency_mgmt/__init__.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow users to specify different versions for different instances of the same component
2 participants