Fix provider review findings
This commit is contained in:
@@ -59,7 +59,10 @@ func WriteInstanceResource(outDir string, svc types.GenResource) error {
|
||||
return err
|
||||
}
|
||||
|
||||
formatted := helpers.FormatSourceOrWarn(filePath, buf.Bytes())
|
||||
formatted, err := helpers.FormatSourceOrWarn(filePath, buf.Bytes())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return os.WriteFile(filePath, formatted, 0644)
|
||||
}
|
||||
@@ -91,7 +94,10 @@ func WriteSubresource(outDir string, sr types.GenSubresource) error {
|
||||
return err
|
||||
}
|
||||
|
||||
formatted := helpers.FormatSourceOrWarn(filePath, buf.Bytes())
|
||||
formatted, err := helpers.FormatSourceOrWarn(filePath, buf.Bytes())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return os.WriteFile(filePath, formatted, 0644)
|
||||
}
|
||||
@@ -121,7 +127,10 @@ func WriteActionResource(outDir string, act types.GenAction) error {
|
||||
return err
|
||||
}
|
||||
|
||||
formatted := helpers.FormatSourceOrWarn(filePath, buf.Bytes())
|
||||
formatted, err := helpers.FormatSourceOrWarn(filePath, buf.Bytes())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return os.WriteFile(filePath, formatted, 0644)
|
||||
}
|
||||
@@ -131,7 +140,7 @@ func WriteRegistry(outDir string, services []types.GenResource, subs []types.Gen
|
||||
var buf bytes.Buffer
|
||||
buf.WriteString("package resources_gen\n\n")
|
||||
buf.WriteString("import \"github.com/hashicorp/terraform-plugin-framework/resource\"\n\n")
|
||||
buf.WriteString("// Code generated by tools/gen_v2. DO NOT EDIT.\n")
|
||||
buf.WriteString("// Code generated by TOOLS/resource-generator. DO NOT EDIT.\n")
|
||||
buf.WriteString("func AllResources() []func() resource.Resource {\n")
|
||||
buf.WriteString("\treturn []func() resource.Resource{\n")
|
||||
for _, svc := range services {
|
||||
@@ -147,7 +156,10 @@ func WriteRegistry(outDir string, services []types.GenResource, subs []types.Gen
|
||||
buf.WriteString("}\n")
|
||||
|
||||
regPath := filepath.Join(outDir, "registry.go")
|
||||
formatted := helpers.FormatSourceOrWarn(regPath, buf.Bytes())
|
||||
formatted, err := helpers.FormatSourceOrWarn(regPath, buf.Bytes())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return os.WriteFile(regPath, formatted, 0644)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user