Skip to content

Commit

Permalink
Add status tag for tracking autogen-created resources (GoogleCloudPla…
Browse files Browse the repository at this point in the history
  • Loading branch information
slevenick authored Nov 11, 2024
1 parent 91659ee commit 12341a5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions mmv1/api/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions mmv1/openapi_generate/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package openapi_generate

import (
"context"
"encoding/base64"
"fmt"
"os"
"path"
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 12341a5

Please sign in to comment.