GoogleCloudPlatform / anthos-service-mesh-packages

Packaged configuration for setting up a Kubernetes cluster with Anthos Service Mesh features enabled
https://cloud.google.com/anthos/service-mesh
Apache License 2.0
134 stars 168 forks source link

Allow script to export variables when run with source (e.g. revision, istioctl location) #187

Open jbrook opened 3 years ago

jbrook commented 3 years ago

If the script can be run with source then it will be possible to set environment variables in the current shell. That would make it easier to build the script into other scripts and to use it in documentation without having to ask the user to copy and paste or run additional commands. It would be really useful to set the following:

The outro should show the variables that have been set and their values and could include a few examples of how they can be used, e.g.

If the compiled YAML could be written to a file it would also be useful to set a variable with the path to that file.

zerobfd commented 3 years ago

189 has the script dump the dry and hydrated yaml

zerobfd commented 3 years ago

I tested this a bit and it's actually pretty tough to get the script to act right if you source it. Some of it is fixable, but all of the error handling is built on the idea that it's in the script and most of it will forcibly exit the shell it's in, which isn't a great experience.

It's possible to pass the --output-dir flag to tell it specifically where to download packages to. I could have the istio-$RELEASE folder get renamed to just "istio" so there's a consistent way of finding the bin directory/istioctl/configs. It's not quite as convenient as one variable, but I feel like it might meet the spirit of the request.

I can't think of something similar to do with the revision label, but the outro does contain the kubectl command to label the namespace which has the label in it.

Now that the configs are written to a file, do you think making istioctl a stable relative path would meet your requirements?

jbrook commented 3 years ago

I think that would help. I guess the other thing the script could do is write an installed.env file to the output directory but users would still need to source it for it to be useful.