Skip to content
This repository has been archived by the owner on Dec 8, 2020. It is now read-only.

[WIP] added deploy key resource #9

Closed
wants to merge 3 commits into from
Closed

[WIP] added deploy key resource #9

wants to merge 3 commits into from

Conversation

sjauld
Copy link

@sjauld sjauld commented Oct 4, 2017

My first crack at adding a new resource - please let me know if anything else is needed.

make testacc
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test $(go list ./... |grep -v 'vendor') -v  -timeout 120m
?   	github.com/terraform-providers/terraform-provider-bitbucket	[no test files]
=== RUN   TestProvider
--- PASS: TestProvider (0.00s)
=== RUN   TestProvider_impl
--- PASS: TestProvider_impl (0.00s)
=== RUN   TestAccBitbucketDefaultReviewers_basic
--- PASS: TestAccBitbucketDefaultReviewers_basic (19.40s)
=== RUN   TestAccBitbucketDeployKey_basic
--- PASS: TestAccBitbucketDeployKey_basic (20.88s)
=== RUN   TestAccBitbucketHook_basic
--- PASS: TestAccBitbucketHook_basic (22.34s)
=== RUN   TestAccBitbucketRepository_basic
--- PASS: TestAccBitbucketRepository_basic (10.86s)
=== RUN   TestAccBitbucketRepository_camelcase
--- PASS: TestAccBitbucketRepository_camelcase (11.90s)
PASS
ok  	github.com/terraform-providers/terraform-provider-bitbucket/bitbucket	85.394s

Copy link
Contributor

@pdecat pdecat left a comment

Choose a reason for hiding this comment

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

I'm not a maintainer but as I also submitted my first PR to add a group resource using the 1.0 API a few weeks ago, I was curious to see if we did things differently or not.

Anyway, here is my informal review.

Exists: resourceDeployKeyExists,

Schema: map[string]*schema.Schema{
"owner": &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.

The API documentation refers to this as accountnamewhich is what I used in my own PR https://github.com/terraform-providers/terraform-provider-bitbucket/pull/6/files#diff-212cd6fa62f60904d8a923069edaa6c9R43

Not sure which is better.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah I used owner to align with the existing resources in this repo. Atlassian's docs seem to interchangeably use accountname or username (maybe a 1.0 vs 2.0 difference), so I guess owner is as good as anything.

t.Fatal("BITBUCKET_PASSWORD must be set for acceptence tests")
t.Fatal("BITBUCKET_PASSWORD must be set for acceptance tests")
}
if v := os.Getenv("BITBUCKET_TEAM"); v == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not that my opinion matters at all, but I like the idea of introducing a BITBUCKET_TEAM environment variable.

deployKey_req, _ := client.Get(fmt.Sprintf("1.0/repositories/%s/%s/deploy-keys/%s",
d.Get("owner").(string),
d.Get("repository").(string),
url.PathEscape(d.Id()),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why escape as the pk/id is an integer?

url.PathEscape(d.Id()),
))

log.Printf("ID: %s", url.PathEscape(d.Id()))
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't that be in debug level?

_, err = client.Put(fmt.Sprintf("1.0/repositories/%s/%s/deploy-keys/%s",
d.Get("owner").(string),
d.Get("repository").(string),
url.PathEscape(d.Id()),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why escape as the pk/id is an integer?

@sjauld
Copy link
Author

sjauld commented Oct 18, 2017

ForceNew: true,
ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) {
value := v.(string)
pattern := "ssh-rsa AAAA[0-9A-Za-z+/]+[=]{0,3}( [^@]+@[^@]+)?"
Copy link
Contributor

Choose a reason for hiding this comment

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

We support more than just rsa. So this will break if you try to do a ecdsa key.

@cwood
Copy link
Contributor

cwood commented Nov 7, 2017

My only real concern is that the validation string wont really work since we support more than just RSA.

@cwood
Copy link
Contributor

cwood commented Nov 7, 2017

Sorry to have negative information. But essentially we are gonna be removing all of the 1.0 API's soon(can't give specifics - watch for a blog post). Iv talked to the devs who maintain and work on the apis for us and they havnt come up with any specifics. But it is similar to users/groups.

@cwood cwood closed this Nov 7, 2017
@sjauld
Copy link
Author

sjauld commented Nov 9, 2017

Sorry, are you saying that Atlassian is removing support for adding deploy keys via the API? I'm a little confused...

@pdecat
Copy link
Contributor

pdecat commented Nov 10, 2017

On the same stance here, confused, as the same arguments were invoked to decline #6.

@cwood
Copy link
Contributor

cwood commented Nov 10, 2017 via email

@sjauld
Copy link
Author

sjauld commented Nov 10, 2017 via email

@cwood
Copy link
Contributor

cwood commented Nov 10, 2017

Yea unfortunately. I am not happy about this either. Your best bet would to make a site/master issue and ask for a 2.0 version of the deployment keys. I asked our API team again and they confirmed it.

@erikvanzijst
Copy link

So to confirm, Atlassian will remove the existing feature enabling the programmatic management of deploy keys?

This is correct.

We don't yet have a date for when we turn off these APIs, but we will not be creating copies of these in 2.0. I've left a more complete motivation on the site/master ticket.

@cwood
Copy link
Contributor

cwood commented Nov 16, 2017 via email

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