Skip to content

Commit 7a236ca

Browse files
authored
Use d.Id() on Google Cloud machines (#695)
* Use `d.Id()` on Google Cloud machines * Remove unused flag from `destroy-runner` command
1 parent 2b46b50 commit 7a236ca

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

cmd/leo/destroyrunner/destroyrunner.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
)
1717

1818
type Options struct {
19-
Name string
2019
}
2120

2221
func New(cloud *common.Cloud) *cobra.Command {
@@ -33,21 +32,12 @@ func New(cloud *common.Cloud) *cobra.Command {
3332
},
3433
}
3534

36-
cmd.Flags().StringVar(&o.Name, "name", "", "needed for Google Cloud runners") // FIXME: it shouldn't
37-
3835
return cmd
3936
}
4037

4138
func (o *Options) Run(cmd *cobra.Command, args []string, cloud *common.Cloud) error {
42-
r := map[string]interface{}{
43-
"region": string(cloud.Region),
44-
"name": o.Name,
45-
}
46-
s := map[string]*schema.Schema{
47-
"region": {Type: schema.TypeString},
48-
"name": {Type: schema.TypeString},
49-
}
50-
39+
r := map[string]interface{}{"region": string(cloud.Region)}
40+
s := map[string]*schema.Schema{"region": {Type: schema.TypeString}}
5141
d := schema.TestResourceDataRaw(&testing.RuntimeT{}, s, r)
5242
d.SetId(args[0])
5343

iterative/gcp/provider.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func ResourceMachineCreate(ctx context.Context, d *schema.ResourceData, m interf
3131
}
3232

3333
networkName := "iterative"
34-
instanceName := d.Get("name").(string)
34+
instanceName := d.Id()
3535
instanceZone := getRegion(d.Get("region").(string))
3636
instanceHddSize := int64(d.Get("instance_hdd_size").(int))
3737
instancePublicSshKey := fmt.Sprintf("%s:%s %s\n", "ubuntu", strings.TrimSpace(d.Get("ssh_public").(string)), "ubuntu")
@@ -281,7 +281,7 @@ func ResourceMachineDelete(ctx context.Context, d *schema.ResourceData, m interf
281281
}
282282

283283
instanceZone := getRegion(d.Get("region").(string))
284-
instanceName := d.Get("name").(string)
284+
instanceName := d.Id()
285285

286286
service.Instances.Delete(project, instanceZone, instanceName).Do()
287287
service.Firewalls.Delete(project, instanceName+"-ingress").Do()

0 commit comments

Comments
 (0)