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

Expose Action.Getenv #37

Merged
merged 1 commit into from
Feb 9, 2022
Merged

Expose Action.Getenv #37

merged 1 commit into from
Feb 9, 2022

Conversation

AlekSi
Copy link
Contributor

@AlekSi AlekSi commented Feb 9, 2022

This commit makes Action.getenv accessible without making it settable without using WithGetenv. That allows tests with a fake environment to pass only Action.

For example, there I have to pass both Action and a fake getenv function to the function I want to test: https://github.com/FerretDB/github-actions/blob/e34bef95940ca0d735069846e840f4e0aacddfc9/extract-docker-tag/main_test.go#L11-L39

@sethvargo
Copy link
Owner

Sorry, I don't understand the request here. You have a getenv func, why not call that directly?

@AlekSi
Copy link
Contributor Author

AlekSi commented Feb 9, 2022

I do that: https://github.com/FerretDB/github-actions/blob/e34bef95940ca0d735069846e840f4e0aacddfc9/extract-docker-tag/main.go#L38-L40
The problem is that now I have two: one is passed explicitly, and one is used by an Action internally. I have to keep two in sync.

@@ -405,6 +405,11 @@ func (c *Action) GetIDToken(ctx context.Context, audience string) (string, error
return tokenResp.Value, nil
}

// Getenv retrieves the value of the environment variable named by the key.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you document that it uses the internal Getenv function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, added the second line to this comment

This commit makes `Action.getenv` accessible without making it settable without using `WithGetenv`. That allows tests with a fake environment to pass only Action.
@sethvargo sethvargo merged commit 2b8e95d into sethvargo:main Feb 9, 2022
@sethvargo
Copy link
Owner

Do you want me to cut a release, or do you have some other PRs up your sleeve?

@AlekSi AlekSi deleted the getenv branch February 9, 2022 19:16
@AlekSi
Copy link
Contributor Author

AlekSi commented Feb 9, 2022

Nope, nothing today :) Thank you!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants