Skip to content

Commit 34532f1

Browse files
slevenickakshat-jindal-nit
authored andcommitted
Add status tag for tracking autogen-created resources (GoogleCloudPlatform#12293)
1 parent 8aa474d commit 34532f1

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

mmv1/api/resource.go

+4
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,10 @@ type Resource struct {
330330
ApiResourceTypeKind string `yaml:"api_resource_type_kind,omitempty"`
331331

332332
ImportPath string `yaml:"-"`
333+
334+
// Tag autogen resources so that we can track them. In the future this will
335+
// control if a resource is continuously generated from public OpenAPI docs
336+
AutogenStatus string `yaml:"autogen_status"`
333337
}
334338

335339
func (r *Resource) UnmarshalYAML(unmarshal func(any) error) error {

mmv1/openapi_generate/parser.go

+6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package openapi_generate
1717

1818
import (
1919
"context"
20+
"encoding/base64"
2021
"fmt"
2122
"os"
2223
"path"
@@ -259,6 +260,11 @@ func buildResource(filePath, resourcePath, resourceName string, root *openapi3.T
259260

260261
resource.Examples = []r.Examples{example}
261262

263+
resourceNameBytes := []byte(resourceName)
264+
// Write the status as an encoded string to flag when a YAML file has been
265+
// copy and pasted without actually using this tool
266+
resource.AutogenStatus = base64.StdEncoding.EncodeToString(resourceNameBytes)
267+
262268
return resource
263269
}
264270

0 commit comments

Comments
 (0)