mirror of
https://github.com/ysoftdevs/terraform-provider-bitbucketserver.git
synced 2026-04-05 08:47:02 +02:00
fix(repository_deploy_keys): Make deploy keys compatible to bitbucket-dc-lts
For some reason this api does return ints, where it is supposed to return strings in older LTS versions.
This commit is contained in:
@@ -18,9 +18,9 @@ func TestAccBitbucketDataApplicationProperties(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Config: config,
|
Config: config,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
resource.TestCheckResourceAttr("data.bitbucketserver_application_properties.main", "version", "8.5.4"),
|
resource.TestCheckResourceAttr("data.bitbucketserver_application_properties.main", "version", "9.4.2"),
|
||||||
resource.TestCheckResourceAttr("data.bitbucketserver_application_properties.main", "build_number", "8005004"),
|
resource.TestCheckResourceAttr("data.bitbucketserver_application_properties.main", "build_number", "9004002"),
|
||||||
resource.TestCheckResourceAttr("data.bitbucketserver_application_properties.main", "build_date", "1681201969213"),
|
resource.TestCheckResourceAttr("data.bitbucketserver_application_properties.main", "build_date", "1736803793767"),
|
||||||
resource.TestCheckResourceAttr("data.bitbucketserver_application_properties.main", "display_name", "Bitbucket"),
|
resource.TestCheckResourceAttr("data.bitbucketserver_application_properties.main", "display_name", "Bitbucket"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ func TestAccBitbucketDataProjectHooks_simple(t *testing.T) {
|
|||||||
resource.TestCheckResourceAttr("data.bitbucketserver_project_hooks.test", "hooks.0.name", "All reviewers approve"),
|
resource.TestCheckResourceAttr("data.bitbucketserver_project_hooks.test", "hooks.0.name", "All reviewers approve"),
|
||||||
resource.TestCheckResourceAttr("data.bitbucketserver_project_hooks.test", "hooks.0.type", "PRE_PULL_REQUEST_MERGE"),
|
resource.TestCheckResourceAttr("data.bitbucketserver_project_hooks.test", "hooks.0.type", "PRE_PULL_REQUEST_MERGE"),
|
||||||
resource.TestCheckResourceAttr("data.bitbucketserver_project_hooks.test", "hooks.0.description", "Require all reviewers to approve the pull request."),
|
resource.TestCheckResourceAttr("data.bitbucketserver_project_hooks.test", "hooks.0.description", "Require all reviewers to approve the pull request."),
|
||||||
resource.TestCheckResourceAttr("data.bitbucketserver_project_hooks.test", "hooks.0.version", "8.5.4"),
|
resource.TestCheckResourceAttr("data.bitbucketserver_project_hooks.test", "hooks.0.version", "9.4.2"),
|
||||||
resource.TestCheckResourceAttr("data.bitbucketserver_project_hooks.test", "hooks.0.scope_types.#", "2"),
|
resource.TestCheckResourceAttr("data.bitbucketserver_project_hooks.test", "hooks.0.scope_types.#", "2"),
|
||||||
resource.TestCheckResourceAttr("data.bitbucketserver_project_hooks.test", "hooks.0.scope_types.0", "PROJECT"),
|
resource.TestCheckResourceAttr("data.bitbucketserver_project_hooks.test", "hooks.0.scope_types.0", "PROJECT"),
|
||||||
resource.TestCheckResourceAttr("data.bitbucketserver_project_hooks.test", "hooks.0.scope_types.1", "REPOSITORY"),
|
resource.TestCheckResourceAttr("data.bitbucketserver_project_hooks.test", "hooks.0.scope_types.1", "REPOSITORY"),
|
||||||
@@ -74,7 +74,7 @@ func TestAccBitbucketDataProjectHooks_type(t *testing.T) {
|
|||||||
resource.TestCheckResourceAttr("data.bitbucketserver_project_hooks.test", "hooks.0.name", "Reject Force Push"),
|
resource.TestCheckResourceAttr("data.bitbucketserver_project_hooks.test", "hooks.0.name", "Reject Force Push"),
|
||||||
resource.TestCheckResourceAttr("data.bitbucketserver_project_hooks.test", "hooks.0.type", "PRE_RECEIVE"),
|
resource.TestCheckResourceAttr("data.bitbucketserver_project_hooks.test", "hooks.0.type", "PRE_RECEIVE"),
|
||||||
resource.TestCheckResourceAttr("data.bitbucketserver_project_hooks.test", "hooks.0.description", "Reject all force pushes (git push --force) to this repository"),
|
resource.TestCheckResourceAttr("data.bitbucketserver_project_hooks.test", "hooks.0.description", "Reject all force pushes (git push --force) to this repository"),
|
||||||
resource.TestCheckResourceAttr("data.bitbucketserver_project_hooks.test", "hooks.0.version", "8.5.4"),
|
resource.TestCheckResourceAttr("data.bitbucketserver_project_hooks.test", "hooks.0.version", "9.4.2"),
|
||||||
resource.TestCheckResourceAttr("data.bitbucketserver_project_hooks.test", "hooks.0.scope_types.#", "2"),
|
resource.TestCheckResourceAttr("data.bitbucketserver_project_hooks.test", "hooks.0.scope_types.#", "2"),
|
||||||
resource.TestCheckResourceAttr("data.bitbucketserver_project_hooks.test", "hooks.0.scope_types.0", "PROJECT"),
|
resource.TestCheckResourceAttr("data.bitbucketserver_project_hooks.test", "hooks.0.scope_types.0", "PROJECT"),
|
||||||
resource.TestCheckResourceAttr("data.bitbucketserver_project_hooks.test", "hooks.0.scope_types.1", "REPOSITORY"),
|
resource.TestCheckResourceAttr("data.bitbucketserver_project_hooks.test", "hooks.0.scope_types.1", "REPOSITORY"),
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ func TestAccBitbucketDataRepositoryHooks_simple(t *testing.T) {
|
|||||||
resource.TestCheckResourceAttr("data.bitbucketserver_repository_hooks.test", "hooks.0.name", "All reviewers approve"),
|
resource.TestCheckResourceAttr("data.bitbucketserver_repository_hooks.test", "hooks.0.name", "All reviewers approve"),
|
||||||
resource.TestCheckResourceAttr("data.bitbucketserver_repository_hooks.test", "hooks.0.type", "PRE_PULL_REQUEST_MERGE"),
|
resource.TestCheckResourceAttr("data.bitbucketserver_repository_hooks.test", "hooks.0.type", "PRE_PULL_REQUEST_MERGE"),
|
||||||
resource.TestCheckResourceAttr("data.bitbucketserver_repository_hooks.test", "hooks.0.description", "Require all reviewers to approve the pull request."),
|
resource.TestCheckResourceAttr("data.bitbucketserver_repository_hooks.test", "hooks.0.description", "Require all reviewers to approve the pull request."),
|
||||||
resource.TestCheckResourceAttr("data.bitbucketserver_repository_hooks.test", "hooks.0.version", "8.5.4"),
|
resource.TestCheckResourceAttr("data.bitbucketserver_repository_hooks.test", "hooks.0.version", "9.4.2"),
|
||||||
resource.TestCheckResourceAttr("data.bitbucketserver_repository_hooks.test", "hooks.0.scope_types.#", "2"),
|
resource.TestCheckResourceAttr("data.bitbucketserver_repository_hooks.test", "hooks.0.scope_types.#", "2"),
|
||||||
resource.TestCheckResourceAttr("data.bitbucketserver_repository_hooks.test", "hooks.0.scope_types.0", "PROJECT"),
|
resource.TestCheckResourceAttr("data.bitbucketserver_repository_hooks.test", "hooks.0.scope_types.0", "PROJECT"),
|
||||||
resource.TestCheckResourceAttr("data.bitbucketserver_repository_hooks.test", "hooks.0.scope_types.1", "REPOSITORY"),
|
resource.TestCheckResourceAttr("data.bitbucketserver_repository_hooks.test", "hooks.0.scope_types.1", "REPOSITORY"),
|
||||||
@@ -86,7 +86,7 @@ func TestAccBitbucketDataRepositoryHooks_type(t *testing.T) {
|
|||||||
resource.TestCheckResourceAttr("data.bitbucketserver_repository_hooks.test", "hooks.0.name", "Reject Force Push"),
|
resource.TestCheckResourceAttr("data.bitbucketserver_repository_hooks.test", "hooks.0.name", "Reject Force Push"),
|
||||||
resource.TestCheckResourceAttr("data.bitbucketserver_repository_hooks.test", "hooks.0.type", "PRE_RECEIVE"),
|
resource.TestCheckResourceAttr("data.bitbucketserver_repository_hooks.test", "hooks.0.type", "PRE_RECEIVE"),
|
||||||
resource.TestCheckResourceAttr("data.bitbucketserver_repository_hooks.test", "hooks.0.description", "Reject all force pushes (git push --force) to this repository"),
|
resource.TestCheckResourceAttr("data.bitbucketserver_repository_hooks.test", "hooks.0.description", "Reject all force pushes (git push --force) to this repository"),
|
||||||
resource.TestCheckResourceAttr("data.bitbucketserver_repository_hooks.test", "hooks.0.version", "8.5.4"),
|
resource.TestCheckResourceAttr("data.bitbucketserver_repository_hooks.test", "hooks.0.version", "9.4.2"),
|
||||||
resource.TestCheckResourceAttr("data.bitbucketserver_repository_hooks.test", "hooks.0.scope_types.#", "2"),
|
resource.TestCheckResourceAttr("data.bitbucketserver_repository_hooks.test", "hooks.0.scope_types.#", "2"),
|
||||||
resource.TestCheckResourceAttr("data.bitbucketserver_repository_hooks.test", "hooks.0.scope_types.0", "PROJECT"),
|
resource.TestCheckResourceAttr("data.bitbucketserver_repository_hooks.test", "hooks.0.scope_types.0", "PROJECT"),
|
||||||
resource.TestCheckResourceAttr("data.bitbucketserver_repository_hooks.test", "hooks.0.scope_types.1", "REPOSITORY"),
|
resource.TestCheckResourceAttr("data.bitbucketserver_repository_hooks.test", "hooks.0.scope_types.1", "REPOSITORY"),
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ func TestAccBitbucketPlugin_install(t *testing.T) {
|
|||||||
config := `
|
config := `
|
||||||
resource "bitbucketserver_plugin" "test" {
|
resource "bitbucketserver_plugin" "test" {
|
||||||
key = "com.plugin.commitgraph.commitgraph"
|
key = "com.plugin.commitgraph.commitgraph"
|
||||||
version = "5.3.3"
|
version = "6.0.0"
|
||||||
license = "AAABCA0ODAoPeNpdj01PwkAURffzKyZxZ1IyUzARkllQ24gRaQMtGnaP8VEmtjPNfFT59yJVFyzfubkn796Ux0Bz6SmbUM5nbDzj97RISxozHpMUnbSq88poUaLztFEStUN6MJZ2TaiVpu/YY2M6tI6sQrtHmx8qd74EZ+TBIvyUU/AoYs7jiE0jzknWQxMuifA2IBlUbnQ7AulVjwN9AaU9atASs69O2dNFU4wXJLc1aOUGw9w34JwCTTZoe7RPqUgep2X0Vm0n0fNut4gSxl/Jcnj9nFb6Q5tP/Ueu3L+0PHW4ghZFmm2zZV5k6/95CbR7Y9bYGo/zGrV3Ir4jRbDyCA6vt34DO8p3SDAsAhQnJjLD5k9Fr3uaIzkXKf83o5vDdQIUe4XequNCC3D+9ht9ZYhNZFKmnhc=X02dh"
|
license = "AAABCA0ODAoPeNpdj01PwkAURffzKyZxZ1IyUzARkllQ24gRaQMtGnaP8VEmtjPNfFT59yJVFyzfubkn796Ux0Bz6SmbUM5nbDzj97RISxozHpMUnbSq88poUaLztFEStUN6MJZ2TaiVpu/YY2M6tI6sQrtHmx8qd74EZ+TBIvyUU/AoYs7jiE0jzknWQxMuifA2IBlUbnQ7AulVjwN9AaU9atASs69O2dNFU4wXJLc1aOUGw9w34JwCTTZoe7RPqUgep2X0Vm0n0fNut4gSxl/Jcnj9nFb6Q5tP/Ueu3L+0PHW4ghZFmm2zZV5k6/95CbR7Y9bYGo/zGrV3Ir4jRbDyCA6vt34DO8p3SDAsAhQnJjLD5k9Fr3uaIzkXKf83o5vDdQIUe4XequNCC3D+9ht9ZYhNZFKmnhc=X02dh"
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
@@ -24,16 +24,16 @@ func TestAccBitbucketPlugin_install(t *testing.T) {
|
|||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
resource.TestCheckResourceAttr("bitbucketserver_plugin.test", "key", "com.plugin.commitgraph.commitgraph"),
|
resource.TestCheckResourceAttr("bitbucketserver_plugin.test", "key", "com.plugin.commitgraph.commitgraph"),
|
||||||
resource.TestCheckResourceAttr("bitbucketserver_plugin.test", "enabled", "true"),
|
resource.TestCheckResourceAttr("bitbucketserver_plugin.test", "enabled", "true"),
|
||||||
resource.TestCheckResourceAttr("bitbucketserver_plugin.test", "version", "5.3.3"),
|
resource.TestCheckResourceAttr("bitbucketserver_plugin.test", "version", "6.0.0"),
|
||||||
resource.TestCheckResourceAttr("bitbucketserver_plugin.test", "license", "AAABCA0ODAoPeNpdj01PwkAURffzKyZxZ1IyUzARkllQ24gRaQMtGnaP8VEmtjPNfFT59yJVFyzfubkn796Ux0Bz6SmbUM5nbDzj97RISxozHpMUnbSq88poUaLztFEStUN6MJZ2TaiVpu/YY2M6tI6sQrtHmx8qd74EZ+TBIvyUU/AoYs7jiE0jzknWQxMuifA2IBlUbnQ7AulVjwN9AaU9atASs69O2dNFU4wXJLc1aOUGw9w34JwCTTZoe7RPqUgep2X0Vm0n0fNut4gSxl/Jcnj9nFb6Q5tP/Ueu3L+0PHW4ghZFmm2zZV5k6/95CbR7Y9bYGo/zGrV3Ir4jRbDyCA6vt34DO8p3SDAsAhQnJjLD5k9Fr3uaIzkXKf83o5vDdQIUe4XequNCC3D+9ht9ZYhNZFKmnhc=X02dh"),
|
resource.TestCheckResourceAttr("bitbucketserver_plugin.test", "license", "AAABCA0ODAoPeNpdj01PwkAURffzKyZxZ1IyUzARkllQ24gRaQMtGnaP8VEmtjPNfFT59yJVFyzfubkn796Ux0Bz6SmbUM5nbDzj97RISxozHpMUnbSq88poUaLztFEStUN6MJZ2TaiVpu/YY2M6tI6sQrtHmx8qd74EZ+TBIvyUU/AoYs7jiE0jzknWQxMuifA2IBlUbnQ7AulVjwN9AaU9atASs69O2dNFU4wXJLc1aOUGw9w34JwCTTZoe7RPqUgep2X0Vm0n0fNut4gSxl/Jcnj9nFb6Q5tP/Ueu3L+0PHW4ghZFmm2zZV5k6/95CbR7Y9bYGo/zGrV3Ir4jRbDyCA6vt34DO8p3SDAsAhQnJjLD5k9Fr3uaIzkXKf83o5vDdQIUe4XequNCC3D+9ht9ZYhNZFKmnhc=X02dh"),
|
||||||
resource.TestCheckResourceAttr("bitbucketserver_plugin.test", "enabled_by_default", "true"),
|
resource.TestCheckResourceAttr("bitbucketserver_plugin.test", "enabled_by_default", "true"),
|
||||||
resource.TestCheckResourceAttr("bitbucketserver_plugin.test", "name", "Charts and Graphs for Bitbucket Server"),
|
resource.TestCheckResourceAttr("bitbucketserver_plugin.test", "name", "Charts and Graphs for Bitbucket Server"),
|
||||||
resource.TestCheckResourceAttr("bitbucketserver_plugin.test", "description", "Gain insight into Bitbucket with charts and graphs that help you visualize user contributions, commits, and team activity."),
|
resource.TestCheckResourceAttr("bitbucketserver_plugin.test", "description", "Gain insight into Bitbucket with charts and graphs that help you visualize user contributions, commits, and team activity."),
|
||||||
resource.TestCheckResourceAttr("bitbucketserver_plugin.test", "user_installed", "true"),
|
resource.TestCheckResourceAttr("bitbucketserver_plugin.test", "user_installed", "true"),
|
||||||
resource.TestCheckResourceAttr("bitbucketserver_plugin.test", "optional", "true"),
|
resource.TestCheckResourceAttr("bitbucketserver_plugin.test", "optional", "true"),
|
||||||
resource.TestCheckResourceAttr("bitbucketserver_plugin.test", "vendor.name", "Mohami"),
|
resource.TestCheckResourceAttr("bitbucketserver_plugin.test", "vendor.name", "Appfire"),
|
||||||
resource.TestCheckResourceAttr("bitbucketserver_plugin.test", "vendor.link", "https://mohami.io"),
|
resource.TestCheckResourceAttr("bitbucketserver_plugin.test", "vendor.link", "https://apps.appf.re/landing"),
|
||||||
resource.TestCheckResourceAttr("bitbucketserver_plugin.test", "vendor.marketplace_link", "https://mohami.io"),
|
resource.TestCheckResourceAttr("bitbucketserver_plugin.test", "vendor.marketplace_link", "https://apps.appf.re/landing"),
|
||||||
resource.TestCheckResourceAttr("bitbucketserver_plugin.test", "applied_license.0.valid", "true"),
|
resource.TestCheckResourceAttr("bitbucketserver_plugin.test", "applied_license.0.valid", "true"),
|
||||||
resource.TestCheckResourceAttr("bitbucketserver_plugin.test", "applied_license.0.evaluation", "true"),
|
resource.TestCheckResourceAttr("bitbucketserver_plugin.test", "applied_license.0.evaluation", "true"),
|
||||||
resource.TestCheckResourceAttr("bitbucketserver_plugin.test", "applied_license.0.nearly_expired", "true"),
|
resource.TestCheckResourceAttr("bitbucketserver_plugin.test", "applied_license.0.nearly_expired", "true"),
|
||||||
|
|||||||
@@ -15,14 +15,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SSHKey struct {
|
type SSHKey struct {
|
||||||
ID int `json:"id,omitempty"`
|
ID int `json:"id,omitempty"`
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
CreatedDate jsonTime `json:"createdDate,omitempty"`
|
CreatedDate jsonTime `json:"createdDate,omitempty"`
|
||||||
UpdatedDate jsonTime `json:"updatedDate,omitempty"`
|
UpdatedDate jsonTime `json:"updatedDate,omitempty"`
|
||||||
URL string `json:"url,omitempty"`
|
|
||||||
Active bool `json:"active"`
|
|
||||||
Events []interface{} `json:"events"`
|
|
||||||
Configuration WebhookConfiguration `json:"configuration"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceRepositoryDeployKey() *schema.Resource {
|
func resourceRepositoryDeployKey() *schema.Resource {
|
||||||
@@ -57,13 +53,19 @@ func resourceRepositoryDeployKey() *schema.Resource {
|
|||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
ValidateFunc: validation.StringInSlice([]string{"REPO_READ", "REPO_WRITE", "REPO_ADMIN"}, false),
|
ValidateFunc: validation.StringInSlice([]string{"REPO_READ", "REPO_WRITE", "REPO_ADMIN"}, false),
|
||||||
},
|
},
|
||||||
|
"expiry_days": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
ForceNew: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type KeyRequestKey struct {
|
type KeyRequestKey struct {
|
||||||
Label string `json:"label"`
|
Label string `json:"label"`
|
||||||
Text string `json:"text"`
|
Text string `json:"text"`
|
||||||
|
ExpiryDays int `json:"expiryDays,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type KeyRequest struct {
|
type KeyRequest struct {
|
||||||
@@ -73,85 +75,18 @@ type KeyRequest struct {
|
|||||||
|
|
||||||
type KeyResponse struct {
|
type KeyResponse struct {
|
||||||
Key struct {
|
Key struct {
|
||||||
Id int `json:"id"`
|
Id int `json:"id"`
|
||||||
ExpiryDays int `json:"expiryDays"`
|
ExpiryDays int `json:"expiryDays"`
|
||||||
BitLength int `json:"bitLength"`
|
CreatedDate int `json:"createdDate"`
|
||||||
AlgorithmType string `json:"algorithmType"`
|
Label string `json:"label"`
|
||||||
CreatedDate string `json:"createdDate"`
|
Text string `json:"text"`
|
||||||
Fingerprint string `json:"fingerprint"`
|
|
||||||
LastAuthenticated string `json:"lastAuthenticated"`
|
|
||||||
Label string `json:"label"`
|
|
||||||
Text string `json:"text"`
|
|
||||||
} `json:"key"`
|
} `json:"key"`
|
||||||
Permission string `json:"permission"`
|
Permission string `json:"permission"`
|
||||||
Project struct {
|
|
||||||
Name string `json:"name"`
|
|
||||||
Key string `json:"key"`
|
|
||||||
Id int `json:"id"`
|
|
||||||
Type string `json:"type"`
|
|
||||||
Public bool `json:"public"`
|
|
||||||
Avatar string `json:"avatar"`
|
|
||||||
Description string `json:"description"`
|
|
||||||
Namespace string `json:"namespace"`
|
|
||||||
Scope string `json:"scope"`
|
|
||||||
} `json:"project"`
|
|
||||||
Repository struct {
|
Repository struct {
|
||||||
Name string `json:"name"`
|
Slug string `json:"slug"`
|
||||||
Id int `json:"id"`
|
Project struct {
|
||||||
State string `json:"state"`
|
Key string `json:"key"`
|
||||||
Public bool `json:"public"`
|
|
||||||
DefaultBranch string `json:"defaultBranch"`
|
|
||||||
HierarchyId string `json:"hierarchyId"`
|
|
||||||
StatusMessage string `json:"statusMessage"`
|
|
||||||
Archived bool `json:"archived"`
|
|
||||||
Forkable bool `json:"forkable"`
|
|
||||||
RelatedLinks struct {
|
|
||||||
} `json:"relatedLinks"`
|
|
||||||
Partition int `json:"partition"`
|
|
||||||
Origin struct {
|
|
||||||
Name string `json:"name"`
|
|
||||||
Id int `json:"id"`
|
|
||||||
State string `json:"state"`
|
|
||||||
Public bool `json:"public"`
|
|
||||||
DefaultBranch string `json:"defaultBranch"`
|
|
||||||
HierarchyId string `json:"hierarchyId"`
|
|
||||||
StatusMessage string `json:"statusMessage"`
|
|
||||||
Archived bool `json:"archived"`
|
|
||||||
Forkable bool `json:"forkable"`
|
|
||||||
RelatedLinks struct {
|
|
||||||
} `json:"relatedLinks"`
|
|
||||||
Partition int `json:"partition"`
|
|
||||||
Description string `json:"description"`
|
|
||||||
Project struct {
|
|
||||||
Name string `json:"name"`
|
|
||||||
Key string `json:"key"`
|
|
||||||
Id int `json:"id"`
|
|
||||||
Type string `json:"type"`
|
|
||||||
Public bool `json:"public"`
|
|
||||||
Avatar string `json:"avatar"`
|
|
||||||
Description string `json:"description"`
|
|
||||||
Namespace string `json:"namespace"`
|
|
||||||
Scope string `json:"scope"`
|
|
||||||
} `json:"project"`
|
|
||||||
Scope string `json:"scope"`
|
|
||||||
ScmId string `json:"scmId"`
|
|
||||||
Slug string `json:"slug"`
|
|
||||||
} `json:"origin"`
|
|
||||||
Description string `json:"description"`
|
|
||||||
Project struct {
|
|
||||||
Name string `json:"name"`
|
|
||||||
Key string `json:"key"`
|
|
||||||
Id int `json:"id"`
|
|
||||||
Type string `json:"type"`
|
|
||||||
Public bool `json:"public"`
|
|
||||||
Avatar string `json:"avatar"`
|
|
||||||
Description string `json:"description"`
|
|
||||||
Namespace string `json:"namespace"`
|
|
||||||
Scope string `json:"scope"`
|
|
||||||
} `json:"project"`
|
} `json:"project"`
|
||||||
Scope string `json:"scope"`
|
|
||||||
ScmId string `json:"scmId"`
|
|
||||||
Slug string `json:"slug"`
|
|
||||||
} `json:"repository"`
|
} `json:"repository"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,6 +99,11 @@ func resourceRepositoryDeployKeyCreate(d *schema.ResourceData, m interface{}) er
|
|||||||
Permission: d.Get("permission").(string),
|
Permission: d.Get("permission").(string),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
expiryDays := d.Get("expiry_days")
|
||||||
|
if expiryDays != nil && expiryDays.(int) != 0 {
|
||||||
|
keyRequest.Key.ExpiryDays = expiryDays.(int)
|
||||||
|
}
|
||||||
|
|
||||||
request, err := json.Marshal(keyRequest)
|
request, err := json.Marshal(keyRequest)
|
||||||
|
|
||||||
client := m.(*bitbucketTypes.BitbucketServerProvider).BitbucketClient
|
client := m.(*bitbucketTypes.BitbucketServerProvider).BitbucketClient
|
||||||
@@ -220,6 +160,8 @@ func storeResponse(d *schema.ResourceData, resp *http.Response) error {
|
|||||||
keyError := store(d, keyResponse, keyResponse.Key.Text, "key")
|
keyError := store(d, keyResponse, keyResponse.Key.Text, "key")
|
||||||
projectError := store(d, keyResponse, keyResponse.Repository.Project.Key, "project")
|
projectError := store(d, keyResponse, keyResponse.Repository.Project.Key, "project")
|
||||||
repositoryError := store(d, keyResponse, keyResponse.Repository.Slug, "repository")
|
repositoryError := store(d, keyResponse, keyResponse.Repository.Slug, "repository")
|
||||||
|
days := keyResponse.Key.ExpiryDays
|
||||||
|
d.Set("expiry_days", days)
|
||||||
|
|
||||||
return errors.Join(labelError, permissionError, keyError, projectError, repositoryError)
|
return errors.Join(labelError, permissionError, keyError, projectError, repositoryError)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,15 @@ func TestAccBitbucketResourceRepositoryDeployKey(t *testing.T) {
|
|||||||
key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQD1F2KTOi8ptpqkXdcARgYy27uWRCav1isJUB3Hz59MDM6CSAXa+HCgUNDV+6gXQ1eR24nr1Efb7AkEM8LmvMkNlQqpAsPEPxVlndA0KSRLXb3mWruJzkZtrJo1HhVDffuKnevPLFkB75wyBX3jn1FNtc2qfc2i80mu8TfviZnOPYnrRa8B2S9Q8IlUtXAyihQ1G3fn5r5nxrw3QQGrD3cckB9nCZpzAPn6hlDHVk6n5efoWAUxM5AhKln0OLsA1HwjGJN7/dbDPu1nSLuiJSAISSSg4E4SNdfnr3FOhTA79AKNzsor2/EXdbG+f+S4op3s3wtt05zwkHLXRSqKYoT31RFiV9d1XIav+dGTvXCgc6DNG6rbogE6ZbugDZXdcHOAoNs7IUDFbtI/HGKS7CStxAUEchoxM8HDYXmhYt1kUEpmP3g2ckILHGoGPEkOCYGPqx5HbDvAXAJVk3DdSOibCckR2FK2qEoCbMgnPUX84CqNJPHBZ24AaE8htE6TKr0= user@somewhere"
|
key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQD1F2KTOi8ptpqkXdcARgYy27uWRCav1isJUB3Hz59MDM6CSAXa+HCgUNDV+6gXQ1eR24nr1Efb7AkEM8LmvMkNlQqpAsPEPxVlndA0KSRLXb3mWruJzkZtrJo1HhVDffuKnevPLFkB75wyBX3jn1FNtc2qfc2i80mu8TfviZnOPYnrRa8B2S9Q8IlUtXAyihQ1G3fn5r5nxrw3QQGrD3cckB9nCZpzAPn6hlDHVk6n5efoWAUxM5AhKln0OLsA1HwjGJN7/dbDPu1nSLuiJSAISSSg4E4SNdfnr3FOhTA79AKNzsor2/EXdbG+f+S4op3s3wtt05zwkHLXRSqKYoT31RFiV9d1XIav+dGTvXCgc6DNG6rbogE6ZbugDZXdcHOAoNs7IUDFbtI/HGKS7CStxAUEchoxM8HDYXmhYt1kUEpmP3g2ckILHGoGPEkOCYGPqx5HbDvAXAJVk3DdSOibCckR2FK2qEoCbMgnPUX84CqNJPHBZ24AaE8htE6TKr0= user@somewhere"
|
||||||
permission = "REPO_READ"
|
permission = "REPO_READ"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resource "bitbucketserver_repository_deploy_key" "test_with_expiration" {
|
||||||
|
project = bitbucketserver_project.test.key
|
||||||
|
repository = bitbucketserver_repository.test.slug
|
||||||
|
label = "newLabelForTest"
|
||||||
|
expiry_days = 90
|
||||||
|
key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQD1F2KTOi8ptpqkXdcARgYy27uWRCav1isJUB3Hz59MDM6CSAXa+HCgUNDV+6gXQ1eR24nr1Efb7AkEM8LmvMkNlQqpAsPEPxVlndA0KSRLXb3mWruJzkZtrJo1HhVDffuKnevPLFkB75wyBX3jn1FNtc2qfc2i80mu8TfviZnOPYnrRa8B2S9Q8IlUtXAyihQ1G3fn5r5nxrw3QQGrD3cckB9nCZpzAPn6hlDHVk6n5efoWAUxM5AhKln0OLsA1HwjGJN7/dbDPu1nSLuiJSAISSSg4E4SNdfnr3FOhTA79AKNzsor2/EXdbG+f+S4op3s3wtt05zwkHLXRSqKYoT31RFiV9d1XIav+dGTvXCgc6DNG6rbogE6ZbugDZXdcHOAoNs7IUDFbtI/HGKS7CStxAUEchoxM8HDYXmhYt1kUEpmP3g2ckILHGoGPEkOCYGPqx5HbDvAXAJVk3DdSOibCckR2FK2qEoCbMgnPUX84CqNJPHBZ24AaE8htE6TKr0= user@somewhere"
|
||||||
|
permission = "REPO_READ"
|
||||||
|
}
|
||||||
`, projectKey, projectKey)
|
`, projectKey, projectKey)
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
@@ -43,6 +52,18 @@ func TestAccBitbucketResourceRepositoryDeployKey(t *testing.T) {
|
|||||||
resource.TestCheckResourceAttr("bitbucketserver_repository_deploy_key.test", "repository", "repo"),
|
resource.TestCheckResourceAttr("bitbucketserver_repository_deploy_key.test", "repository", "repo"),
|
||||||
resource.TestCheckResourceAttr("bitbucketserver_repository_deploy_key.test", "key", "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQD1F2KTOi8ptpqkXdcARgYy27uWRCav1isJUB3Hz59MDM6CSAXa+HCgUNDV+6gXQ1eR24nr1Efb7AkEM8LmvMkNlQqpAsPEPxVlndA0KSRLXb3mWruJzkZtrJo1HhVDffuKnevPLFkB75wyBX3jn1FNtc2qfc2i80mu8TfviZnOPYnrRa8B2S9Q8IlUtXAyihQ1G3fn5r5nxrw3QQGrD3cckB9nCZpzAPn6hlDHVk6n5efoWAUxM5AhKln0OLsA1HwjGJN7/dbDPu1nSLuiJSAISSSg4E4SNdfnr3FOhTA79AKNzsor2/EXdbG+f+S4op3s3wtt05zwkHLXRSqKYoT31RFiV9d1XIav+dGTvXCgc6DNG6rbogE6ZbugDZXdcHOAoNs7IUDFbtI/HGKS7CStxAUEchoxM8HDYXmhYt1kUEpmP3g2ckILHGoGPEkOCYGPqx5HbDvAXAJVk3DdSOibCckR2FK2qEoCbMgnPUX84CqNJPHBZ24AaE8htE6TKr0= user@somewhere"),
|
resource.TestCheckResourceAttr("bitbucketserver_repository_deploy_key.test", "key", "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQD1F2KTOi8ptpqkXdcARgYy27uWRCav1isJUB3Hz59MDM6CSAXa+HCgUNDV+6gXQ1eR24nr1Efb7AkEM8LmvMkNlQqpAsPEPxVlndA0KSRLXb3mWruJzkZtrJo1HhVDffuKnevPLFkB75wyBX3jn1FNtc2qfc2i80mu8TfviZnOPYnrRa8B2S9Q8IlUtXAyihQ1G3fn5r5nxrw3QQGrD3cckB9nCZpzAPn6hlDHVk6n5efoWAUxM5AhKln0OLsA1HwjGJN7/dbDPu1nSLuiJSAISSSg4E4SNdfnr3FOhTA79AKNzsor2/EXdbG+f+S4op3s3wtt05zwkHLXRSqKYoT31RFiV9d1XIav+dGTvXCgc6DNG6rbogE6ZbugDZXdcHOAoNs7IUDFbtI/HGKS7CStxAUEchoxM8HDYXmhYt1kUEpmP3g2ckILHGoGPEkOCYGPqx5HbDvAXAJVk3DdSOibCckR2FK2qEoCbMgnPUX84CqNJPHBZ24AaE8htE6TKr0= user@somewhere"),
|
||||||
resource.TestCheckResourceAttr("bitbucketserver_repository_deploy_key.test", "label", "newLabelForTest"),
|
resource.TestCheckResourceAttr("bitbucketserver_repository_deploy_key.test", "label", "newLabelForTest"),
|
||||||
|
resource.TestCheckResourceAttr("bitbucketserver_repository_deploy_key.test", "expiry_days", "0"),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Config: config,
|
||||||
|
Check: resource.ComposeTestCheckFunc(
|
||||||
|
resource.TestCheckResourceAttrSet("bitbucketserver_repository_deploy_key.test_with_expiration", "id"),
|
||||||
|
resource.TestCheckResourceAttr("bitbucketserver_repository_deploy_key.test_with_expiration", "project", projectKey),
|
||||||
|
resource.TestCheckResourceAttr("bitbucketserver_repository_deploy_key.test_with_expiration", "repository", "repo"),
|
||||||
|
resource.TestCheckResourceAttr("bitbucketserver_repository_deploy_key.test_with_expiration", "key", "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQD1F2KTOi8ptpqkXdcARgYy27uWRCav1isJUB3Hz59MDM6CSAXa+HCgUNDV+6gXQ1eR24nr1Efb7AkEM8LmvMkNlQqpAsPEPxVlndA0KSRLXb3mWruJzkZtrJo1HhVDffuKnevPLFkB75wyBX3jn1FNtc2qfc2i80mu8TfviZnOPYnrRa8B2S9Q8IlUtXAyihQ1G3fn5r5nxrw3QQGrD3cckB9nCZpzAPn6hlDHVk6n5efoWAUxM5AhKln0OLsA1HwjGJN7/dbDPu1nSLuiJSAISSSg4E4SNdfnr3FOhTA79AKNzsor2/EXdbG+f+S4op3s3wtt05zwkHLXRSqKYoT31RFiV9d1XIav+dGTvXCgc6DNG6rbogE6ZbugDZXdcHOAoNs7IUDFbtI/HGKS7CStxAUEchoxM8HDYXmhYt1kUEpmP3g2ckILHGoGPEkOCYGPqx5HbDvAXAJVk3DdSOibCckR2FK2qEoCbMgnPUX84CqNJPHBZ24AaE8htE6TKr0= user@somewhere"),
|
||||||
|
resource.TestCheckResourceAttr("bitbucketserver_repository_deploy_key.test_with_expiration", "label", "newLabelForTest"),
|
||||||
|
resource.TestCheckResourceAttr("bitbucketserver_repository_deploy_key.test_with_expiration", "expiry_days", "90"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ data "bitbucketserver_project_hooks" "main" {
|
|||||||
# "name" = "Reject Force Push",
|
# "name" = "Reject Force Push",
|
||||||
# "type" = "PRE_RECEIVE",
|
# "type" = "PRE_RECEIVE",
|
||||||
# "description" = "Reject all force pushes (git push --force) to this repository",
|
# "description" = "Reject all force pushes (git push --force) to this repository",
|
||||||
# "version" = "8.5.4",
|
# "version" = "9.4.2",
|
||||||
# "scope_types" = ["PROJECT", "REPOSITORY"],
|
# "scope_types" = ["PROJECT", "REPOSITORY"],
|
||||||
# "enabled" = "false",
|
# "enabled" = "false",
|
||||||
# "configured" = "false",
|
# "configured" = "false",
|
||||||
@@ -46,7 +46,7 @@ data "bitbucketserver_project_hooks" "main" {
|
|||||||
* `name` - Name of the hook e.g. `Reject Force Push`
|
* `name` - Name of the hook e.g. `Reject Force Push`
|
||||||
* `type` - Type of the hook e.g. `PRE_RECEIVE`
|
* `type` - Type of the hook e.g. `PRE_RECEIVE`
|
||||||
* `description` - Detailed description e.g. `Reject all force pushes (git push --force) to this repository`
|
* `description` - Detailed description e.g. `Reject all force pushes (git push --force) to this repository`
|
||||||
* `version` - Version of the hook, for system hooks this is the bitbucket version e.g. `8.5.4`
|
* `version` - Version of the hook, for system hooks this is the bitbucket version e.g. `9.4.2`
|
||||||
* `scope_types` - List of strings containing the scopes available for this hook, e.g. `["PROJECT", "REPOSITORY"]`
|
* `scope_types` - List of strings containing the scopes available for this hook, e.g. `["PROJECT", "REPOSITORY"]`
|
||||||
* `enabled` - Set if this hook is enabled for this project
|
* `enabled` - Set if this hook is enabled for this project
|
||||||
* `configured` - Set if the hook is configured for this project
|
* `configured` - Set if the hook is configured for this project
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ data "bitbucketserver_repository_hooks" "main" {
|
|||||||
# "name" = "Reject Force Push",
|
# "name" = "Reject Force Push",
|
||||||
# "type" = "PRE_RECEIVE",
|
# "type" = "PRE_RECEIVE",
|
||||||
# "description" = "Reject all force pushes (git push --force) to this repository",
|
# "description" = "Reject all force pushes (git push --force) to this repository",
|
||||||
# "version" = "8.5.4",
|
# "version" = "9.4.2",
|
||||||
# "scope_types" = ["PROJECT", "REPOSITORY"],
|
# "scope_types" = ["PROJECT", "REPOSITORY"],
|
||||||
# "enabled" = "false",
|
# "enabled" = "false",
|
||||||
# "configured" = "false",
|
# "configured" = "false",
|
||||||
@@ -49,7 +49,7 @@ data "bitbucketserver_project_hooks" "main" {
|
|||||||
* `name` - Name of the hook e.g. `Reject Force Push`
|
* `name` - Name of the hook e.g. `Reject Force Push`
|
||||||
* `type` - Type of the hook e.g. `PRE_RECEIVE`
|
* `type` - Type of the hook e.g. `PRE_RECEIVE`
|
||||||
* `description` - Detailed description e.g. `Reject all force pushes (git push --force) to this repository`
|
* `description` - Detailed description e.g. `Reject all force pushes (git push --force) to this repository`
|
||||||
* `version` - Version of the hook, for system hooks this is the bitbucket version e.g. `8.5.4`
|
* `version` - Version of the hook, for system hooks this is the bitbucket version e.g. `9.4.2`
|
||||||
* `scope_types` - List of strings containing the scopes available for this hook, e.g. `["PROJECT", "REPOSITORY"]`
|
* `scope_types` - List of strings containing the scopes available for this hook, e.g. `["PROJECT", "REPOSITORY"]`
|
||||||
* `enabled` - Set if this hook is enabled for this project
|
* `enabled` - Set if this hook is enabled for this project
|
||||||
* `configured` - Set if the hook is configured for this project
|
* `configured` - Set if the hook is configured for this project
|
||||||
|
|||||||
32
docs/resources/bitbucketserver_repository_access_token.md
Normal file
32
docs/resources/bitbucketserver_repository_access_token.md
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# Resource: bitbucketserver_user_access_token
|
||||||
|
|
||||||
|
Repository access tokens can be used to authenticate using the Bitbucket Server REST API over Token auth.
|
||||||
|
|
||||||
|
## Example Usage
|
||||||
|
|
||||||
|
```hcl
|
||||||
|
resource "bitbucketserver_repository_access_token" "test" {
|
||||||
|
project = bitbucketserver_project.test.key
|
||||||
|
repository = bitbucketserver_repository.test.slug
|
||||||
|
name = "newLabelForTest"
|
||||||
|
permissions = ["REPO_READ"]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Argument Reference
|
||||||
|
|
||||||
|
* `project` - Required. Project for the repository.
|
||||||
|
* `repository` - Required. Slug for the repository.
|
||||||
|
* `name` - Required. Name of the access token.
|
||||||
|
* `permissions` - Required. List of permissions to grant the access token.
|
||||||
|
* `REPO_READ`
|
||||||
|
* `REPO_WRITE`
|
||||||
|
* `REPO_ADMIN`
|
||||||
|
|
||||||
|
## Attribute Reference
|
||||||
|
|
||||||
|
* `token` - The generated access token. Only available if token was generated on Terraform resource creation, not import/update.
|
||||||
|
|
||||||
|
## Import
|
||||||
|
|
||||||
|
Currently not supported
|
||||||
33
docs/resources/bitbucketserver_repository_deploy_key.md
Normal file
33
docs/resources/bitbucketserver_repository_deploy_key.md
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# Resource: bitbucketserver_user_access_token
|
||||||
|
|
||||||
|
Repository access tokens can be used to authenticate using the Bitbucket Server REST API over Token auth.
|
||||||
|
|
||||||
|
## Example Usage
|
||||||
|
|
||||||
|
```hcl
|
||||||
|
resource "bitbucketserver_repository_deploy_key" "test" {
|
||||||
|
project = bitbucketserver_project.test.key
|
||||||
|
repository = bitbucketserver_repository.test.slug
|
||||||
|
label = "newLabelForTest"
|
||||||
|
key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQD1F2KTOi8ptpqkXdcARgYy27uWRCav1isJUB3Hz59MDM6CSAXa+HCgUNDV+6gXQ1eR24nr1Efb7AkEM8LmvMkNlQqpAsPEPxVlndA0KSRLXb3mWruJzkZtrJo1HhVDffuKnevPLFkB75wyBX3jn1FNtc2qfc2i80mu8TfviZnOPYnrRa8B2S9Q8IlUtXAyihQ1G3fn5r5nxrw3QQGrD3cckB9nCZpzAPn6hlDHVk6n5efoWAUxM5AhKln0OLsA1HwjGJN7/dbDPu1nSLuiJSAISSSg4E4SNdfnr3FOhTA79AKNzsor2/EXdbG+f+S4op3s3wtt05zwkHLXRSqKYoT31RFiV9d1XIav+dGTvXCgc6DNG6rbogE6ZbugDZXdcHOAoNs7IUDFbtI/HGKS7CStxAUEchoxM8HDYXmhYt1kUEpmP3g2ckILHGoGPEkOCYGPqx5HbDvAXAJVk3DdSOibCckR2FK2qEoCbMgnPUX84CqNJPHBZ24AaE8htE6TKr0= user@somewhere"
|
||||||
|
permission = "REPO_READ"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Argument Reference
|
||||||
|
|
||||||
|
* `project` - Required. Project for the repository.
|
||||||
|
* `repository` - Required. Slug for the repository.
|
||||||
|
* `label` - Required. Name of the deploy key token.
|
||||||
|
* `key` - Required. The public key to grant access to
|
||||||
|
* `permissions` - Required. List of permissions to grant the access token.
|
||||||
|
* `REPO_READ`
|
||||||
|
* `REPO_WRITE`
|
||||||
|
* `REPO_ADMIN`
|
||||||
|
* expiry_days - Optional. Set if the key should expire. 0 means "does not expire" and is the default
|
||||||
|
|
||||||
|
## Attribute Reference
|
||||||
|
|
||||||
|
## Import
|
||||||
|
|
||||||
|
Currently not supported
|
||||||
@@ -2,7 +2,7 @@ version: '2'
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
bitbucket:
|
bitbucket:
|
||||||
image: atlassian/bitbucket-server:8.5-ubuntu-jdk11
|
image: atlassian/bitbucket:9.4.2-jdk21
|
||||||
restart: always
|
restart: always
|
||||||
networks:
|
networks:
|
||||||
- bridge
|
- bridge
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ cd ${DIR}
|
|||||||
|
|
||||||
if [ ! -f ${DIR}/docker-compose ]; then
|
if [ ! -f ${DIR}/docker-compose ]; then
|
||||||
echo "--> Downloading docker-compose"
|
echo "--> Downloading docker-compose"
|
||||||
curl -L https://github.com/docker/compose/releases/download/1.20.1/docker-compose-`uname -s`-`uname -m` > ${DIR}/docker-compose
|
curl -L https://github.com/docker/compose/releases/download/v2.34.0/docker-compose-`uname -s`-`uname -m` > ${DIR}/docker-compose
|
||||||
chmod +x ${DIR}/docker-compose
|
chmod +x ${DIR}/docker-compose
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user