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

Loading environment variable set? #191

Open
iamcam opened this issue Oct 16, 2020 · 5 comments
Open

Loading environment variable set? #191

iamcam opened this issue Oct 16, 2020 · 5 comments

Comments

@iamcam
Copy link

iamcam commented Oct 16, 2020

Looking through the documentation, it's not very clear if/how you should load a variable set. I see .envset mentioned in passing in the README, but it doesn't appear in the source code, as far as I can tell.

If this is indeed a feature, would you be able to add how it should be used, including file structure and command line usage?

@mjones-droid
Copy link

Hello! I'm not sure I totally understand the question. Once you've exposed an environment variable via envman it should be accessible to the system just like any other environment variable.

@iamcam
Copy link
Author

iamcam commented Nov 20, 2020

Yes, and I realize I misspoke about ".envset".

I am curious about the .envstore file and how specifically it is configured. Is it a key=value with pairs separated by spaces or newlines? Yaml? etc?

There is also mention in the README: "switch between environment sets", but no mention of how that is done. Some configuration packages simply use a single supplied .env file with just the necessary parts (which I suspect envman does), while others will use headers for each environment, etc.

So what I suppose I'm asking for is more clarification in the documentation about how this tool is used with environment configuration files that may be injectable in a Bitrise workflow. I'm sure it would be helpful for other developers, as well.

@mjones-droid
Copy link

Hey @iamcam! I see what you're saying. I agree that more official documentation about what's going on under the hood would be useful.

First off, if you haven't seen this thread yet I'd suggest taking a look:
#130

It looks like the .envstore is a YML file based on this chunk of code:

// ReadEnvs ...
func ReadEnvs(pth string) ([]models.EnvironmentItemModel, error) {
	bytes, err := fileutil.ReadBytesFromFile(pth)
	if err != nil {
		return []models.EnvironmentItemModel{}, err
	}

	return ParseEnvsYML(bytes)
}

https://github.com/bitrise-io/envman/blob/master/envman/util.go

I will pass the suggestion for enhanced documentation on to the dev's. In the mean time, I'd like to remind anyone who finds this in the future that Bitrise is open source and we accept community contributions. :)

Also I know you've already found our documentation, but I'm going to link to our existing docs for envman and environment variables for others who might find this.

GitHub Repo
https://github.com/bitrise-io/envman

Exposing Environment Variables
https://devcenter.bitrise.io/tips-and-tricks/expose-environment-variable/

Using Env Vars in the value of an Env Var
https://devcenter.bitrise.io/tips-and-tricks/embedding-env-vars/

Default Environment Variables
https://devcenter.bitrise.io/builds/available-environment-variables/

Secrets and Environment Variables - General Overview
https://devcenter.bitrise.io/builds/env-vars-secret-env-vars/

Finally, I'm going to check with my immediate colleagues and see if they have any additional insight to what's going on under the hood. If I find anything useful I'll respond here.

@iainelder
Copy link

I'm a first time user and also confused by this.

The README says:

switch between environment sets : if you work on multiple projects where each one requires different environments you can manage this with envman

How do you do that?

I was expecting there to be a syntax like "envman run ENV CMD" where ENV is the name of an environment and CMD is name of the command.

Is that possible?

@iamcam
Copy link
Author

iamcam commented Jul 3, 2021

@iainelder It's been a while since I looked at resolving this issue, but I believe the idea is that you could swap out .envstores or share the same ones between projects (say you had the configuration in a secure location, you could download it from the remote on whichever projects you wish). Since there's currently no way to have organization-level shared variables and secrets, this is the best bet. IIRC I figured out the gist after playing with a few ideas on a dummy workflow, then transferred it to the one I was building out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants