这是indexloc提供的服务,不要输入任何密码
Skip to content

Support per-branch environment variables #20

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

Merged
merged 2 commits into from
Apr 22, 2022

Conversation

BarnabyShearer
Copy link
Contributor

Fixes #13

Straightforward change to expose the API field.

@@ -93,6 +93,7 @@ resource "vercel_project" "example" {

Optional:

- **git_branch** (String) The git branch of the environment variable.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not 100% familiar with this API, but can you only specify git_branch for preview targets, or does it work across all different target possibilities?
e.g. what happens if I specified

target     = ["production", "preview"]
git_branch = "staging" 
key        = "foo"
value      = "bar" 

I'm wondering if it's worth adding some additional validation around that.
Granted the provider is currently pretty light on up-front validation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The API is very strict; the branch has to actually exist, can't be your production branch etc. Lots of things we cannot validate here. You get good error messages if you try to do something impossible.

Comment on lines +76 to +80
"git_branch": {
Description: "The git branch of the environment variable.",
Type: types.StringType,
Optional: true,
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we're also missing a test that includes the git_branch being used.

Copy link
Contributor Author

@BarnabyShearer BarnabyShearer Apr 22, 2022

Choose a reason for hiding this comment

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

I think at the moment the git tests only actually work for you. I get

Could not create project, unexpected error: bad_request - To link a GitHub
        repository, you need to install the GitHub integration first.

Which I think is because I can only use my own repositories. However I have added some reasonable tests that will hopefully work. (You will need to crate a staging branch in your test repository).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ahh yeah, makes sense. We should probably read an environment variable for the non-team git repository or something. I don't think we can keep it pointing at my git repos forever 🤣. One for later though!

Fixes vercel#13

Straightforward change to expose the API field.
@dglsparsons dglsparsons merged commit 63bb67f into vercel:main Apr 22, 2022
dglsparsons added a commit that referenced this pull request Apr 25, 2022
The Project struct is used by both the data_source
and the resource. However, git_branch for environment_variables
were only added to the resource.
dglsparsons added a commit that referenced this pull request Apr 25, 2022
The Project struct is used by both the data_source
and the resource. However, git_branch for environment_variables
were only added to the resource.
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

Successfully merging this pull request may close these issues.

Support per-branch environment variables
2 participants