-
Notifications
You must be signed in to change notification settings - Fork 319
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
feature: add project mirror resources to provider #358
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.
General thing I noticed - you can use %d
instead of %v
for the mirror ID (int) throughout, in format strings.
Also, tests?
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.
lgtm
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.
sorry, just realized again - please add a test :)
Can you add a test for the importer as well? You can copy an _import test from another resource without much change. |
Will do, late GMT so will do tomorrow. Thanks for reviewing and patience much appreciated. |
Having issues adding the importer at the moment, and quite make sense of the error either. Still working on this, any input would be great - im not too familiar with the import tests, or the workflow it runs. Trying to pin down where the call to gitlab is being made. |
The importer test is fine. The problem occurs after the import, during the read. Your read function uses some attributes that are not set in your import function. Check the docs for https://www.terraform.io/docs/extend/resources/import.html#importer-state-function
|
You can now rebase on master, go-gitlab has been updated |
I've got the acceptance tests working, testing manually resource imports fine also. |
rebased and caused a lot of mess. Resouce is working as expected. Do you require the commit history to be cleared up any further or is this good? |
d.Set("enabled", projectMirror.Enabled) | ||
d.Set("only_protected_branches", projectMirror.OnlyProtectedBranches) | ||
d.Set("keep_divergent_refs", projectMirror.KeepDivergentRefs) | ||
d.SetId(buildTwoPartID(projectID, &mirrorID)) |
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.
Nitpick, but this line is unnecessary since in all cases the ID will have already been set before calling this function.
@@ -0,0 +1,213 @@ | |||
package gitlab | |||
|
|||
// TODO convert to handle project mirror. |
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.
I can't tell what this means.
ResourceName: "gitlab_project_mirror.foo", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"enabled", "mirror_id", "project", "url"}, |
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.
Why was this needed? The import should result in a fully synced state, ideally.
If you could squash this MR that could be good, because GitHub looks confused. Maybe it's just me but it's showing changes in the diff that aren't yours. |
That occured once I performed Re: import test. Testing manually the resource is imported fine using the terraform cli, the import test does not show any fields. I've copied the test from other resources unsure why this is causing problems as the functionality works. |
Import test success, I wasn't setting all properties |
} | ||
} | ||
|
||
func testAccCheckGitlabProjectMirrorDestroy(s *terraform.State) error { |
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.
Just an fyi, a "destroy" test should be testing the behavior of your own resource destroy function, i.e. checking that the mirror gets disabled. There's an open issue about this generally #205 so we can come back and do this later.
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.
sure, I will not make any changes in this PR for this.
Can you add a new documentation page for this new resource? |
added docs page. |
Looks good, but can you add the new doc page to the index (like so #391) |
ack I actually searched for an index, didn't realise it was the erb file. should be done. |
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.
Thanks!
@armsnyder is there anything I can do to speed this up getting merged? I have some work in the next week that i'd be keen to use this resource for... unsure on the release cadence or the process? |
I don't have merging powers, but @nicholasklick may be able to give an update. |
Hi @nicholasklick any timeframe on this getting merged? |
Implemented functionality for project mirrors, as per issue https://github.com/terraform-providers/terraform-provider-gitlab/issues/150
This was recently added to the go-gitlab library by myself and released in v0.33.0
xanzy/go-gitlab#879