-
Notifications
You must be signed in to change notification settings - Fork 763
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
Add visibility parameter to data source and resource #454
Conversation
Definitely something funky going on. |
@@ -179,6 +184,7 @@ func resourceGithubRepositoryObject(d *schema.ResourceData) *github.Repository { | |||
Description: github.String(d.Get("description").(string)), | |||
Homepage: github.String(d.Get("homepage_url").(string)), | |||
Private: github.Bool(d.Get("private").(bool)), | |||
Visibility: github.String(d.Get("visibility").(string)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from running the acceptance tests, it seems passing an empty string here causes a strange 403 error about not having admin rights..in this case, it may make more sense to pull out this attribute and only set it if the string's available
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aiming to perform a follow-up pass to address this. Thanks for raising this.
@@ -303,6 +309,7 @@ func resourceGithubRepositoryRead(d *schema.ResourceData, meta interface{}) erro | |||
d.Set("description", repo.GetDescription()) | |||
d.Set("homepage_url", repo.GetHomepage()) | |||
d.Set("private", repo.GetPrivate()) | |||
d.Set("visibility", repo.GetVisibility()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in cases where visibility
isn't provided, looks like we'll be left with a non-empty plan as the API returns one of the 3 visibility type values. we can account for this if we make the param also Computed
.. I was considering not setting this if the param is not available but I believe it's generally discouraged to use d.GetOk() or d.Get()
to influence d.Set()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This too is queued to be addressed by a subsequent pass.
@patrickmarabeas as a sanity check, we should also add a test case that uses a config w/ |
So there's an issue with the Github API itself. Basically you cannot patch the endpoint with a visibility value that is the same. I don't know if this is a usable parameter for Terraform currently...
|
ah interesting, I wonder if for some reason the *nvm |
Same issues with Just ran this twice:
I'll try |
you may have to chain this condition with |
75d7f30
to
4914739
Compare
So there is some naff auth stuff happening with that endpoint. Wish I had taken more notice of your first comment. This occurs when creating a repository with the Looks like it is now behaving as expected:
|
Still needs work, plans are still detecting diffs each run:
So from an API perspective it is working ( (
It seems once you start using |
😬 yikes, turning out to be more thorny than i expected..i can help investigate on my end as well |
OK - it's just the funkiness of |
4914739
to
c3aba12
Compare
@anGie44 give it a whirl and see what you think. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running the acceptance tests results in a few failures like this:
=== CONT TestAccGithubRepository_topics
--- FAIL: TestAccGithubRepository_topics (10.09s)
testing.go:654: Step 3 error: Check failed: Check 2/2 error: got visibility "public"; want ""
FAIL
FAIL github.com/terraform-providers/terraform-provider-github/github 10.335s
? github.com/terraform-providers/terraform-provider-github [no test files]
I've got this queued to investigate and also aim to add coverage for the behaviours investigated in this comment.
Ah yes - @jcudit Is it possible to run a subset of acceptance tests? I will squash and rebase when ready to merge. |
Adding a label to a PR prefixed with |
I meant locally - I think Github Actions will have limitations around forks |
Ah, locally tests can be invoked via: TF_ACC=1 go test -v -timeout 30m ./... -run TestProvider_insecure The script that runs the automated tests is locally runnable as well. |
@patrickmarabeas hare are a pair of commits available to cherry-pick that will get acceptance tests passing: |
12186af
to
4c243d8
Compare
@jcudit commits cherry-picked and PR rebased |
@patrickmarabeas this looks ready to go, however we hit a conflict. Can you take a last look at this one? This PR is next up to merge and will close out the v2.9.0 milestone. |
Adds the additional visibility parameter allowing for enterprise accounts to have set the repository to be only internally visible. Resolves integrations#304
Adds the additional visibility parameter allowing for enterprise accounts to set the repository to be only internally visible. The endpoint is a little sketchy: * an error if trying to update with a visibility value that is the same * auth issues are encountered if trying to create with a visibility value. The parameter needs to be ignored during create, and updated subsequently. Resolves integrations#304
a7aa102
to
855ba33
Compare
@jcudit rebased. |
Adds the additional visibility parameter allowing for enterprise
accounts to set the repository to be only internally visible.
Fixes issues within #441
Resolves #304