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

Consider adding JSON/key value pair output to docker-env command #12242

Closed
tcsmith opened this issue Aug 12, 2021 · 7 comments · Fixed by #12263
Closed

Consider adding JSON/key value pair output to docker-env command #12242

tcsmith opened this issue Aug 12, 2021 · 7 comments · Fixed by #12263
Labels
co/runtime/docker Issues specific to a docker runtime kind/feature Categorizes issue or PR as related to a new feature. priority/backlog Higher priority than priority/awaiting-more-evidence.

Comments

@tcsmith
Copy link

tcsmith commented Aug 12, 2021

We use python to do a good amount of automation at my shop. When iterating locally it would be nice to be able to have a cross platform/language agnostic output of the docker-env command that a tool written in a non-shell script language could use.

$ minikube docker-env
You can further specify your shell with either 'cmd' or 'powershell' with the --shell flag.

SET DOCKER_TLS_VERIFY=1
SET DOCKER_HOST=tcp://127.0.0.1:61041
SET DOCKER_CERT_PATH=C:\Users\user\.minikube\certs
SET MINIKUBE_ACTIVE_DOCKERD=minikube
REM To point your shell to minikube's docker-daemon, run:
REM @FOR /f "tokens=*" %i IN ('minikube -p minikube docker-env') DO @%i

Ideally something like this:

$ minikube docker-env --output-kvp
{ 
"DOCKER_TLS_VERIFY": 1,
"DOCKER_HOST":"tcp://127.0.0.1:61041",
"DOCKER_CERT_PATH":"C:\\Users\\user\\.minikube\\certs",
"MINIKUBE_ACTIVE_DOCKERD":"minikube"
}

I realize this could be done with regex libraries in the language of choice but having a convenience function would be fantastic.

@medyagh
Copy link
Member

medyagh commented Aug 12, 2021

@tcsmith that sounds like a great idea !

We already have an option for docker-env to choose the shell type
One option is shell=none

I would review any pr that would add Jason feature to this command.

Would you like to contribute this feature?

@tcsmith
Copy link
Author

tcsmith commented Aug 13, 2021

Ahhhhh, I knew of the --shell option but I did not know about the none option. the help string doesnt mention that and I, lazily, did not dig thru the source XD.

--shell=none definitely makes it much easier to parse!

i would def be interested in adding JSON/KVP output though. what should the option be? we could have a shell type of json or kvp but that doesn't seem 'right'. on the other hand, the option i suggested, --output-kvp, seems a tad bit bloated?

@afbjorklund
Copy link
Collaborator

Apparently it was added already in a02541d but not mentioned in the docs. (and not in the upstream docker-machine env)

The other commands take a --output option, so you can do the same here. And have options like text (default), json, yaml

minikube docker-env --shell none --output json

minikube podman-env --shell none --output yaml

@afbjorklund afbjorklund added co/runtime/docker Issues specific to a docker runtime kind/feature Categorizes issue or PR as related to a new feature. labels Aug 13, 2021
@afbjorklund

This comment has been minimized.

@afbjorklund

This comment has been minimized.

@afbjorklund afbjorklund added the priority/backlog Higher priority than priority/awaiting-more-evidence. label Aug 13, 2021
@afbjorklund
Copy link
Collaborator

afbjorklund commented Aug 13, 2021

Is KVP actually a thing ? Like, a real format

Anyway, there is JSON format now (in the PR)

$ ./out/minikube docker-env --shell none --output json
{"DOCKER_CERT_PATH":"/home/anders/.minikube/certs","DOCKER_HOST":"tcp://192.168.49.2:2376","DOCKER_TLS_VERIFY":"1","MINIKUBE_ACTIVE_DOCKERD":"minikube"}

@tcsmith
Copy link
Author

tcsmith commented Aug 14, 2021

Fantastic, and thank you.

I was able to use the --shell=none output to easily parse it, that output is basically KVP, in my python tools. Your change will even make it easer!

I realized after the fact that K8S/minkube are written in go. I don't have any experience with Go and given the phase my project is in, I wouldnt have the time to learn. Once my project ships, I will learn Go and come back to contribute. I'm learning and loving K8S and just found out about Minikube and its a gamechanger being able to iterate locally, and this feature will help immensely.

Thanks again!
Todd

👁❤🧊🤗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
co/runtime/docker Issues specific to a docker runtime kind/feature Categorizes issue or PR as related to a new feature. priority/backlog Higher priority than priority/awaiting-more-evidence.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants