Skip to content

Commit

Permalink
make the generationmetadata more strong typed
Browse files Browse the repository at this point in the history
  • Loading branch information
ArcturusZhang committed Apr 16, 2021
1 parent 3521892 commit 93f6a3b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
20 changes: 12 additions & 8 deletions tools/generator/autorest/generationMetadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,25 @@ import (
// GenerationMetadata contains all the metadata that has been used when generating a track 1 package
type GenerationMetadata struct {
// AutorestVersion is the version of autorest.core
AutorestVersion string `json:"autorest,omitempty"`
AutorestVersion string `json:"autorest,omitempty"`
// CommitHash is the commit hash of azure-rest-api-specs from which this SDK package is generated
CommitHash string `json:"commit,omitempty"`
CommitHash string `json:"commit,omitempty"`
// Readme is the normalized path of the readme file from which this SDK package is generated. It should be in this pattern: /_/azure-rest-api-specs/{relative_path}
Readme string `json:"readme,omitempty"`
Readme string `json:"readme,omitempty"`
// Tag is the tag from which this SDK package is generated
Tag string `json:"tag,omitempty"`
Tag string `json:"tag,omitempty"`
// CodeGenVersion is the version of autorest.go using when this package is generated
CodeGenVersion string `json:"use,omitempty"`
CodeGenVersion string `json:"use,omitempty"`
// RepositoryURL is the URL of the azure-rest-api-specs. This should always be a constant "https://github.com/Azure/azure-rest-api-specs.git"
RepositoryURL string `json:"repository_url,omitempty"`
RepositoryURL string `json:"repository_url,omitempty"`
// AutorestCommand is the full command that generates this package
AutorestCommand string `json:"autorest_command,omitempty"`
AutorestCommand string `json:"autorest_command,omitempty"`
// AdditionalProperties is a map of addition information in this metadata
AdditionalProperties map[string]interface{} `json:"additional_properties,omitempty"`
AdditionalProperties GenerationMetadataAdditionalProperties `json:"additional_properties,omitempty"`
}

type GenerationMetadataAdditionalProperties struct {
AdditionalOptions string `json:"additional_options,omitempty"`
}

// RelativeReadme returns the relative readme path
Expand Down
4 changes: 2 additions & 2 deletions tools/generator/cmd/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ func (ctx changelogContext) process(metadataLocation string) ([]autorest.Changel
metadata := ctx.commonMetadata
metadata.Tag = result.Tag
options := additionalOptions(ctx.autorestArguments)
metadata.AdditionalProperties = map[string]interface{}{
"additional_options": strings.Join(options, " "),
metadata.AdditionalProperties = autorest.GenerationMetadataAdditionalProperties{
AdditionalOptions: strings.Join(options, " "),
}
metadata.AutorestCommand = fmt.Sprintf("autorest --tag=%s --go-sdk-folder=/_/azure-sdk-for-go %s /_/azure-rest-api-specs/%s",
result.Tag, strings.Join(options, " "), utils.NormalizePath(ctx.readme))
Expand Down

0 comments on commit 93f6a3b

Please sign in to comment.