Skip to content

generate csv: move manifest collector to its own package#3064

Merged
estroz merged 1 commit intooperator-framework:masterfrom
estroz:refactor/move-csv-collector
May 19, 2020
Merged

generate csv: move manifest collector to its own package#3064
estroz merged 1 commit intooperator-framework:masterfrom
estroz:refactor/move-csv-collector

Conversation

@estroz
Copy link
Copy Markdown
Member

@estroz estroz commented May 18, 2020

Description of the change:

  • internal/generate/collector: refactor manifestCollection here and export as Manifests, but not apply* methods which will stay in CSV package
  • internal/generate/olm-catalog: use collector.Manifests

Motivation for the change: separates input to the CSV/bundle generator from generation itself. Required by #2860

/cc @hasbro17 @camilamacedo86

@estroz
Copy link
Copy Markdown
Member Author

estroz commented May 18, 2020

There are ways the collector package can be improved upon/generalized, but we do not need to do those things just yet since this is an internal package and currently has a specific use case.

export as Manifests, but not apply* methods which will stay in CSV
package

internal/generate/olm-catalog: use collector.Manifests
@estroz estroz force-pushed the refactor/move-csv-collector branch from c5761c9 to 0724a9b Compare May 18, 2020 20:38

// ApplyTo applies relevant manifests in c to csv, sorts the applied updates,
// and validates the result.
func ApplyTo(c *collector.Manifests, csv *operatorsv1alpha1.ClusterServiceVersion) error {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Everything in this file was copied from here.

)

// Manifests holds a collector of all manifests relevant to CSV updates.
type Manifests struct {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Everything in this package was copied from here.

Copy link
Copy Markdown
Contributor

@hasbro17 hasbro17 left a comment

Choose a reason for hiding this comment

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

LGTM

// hashContents creates a sha256 md5 digest of b's bytes.
func hashContents(b []byte) string {
h := sha256.New()
_, _ = h.Write(b)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: I realize this is just copying over but maybe we should log the error at the very least.
So perhaps a TODO for this.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This will never return an error (looking at the implementation) but if std changes it may. I will follow up with an error check.

@estroz estroz merged commit 8a8e2b1 into operator-framework:master May 19, 2020
@estroz estroz deleted the refactor/move-csv-collector branch May 19, 2020 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants