Skip to content

allow creating a new operator based off a previous operator#3699

Merged
radTuti merged 9 commits intotigera:masterfrom
radTuti:operator-from
Jan 24, 2025
Merged

allow creating a new operator based off a previous operator#3699
radTuti merged 9 commits intotigera:masterfrom
radTuti:operator-from

Conversation

@radTuti
Copy link
Copy Markdown
Contributor

@radTuti radTuti commented Jan 14, 2025

Description

Allow building an operator image using a previous hashrelease/release as base and changing a few components.

For PR author

  • Tests for change.
  • If changing pkg/apis/, run make gen-files
  • If changing versions, run make gen-versions

For PR reviewers

A note for code reviewers - all pull requests must have the following:

  • Milestone set according to targeted release.
  • Appropriate labels:
    • kind/bug if this is a bugfix.
    • kind/enhancement if this is a a new feature.
    • enterprise if this PR applies to Calico Enterprise only.

Copy link
Copy Markdown
Contributor

@danudey danudey left a comment

Choose a reason for hiding this comment

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

A bit of feedback. I would also request a small README.md with usage examples just to get people up to speed more quickly on how to use the tool and where/when/why.

Comment thread hack/release-from/action.go Outdated
Comment thread hack/release-from/action.go Outdated
Comment thread hack/release-from/action.go
Comment thread hack/release-from/action.go Outdated
Comment thread hack/release-from/action.go Outdated
Comment thread hack/release-from/action.go Outdated
Comment thread hack/release-from/action.go Outdated
Comment thread hack/release-from/action.go Outdated
Comment thread hack/release-from/action.go
Comment thread hack/release-from/utils.go
- support custom registry
- fixes from validating
- modify config files and preserve comments
- update examples in README
Copy link
Copy Markdown
Contributor

@danudey danudey left a comment

Choose a reason for hiding this comment

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

lgtm, no other feedback

Comment thread go.mod Outdated
require (
github.com/corazawaf/coraza-coreruleset v0.0.0-20240226094324-415b1017abdc // indirect
github.com/magefile/mage v1.14.0 // indirect
github.com/corazawaf/coraza-coreruleset v0.0.0-20240226094324-415b1017abdc
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: These 2 require blocks should be merged into the existing ones.

```

> [!IMPORTANT]
> To publish the newly created operator, use the `--publish` flag
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe you can clarify what publish means, from what I understand it is pushing the tag, pushing images + image manifest, but not creating a release in https://github.com/tigera/operator/releases

Comment thread hack/release-from/action.go Outdated
// get root directory of operator git repo
repoRootDir, err := runCommand("git", []string{"rev-parse", "--show-toplevel"}, nil)
if err != nil {
return fmt.Errorf("Error getting git root directory: %s", err)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For golang users such as myself, there are a lot of warnings. Maybe nice to clean up.
https://go.dev/wiki/CodeReviewComments#error-strings

Error Strings
Error strings should not be capitalized (unless beginning with proper nouns or acronyms) or end with > punctuation, since they are usually printed following other context. That is, use fmt.Errorf("something bad") not fmt.Errorf("Something bad"), so that log.Printf("Reading %s: %v", filename, err) formats without a spurious capital letter mid-message. This does not apply to logging, which is implicitly line-oriented and not combined inside other messages.

Comment thread hack/release-from/action.go Outdated
if err := encoder.Encode(&root); err != nil {
return fmt.Errorf("Error encoding updated config: %s", err)
}
encoder.Close()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You are not handling the potential error

Comment thread hack/release-from/flags.go Outdated

var exceptEnterpriseFlag = &cli.StringSliceFlag{
Name: "except-calico-enterprise",
Aliases: []string{"except-enterprise", "except-calient"},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The help for this cli is hard to read. I think the number of aliases is part of the reason why. Maybe keep it to 0 or 1 alias?

Comment thread hack/release-from/flags.go Outdated
var exceptEnterpriseFlag = &cli.StringSliceFlag{
Name: "except-calico-enterprise",
Aliases: []string{"except-enterprise", "except-calient"},
Usage: "A list of Enterprise images and the versions to use for them. " +
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this cli tool is not made to handle long usage strings, as a result the help output is hard to read.

@radTuti radTuti merged commit 62c8d34 into tigera:master Jan 24, 2025
@radTuti radTuti deleted the operator-from branch January 24, 2025 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants