-
Notifications
You must be signed in to change notification settings - Fork 771
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
--provider global flag for kompose #182
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that it is not really user friendly to show options for all providers.
When you do kompose --provider kubernetes convert --h
it should show only options that are valid for Kubernetes and when you do kompose --provider openshift convert --h
user should see only options for OpenShift
Today on train to Berlin I've worked on same thing as part of work on Because I wanted I've used I don't know how much time I'm going to have this week to clean it up and finish. But If you want to have provider flag sooner, look at my branch and you can use it ;-) |
@kadel thanks for pointers, this helps with the missing point I had! |
5e31f05
to
5b74d54
Compare
@kadel addressed the issues you mentioned! Now output looks like this: for openshift $ kompose --provider=openshift convert -h
NAME:
kompose convert - Convert Docker Compose file (e.g. docker-compose.yml) to Kubernetes objects
USAGE:
kompose convert [command options] [arguments...]
OPTIONS:
--out, -o Specify file name in order to save objects into [$OUTPUT_FILE]
--replicas "1" Specify the number of replicas in the generated resource spec (default 1)
--chart, -c Create a chart deployment
--yaml, -y Generate resource file in yaml format
--stdout Print converted objects to stdout
--deploymentconfig, --dc Generate a DeploymentConfig for OpenShift for k8s $ kompose convert -h
NAME:
kompose convert - Convert Docker Compose file (e.g. docker-compose.yml) to Kubernetes objects
USAGE:
kompose convert [command options] [arguments...]
OPTIONS:
--out, -o Specify file name in order to save objects into [$OUTPUT_FILE]
--replicas "1" Specify the number of replicas in the generated resource spec (default 1)
--chart, -c Create a chart deployment
--yaml, -y Generate resource file in yaml format
--stdout Print converted objects to stdout
--deployment, -d Generate a deployment resource file (default on)
--daemonset, --ds Generate a daemonset resource file
--replicationcontroller, --rc Generate a replication controller resource file
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @surajssd.
Just couple suggestions ;-)
if !opt.CreateD && !opt.CreateDS && !opt.CreateRC { | ||
opt.CreateD = true | ||
} | ||
if opt.CreateDeploymentConfig { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this check is not needed, this can never happen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes, now this is not needed since command line handling will take care of it :)
// create deploymentconfig by default if no controller has been set | ||
if !opt.CreateDeploymentConfig { | ||
opt.CreateDeploymentConfig = true | ||
} | ||
if opt.CreateD { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this check is not needed, this can never happen same for CreateDS and CreateRS
provider := strings.ToLower(c.GlobalString("provider")) | ||
switch provider { | ||
case "kubernetes": | ||
k8sControllers := []cli.Flag{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we create whole new cli.Command
here? So we can set usage help for every provider independently?
Or set commands.Usage
here
If I run kompose --provider openshift convert -h
It is still displaying usage mentioning Kubernetes
NAME:
kompose convert - Convert Docker Compose file (e.g. docker-compose.yml) to Kubernetes objects
....
This is also relying on ConvertCommand
always being first in that slice :-( This might lead to errors in the future. At least there should be comment in app.Commands
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes sure we can create new cli.Command
, and nice catch of that usage string BTW!
@@ -33,7 +32,7 @@ func main() { | |||
app.Author = "Skippbox Kompose Contributors" | |||
app.Email = "https://github.com/skippbox/kompose" | |||
app.EnableBashCompletion = true | |||
app.Before = cliApp.BeforeApp | |||
app.Before = command.BeforeApp | |||
app.Flags = append(command.CommonFlags()) | |||
app.Commands = []cli.Command{ | |||
command.ConvertCommand(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in command.BeforeApp
you are counting on ConvertCommand being always in the first place here.
If you want it like that, here should be comment explaining that this cannot be moved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I stuck to the way you did it, add the command itself in BeforeApp
function, so this is not needed I think.
5b74d54
to
89385cd
Compare
Changed it now to have new $ kompose --provider=openshift convert -h
NAME:
- Convert Docker Compose file (e.g. docker-compose.yml) to OpenShift objects
USAGE:
[command options] [arguments...]
OPTIONS:
--deploymentconfig, --dc Generate a OpenShift DeploymentConfig object
--out, -o Specify file name in order to save objects into [$OUTPUT_FILE]
--replicas "1" Specify the number of replicas in the generated resource spec (default 1)
--yaml, -y Generate resource file in yaml format
--stdout Print converted objects to stdout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return command | ||
} | ||
|
||
func commonConvertFlags() []cli.Flag { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Great work @surajssd 👍 I will try it today. Thanks |
Hey @surajssd, at first test I see $ kompose --help
...
COMMANDS:
up Deploy your Dockerized application to Kubernetes (default: creating Kubernetes deployment and service)
down Delete instantiated services/deployments from kubernetes
... |
Otherwise LGTM. I like the idea of changing usage between providers 💯 |
Then provider owners have their own space to arrange outputs. |
Now a user can select a provider using global flag --provider=openshift to select openshift provider or --provider-kubernetes to select kubernetes provider if nothing is provided kubernetes is the default provider. Fixes kubernetes#179
89385cd
to
b969f7a
Compare
@ngtuna nice catch about convert not being visible. Made changes accordingly here https://github.com/skippbox/kompose/pull/182/files#diff-3145698b159fb0a026984b4a017a8b24R67 also added note here https://github.com/skippbox/kompose/pull/182/files#diff-d9814220427d68b7f7ade416b1440032R38 |
And also it shows up under help $ kompose -h
NAME:
[SNIP]
Skippbox Kompose Contributors <https://github.com/skippbox/kompose>
COMMANDS:
convert Convert Docker Compose file (e.g. docker-compose.yml) to Kubernetes/OpenShift objects
up Deploy your Dockerized application to Kubernetes (default: creating Kubernetes deployment and service)
down Delete instantiated services/deployments from kubernetes
GLOBAL OPTIONS:
[SNIP] |
Thanks @surajssd . Merging now for the release tonight. |
Thanks @ngtuna ! |
Now a user can select a provider using global flag
--provider=openshift
to select openshift provideror
--provider-kubernetes
to select kubernetes provider if nothing is provided kubernetes is the default provider.Fixes #179