From 12341a5530da29c545e86875ee54c8e8fa7b02dd Mon Sep 17 00:00:00 2001 From: Sam Levenick Date: Mon, 11 Nov 2024 12:30:11 -0500 Subject: [PATCH] Add status tag for tracking autogen-created resources (#12293) --- mmv1/api/resource.go | 4 ++++ mmv1/openapi_generate/parser.go | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/mmv1/api/resource.go b/mmv1/api/resource.go index c6f9ec5e84bb..771c780bb48b 100644 --- a/mmv1/api/resource.go +++ b/mmv1/api/resource.go @@ -330,6 +330,10 @@ type Resource struct { ApiResourceTypeKind string `yaml:"api_resource_type_kind,omitempty"` ImportPath string `yaml:"-"` + + // Tag autogen resources so that we can track them. In the future this will + // control if a resource is continuously generated from public OpenAPI docs + AutogenStatus string `yaml:"autogen_status"` } func (r *Resource) UnmarshalYAML(unmarshal func(any) error) error { diff --git a/mmv1/openapi_generate/parser.go b/mmv1/openapi_generate/parser.go index 23a8c91a057a..3c2a63344e89 100644 --- a/mmv1/openapi_generate/parser.go +++ b/mmv1/openapi_generate/parser.go @@ -17,6 +17,7 @@ package openapi_generate import ( "context" + "encoding/base64" "fmt" "os" "path" @@ -259,6 +260,11 @@ func buildResource(filePath, resourcePath, resourceName string, root *openapi3.T resource.Examples = []r.Examples{example} + resourceNameBytes := []byte(resourceName) + // Write the status as an encoded string to flag when a YAML file has been + // copy and pasted without actually using this tool + resource.AutogenStatus = base64.StdEncoding.EncodeToString(resourceNameBytes) + return resource }