Skip to content

Commit e12e90f

Browse files
committed
same id
1 parent c4c3320 commit e12e90f

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

examples/main.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,20 @@ terraform {
1212
}
1313
}
1414

15+
provider "iterative" {}
16+
resource "iterative_runner" "runner-aws" {
17+
name = "holy-moly57"
18+
token = "arszDpb3xtNdKaXmQ6vN"
19+
repo = "https://gitlab.com/DavidGOrtega/3_tensorboard"
20+
driver = "gitlab"
21+
labels = "tf"
22+
23+
cloud = "aws"
24+
region = "us-west"
25+
instance_type = "t2.micro"
26+
}
27+
28+
/*
1529
provider "iterative" {}
1630
resource "iterative_runner" "runner-az" {
1731
name = "holy-moly56"
@@ -24,6 +38,7 @@ resource "iterative_runner" "runner-az" {
2438
region = "us-west"
2539
instance_type = "m"
2640
}
41+
*/
2742

2843

2944
/*

iterative/utils/helpers.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ func MachinePrefix(d *schema.ResourceData) string {
1616
}
1717

1818
func SetId(d *schema.ResourceData) {
19-
sid, _ := shortid.New(1, shortid.DefaultABC, 2342)
20-
id, _ := sid.Generate()
21-
name := "iterative-" + id
22-
d.SetId(name)
19+
if len(d.Id()) == 0 {
20+
sid, _ := shortid.New(1, shortid.DefaultABC, 2342)
21+
id, _ := sid.Generate()
22+
name := "iterative-" + id
23+
d.SetId(name)
2324

24-
if len(d.Get("name").(string)) == 0 {
25-
d.Set("name", name)
25+
if len(d.Get("name").(string)) == 0 {
26+
d.Set("name", name)
27+
}
2628
}
2729
}

0 commit comments

Comments
 (0)