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

Update and clean up library helpers #101

Merged
merged 14 commits into from
Sep 17, 2021

Conversation

varshaprasad96
Copy link
Member

This PR does the following:

  1. Updates internal/cmd/run/cmd.go with the changes made to operator flags.
  2. Remove existing example/ repository as the testdata/ folder present in respective plugins folder has the sample operator.
  3. Update scaffolding to use latest versions of controller-runtime and controller-tools.
  4. Cleanup and update a few sections sections of codebase.
  5. Update testdata/ with the changes made to the scaffolding.

The sample testdata present in the PR has been updated with the changes made in the scaffolding code in this PR.

@coveralls
Copy link

coveralls commented Aug 25, 2021

Pull Request Test Coverage Report for Build 1238557586

  • 137 of 144 (95.14%) changed or added relevant lines in 2 files are covered.
  • 4 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.2%) to 89.724%

Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/flags/flag.go 101 102 99.02%
pkg/watches/watches.go 36 42 85.71%
Files with Coverage Reduction New Missed Lines %
pkg/client/actionclient.go 4 78.3%
Totals Coverage Status
Change from base Build 1199182260: 0.2%
Covered Lines: 1493
Relevant Lines: 1664

💛 - Coveralls

@varshaprasad96 varshaprasad96 force-pushed the update/lib branch 2 times, most recently from 64e2199 to 2fbbfbd Compare August 26, 2021 01:08
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/yaml"
)

type Watch struct {
schema.GroupVersionKind `json:",inline"`
ChartPath string `json:"chart"`
ChartDir string `json:"chart"`
Copy link
Member Author

Choose a reason for hiding this comment

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

This is to be consistent with the terminology we use in Helm operator.

Copy link
Member

Choose a reason for hiding this comment

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

/cc @joelanford thoughts on this breaking API change?

Copy link
Member

Choose a reason for hiding this comment

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

I think we accept either a chart directory or a chart tar.gz file, hence the name ChartPath over ChartDir. If we only handle chart directories, this change seems fine.

@@ -153,13 +153,6 @@ func addInitCustomizations(projectName string) error {
return err
}

// Remove the webhook option for the componentConfig since webhooks are not supported by helm
Copy link
Member Author

Choose a reason for hiding this comment

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

Removing this part of the code which commented out the webhooks out of config files. Since webhooks can be used with Go API, we can leave it here.

Copy link
Member

@fabianvf fabianvf left a comment

Choose a reason for hiding this comment

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

/lgtm

I think this all looks good to me, plus tests look like they're running. Probably should hold off on merge until Joe responds about the one breaking change.

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Aug 31, 2021
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Sep 3, 2021
Signed-off-by: varshaprasad96 <[email protected]>
internal/cmd/run/cmd.go Show resolved Hide resolved
internal/cmd/run/cmd.go Outdated Show resolved Hide resolved
internal/cmd/run/cmd.go Outdated Show resolved Hide resolved
internal/cmd/run/cmd.go Show resolved Hide resolved
internal/cmd/run/cmd.go Outdated Show resolved Hide resolved
pkg/watches/watches.go Outdated Show resolved Hide resolved
pkg/watches/watches.go Outdated Show resolved Hide resolved
pkg/watches/watches_test.go Show resolved Hide resolved
@@ -46,7 +46,8 @@ const (
hybridOperatorVersion = "0.0.1"

// helmPluginVersion is the operator-framework/helm-operator-plugin version to be used in the project
helmPluginVersion = "dc6c589504b2884e68dff6dc0e5e87ce8c24702f"
// This is the SHA of the latest commit on master, which will be used to scaffold the project.
Copy link
Member

Choose a reason for hiding this comment

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

Does this mean every PR that merges to master needs to update this line?

Could we instead inject the value at build time similar to how we inject version information?

Copy link
Member

Choose a reason for hiding this comment

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

See

func mustGetScaffoldVersion() string {
if version.ScaffoldVersion == "" || version.ScaffoldVersion == version.Unknown {
panic("helm-operator scaffold version is unknown; it must be set during build or by importing this plugin via go modules")
}
return version.ScaffoldVersion
}

Copy link
Member Author

@varshaprasad96 varshaprasad96 Sep 9, 2021

Choose a reason for hiding this comment

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

@joelanford This is really helpful! But right now, the tests configured in Makefile build SDK locally and replace the plugin with the local path to test it out and it breaks since we don't import it as dependency in go.mod. Ill create an issue to track this, so that we can make this modification and change the way test is written too?

Copy link
Member

Choose a reason for hiding this comment

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

That seems reasonable for now.

But I'm curious if this needs to be resolved before the next release. I might not be fully understanding how this works, but it seems like it will never be possible for the commit SHA on this line to match the SHA of the commit that this line is in.

And if that's true, it means that when we go to tag this repo, this line will actually point to an older commit, and users will end up importing the library at that older commit.

I'm also curious if that test will actually test the current commit. It seems like it will always test the commit that's in this line?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm. Yeah, that's true. Can we let this be an input through operator-sdk where we provide the release to scaffold, till its used as a phase 1 plugin? This doesn't seem to be the ideal way to do so, I think.
But on a longer run even with phase 2 plugins this could be an issue because we have the library and plugin in the same place.
Yes, the test uses the current changes committed to scaffold and check if we are able to build an image. Thinking about it, how would we modify the tests to get the current commit and scaffold? If we cannot put the current commit at this place, the generated testdata and tests will always be verifying the previous commit.

Signed-off-by: varshaprasad96 <[email protected]>
@varshaprasad96
Copy link
Member Author

varshaprasad96 commented Sep 14, 2021

@joelanford @fabianvf I have opened an issue and created a follow up task in jira to capture the work on removing the current test in Makefile. Can we merge this PR if it looks good?

@joelanford
Copy link
Member

@varshaprasad96 Just the one last question about bumping the envtest k8s version. Otherwise...

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Sep 15, 2021
@joelanford
Copy link
Member

Oh also, did you see this comment? #101 (comment)

@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Sep 15, 2021
Copy link
Member

@fabianvf fabianvf left a comment

Choose a reason for hiding this comment

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

/lgtm

Pending the last open discussion with Joe

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Sep 15, 2021
@varshaprasad96
Copy link
Member Author

Merging this PR. Will add a TODO to investigate on having a separate helmConfig to disallow users setting webhooks host, port and cert Dir through controller-runtime config.

@varshaprasad96 varshaprasad96 merged commit c5ecef2 into operator-framework:main Sep 17, 2021
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