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

Operator Skeleton Generator #1206

Merged
merged 9 commits into from
Dec 20, 2019
Merged

Operator Skeleton Generator #1206

merged 9 commits into from
Dec 20, 2019

Conversation

kensipe
Copy link
Member

@kensipe kensipe commented Dec 18, 2019

What this PR does / why we need it:
Creates the start of an operator via walking thru validated prompts. Expectations are:

  • the required operator folder doesn't exist
  • there isn't an operator.yaml file in the current directory (which assumes that you are in an operator folder.

Answering the prompts will result in:

  1. the creation of a folder (defaulted to "operator") which is the folder containing the operator
  2. the creation of a file "operator.yaml" in the operator folder
  3. operator.yaml contains the answers to prompts

NOT included:

  • maintainers
  • tasks
  • plans
    there will be a separate generator for them

Added to flags --interactive and --overwrite. The default now goes with defaults and creates the operator. -i goes into interactive mode where questions are asked to fill in the detail. -w allows for an overwrite of an existing operator. Initially I didn't like the -w because I wanted to potentially have an interactive package update vs package new which is suppose to be new. BUT... I can see the case that someone created with defaults and wants to do it "interactive"

Fixes #1085

Copy link
Contributor

@alenkacz alenkacz left a comment

Choose a reason for hiding this comment

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

Let's add the test at least for the non-interactive one and then I think it's good to go

As of how far we want to move this feature I am fine with this scaffolding some general structure of the operator, with folders and everything, I am not sure I would go as far as defining tasks from CLI. Since we're dealing with yaml and not ruby, I think people are able to write yaml even without interactive prompts


// run returns the errors associated with cmd env
func (pkg *packageNewCmd) run() error {
folderDefault := "operator"
Copy link
Contributor

Choose a reason for hiding this comment

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

why not default to something like operator-$operatorName

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 consistent with 80%+ of our repo...

pkg/kudoctl/cmd/package_new.go Outdated Show resolved Hide resolved
pkg/kudoctl/cmd/package_new.go Outdated Show resolved Hide resolved
pkg/kudoctl/cmd/package_new.go Outdated Show resolved Hide resolved
pkg/kudoctl/cmd/package_new.go Outdated Show resolved Hide resolved
pkg/kudoctl/cmd/package_new.go Outdated Show resolved Hide resolved
Copy link
Contributor

@alenkacz alenkacz left a comment

Choose a reason for hiding this comment

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

LGTM minus few minor nits

pkg/kudoctl/cmd/generate/operator.go Outdated Show resolved Hide resolved
pkg/kudoctl/cmd/generate/operator_test.go Outdated Show resolved Hide resolved
pkg/kudoctl/cmd/package_new.go Outdated Show resolved Hide resolved
pkg/kudoctl/cmd/prompt/prompt.go Outdated Show resolved Hide resolved
Signed-off-by: Ken Sipe <kensipe@gmail.com>
Signed-off-by: Ken Sipe <kensipe@gmail.com>
Signed-off-by: Ken Sipe <kensipe@gmail.com>
Signed-off-by: Ken Sipe <kensipe@gmail.com>
Signed-off-by: Ken Sipe <kensipe@gmail.com>
Signed-off-by: Ken Sipe <kensipe@gmail.com>
Signed-off-by: Ken Sipe <kensipe@gmail.com>
@kensipe
Copy link
Member Author

kensipe commented Dec 20, 2019

resolved all pr feedback... thanks alenkacz !
rebased to latest master

@kensipe kensipe merged commit 3ca2ebe into master Dec 20, 2019
@kensipe kensipe deleted the ken/skel-operator branch December 20, 2019 15:02
ANeumann82 pushed a commit that referenced this pull request Feb 13, 2020
Provides the ability to generate a new operator with: `kudo package new foo`

Also provides a way to generate a new operator interactively with `kudo package new -i foo

Signed-off-by: Ken Sipe <kensipe@gmail.com>
Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
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.

Skeleton: Create Operator
2 participants