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

Added flag --suppress-warnings, --verbose, --error-on-warning global flags #111

Merged
merged 1 commit into from
Sep 17, 2016

Conversation

surajssd
Copy link
Member

@surajssd surajssd commented Aug 17, 2016

  • --suppress-warnings it ignores all warnings.
  • --verbose displays everything
  • --error-on-warning with any warning exits displaying error.

Fixes #100

@surajssd surajssd force-pushed the suppress-warnings branch 2 times, most recently from 304c315 to 7830721 Compare August 18, 2016 06:08
@surajssd
Copy link
Member Author

@ngtuna @janetkuo apart from the flags mentioned above what all flags would you guys want?

@janetkuo
Copy link
Member

I'd suggest changing -w to --quiet

@janetkuo
Copy link
Member

We should choose short flags sparingly, only for the most frequently used options (since there are only 26 ones we can use).

@surajssd surajssd changed the title Added flag -w and --verbose global flags Added flag --quiet and --verbose global flags Aug 24, 2016
@surajssd
Copy link
Member Author

@janetkuo updated comment above

@surajssd
Copy link
Member Author

So now with --quiet enabled it will fail on a single warning itself!

@surajssd surajssd closed this Sep 2, 2016
@surajssd surajssd reopened this Sep 2, 2016
@surajssd
Copy link
Member Author

surajssd commented Sep 2, 2016

Mistakenly pushed close PR button, sorry about that.

@janetkuo can you confirm about this PR with the flags that I have added?

@ngtuna
Copy link
Contributor

ngtuna commented Sep 6, 2016

@surajssd , code looks good to me. I tested with docker-voting.yml , output below:

$ kompose --quiet convert --file docker-voting.yml --out voting.txt
Unsupported key build - ignoring

$ kompose convert --file docker-voting.yml --out voting.txt
WARN[0000] Unsupported key build - ignoring             
WARN[0000] Volume mount on the host "./result" isn't supported - ignoring path on the host 
WARN[0000] Volume mount on the host "./vote" isn't supported - ignoring path on the host 
WARN[0000] [worker] Service cannot be created because of missing port. 
WARN[0000] [db] Service cannot be created because of missing port.

Do we expect that output ?

@surajssd
Copy link
Member Author

surajssd commented Sep 7, 2016

@ngtuna yes the behavior of --quiet flag is that it exits even on a single warning! (of-course showing the warning)

Rebased on current master.

@ngtuna
Copy link
Contributor

ngtuna commented Sep 7, 2016

@surajssd yeah but how about volume mount & service warning ?

@surajssd
Copy link
Member Author

surajssd commented Sep 7, 2016

@ngtuna what @janetkuo said here

"Treating warnings as errors" means that "I expect myself to fix my config so that I won't see any warnings; but in case I missed anything, please give me error on those warnings".

so i am exiting on any warning, so that user will have to fix those warnings before she/he can go forward. How do you perceive this?

@ngtuna
Copy link
Contributor

ngtuna commented Sep 7, 2016

@surajssd Ah ha... Sorry I missed it. +1 LGTM. Let's wait for @janetkuo reply.

@surajssd
Copy link
Member Author

surajssd commented Sep 7, 2016

@ngtuna sure thanks :)

@ngtuna ngtuna removed the in progress label Sep 7, 2016
@ngtuna
Copy link
Contributor

ngtuna commented Sep 11, 2016

Just realize we have missed it for the release 0.1.0. So let's leave it at 0.1.1

@janetkuo janetkuo self-assigned this Sep 12, 2016
@janetkuo
Copy link
Member

@ngtuna what @janetkuo said here

"Treating warnings as errors" means that "I expect myself to fix my config so that I won't see any warnings; but in case I missed anything, please give me error on those warnings".

so i am exiting on any warning, so that user will have to fix those warnings before she/he can go forward. How do you perceive this?

@surajssd sorry I should've made this more clear. I meant:

  • --quiet: don't display warnings. User use --quiet to suppress all warnings when they're aware of those warnings and choose to ignore them.
  • --verbose (bool or int): customized verbose level
  • --error-on-warnings (or some other name similar): make all warnings into errors (something like GCC -Werror). Users use --error-on-warnings when they believe they've fixed all warnings, and want kompose to treat warnings as errors so that they can fix them before continue.

