-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: Vendir schema support #427
base: main
Are you sure you want to change the base?
Conversation
WalkthroughNew YAML configuration and schema files introduce a flexible, prototype-based approach for vendir dependency management. The changes restructure configurations from a singular application definition to an array of prototypes with detailed validations and attributes. A new helper function, Changes
Sequence Diagram(s)sequenceDiagram
participant S as Syncer
participant FS as FileSystem
participant YTT as YTTFiles Collector
S->>FS: Check if baseDir exists (PrototypesDir/_vendir)
FS-->>S: Return existence status or error
alt baseDir exists
S->>YTT: Append baseDir to YTT files list
else Error
S->>S: Return error
end
sequenceDiagram
participant Caller as Template Processor
participant PF as pathForKind Function
participant Data as Prototype Data Source
Caller->>PF: Invoke pathForKind(kind, name)
alt kind equals "helm"
PF-->>Caller: Return helm-specific path
else
PF-->>Caller: Return generic path based on name
end
Poem
Tip ⚡🧪 Multi-step agentic review comment chat (experimental)
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (4)
⏰ Context from checks skipped due to timeout of 90000ms (2)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (7)
examples/default/prototypes/_vendir/base.ytt.yaml (1)
11-35
: Flexible vendir configuration template with minor formatting issuesThe template effectively iterates through prototypes and generates appropriate vendir configurations based on repository type. The conditional inclusion of fields like
lazy
,newRootPath
, andincludePaths
provides good flexibility.Two minor formatting issues to fix:
- Line 19: Indentation - adjust from 4 spaces to 2 spaces for better YAML consistency
- Line 35: Add a newline character at the end of file
contents: - - path: . + - path: . #@ if/end src.repo == "git":And add a newline at the end of the file.
🧰 Tools
🪛 YAMLlint (1.35.1)
[warning] 19-19: wrong indentation: expected 2 but found 4
(indentation)
[error] 35-35: no new line character at the end of file
(new-line-at-end-of-file)
internal/myks/assets/prototypes/_vendir/base.ytt.yaml (2)
19-19
: YAML indentation warning from YAMLlint.
YAMLlint reports a wrong indentation at this line: expected 2 spaces but found 4. Please verify and adjust the indentation for the list item undercontents
to ensure that the rendered YAML conforms to YAML standards.🧰 Tools
🪛 YAMLlint (1.35.1)
[warning] 19-19: wrong indentation: expected 2 but found 4
(indentation)
35-35
: Missing newline at the end of file.
Please add a newline at the end of the file to adhere to YAML best practices and avoid tooling warnings.🧰 Tools
🪛 YAMLlint (1.35.1)
[error] 35-35: no new line character at the end of file
(new-line-at-end-of-file)
internal/myks/assets/prototypes/_vendir/data-schema.ytt.yaml (1)
11-12
: Typographical error in schema title.
The schema title "Protoytpe kind" appears to be misspelled. It should be corrected to "Prototype kind" to maintain clarity and professionalism in the documentation.examples/default/prototypes/_vendir/data-schema.ytt.yaml (3)
6-10
: Prototypes List and Name Field:
The keyprototypes
is appropriately established as a list container for vendored applications. Thename
field includes a minimum-length validation (min_len=1
), ensuring each entry will have a meaningful identifier. Consider providing a sample default value (or an example comment) to guide users, though leaving it blank may be intentional for user input.
11-14
: Typographical Correction in Kind Field:
The title on line 11 contains a typographical error ("Protoytpe kind"). Please update it to "Prototype kind" for clarity and professionalism.
26-29
: Version Field Requirements:
Theversion
field includes a validation to enforce a non-empty string. Consider including a sample version (for example,"1.0.0"
) in the documentation or in a comment to guide users on the expected format.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (15)
examples/default/prototypes/_vendir/base.ytt.yaml
(1 hunks)examples/default/prototypes/_vendir/data-schema.ytt.yaml
(1 hunks)examples/default/prototypes/argocd/vendir/base.ytt.yaml
(0 hunks)examples/default/prototypes/argocd/vendir/vendir-data.ytt.yaml
(1 hunks)examples/default/prototypes/goldpinger/vendir/base.yaml
(0 hunks)examples/default/prototypes/goldpinger/vendir/vendir-data.ytt.yaml
(1 hunks)examples/default/prototypes/httpbingo/vendir/base.ytt.yaml
(0 hunks)examples/default/prototypes/httpbingo/vendir/vendir-data.ytt.yaml
(1 hunks)internal/myks/assets/prototypes/_vendir/base.ytt.yaml
(1 hunks)internal/myks/assets/prototypes/_vendir/data-schema.ytt.yaml
(1 hunks)internal/myks/assets/prototypes/argocd/vendir/base.ytt.yaml
(0 hunks)internal/myks/assets/prototypes/argocd/vendir/vendir-data.ytt.yaml
(1 hunks)internal/myks/assets/prototypes/httpbingo/vendir/base.ytt.yaml
(0 hunks)internal/myks/assets/prototypes/httpbingo/vendir/vendir-data.ytt.yaml
(1 hunks)internal/myks/sync_vendir.go
(1 hunks)
💤 Files with no reviewable changes (5)
- internal/myks/assets/prototypes/argocd/vendir/base.ytt.yaml
- examples/default/prototypes/goldpinger/vendir/base.yaml
- internal/myks/assets/prototypes/httpbingo/vendir/base.ytt.yaml
- examples/default/prototypes/httpbingo/vendir/base.ytt.yaml
- examples/default/prototypes/argocd/vendir/base.ytt.yaml
🧰 Additional context used
🪛 YAMLlint (1.35.1)
examples/default/prototypes/_vendir/base.ytt.yaml
[warning] 19-19: wrong indentation: expected 2 but found 4
(indentation)
[error] 35-35: no new line character at the end of file
(new-line-at-end-of-file)
internal/myks/assets/prototypes/_vendir/base.ytt.yaml
[warning] 19-19: wrong indentation: expected 2 but found 4
(indentation)
[error] 35-35: no new line character at the end of file
(new-line-at-end-of-file)
🔇 Additional comments (16)
internal/myks/sync_vendir.go (1)
64-69
: LGTM: Properly implemented directory search for _vendirThe implementation correctly adds the new
_vendir
directory to the vendir configuration search path, aligning with the PR's objective. The code follows good practices by:
- Checking for directory existence with proper error handling
- Following the established pattern of building the
yttFiles
sliceinternal/myks/assets/prototypes/httpbingo/vendir/vendir-data.ytt.yaml (1)
1-9
: Schema structure updated to use prototypes arrayThe change from an
application
object to aprototypes
array correctly implements the new schema structure, providing better support for multiple prototype configurations.examples/default/prototypes/_vendir/base.ytt.yaml (1)
3-9
: Well-designed helper function for path generationThe
pathForKind
function elegantly determines the appropriate path based on the resource kind, which simplifies the configuration structure and improves maintainability.examples/default/prototypes/httpbingo/vendir/vendir-data.ytt.yaml (1)
1-9
: Schema structure updated to match new prototypes array formatThe change from an
application
object to aprototypes
array correctly implements the new schema structure, providing consistency with the other configuration files in this PR.internal/myks/assets/prototypes/_vendir/base.ytt.yaml (2)
3-9
: Clear implementation ofpathForKind
function.
The function cleanly distinguishes between helm resources (which are routed under"charts/"
) and other resource types. The logic is straightforward and easy to follow.
16-20
: Dynamic directory generation with conditional resource blocks.
The loop correctly iterates overprotos
and generates directory entries, conditionally including Git or Helm chart configurations based on the value ofsrc.repo
. Please verify that the inline conditional syntax (#@ if/end ...
) renders as expected in ytt.🧰 Tools
🪛 YAMLlint (1.35.1)
[warning] 19-19: wrong indentation: expected 2 but found 4
(indentation)
internal/myks/assets/prototypes/argocd/vendir/vendir-data.ytt.yaml (1)
1-11
: Argo CD prototype configuration is well-structured.
The new structure underprototypes
correctly defines all required attributes (name, kind, repo, URL, version, includePaths, newRootPath) for the Argo CD vendir configuration. This update aligns with the enhanced vendir schema design.internal/myks/assets/prototypes/_vendir/data-schema.ytt.yaml (1)
1-37
: Comprehensive vendir application schema defined.
The schema thoroughly validates and documents each field required for vendored applications. This detailed specification (including validations such asmin_len
andone_of
constraints) will help enforce consistency across configurations.examples/default/prototypes/argocd/vendir/vendir-data.ytt.yaml (1)
1-11
: Argo CD vendir data configuration updated successfully.
The file now leverages the new#@data/values
declaration with theprototypes
key, reflecting the intended restructuring. All required prototype attributes are present and correctly defined.examples/default/prototypes/goldpinger/vendir/vendir-data.ytt.yaml (1)
1-16
: Goldpinger vendir data configuration is updated and well-organized.
The configuration now supports multiple prototypes. The first prototype (goldpinger) is defined withhelm
andhelmChart
settings, while the newly introduced prototype (grafana-dashboards) follows aytt
configuration pattern. This modular structure aligns perfectly with the PR objectives of supporting a flexible vendir schema.examples/default/prototypes/_vendir/data-schema.ytt.yaml (6)
1-5
: Schema Metadata and Overlay Definition:
The metadata annotations (e.g.,#@data/values-schema
, title, and description) along with the overlay setting are correctly defined. They clearly document the purpose of the file and set the foundation for schema validation.
15-18
: Repository Type Field Definition:
Therepo
field is well-defined with clear validation restricting the value to either"git"
or"helmChart"
. The description effectively explains its purpose.
19-22
: URL Field Validation:
Theurl
field is mandated to be a non-empty string, with a proper description covering both git repositories and helm charts. This clear validation ensures that every entry will contain a valid source URL.
23-25
: Lazy Vendoring Field:
The boolean fieldlazy
is correctly configured with a default value oftrue
, aligning with the intention of on-demand vendoring.
30-32
: New Root Path Specification:
ThenewRootPath
field is clearly described and correctly positioned for defining the root directory within a git repository. The empty string default is acceptable if the field is meant to be user-configurable.
33-36
: Include Paths Field Setup:
TheincludePaths
field is implemented as a list with a default entry ofincludes.yaml
. This setup ensures that the necessary include file is referenced by default, which aligns with the intended vendir configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice!
I was thinking about something like this for my big project just last week. I thought to implement a library function and some simplified schema for vendir sources in the envs/env-data.vendir.yaml
or similar.
I like your approach more. However, I think we should change the schema a little bit. Since #422, vendir is invoked with the main ytt schema (giving you access to the current environment and application data values), so the schema in _vendir
should extend the main one.
Here is one option:
#! This configuration is applied to the current prototype
#! and can be set in any data/values file.
prototype:
#! Nest sources under the vendir key to be able to add
#! more vendir configuration in the future. (questionable)
vendir:
sources:
- #! source definition
This looks a little too nested. Here is another option:
prototype:
sources:
- #! source definition
vendir: {} #! if we need to configure vendir at some point, can be omitted for now.
The prototype
key can be also shortened to just proto
.
Adds
prototypes/_vendir
to the search list for rendering the vendir config for prototypes.This allows adding a schema and a default generator.
Additionally I updated the default example and assets to show how this feature can be used.
It's an opt in feature. The old way, with base and data in prototype/vendir still works.
Summary by CodeRabbit
New Features
Bug Fixes
Refactor