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

Add Support for Google source repos #256

Merged
merged 6 commits into from
Aug 3, 2017
Merged

Add Support for Google source repos #256

merged 6 commits into from
Aug 3, 2017

Conversation

alex1x
Copy link
Contributor

@alex1x alex1x commented Jul 27, 2017

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".

@alex1x alex1x changed the title Google source repos Add Support for Google source repos Jul 27, 2017
Copy link
Contributor

@rosbo rosbo left a 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.
Copy link
Contributor

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:
Copy link
Contributor

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{
Copy link
Contributor

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 {
Copy link
Contributor

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
Copy link
Contributor

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()
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove these comments

@alex1x
Copy link
Contributor Author

alex1x commented Aug 3, 2017

Thanks for the comments, I think I addressed everything. Good assist on the "size". I can now get this:

$ terraform output
reposize = 12614

I didn't change "repos" to "repo" in every single part of the code but I think it should be fine.

@rosbo
Copy link
Contributor

rosbo commented Aug 3, 2017

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
? github.com/terraform-providers/terraform-provider-google [no test files]
=== RUN TestAccSourceRepoRepository_basic
--- PASS: TestAccSourceRepoRepository_basic (2.47s)
PASS
ok github.com/terraform-providers/terraform-provider-google/google 2.609s

@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.

@alex1x
Copy link
Contributor Author

alex1x commented Aug 3, 2017

Awesome, thanks for fixing that too.

@rosbo
Copy link
Contributor

rosbo commented Aug 3, 2017

@danawillow Are you onboard with the naming convention for Source Repo?

google_sourcerepo_repository for a repository.

And whenever they add new feature, we could have something like

google_sourcerepo_webhook (Edit, removed the s, typo).

@rileykarson
Copy link
Collaborator

Just to chime in with my two cents - I think we should use sourcerepo all the time; preferring google_sourcerepo_webhook over google_sourcerepos_webhook.

My thoughts behind naming it like that are that it is a google provider feature from the sourcerepo API, and the resource name is webhook.

@@ -250,6 +250,15 @@
</ul>
</li>

<li<%= sidebar_current("docs-google-sourcerepo") %>>
<a href="#">Google Source Repos Resources</a>
Copy link
Contributor

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

@danawillow
Copy link
Contributor

Yup I'm on board for google_sourcerepo_{feature}

@rosbo
Copy link
Contributor

rosbo commented Aug 3, 2017

@rileykarson the "s" was a typo in my comment... I meant using google_sourcerepo_*. Sorry about the confusion.

@alex1x
Copy link
Contributor Author

alex1x commented Aug 3, 2017

Woops, I steamrolled over your fix, rosbo, I'll re-add it.

@rosbo
Copy link
Contributor

rosbo commented Aug 3, 2017

@alex1x

In case you lost my commit when you steamrolled it, I pushed it to my fork and you can take it from there:
rosbo@d12a694

@alex1x
Copy link
Contributor Author

alex1x commented Aug 3, 2017

Thanks, should be all good now.

@rosbo rosbo merged commit 8570849 into hashicorp:master Aug 3, 2017
z1nkum pushed a commit to z1nkum/terraform-provider-google that referenced this pull request Aug 15, 2017
negz pushed a commit to negz/terraform-provider-google that referenced this pull request Oct 17, 2017
chrisst pushed a commit to chrisst/terraform-provider-google that referenced this pull request Nov 9, 2018
luis-silva pushed a commit to luis-silva/terraform-provider-google that referenced this pull request May 21, 2019
<!-- This change is generated by MagicModules. -->
/cc @akramhussein
@ghost
Copy link

ghost commented Mar 31, 2020

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!

@ghost ghost locked and limited conversation to collaborators Mar 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants