generated from davidji99/terraform-provider-scaffolding
/
resource_herokux_pipeline_github_integration_migrate.go
65 lines (54 loc) · 1.48 KB
/
resource_herokux_pipeline_github_integration_migrate.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package herokux
import (
"context"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"regexp"
)
func resourceHerokuxPipelineGithubIntegrationResourceV0() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"pipeline_id": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.IsUUID,
},
"github_org_repo": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringMatch(regexp.MustCompile(`^\S+\/\S+$`),
"Invalid attribute value. Value must be org/repo."),
},
"github_repository_id": {
Type: schema.TypeInt,
Computed: true,
},
"creator_id": {
Type: schema.TypeString,
Computed: true,
},
"owner_id": {
Type: schema.TypeString,
Computed: true,
},
"integration_id": {
Type: schema.TypeString,
Computed: true,
},
},
}
}
func resourceHerokuxPipelineGithubIntegrationStateUpgradeV0(_ context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) {
if rawState == nil {
return nil, nil
}
if val, ok := rawState["github_org_repo"]; ok {
// Set org_repo attribute value to be the same as github_org_repo.
rawState["org_repo"] = val
// Delete the github_org_repo attribute from state
delete(rawState, "github_org_repo")
}
return rawState, nil
}