Skip to content

Commit

Permalink
'TagInputRequiresTransformation' -> 'TagInputCustomValue'.
Browse files Browse the repository at this point in the history
  • Loading branch information
ewbankkit committed Dec 23, 2019
1 parent 7dfbd4e commit 7418bca
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 53 deletions.
52 changes: 21 additions & 31 deletions aws/internal/keyvaluetags/generators/updatetags/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,27 @@ case "datapipeline":
return "AddTags"
```

#### ServiceTagInputCustomValue

Given the following compilation errors:

```text
aws/internal/keyvaluetags/update_tags_gen.go:1994:4: cannot use updatedTags.IgnoreAws().KinesisTags() (type []*kinesis.Tag) as type map[string]*string in field value
```

or

```text
aws/internal/keyvaluetags/update_tags_gen.go:2534:4: cannot use updatedTags.IgnoreAws().PinpointTags() (type map[string]*string) as type *pinpoint.TagsModel in field value
```

The value of the tags for tagging must be transformed. Add an entry within the `ServiceTagInputCustomValue()` function of the generator to return the custom value. In the above case:

```go
case "kinesis":
return "aws.StringMap(chunk.IgnoreAws().Map())"
```

#### ServiceTagInputIdentifierField

Given the following compilation error:
Expand Down Expand Up @@ -133,37 +154,6 @@ case "ec2":
return "yes"
```

#### ServiceTagInputRequiresTransformation

Given the following compilation error:

```text
aws/internal/keyvaluetags/update_tags_gen.go:1994:4: cannot use updatedTags.IgnoreAws().KinesisTags() (type []*kinesis.Tag) as type map[string]*string in field value
```

or

```text
aws/internal/keyvaluetags/update_tags_gen.go:2534:4: cannot use updatedTags.IgnoreAws().PinpointTags() (type map[string]*string) as type *pinpoint.TagsModel in field value
```

The tags for tagging must be transformed. Add an entry within the `ServiceTagInputRequiresTransformation()` function of the generator to ensure that a transformation is done and add a custom transformation function to `service_customizations.go`. In the above case

```go
case "kinesis":
return "yes"
```

and

```go
// KinesisTagInput transforms a standard KeyValueTags to the form
// required for input to the Kinesis AddTagsToStreamInput() method.
func KinesisTagInput(tags KeyValueTags) map[string]*string {
return aws.StringMap(tags.Map())
}
```

#### ServiceTagInputTagsField

Given the following compilation error:
Expand Down
16 changes: 8 additions & 8 deletions aws/internal/keyvaluetags/generators/updatetags/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ func main() {
"ClientType": keyvaluetags.ServiceClientType,
"TagFunction": ServiceTagFunction,
"TagFunctionBatchSize": ServiceTagFunctionBatchSize,
"TagInputCustomValue": ServiceTagInputCustomValue,
"TagInputIdentifierField": ServiceTagInputIdentifierField,
"TagInputIdentifierRequiresSlice": ServiceTagInputIdentifierRequiresSlice,
"TagInputRequiresTransformation": ServiceTagInputRequiresTransformation,
"TagInputResourceTypeField": ServiceTagInputResourceTypeField,
"TagInputTagsField": ServiceTagInputTagsField,
"TagPackage": keyvaluetags.ServiceTagPackage,
Expand Down Expand Up @@ -256,8 +256,8 @@ func {{ . | Title }}UpdateTags(conn {{ . | ClientType }}, identifier string{{ if
{{- if . | TagInputResourceTypeField }}
{{ . | TagInputResourceTypeField }}: aws.String(resourceType),
{{- end }}
{{- if . | TagInputRequiresTransformation }}
{{ . | TagInputTagsField }}: {{ . | Title }}TagInput(chunk.IgnoreAws()),
{{- if . | TagInputCustomValue }}
{{ . | TagInputTagsField }}: {{ . | TagInputCustomValue }},
{{- else }}
{{ . | TagInputTagsField }}: chunk.IgnoreAws().{{ . | Title }}Tags(),
{{- end }}
Expand All @@ -279,8 +279,8 @@ func {{ . | Title }}UpdateTags(conn {{ . | ClientType }}, identifier string{{ if
{{- if . | TagInputResourceTypeField }}
{{ . | TagInputResourceTypeField }}: aws.String(resourceType),
{{- end }}
{{- if . | TagInputRequiresTransformation }}
{{ . | TagInputTagsField }}: {{ . | Title }}TagInput(updatedTags.IgnoreAws()),
{{- if . | TagInputCustomValue }}
{{ . | TagInputTagsField }}: {{ . | TagInputCustomValue }},
{{- else }}
{{ . | TagInputTagsField }}: updatedTags.IgnoreAws().{{ . | Title }}Tags(),
{{- end }}
Expand Down Expand Up @@ -499,11 +499,11 @@ func ServiceTagInputTagsField(serviceName string) string {
}
}

// ServiceTagInputRequiresTransformation determines if the service tagging tags field requires transformation.
func ServiceTagInputRequiresTransformation(serviceName string) string {
// ServiceTagInputCustomValue determines any custom value for the service tagging tags field.
func ServiceTagInputCustomValue(serviceName string) string {
switch serviceName {
case "kinesis":
return "yes"
return "aws.StringMap(chunk.IgnoreAws().Map())"
default:
return ""
}
Expand Down
13 changes: 0 additions & 13 deletions aws/internal/keyvaluetags/service_customizations.go

This file was deleted.

2 changes: 1 addition & 1 deletion aws/internal/keyvaluetags/update_tags_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7418bca

Please sign in to comment.