-
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
Switch to spf13/cobra from urfave/cli #304
Conversation
@kadel I'll need some help in regards to vendoring in |
bf0e17d
to
ea1581f
Compare
@kadel @ngtuna I don't touch anything regarding the "conversion". Despite having the exact same output at before the conversion:
It still fails with the
test. Did something change? |
ea1581f
to
34d78ac
Compare
@cdrage export envs before you run kompose ✔ ~/git/gowork/src/github.com/kubernetes-incubator/kompose/script/test/fixtures/etherpad [master ↑·307|…1]
09:49 $ export $(cat envs )
✔ ~/git/gowork/src/github.com/kubernetes-incubator/kompose/script/test/fixtures/etherpad [master ↑·307|…1]
09:51 $ kompose --provider openshift up
WARN[0000] Unsupported key depends_on - ignoring
We are going to create OpenShift DeploymentConfigs, Services and PersistentVolumeClaims for your Dockerized application.
If you need different kind of resources, use the 'kompose convert' and 'oc create -f' commands instead.
INFO[0000] Successfully created Service: etherpad
INFO[0000] Successfully created Service: mariadb
INFO[0000] Successfully created DeploymentConfig: etherpad
INFO[0000] Successfully created ImageStream: etherpad
INFO[0000] Successfully created DeploymentConfig: mariadb
INFO[0000] Successfully created ImageStream: mariadb
INFO[0000] Successfully created PersistentVolumeClaim: mariadb-claim0
Your application has been deployed to OpenShift. You can run 'oc get dc,svc,is,pvc' for details. |
21a6194
to
7aa894c
Compare
@cdrage this is what i did and found out it works with openshift ✔ ~/go/src/github.com/kubernetes-incubator/kompose/script/test/fixtures/etherpad [switch-to-cobra|✔]
19:14 $ ll
total 36
-rw-rw-r--. 1 hummer hummer 102 Oct 24 16:11 docker-compose-no-image.yml
-rw-rw-r--. 1 hummer hummer 61 Oct 24 16:11 docker-compose-no-ports.yml
-rw-rw-r--. 1 hummer hummer 509 Nov 24 19:06 docker-compose.yml
-rw-rw-r--. 1 hummer hummer 99 Oct 24 16:11 envs
-rw-rw-r--. 1 hummer hummer 4852 Nov 24 19:06 output-k8s.json
-rw-rw-r--. 1 hummer hummer 7119 Nov 24 19:06 output-os.json
-rw-rw-r--. 1 hummer hummer 180 Oct 24 16:11 README.md
✔ ~/go/src/github.com/kubernetes-incubator/kompose/script/test/fixtures/etherpad [switch-to-cobra|✔]
19:14 $ export $(cat envs)
✔ ~/go/src/github.com/kubernetes-incubator/kompose/script/test/fixtures/etherpad [switch-to-cobra|✔]
19:14 $ kompose --provider openshift convert --stdout
WARN[0000] Unsupported key depends_on - ignoring
{
"kind": "List",
"apiVersion": "v1",
"metadata": {},
"items": [
{
"kind": "Service",
"apiVersion": "v1",
|
@cdrage also $ kompose convert --stdout -y
Error: unknown shorthand flag: 'y' in -y
<snip> |
7aa894c
to
c8316e7
Compare
@surajssd updated, should work now. added |
c8316e7
to
2447483
Compare
For example: Here's a test that should pass even after doing
|
@cdrage so looking closely it seems it's generating |
I see, so in: https://github.com/kubernetes-incubator/kompose/blob/6033025c058e44f00d78c42149a09be025ba6a31/cli/command/command.go We actually have different flags depending on the provider (which I think is a big no-no since suddenly flags disappear if a different provider is provided). So what essentially happens is that by default "deployment" is false since it's not implied. Got it. I'll fix this :) |
If anyone else has a different opinion / way to implement, that'd be great. Another option for "splitting" the flags is simply having a validation (if you pass in --chart for OpenShift it'll simply error out as not compatible / usable). |
2447483
to
303ebf7
Compare
@cdrage that was purposeful changing controller flags depending on provider user mentions. |
All tests pass now 👍 |
|
||
func init() { | ||
|
||
convertCmd.Flags().BoolVarP(&ConvertChart, "chart", "c", false, "Create a Helm chart for converted objects **Kubernetes only**") |
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.
IMO having ** in help is making it look cluttered on command line.
@cdrage I see flags which are not for provider $ ./kompose --provider openshift convert --help
A longer description that spans multiple lines and likely contains examples
Usage:
kompose convert [file] [flags]
Flags:
-c, --chart Create a Helm chart for converted objects **Kubernetes only**
--daemonset Generate a Kubernetes daemonset object **Kubernetes only**
-d, --deployment Generate a Kubernetes deployment object **OpenShift only**
--deploymentconfig Generate a deployment config object. **OpenShift only*
--emptyvols Use Empty Volumes. Do not generate PVCs
-o, --out string Specify a file name to save objects to
--replicas int Specify the number of repliaces in the generate resource spec (default 1)
--replicationcontroller Generate a Kubernetes replication controller object **Kubernetes only**
--stdout Print converted objects to stdout
-y, --yaml Generate resource files into yaml format
Global Flags:
-b, --bundle string Specify a Distributed Application GlobalBundle (DAB) file
--error-on-warning Treat any warning as an error
-f, --file string Specify an alternative compose file (default "docker-compose.yml")
--provider string Specify a provider. Kubernetes or OpenShift. (default "kubernetes")
--suppress-warnings Suppress all warnings
-v, --verbose verbose output |
following do not work
following should error out but it still continues execution
You can set provider using env var Good job with having replicas under sub-command |
Those errors are intentional...
For this I will fix ^^. From your comment, I will split off the CLI flags based on provider so they do not appear. Thanks for another review! |
9317f10
to
9aa3edf
Compare
@surajssd updated with vendoring :) |
@cdrage with this I mean that this should error out, here provider is considered as |
@surajssd Yeah, because of @sebgoa suggestions to put it into one I'll have to implement a custom solution. We're you able to test the environment variable changes? Testing passes so I'm assuming |
@cdrage so this is I guess for cobra flags that can be replaced with env vars, but the thing about env vars you mentioned are read by libcompose to replace in docker-compose file we provide. |
|
@surajssd Ahhhh. that makes sense.. So right now it doesn't seem to work when doing |
I've gone ahead and done (hopefully) the last code change to this PR. This is ready for another review. I've gone ahead and fixed @surajssd suggestions in regards to the flag validation against each provider. For example:
|
7020e10
to
9f6ea1e
Compare
logrus.Fatalf("--deployment-config is an OpenShift only flag") | ||
} | ||
if deployment { | ||
logrus.Fatalf("--deployment, -d is an OpenShift only 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.
It's a kubernetes only flag.
9f6ea1e
to
39f2a1c
Compare
39f2a1c
to
1134e51
Compare
thanks @surajssd I've updated it. Can't believe I missed that! |
58fe43c
to
9f6cd56
Compare
There's A LOT happening in this commit, so here's an outline: First off, urfave/cli has been removed in favour of spf13/cobra. With this, comes changes to the formatting as well as the help page for Kompose. Upon converting, I noticed a CLI flag was NOT appearing for OpenShift. Specifically, --deploymentconfig. This has been added with a note that says it is OpenShift only. Exit codes have been fixed. If the conversion / down / up fails for any reason, Kompose will exit with Code 1. --verbose as well as --suppress-warnings can now be set at the same time. app_test.go in the cli directory has been moved to pkg/transformer to better reflect the testing coverage. version.go has been removed and converted to it's own CLI command in conjuction with (most) Go software. A new CLI command has been created. kompose version --dab isn't a conventional way for short-form CLI paramters. This has been shortened to -b for bundle. CLI flags consisting of only two/three letters have been removed due to it being unconventional for CLI. For example, --dc was removed in preference for --deploymentconfig --replicas has been added as an option when using kompose down or kompose up. This has been added as previously in app.go the replica amount was hard-coded as 1. Differentiating names have been used for flags. For example, persistent flags use the name Global (ex. GlobalOut). Command-specific flags have their own names (ex. UpOpt). Closes kubernetes#239 kubernetes#253
9f6cd56
to
1b9228e
Compare
Hey @surajssd
Nevermind, travis won't build unless I add the vendoring. |
LGTM 👍 |
There's A LOT happening in this commit, so here's an outline:
First off, urfave/cli has been removed in favour of spf13/cobra. With
this, comes changes to the formatting as well as the help page for
Kompose.
Upon converting, I noticed a CLI flag was NOT appearing for OpenShift.
Specifically,
--deploymentconfig
. This has been added with a notethat says it is OpenShift only.
Exit codes have been fixed. If the conversion / down / up fails for
any reason, Kompose will exit with Code 1.
--verbose
as well as--suppress-warnings
can now be set at thesame time.
app_test.go
in the cli directory has been moved topkg/transformer
to better reflect the testing coverage.
version.go
has been removed and converted to it's own CLI command inconjuction with (most) Go software. A new CLI command has been
created.
kompose version
--dab
isn't a conventional way for short-form CLI paramters. Thishas been shortened to
-b
for bundle.CLI flags consisting of only two/three letters have been removed due to
it being unconventional for CLI. For example,
--dc
was removed in preferencefor
--deploymentconfig
--replicas
has been added as an option when usingkompose down
orkompose up
. This has been added as previously inapp.go
thereplica amount was hard-coded as
1
.Differentiating names have been used for flags. For example,
persistent flags use the name Global (ex. GlobalOut). Command-specific
flags have their own names (ex. UpOpt).
Closes #239 #253