@@ -2,7 +2,9 @@ package provider
2
2
3
3
import (
4
4
"context"
5
+ "fmt"
5
6
"log"
7
+ "strconv"
6
8
7
9
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
8
10
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
@@ -16,7 +18,7 @@ var milestoneStateToStateEvent = map[string]string{
16
18
17
19
var _ = registerResource ("gitlab_project_milestone" , func () * schema.Resource {
18
20
return & schema.Resource {
19
- Description : `The ` + "`gitlab_project_milestone`" + ` resource allows to manage the lifecycle of a milestone ( project) .
21
+ Description : `The ` + "`gitlab_project_milestone`" + ` resource allows to manage the lifecycle of a project milestone .
20
22
21
23
**Upstream API**: [GitLab REST API docs](https://docs.gitlab.com/ee/api/milestones.html)` ,
22
24
@@ -27,9 +29,7 @@ var _ = registerResource("gitlab_project_milestone", func() *schema.Resource {
27
29
Importer : & schema.ResourceImporter {
28
30
StateContext : schema .ImportStatePassthroughContext ,
29
31
},
30
- Schema : constructSchema (
31
- gitlabProjectMilestoneGetSchema (),
32
- ),
32
+ Schema : gitlabProjectMilestoneGetSchema (),
33
33
}
34
34
})
35
35
@@ -65,7 +65,7 @@ func resourceGitlabProjectMilestoneCreate(ctx context.Context, d *schema.Resourc
65
65
log .Printf ("[WARN] failed to create gitlab milestone in project %s with title %s (response %v)" , project , title , resp )
66
66
return diag .FromErr (err )
67
67
}
68
- d .SetId (buildTwoPartIDInterface (project , milestone .ID ))
68
+ d .SetId (resourceGitLabProjectMilestoneBuildId (project , milestone .ID ))
69
69
70
70
updateOptions := gitlab.UpdateMilestoneOptions {}
71
71
if stateEvent , ok := d .GetOk ("state" ); ok {
@@ -83,7 +83,7 @@ func resourceGitlabProjectMilestoneCreate(ctx context.Context, d *schema.Resourc
83
83
84
84
func resourceGitlabProjectMilestoneRead (ctx context.Context , d * schema.ResourceData , meta interface {}) diag.Diagnostics {
85
85
client := meta .(* gitlab.Client )
86
- project , milestoneID , err := parseTwoPartIDInt (d .Id ())
86
+ project , milestoneID , err := resourceGitLabProjectMilestoneParseId (d .Id ())
87
87
if err != nil {
88
88
return diag .FromErr (err )
89
89
}
@@ -109,7 +109,7 @@ func resourceGitlabProjectMilestoneRead(ctx context.Context, d *schema.ResourceD
109
109
110
110
func resourceGitlabProjectMilestoneUpdate (ctx context.Context , d * schema.ResourceData , meta interface {}) diag.Diagnostics {
111
111
client := meta .(* gitlab.Client )
112
- project , milestoneID , err := parseTwoPartIDInt (d .Id ())
112
+ project , milestoneID , err := resourceGitLabProjectMilestoneParseId (d .Id ())
113
113
if err != nil {
114
114
return diag .FromErr (err )
115
115
}
@@ -153,7 +153,7 @@ func resourceGitlabProjectMilestoneUpdate(ctx context.Context, d *schema.Resourc
153
153
154
154
func resourceGitlabProjectMilestoneDelete (ctx context.Context , d * schema.ResourceData , meta interface {}) diag.Diagnostics {
155
155
client := meta .(* gitlab.Client )
156
- project , milestoneID , err := parseTwoPartIDInt (d .Id ())
156
+ project , milestoneID , err := resourceGitLabProjectMilestoneParseId (d .Id ())
157
157
if err != nil {
158
158
return diag .FromErr (err )
159
159
}
@@ -166,3 +166,22 @@ func resourceGitlabProjectMilestoneDelete(ctx context.Context, d *schema.Resourc
166
166
}
167
167
return nil
168
168
}
169
+
170
+ func resourceGitLabProjectMilestoneParseId (id string ) (string , int , error ) {
171
+ project , milestone , err := parseTwoPartID (id )
172
+ if err != nil {
173
+ return "" , 0 , err
174
+ }
175
+
176
+ milestoneID , err := strconv .Atoi (milestone )
177
+ if err != nil {
178
+ return "" , 0 , err
179
+ }
180
+
181
+ return project , milestoneID , nil
182
+ }
183
+
184
+ func resourceGitLabProjectMilestoneBuildId (project string , milestoneID int ) string {
185
+ stringMilestoneID := fmt .Sprintf ("%d" , milestoneID )
186
+ return buildTwoPartID (& project , & stringMilestoneID )
187
+ }
0 commit comments