Skip to content

Commit 5695395

Browse files
committed
Review 3
1 parent 3faa449 commit 5695395

6 files changed

+37
-37
lines changed

docs/resources/project_milestone.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,20 @@ resource "gitlab_project_milestone" "example" {
3939

4040
### Optional
4141

42-
- `created_at` (String) The time of creation of the milestone. Date time string, ISO 8601 formatted, for example 2016-03-11T03:45:40Z.
4342
- `description` (String) The description of the milestone.
4443
- `due_date` (String) The due date of the milestone. Date time string in the format YYYY-MM-DD, for example 2016-03-11.
4544
- `start_date` (String) The start date of the milestone. Date time string in the format YYYY-MM-DD, for example 2016-03-11.
4645
- `state` (String) The state of the milestone. Valid values are: `active`, `closed`.
47-
- `updated_at` (String) The last update time of the milestone. Date time string, ISO 8601 formatted, for example 2016-03-11T03:45:40Z.
4846

4947
### Read-Only
5048

49+
- `created_at` (String) The time of creation of the milestone. Date time string, ISO 8601 formatted, for example 2016-03-11T03:45:40Z.
5150
- `expired` (Boolean) Bool, true if milestore expired.
5251
- `id` (String) The ID of this resource.
5352
- `iid` (Number) The ID of the project's milestone.
5453
- `milestone_id` (Number) The instance-wide ID of the project’s milestone.
5554
- `project_id` (Number) The project ID of milestone.
55+
- `updated_at` (String) The last update time of the milestone. Date time string, ISO 8601 formatted, for example 2016-03-11T03:45:40Z.
5656
- `web_url` (String) The web URL of the milestone.
5757

5858
## Import

internal/provider/data_source_gitlab_project_milestone_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ func TestAccDataSourceGitlabProjectMilestone_basic(t *testing.T) {
2020
Steps: []resource.TestStep{
2121
{
2222
Config: fmt.Sprintf(`
23-
data "gitlab_project_milestone" "this" {
24-
project = "%d"
25-
milestone_id = "%d"
26-
}`, testProject.ID, testMilestone.ID),
23+
data "gitlab_project_milestone" "this" {
24+
project = "%d"
25+
milestone_id = "%d"
26+
}`, testProject.ID, testMilestone.ID),
2727
Check: resource.ComposeTestCheckFunc(
2828
resource.TestCheckResourceAttr("data.gitlab_project_milestone.this", "milestone_id", fmt.Sprintf("%v", testMilestone.ID)),
2929
resource.TestCheckResourceAttr("data.gitlab_project_milestone.this", "title", testMilestone.Title),

internal/provider/data_source_gitlab_project_milestones_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ func TestAccDataGitlabProjectMilestones_basic(t *testing.T) {
2020
Steps: []resource.TestStep{
2121
{
2222
Config: fmt.Sprintf(`
23-
data "gitlab_project_milestones" "this" {
24-
project = "%d"
25-
}`, testProject.ID),
23+
data "gitlab_project_milestones" "this" {
24+
project = "%d"
25+
}`, testProject.ID),
2626
Check: resource.ComposeTestCheckFunc(
2727
resource.TestCheckResourceAttr("data.gitlab_project_milestones.this", "milestones.#", fmt.Sprintf("%d", len(testMilestones))),
2828
resource.TestCheckResourceAttr("data.gitlab_project_milestones.this", "milestones.0.title", testMilestones[1].Title),

internal/provider/resource_gitlab_project_milestone.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func resourceGitlabProjectMilestoneRead(ctx context.Context, d *schema.ResourceD
9494
if is404(err) {
9595
log.Printf("[WARN] recieved 404 for gitlab milestone ID %d in project %s, removing from state", milestoneID, project)
9696
d.SetId("")
97-
return diag.FromErr(err)
97+
return nil
9898
}
9999
log.Printf("[WARN] failed to read gitlab milestone ID %d in project %s. Response %v", milestoneID, project, resp)
100100
return diag.FromErr(err)

internal/provider/resource_gitlab_project_milestone_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ func TestAccGitlabProjectMilestone_basic(t *testing.T) {
2525
{
2626
// create Milestone with required values only
2727
Config: fmt.Sprintf(`
28-
resource "gitlab_project_milestone" "this" {
29-
project = "%v"
30-
title = "test-%d"
31-
}`, project.PathWithNamespace, rInt1),
28+
resource "gitlab_project_milestone" "this" {
29+
project = "%v"
30+
title = "test-%d"
31+
}`, project.PathWithNamespace, rInt1),
3232
Check: resource.ComposeTestCheckFunc(
3333
resource.TestCheckResourceAttrSet("gitlab_project_milestone.this", "iid"),
3434
resource.TestCheckResourceAttrSet("gitlab_project_milestone.this", "milestone_id"),
@@ -47,14 +47,14 @@ func TestAccGitlabProjectMilestone_basic(t *testing.T) {
4747
{
4848
// update some Milestone attributes
4949
Config: fmt.Sprintf(`
50-
resource "gitlab_project_milestone" "this" {
51-
project = "%[1]d"
52-
title = "test-%[2]d"
53-
description = "test-%[2]d"
54-
start_date = "2022-04-10"
55-
due_date = "2022-04-15"
56-
state = "closed"
57-
}`, project.ID, rInt2),
50+
resource "gitlab_project_milestone" "this" {
51+
project = "%[1]d"
52+
title = "test-%[2]d"
53+
description = "test-%[2]d"
54+
start_date = "2022-04-10"
55+
due_date = "2022-04-15"
56+
state = "closed"
57+
}`, project.ID, rInt2),
5858
Check: resource.ComposeTestCheckFunc(
5959
resource.TestCheckResourceAttrSet("gitlab_project_milestone.this", "iid"),
6060
resource.TestCheckResourceAttrSet("gitlab_project_milestone.this", "milestone_id"),

internal/provider/schema_gitlab_project_milestone.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,7 @@ func gitlabProjectMilestoneGetSchema() map[string]*schema.Schema {
5252
"created_at": {
5353
Description: "The time of creation of the milestone. Date time string, ISO 8601 formatted, for example 2016-03-11T03:45:40Z.",
5454
Type: schema.TypeString,
55-
Optional: true,
56-
Computed: true,
57-
// NOTE: since RFC3339 is pretty much a subset of ISO8601 and actually expected by GitLab,
58-
// we use it here to avoid having to parse the string ourselves.
59-
ValidateDiagFunc: validation.ToDiagFunc(validation.IsRFC3339Time),
60-
},
61-
"updated_at": {
62-
Description: "The last update time of the milestone. Date time string, ISO 8601 formatted, for example 2016-03-11T03:45:40Z.",
63-
Type: schema.TypeString,
64-
Optional: true,
6555
Computed: true,
66-
// NOTE: since RFC3339 is pretty much a subset of ISO8601 and actually expected by GitLab,
67-
// we use it here to avoid having to parse the string ourselves.
68-
ValidateDiagFunc: validation.ToDiagFunc(validation.IsRFC3339Time),
6956
},
7057
"expired": {
7158
Description: "Bool, true if milestore expired.",
@@ -87,6 +74,11 @@ func gitlabProjectMilestoneGetSchema() map[string]*schema.Schema {
8774
Type: schema.TypeInt,
8875
Computed: true,
8976
},
77+
"updated_at": {
78+
Description: "The last update time of the milestone. Date time string, ISO 8601 formatted, for example 2016-03-11T03:45:40Z.",
79+
Type: schema.TypeString,
80+
Computed: true,
81+
},
9082
"web_url": {
9183
Description: "The web URL of the milestone.",
9284
Type: schema.TypeString,
@@ -113,8 +105,16 @@ func gitlabProjectMilestoneToStateMap(project string, milestone *gitlab.Mileston
113105
} else {
114106
stateMap["start_date"] = nil
115107
}
116-
stateMap["updated_at"] = milestone.UpdatedAt.Format(time.RFC3339)
117-
stateMap["created_at"] = milestone.CreatedAt.Format(time.RFC3339)
108+
if milestone.UpdatedAt != nil {
109+
stateMap["updated_at"] = milestone.UpdatedAt.Format(time.RFC3339)
110+
} else {
111+
stateMap["updated_at"] = nil
112+
}
113+
if milestone.CreatedAt != nil {
114+
stateMap["created_at"] = milestone.CreatedAt.Format(time.RFC3339)
115+
} else {
116+
stateMap["created_at"] = nil
117+
}
118118
stateMap["state"] = milestone.State
119119
stateMap["web_url"] = milestone.WebURL
120120
if milestone.Expired != nil {

0 commit comments

Comments
 (0)