Skip to content

Commit 711c843

Browse files
Eric Stroczynskijmrodri
authored andcommitted
doc/proposals/improve-csv-cli.md: 'gen-csv --inputs' proposal (#2279)
1 parent 8f827d1 commit 711c843

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed

doc/proposals/improve-csv-cli.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
---
2+
title: Improve `gen-csv` CLI
3+
authors:
4+
- "@estroz"
5+
reviewers:
6+
- "@joelanford"
7+
- "@dmesser"
8+
- "@robszumski"
9+
approvers:
10+
- "@joelanford"
11+
- "@dmesser"
12+
- "@robszumski"
13+
creation-date: 2019-11-27
14+
last-updated: 2019-11-27
15+
status: implementable
16+
see-also:
17+
- "doc/user/olm-catalog/generating-a-csv.md"
18+
---
19+
20+
# Improve `gen-csv` CLI
21+
22+
## Release Signoff Checklist
23+
24+
- \[x\] Enhancement is `implementable`
25+
- \[ \] Design details are appropriately documented from clear requirements
26+
- \[ \] Test plan is defined
27+
- \[ \] Graduation criteria for dev preview, tech preview, GA
28+
- \[ \] User-facing documentation is created in [operator-sdk/doc][operator-sdk-doc]
29+
30+
## Summary
31+
32+
The ClusterServiceVersion (CSV) generator's entry point, `operator-sdk olm-catalog gen-csv`, currently uses a configuration file that points to several files required to generate a CSV manifest from an Operator project. This config was intended to allow Operators either of high complexity or a non-standard project structure to generate CSV manifests. The config file path can be passed to `gen-csv` with `--csv-config=<path>`.
33+
34+
## Motivation
35+
36+
The CSV manifest format is currently in `v1alpha1`, indicating that fields may be added, modified, or removed until stabilization. Perhaps certain SDK files are no longer or new files are required after a manifest format change. This implies that the config format will also change, so it must maintained by SDK authors and updated by SDK users when switching versions.
37+
38+
Another issue crops up when updating existing CSV manifests generated with a different set of Operator manifests. Say I have an existing CSV `my-operator.v0.1.0` that contains legacy Deployment and Role manifests (the project has released `v1.0.0` recently, and the current Deployment and Role will not work with Operator `0.1.0`). However this CSV manifest must be maintained because downstream users are still using version `0.1.0` of the Operator. This scenario requires the operator maintainer to do one of two things:
39+
40+
- Update the CSV config just for this update, such that `operator-path` and `role-paths` point to the legacy Deployment and Role manifest files, respectively. They would then revert those changes once the update is complete.
41+
- Maintain a legacy config for `my-operator.v0.1.0` such that the current config does not need to be updated when updating legacy CSV manifests.
42+
43+
Neither option is desirable. The first option is messy; config files should not have to be modified ad-hoc. The second option implies N configs for N Operator versions in the limit, which is not scalable. Plus each config would have to be modified when upgrading SDK versions if the config format changes, or use old SDK versions to update legacy CSV manifests.
44+
45+
In summary: a config file for CSV manifest generation is too heavy-handed, since it may change often in the future, only configures one `operator-sdk` generator, and adds overhead when migrating to new SDK versions. This file should be replaced by a streamlined CLI approach, which this document details.
46+
47+
## Goals
48+
49+
- I should be able to create/update a CSV manifest from a complex Operator SDK-based project structure.
50+
- I should be able to create/update a CSV manifest from a non-standard Operator project structure.
51+
- I should be able to configure CSV manifest generation for non-Go Operator projects (when this feature is implemented).
52+
- I should not have to rely on on-disk configuration to create/update a CSV manifest.
53+
54+
### Non-Goals
55+
56+
- Reduce the ability to configure the CSV manifest generator.
57+
- Implement CSV manifest generation for non-Go Operator projects.
58+
59+
## Proposal
60+
61+
### Implementation Details/Notes/Constraints
62+
63+
`--inputs` will take a list of patterns, which will be matched against files in the Operator project using [`strings.HasPrefix()`](https://golang.org/pkg/strings/#HasPrefix).
64+
- The default path for Go projects, if `--inputs` is not set, will be `deploy/`. This emulates current behavior.
65+
- An error is returned if no matches are found for a pattern in the list.
66+
- Future non-Go CSV generators can use `--inputs` easily, with new/additional defaults set by individual generators.
67+
68+
### Risks and Mitigations
69+
70+
- Removing `--csv-config` will break existing users that have complex Operator SDK-based or non-standard Operator project structures. A version upgrade guide section is required to migrate these users.
71+
72+
## Design Details
73+
74+
A general CLI option `--inputs` to configure the CSV generator handles either situation described above without changes required in future Operator SDK versions.
75+
76+
The `--inputs` option takes a list of patterns to include in the generation process. For example:
77+
78+
```
79+
$ operator-sdk olm-catalog gen-csv --csv-version 0.1.0 --inputs config,deploy/legacy/operator.yaml,deploy/legacy/role.yaml
80+
```
81+
82+
would pass all files in the `config/` dir, `deploy/legacy/operator.yaml`, and `deploy/legacy/role.yaml` to the CSV generator and update the legacy `0.1.0` CSV manifest.
83+
84+
### Test Plan
85+
86+
Unit tests will be implemented for scenarios described above.
87+
88+
##### Removing a deprecated feature
89+
90+
- `--csv-config` and all related code will be removed.
91+
92+
### Upgrade / Downgrade Strategy
93+
94+
- There will be a version upgrade guide section dedicated to transitioning users to the new CLI.
95+
96+
## Alternatives
97+
98+
- An `--exclude` flag to which a list of patterns that should be excluded from CSV generation is passed.
99+
- This alternative would not easily support non-standard Operator project structures.
100+
101+
[operator-sdk-doc]: ../../doc

0 commit comments

Comments
 (0)