@@ -72,11 +72,12 @@ func resourceGitlabDeployTokenCreate(d *schema.ResourceData, meta interface{}) e
72
72
project , isProject := d .GetOk ("project" )
73
73
group , isGroup := d .GetOk ("group" )
74
74
75
- var expiresAt time.Time
75
+ var expiresAt * time.Time
76
76
var err error
77
77
78
78
if exp , ok := d .GetOk ("expires_at" ); ok {
79
- expiresAt , err = time .Parse (time .RFC3339 , exp .(string ))
79
+ parsedExpiresAt , err := time .Parse (time .RFC3339 , exp .(string ))
80
+ expiresAt = & parsedExpiresAt
80
81
if err != nil {
81
82
return fmt .Errorf ("Invalid expires_at date: %v" , err )
82
83
}
@@ -90,7 +91,7 @@ func resourceGitlabDeployTokenCreate(d *schema.ResourceData, meta interface{}) e
90
91
options := & gitlab.CreateProjectDeployTokenOptions {
91
92
Name : gitlab .String (d .Get ("name" ).(string )),
92
93
Username : gitlab .String (d .Get ("username" ).(string )),
93
- ExpiresAt : gitlab . Time ( expiresAt ) ,
94
+ ExpiresAt : expiresAt ,
94
95
Scopes : * scopes ,
95
96
}
96
97
@@ -102,7 +103,7 @@ func resourceGitlabDeployTokenCreate(d *schema.ResourceData, meta interface{}) e
102
103
options := & gitlab.CreateGroupDeployTokenOptions {
103
104
Name : gitlab .String (d .Get ("name" ).(string )),
104
105
Username : gitlab .String (d .Get ("username" ).(string )),
105
- ExpiresAt : gitlab . Time ( expiresAt ) ,
106
+ ExpiresAt : expiresAt ,
106
107
Scopes : * scopes ,
107
108
}
108
109
@@ -151,7 +152,10 @@ func resourceGitlabDeployTokenRead(d *schema.ResourceData, meta interface{}) err
151
152
if token .ID == deployTokenID {
152
153
d .Set ("name" , token .Name )
153
154
d .Set ("username" , token .Username )
154
- d .Set ("expires_at" , token .ExpiresAt .Format (time .RFC3339 ))
155
+
156
+ if token .ExpiresAt != nil {
157
+ d .Set ("expires_at" , token .ExpiresAt )
158
+ }
155
159
156
160
for _ , scope := range token .Scopes {
157
161
if scope == "read_repository" {
0 commit comments