Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 73cc58d

Browse files
committed
Add Tags() option
1 parent b632184 commit 73cc58d

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

cartel/request_body.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,18 @@ func InSubnet(subnetID string) RequestOptionFunc {
119119
}
120120
}
121121

122-
// VPICID Sets the VPC ID to use
122+
// VPCID Sets the VPC ID to use
123123
func VPCID(vpcID string) RequestOptionFunc {
124124
return func(body *RequestBody) error {
125125
body.VpcId = vpcID
126126
return nil
127127
}
128128
}
129+
130+
// Tags sets the Tags for the instance
131+
func Tags(tags map[string]string) RequestOptionFunc {
132+
return func(body *RequestBody) error {
133+
body.Tags = tags
134+
return nil
135+
}
136+
}

cartel/request_body_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,12 @@ func TestRequestBody(t *testing.T) {
5151
err = VolumeEncryption(true)(&requestBody)
5252
assert.Nil(t, err)
5353
assert.Equal(t, true, requestBody.EncryptVols)
54+
55+
err = Tags(map[string]string{
56+
"foo": "bar",
57+
"bar": "baz",
58+
})(&requestBody)
59+
assert.Nil(t, err)
60+
assert.Equal(t, "bar", requestBody.Tags["foo"])
61+
assert.Equal(t, "baz", requestBody.Tags["bar"])
5462
}

0 commit comments

Comments
 (0)