Skip to content

cmd/operator-sdk/olmcatalog/gen-csv.go: --write-config to write CSV config to disk #1346

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

Closed

Conversation

estroz
Copy link
Member

@estroz estroz commented Apr 25, 2019

Description of the change:
internal/pkg/scaffold/olm-catalog: Use a CSVConfigFile in a CSV scaffold directly instead of reading from a file. CSVConfig is now a scaffold that contains a CSVConfigFile with the actual data to write.

cmd/operator-sdk/olmcatalog/gen-csv.go: Add --write-csv-config flag to both olm-catalog and olm-catalog gen-csv so users can write a CSV config to a default path or the one passed to --write-csv-config.

Motivation for the change: #1259 does not directly pertain to the changes here but brought to my attention that CSV config files are not well understood. --write-config should help because it creates a default config with all fields populated.

@estroz estroz added kind/feature Categorizes issue or PR as related to a new feature. olm-integration Issue relates to the OLM integration labels Apr 25, 2019
@openshift-ci-robot openshift-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 25, 2019
@estroz estroz changed the title Csv config optional crdsdir cmd/operator-sdk/olmcatalog/gen-csv.go: --write-config to write CSV config to disk Apr 25, 2019
@estroz estroz force-pushed the csv-config-optional-crdsdir branch from b531638 to bf49c18 Compare April 25, 2019 01:19
@estroz
Copy link
Member Author

estroz commented Apr 25, 2019

/retest

@estroz
Copy link
Member Author

estroz commented Apr 25, 2019

After thinking about this further, its probably better to have a olm-catalog write-csv-config <path> command or olm-catalog --write-csv-config=<path> so a user doesn't have to (re)write their CSV just to get a config.

estroz added 4 commits April 26, 2019 12:49
scaffold directly instead of reading from a file. CSVConfig is now
a scaffold-able file.

cmd/operator-sdk/olmcatalog: add the --write-csv-config flag so
users can write a default CSV config to a default or custom path
@estroz estroz force-pushed the csv-config-optional-crdsdir branch from 1a8a666 to b677bd5 Compare April 26, 2019 19:52
@estroz
Copy link
Member Author

estroz commented May 3, 2019

/hold

Going to wait on this until we figure out configuration file issues.

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 3, 2019
@openshift-ci-robot
Copy link

@estroz: PR needs rebase.

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/test-infra repository.

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 12, 2019
@openshift-ci-robot
Copy link

@estroz: The following tests failed, say /retest to rerun them all:

Test name Commit Details Rerun command
ci/prow/images b677bd5 link /test images
ci/prow/e2e-aws-ansible b677bd5 link /test e2e-aws-ansible
ci/prow/e2e-aws-helm b677bd5 link /test e2e-aws-helm
ci/prow/e2e-aws-go b677bd5 link /test e2e-aws-go
ci/prow/e2e-aws-subcommand b677bd5 link /test e2e-aws-subcommand

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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/test-infra repository. I understand the commands that are listed here.

@openshift-bot
Copy link

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci-robot openshift-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 7, 2019
@camilamacedo86
Copy link
Contributor

/remove-lifecycle

@@ -56,18 +57,18 @@ Configure CSV generation by writing a config file 'deploy/olm-catalog/csv-config
genCSVCmd.Flags().StringVar(&csvVersion, "csv-version", "", "Semantic version of the CSV")
genCSVCmd.MarkFlagRequired("csv-version")
genCSVCmd.Flags().StringVar(&fromVersion, "from-version", "", "Semantic version of an existing CSV to use as a base")
genCSVCmd.Flags().StringVar(&csvConfigPath, "csv-config", "", "Path to CSV config file. Defaults to deploy/olm-catalog/csv-config.yaml")
genCSVCmd.Flags().StringVar(&csvConfigPath, "csv-config", "", "Path to CSV config file. If unset, default file paths are used")
Copy link
Contributor

Choose a reason for hiding this comment

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

I think is good to keep the default path in the info.

"github.com/spf13/cobra"
)

var (
writeCSVConfigOpt = "write-csv-config"

Copy link
Contributor

Choose a reason for hiding this comment

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

space

Comment on lines +46 to +49
i, err := (&catalog.CSVConfig{}).GetInput()
if err != nil {
log.Fatalf("Error retrieving CSV config path: %v", err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Could not the path be an attribute of the struct and the check be made in the Validate func of it?

return err
}
}
return nil
Copy link
Contributor

@camilamacedo86 camilamacedo86 Nov 19, 2019

Choose a reason for hiding this comment

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

Is it creating a new input.Config? Could not it be a NewConfig in its struct, or at least has a more meaningful name?

}
return nil
}
func writeConfig(s *scaffold.Scaffold, cfg *input.Config) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
func writeConfig(s *scaffold.Scaffold, cfg *input.Config) error {
func writeCSVConfig(s *scaffold.Scaffold, cfg *input.Config) error {

} else {
log.Info("Using default CSV config.")
csvCfgFile = &catalog.CSVConfigFile{}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

could not it be improved?
By default, the default CSVFile be set then if do not find it or the customized one return an error?
Could not the logic be when the new struct is created?

@estroz estroz closed this Nov 21, 2019
@estroz estroz deleted the csv-config-optional-crdsdir branch April 1, 2020 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. kind/feature Categorizes issue or PR as related to a new feature. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. olm-integration Issue relates to the OLM integration size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants