Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Bug fixes across terraform provider #132

Merged
merged 3 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions pkg/translate/terraform_provider/funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -940,29 +940,17 @@ func createSchemaAttributeForParameter(schemaTyp schemaType, packageName string,
computed = true
}

// TODO(kklimonda): This is pretty one-off implementation to
// support uuid-style resources, but could be expanded to be more
// generic if needed.
var modifiers *modifierCtx
if schemaTyp == schemaResource && computed && param.Default == "" {
modifiers = &modifierCtx{
SchemaType: fmt.Sprintf("planmodifier.%s", pascalCase(param.Type)),
Modifiers: []string{fmt.Sprintf("%splanmodifier.UseStateForUnknown()", param.Type)},
}
}

return attributeCtx{
Package: packageName,
Name: param.Name,
SchemaType: schemaType,
ElementType: elementType,
Description: param.Description,
Required: param.Required,
Optional: !param.Required,
Sensitive: param.Sensitive,
Default: defaultValue,
Computed: computed,
PlanModifiers: modifiers,
Package: packageName,
Name: param.Name,
SchemaType: schemaType,
ElementType: elementType,
Description: param.Description,
Required: param.Required,
Optional: !param.Required,
Sensitive: param.Sensitive,
Default: defaultValue,
Computed: computed,
}
}

Expand Down Expand Up @@ -2051,13 +2039,18 @@ func DataSourceReadFunction(resourceTyp properties.ResourceType, names *NameProv

var tmpl string
var listAttribute string
var exhaustive bool
switch resourceTyp {
case properties.ResourceEntry:
tmpl = resourceReadFunction
case properties.ResourceEntryPlural:
tmpl = resourceReadEntryListFunction
listAttribute = pascalCase(paramSpec.TerraformProviderConfig.PluralName)
case properties.ResourceUuid, properties.ResourceUuidPlural:
case properties.ResourceUuid:
exhaustive = true
tmpl = resourceReadManyFunction
listAttribute = pascalCase(paramSpec.TerraformProviderConfig.PluralName)
case properties.ResourceUuidPlural:
tmpl = resourceReadManyFunction
listAttribute = pascalCase(paramSpec.TerraformProviderConfig.PluralName)
}
Expand All @@ -2076,6 +2069,7 @@ func DataSourceReadFunction(resourceTyp properties.ResourceType, names *NameProv
"ResourceOrDS": "DataSource",
"ResourceIsMap": resourceIsMap,
"HasEncryptedResources": paramSpec.HasEncryptedResources(),
"Exhaustive": exhaustive,
"ListAttribute": listAttributeVariant,
"EntryOrConfig": paramSpec.EntryOrConfig(),
"HasEntryName": paramSpec.HasEntryName(),
Expand All @@ -2091,6 +2085,9 @@ func DataSourceReadFunction(resourceTyp properties.ResourceType, names *NameProv
"RenderLocationsPangoToState": func(source string, dest string) (string, error) {
return RenderLocationsPangoToState(names, paramSpec, source, dest)
},
"RenderCreateUpdateMovementRequired": func(state string, entries string) (string, error) {
return RendeCreateUpdateMovementRequired(state, entries)
},
"RenderLocationsStateToPango": func(source string, dest string) (string, error) {
return RenderLocationsStateToPango(names, paramSpec, source, dest)
},
Expand Down Expand Up @@ -2152,6 +2149,9 @@ func ResourceReadFunction(resourceTyp properties.ResourceType, names *NameProvid
"RenderLocationsPangoToState": func(source string, dest string) (string, error) {
return RenderLocationsPangoToState(names, paramSpec, source, dest)
},
"RenderCreateUpdateMovementRequired": func(state string, entries string) (string, error) {
return RendeCreateUpdateMovementRequired(state, entries)
},
"RenderLocationsStateToPango": func(source string, dest string) (string, error) {
return RenderLocationsStateToPango(names, paramSpec, source, dest)
},
Expand Down
Loading
Loading