@surajssd surajssd changed the title Added flag --quiet and --verbose global flags Added flag --quiet, --verbose, --error-on-warning global flags Sep 13, 2016
@surajssd
Copy link
Member Author

@janetkuo yep changed code accordingly, and also updated #111 (comment) with the latest usage.

@janetkuo
Copy link
Member

Hi @surajssd thanks, I played around with it and have some more comments:

  • --quiet isn't really quiet, suggest renaming it to --suppress-warnings:
$ kompose -f docker-voting.yml --quiet up
We are going to create Kubernetes deployments and services for your Dockerized application. 
If you need different kind of resources, use the 'kompose convert' and 'kubectl create -f' commands instead. 


Your application has been deployed to Kubernetes. You can run 'kubectl get deployment,svc,pods' for details.
  • --quiet (--suppress-warnings) hides errors too, which it shouldn't (it should only supress warnings):
# There's fatal error when the service already existed
$ kompose -f docker-voting.yml up
We are going to create Kubernetes deployments and services for your Dockerized application. 
If you need different kind of resources, use the 'kompose convert' and 'kubectl create -f' commands instead. 

WARN[0000] [worker] Service cannot be created because of missing port. 
FATA[0000] Error: 'services "db" already exists' while creating service: db

# `--quiet` suppressed the fatal errror 
$ kompose -f docker-voting.yml --quiet up
We are going to create Kubernetes deployments and services for your Dockerized application. 
If you need different kind of resources, use the 'kompose convert' and 'kubectl create -f' commands instead. 
  • --error-on-warning treated warnings as errors, but the error wasn't colored / formatted as other errors:
$ kompose -f docker-voting.yml --error-on-warning up 
We are going to create Kubernetes deployments and services for your Dockerized application. 
If you need different kind of resources, use the 'kompose convert' and 'kubectl create -f' commands instead. 

[worker] Service cannot be created because of missing port.

image

Can we leverage logrus.Fatalf or logrus.Errorf here?

…obal flags

- `--suppress-warnings` it ignores all warnings.
- `--verbose` displays everything
- `--error-on-warning` with any warning exits displaying error.

Fixes kubernetes#100
@surajssd
Copy link
Member Author

@janetkuo

Without any option normal warnings and errors

$ kompose -f ./script/test/fixtures/etherpad/docker-compose.yml convert --stdout 
WARN[0000] The DB_PORT variable is not set. Substituting a blank string. 
WARN[0000] The DB_PASS variable is not set. Substituting a blank string. 
[SNIP]
WARN[0000] Unsupported key depends_on - ignoring        
FATA[0000] "mariadb" failed to load ports from compose file: invalid container port "" 

With --suppress-warnings flag all warnings are ignored, but errors out on any error

$ kompose --suppress-warnings -f ./script/test/fixtures/etherpad/docker-compose.yml convert --stdout 
FATA[0000] "mariadb" failed to load ports from compose file: invalid container port "" 

With --error-on-warning flag errors out on any warning

$ kompose --error-on-warning -f ./script/test/fixtures/etherpad/docker-compose.yml convert --stdout 
FATA[0000] The DB_PORT variable is not set. Substituting a blank string. 

With --verbose flag all logs shown

$ kompose --verbose -f ./script/test/fixtures/etherpad/docker-compose.yml convert --stdout 
DEBU[0000] Opening compose files: ./script/test/fixtures/etherpad/docker-compose.yml 
WARN[0000] The DB_PORT variable is not set. Substituting a blank string. 
[SNIP]
WARN[0000] The DB_HOST variable is not set. Substituting a blank string. 
DEBU[0000] [0/1] [etherpad]: Adding                     
DEBU[0000] [0/1] [mariadb]: Adding                      
WARN[0000] Unsupported key depends_on - ignoring        
FATA[0000] "mariadb" failed to load ports from compose file: invalid container port "" 

@surajssd surajssd changed the title Added flag --quiet, --verbose, --error-on-warning global flags Added flag --suppress-warnings, --verbose, --error-on-warning global flags Sep 16, 2016
@janetkuo janetkuo added lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed review needed labels Sep 16, 2016
@janetkuo
Copy link
Member

Looks good. The change is awesome! Thanks 👍

@surajssd
Copy link
Member Author

Merging!

@surajssd surajssd merged commit 1e58135 into kubernetes:master Sep 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm "Looks good to me", indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants