@@ -82,13 +82,13 @@ func resourceGitlabProjectAccessToken() *schema.Resource {
82
82
func resourceGitlabProjectAccessTokenCreate (ctx context.Context , d * schema.ResourceData , meta interface {}) diag.Diagnostics {
83
83
client := meta .(* gitlab.Client )
84
84
85
- project := d .Get ("project" ).(int )
85
+ project := d .Get ("project" ).(string )
86
86
options := & gitlab.CreateProjectAccessTokenOptions {
87
87
Name : gitlab .String (d .Get ("name" ).(string )),
88
88
Scopes : * stringSetToStringSlice (d .Get ("scopes" ).(* schema.Set )),
89
89
}
90
90
91
- log .Printf ("[DEBUG] create gitlab ProjectAccessToken %s %s for project ID %d " , * options .Name , options .Scopes , project )
91
+ log .Printf ("[DEBUG] create gitlab ProjectAccessToken %s %s for project ID %s " , * options .Name , options .Scopes , project )
92
92
93
93
if v , ok := d .GetOk ("expires_at" ); ok {
94
94
parsedExpiresAt , err := time .Parse ("2006-01-02" , v .(string ))
@@ -97,44 +97,38 @@ func resourceGitlabProjectAccessTokenCreate(ctx context.Context, d *schema.Resou
97
97
}
98
98
parsedExpiresAtISOTime := gitlab .ISOTime (parsedExpiresAt )
99
99
options .ExpiresAt = & parsedExpiresAtISOTime
100
- log .Printf ("[DEBUG] create gitlab ProjectAccessToken %s with expires_at %s for project ID %d " , * options .Name , * options .ExpiresAt , project )
100
+ log .Printf ("[DEBUG] create gitlab ProjectAccessToken %s with expires_at %s for project ID %s " , * options .Name , * options .ExpiresAt , project )
101
101
}
102
102
103
103
projectAccessToken , _ , err := client .ProjectAccessTokens .CreateProjectAccessToken (project , options , gitlab .WithContext (ctx ))
104
104
if err != nil {
105
105
return diag .FromErr (err )
106
106
}
107
107
108
- log .Printf ("[DEBUG] created gitlab ProjectAccessToken %d - %s for project ID %d " , projectAccessToken .ID , * options .Name , project )
108
+ log .Printf ("[DEBUG] created gitlab ProjectAccessToken %d - %s for project ID %s " , projectAccessToken .ID , * options .Name , project )
109
109
110
- projectString := strconv .Itoa (project )
111
110
PATstring := strconv .Itoa (projectAccessToken .ID )
112
- d .SetId (buildTwoPartID (& projectString , & PATstring ))
111
+ d .SetId (buildTwoPartID (& project , & PATstring ))
113
112
d .Set ("token" , projectAccessToken .Token )
114
113
115
114
return resourceGitlabProjectAccessTokenRead (ctx , d , meta )
116
115
}
117
116
118
117
func resourceGitlabProjectAccessTokenRead (ctx context.Context , d * schema.ResourceData , meta interface {}) diag.Diagnostics {
119
118
120
- projectString , PATstring , err := parseTwoPartID (d .Id ())
119
+ project , PATstring , err := parseTwoPartID (d .Id ())
121
120
if err != nil {
122
121
return diag .Errorf ("Error parsing ID: %s" , d .Id ())
123
122
}
124
123
125
124
client := meta .(* gitlab.Client )
126
125
127
- project , err := strconv .Atoi (projectString )
128
- if err != nil {
129
- return diag .Errorf ("%s cannot be converted to int" , projectString )
130
- }
131
-
132
126
projectAccessTokenID , err := strconv .Atoi (PATstring )
133
127
if err != nil {
134
128
return diag .Errorf ("%s cannot be converted to int" , PATstring )
135
129
}
136
130
137
- log .Printf ("[DEBUG] read gitlab ProjectAccessToken %d, project ID %d " , projectAccessTokenID , project )
131
+ log .Printf ("[DEBUG] read gitlab ProjectAccessToken %d, project ID %s " , projectAccessTokenID , project )
138
132
139
133
//there is a slight possibility to not find an existing item, for example
140
134
// 1. item is #101 (ie, in the 2nd page)
@@ -172,25 +166,20 @@ func resourceGitlabProjectAccessTokenRead(ctx context.Context, d *schema.Resourc
172
166
page = response .NextPage
173
167
}
174
168
175
- log .Printf ("[DEBUG] failed to read gitlab ProjectAccessToken %d, project ID %d " , projectAccessTokenID , project )
169
+ log .Printf ("[DEBUG] failed to read gitlab ProjectAccessToken %d, project ID %s " , projectAccessTokenID , project )
176
170
d .SetId ("" )
177
171
return nil
178
172
}
179
173
180
174
func resourceGitlabProjectAccessTokenDelete (ctx context.Context , d * schema.ResourceData , meta interface {}) diag.Diagnostics {
181
175
182
- projectString , PATstring , err := parseTwoPartID (d .Id ())
176
+ project , PATstring , err := parseTwoPartID (d .Id ())
183
177
if err != nil {
184
178
return diag .Errorf ("Error parsing ID: %s" , d .Id ())
185
179
}
186
180
187
181
client := meta .(* gitlab.Client )
188
182
189
- project , err := strconv .Atoi (projectString )
190
- if err != nil {
191
- return diag .Errorf ("%s cannot be converted to int" , projectString )
192
- }
193
-
194
183
projectAccessTokenID , err := strconv .Atoi (PATstring )
195
184
if err != nil {
196
185
return diag .Errorf ("%s cannot be converted to int" , PATstring )
0 commit comments