-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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 Support for Google source repos #256
Conversation
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.
Hi,
Looks good. A few comments:
I would suggest renaming google_sourcerepos_repository
to google_sourcerepo_repository
. For all the other resources we use the singular: google_compute_instance
, google_compute_network
, etc. And this resource represents only one repository.
|
||
# google\_sourcerepos\_repository | ||
|
||
Manages repositories within Google Cloud Source Repositories. |
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.
Can you add links to the Google Cloud documentation. I suggest appending the following to this line:
For more information, see [the official
documentation](https://cloud.google.com/compute/docs/source-repositories) and
[API](https://cloud.google.com/source-repositories/docs/reference/rest/v1/projects.repos)
|
||
## Example Usage | ||
|
||
This example is the common case of creating a repository within Google Cloud Source Repositores: |
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.
typo: s/Repositores/Repositories
Delete: resourceSourceReposRepositoryDelete, | ||
//Update: not supported, | ||
|
||
Schema: map[string]*schema.Schema{ |
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.
Consider adding the size
as a Computed field. I can see the value for a user who might want to add an output block to their Terraform config to print out the current repo size.
func resourceSourceReposRepositoryCreate(d *schema.ResourceData, meta interface{}) error { | ||
config := meta.(*Config) | ||
|
||
if _, ok := d.GetOk("project"); ok { |
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.
Remove this block, I guess you have been using this for debugging :)
Name: name, | ||
} | ||
|
||
project = "projects/" + project |
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.
Change for parent := "projects/" + project to use the same nomenclature than the official docs.
|
||
project = "projects/" + project | ||
|
||
job, err := config.clientSourceRepos.Projects.Repos.Create(project, repo).Do() |
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.
For consistency with the other resources, we call the job
var op
.
return err | ||
} | ||
|
||
//project = "projects/" + project |
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.
Remove these comments
Thanks for the comments, I think I addressed everything. Good assist on the "size". I can now get this:
I didn't change "repos" to "repo" in every single part of the code but I think it should be fine. |
Thank you Alex for your contribution! I pushed a commit to your branch to fix the acceptance test (you forgot to rename the resource there after changing the name. The tests are now passing. TF_ACC=1 go test $(go list ./... |grep -v 'vendor') -v -run TestAccSourceRepoRepository_basic -timeout 120m @paddycarver, we will need to Enable the Cloud Repositories API on the HashiCorp CI server. I don't have the permissions to do that. We also need to make sure that the credentials we are using either have a "Owner" role (grants all permissions) or have the "Cloud Repositories Admin" role. I will merge as soon as @paddycarver confirms that the CI server is properly configured. |
Awesome, thanks for fixing that too. |
@danawillow Are you onboard with the naming convention for Source Repo?
And whenever they add new feature, we could have something like
|
Just to chime in with my two cents - I think we should use My thoughts behind naming it like that are that it is a |
website/google.erb
Outdated
@@ -250,6 +250,15 @@ | |||
</ul> | |||
</li> | |||
|
|||
<li<%= sidebar_current("docs-google-sourcerepo") %>> | |||
<a href="#">Google Source Repos Resources</a> |
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.
For docs let's use the full name- Google Source Repositories Resources
Yup I'm on board for |
@rileykarson the "s" was a typo in my comment... I meant using |
Woops, I steamrolled over your fix, rosbo, I'll re-add it. |
In case you lost my commit when you steamrolled it, I pushed it to my fork and you can take it from there: |
Thanks, should be all good now. |
<!-- This change is generated by MagicModules. --> /cc @akramhussein
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks! |
Addresses #255
The naming of the resource was not self evident because it's not very consistent on GCP either. I went for "source repos" as in the API (google.golang.org/api/sourcerepo/v1) to avoid the length and repetitiveness of calling it a "Google Source Repositories Repository".