Skip to content

cleanup: keeping sdk scaffolds centralized#3349

Merged
camilamacedo86 merged 2 commits intooperator-framework:masterfrom
camilamacedo86:just-go-cleanup
Jul 13, 2020
Merged

cleanup: keeping sdk scaffolds centralized#3349
camilamacedo86 merged 2 commits intooperator-framework:masterfrom
camilamacedo86:just-go-cleanup

Conversation

@camilamacedo86
Copy link
Copy Markdown
Contributor

Description of the change:
Just moving the SDK scaffolds for plugins to the sdk dir and allow it to be re-used.

Motivation for the change:
The SDK scaffolds will be required to other plugins. See for example #3295

Checklist

If the pull request includes user-facing changes, extra documentation is required:

Copy link
Copy Markdown
Member

@estroz estroz left a comment

Choose a reason for hiding this comment

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

This approach could work. However the SDK controls what the Makefile template is for both upcoming Ansible and Helm plugins, so we can write these Makefile fragments directly into its template.

Comment thread internal/plugins/golang/v2/init.go Outdated
Comment thread internal/plugins/golang/v2/init.go Outdated
Comment thread internal/plugins/sdk/api.go Outdated
Comment thread internal/plugins/sdk/init.go Outdated
Comment thread internal/plugins/sdk/init.go Outdated
Comment thread internal/plugins/sdk/init.go Outdated
Comment thread internal/plugins/sdk/init.go Outdated
Comment thread internal/plugins/sdk/init.go Outdated
@camilamacedo86 camilamacedo86 requested a review from estroz July 8, 2020 17:00
@camilamacedo86
Copy link
Copy Markdown
Contributor Author

camilamacedo86 commented Jul 8, 2020

Hi @estroz,

This approach could work. However the SDK controls what the Makefile template is for both upcoming Ansible and Helm plugins, so we can write these Makefile fragments directly into its template.

Note that, we need to do the same for helm/go/ansible and then, by following your recommendation it means to duplicate the code in at least 6 different places/files which shows reduce the Maintenace ability and lead the code more susceptible to errors besides increase the effort when changes are required related to it.

Then, see that these scaffolds are specific to SDK CLI and should not be pushed in the plugins repos Helm/Ansible for example. Let's imagine that we need to change the OLM subcommand and its scaffolds, if we follow your suggestion it means that in the future to achieve this goal we would need to do a PR against SDK, Ansible and Helm repos.

Note that everything that is in the helm plugin will be extracted for its repo and there we will not have SDK or its specific features to be able to test/check it.

So, the idea here is that these customizations should be centralized in the SDK CLI repo instead of it. Because of this, I'd be against to do that as I spoke with @joelanford which at the first moment also brings this idea. Is it make sense?

Comment thread internal/plugins/sdk/api.go
Comment thread internal/plugins/sdk/api.go
Comment thread internal/plugins/sdk/init.go
Comment thread internal/util/projutil/project_util.go Outdated
@camilamacedo86 camilamacedo86 requested a review from joelanford July 9, 2020 16:24
Comment thread internal/pluginutil/sdk/api.go
Comment thread internal/plugins/golang/v2/api.go Outdated
@camilamacedo86
Copy link
Copy Markdown
Contributor Author

camilamacedo86 commented Jul 10, 2020

HI @estroz @joelanford,

All suggestions made were addressed with expectations that ones which go against a previous suggestion made its motivations. I cannot see anything else here that would blocks this PR get merged. I am looking for your approvals for we are able to merge it.

PS. It is booking directly the #3330 and #3295

@camilamacedo86
Copy link
Copy Markdown
Contributor Author

Hi @estroz,

Merged #3330 as requested first and it is rebased with the master now 👍 . Thank you for your time and reviews.

Comment thread internal/util/plugins/init.go Outdated
Comment thread internal/util/plugins/api.go Outdated
Comment thread internal/plugins/golang/v2/init.go Outdated
@camilamacedo86 camilamacedo86 requested a review from estroz July 11, 2020 11:04

// Update the scaffolded Makefile with operator-sdk recipes.
// TODO: rewrite this when plugins phase 2 is implemented.
if err := initUpdateMakefile("Makefile"); err != nil {
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.

Call p.run() here instead of at the end.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It shows no make difference, however, done. 👍

Comment thread internal/plugins/golang/v2/init.go Outdated
}

return nil
return p.run()
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.

Suggested change
return p.run()
return nil

Comment thread internal/util/plugins/makefile.go Outdated
Comment on lines +48 to +53
if operatorType == projutil.OperatorTypeGo {
makefileBytes = append(makefileBytes, []byte(makefileBundleFragmentGo)...)
} else {
// if is not go project then, has not the manifest target
makefileBytes = append(makefileBytes, []byte(makefileBundleFragmentNonGo)...)
}
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.

Suggested change
if operatorType == projutil.OperatorTypeGo {
makefileBytes = append(makefileBytes, []byte(makefileBundleFragmentGo)...)
} else {
// if is not go project then, has not the manifest target
makefileBytes = append(makefileBytes, []byte(makefileBundleFragmentNonGo)...)
}
switch operatorType {
case projutil.OperatorTypeUnknown:
return fmt.Errorf("unsupported plugin key %q", cfg.Layout)
case projutil.OperatorTypeGo:
makefileBytes = append(makefileBytes, []byte(makefileBundleFragmentGo)...)
default:
makefileBytes = append(makefileBytes, []byte(makefileBundleFragmentNonGo)...)
}

Copy link
Copy Markdown
Member

@estroz estroz left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 13, 2020
@camilamacedo86 camilamacedo86 dismissed joelanford’s stale review July 13, 2020 20:57

dismissing for we are able to move forward, however, it was re-checked with @joe as well.

@camilamacedo86 camilamacedo86 merged commit 795bc25 into operator-framework:master Jul 13, 2020
@camilamacedo86 camilamacedo86 deleted the just-go-cleanup branch July 13, 2020 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants