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

internal/scaffold/olm-catalog: populate CSV customresourcedefinitions from Go type annotations #1162

Merged

Conversation

estroz
Copy link
Member

@estroz estroz commented Mar 1, 2019

Description of the change: use doc and code comments on CR types to populate customresourcedefinitions.owned fields except for actionDescriptors, which will be persisted to the new CSV.

Motivation for the change: see #1132

Closes #1132

@estroz estroz added kind/feature Categorizes issue or PR as related to a new feature. olm-integration Issue relates to the OLM integration labels Mar 1, 2019
@openshift-ci-robot openshift-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 1, 2019
@estroz estroz changed the title [WIP] pkg/scaffold/olm-catalog: generate CSV manifest {spec,status}Descriptors from *_types.go files pkg/scaffold/olm-catalog: generate CSV manifest {spec,status}Descriptors from *_types.go files Mar 4, 2019
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 4, 2019
@joelanford
Copy link
Member

@estroz I noticed that when we updated our dependencies, we had to update crd_test.go to include field descriptions that were populated by the updated CRD generator.

Not sure if that's related to this, but it sounded similar. Can any of those updates be used to simplify this PR?

@estroz
Copy link
Member Author

estroz commented Mar 22, 2019

Looks like there were changes made upstream in the CRD generator to add validation field descriptions. Unfortunately for x-descriptors and path we'd still need to partse *_types.go files using the method in this PR. If we only wanted to add a description we could use CRD manifests alone.

lilic
lilic previously requested changes Mar 25, 2019
Copy link
Member

@lilic lilic left a comment

Choose a reason for hiding this comment

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

I have some concerns that users most of the time don't have detailed enough code comments to make this work all the time. Could we make this optional or warn that it's done on a best effort bases.

Agree about the logging vs overriding part, especially if the guess is not good enough for most use cases.

@estroz
Copy link
Member Author

estroz commented Mar 25, 2019

@lilic in the docs I'll address the fact that code comments will be used as descriptions. The controller-tools CRD generator uses them already.

@estroz estroz requested a review from lilic April 8, 2019 21:43
@estroz
Copy link
Member Author

estroz commented Apr 11, 2019

@joelanford I think I'm going to switch to a parser like gengo instead of writing my own. I should still be able to get all the info I need from parsed data.

@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 21, 2019
Copy link
Contributor

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

Fantastic! 👍
All working now. It is /lgtm /approved for me.

@camilamacedo86 camilamacedo86 added approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. labels Nov 21, 2019
@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-ci-robot
Copy link

New changes are detected. LGTM label has been removed.

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Nov 21, 2019
Comment on lines +225 to +227
if len(name) == 0 {
return true
}
Copy link
Member

Choose a reason for hiding this comment

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

Does an embedded struct (that would otherwise be inlined) have a name?

For example:

type EmbeddedPublic struct {
	Public string `json:"public"`
}

type embeddedPrivate struct {
	Private string `json:"private"`
}

type Parent struct {
	EmbeddedPublic
	embeddedPrivate
}

In this case, the marshaled JSON would include both "public" and "private" fields in the output.

Copy link
Member Author

@estroz estroz Dec 2, 2019

Choose a reason for hiding this comment

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

The embedded struct name will always be its type name. We should include an embedded struct's fields regardless if that's how the JSON Marshaller does it:

if member.Embedded {
	return inlinedTag, nil
}
if isNotExported(member.Name) {
	return ignoredTag, nil
}

Copy link
Member

@joelanford joelanford left a comment

Choose a reason for hiding this comment

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

LGTM once sanity test failures are resolved.

@estroz estroz force-pushed the csv-customresourcedefinitions branch from 075c236 to 241f71a Compare December 4, 2019 06:01
@estroz estroz changed the title pkg/scaffold/olm-catalog: generate CSV manifest customresourcedefinitions from Go API files internal/scaffold/olm-catalog: populate CSV customresourcedefinitions from Go type annotations Dec 4, 2019
@estroz estroz merged commit e598f60 into operator-framework:master Dec 4, 2019
@estroz estroz deleted the csv-customresourcedefinitions branch December 4, 2019 06:29
@@ -0,0 +1,195 @@
# Code Annotations for Cluster Service Versions
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @estroz,

We forget to add the changelog entry over this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/feature Categorizes issue or PR as related to a new feature. olm-integration Issue relates to the OLM integration size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Populate CSV spec and status descriptors from types.go
7 participants