Skip to content

Commit

Permalink
CLOUDP-262703: Add x-xgen-sha flag to GenerateAtlasOpenApiSpecTool (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaangiolillo authored Jul 22, 2024
1 parent 59fd704 commit 8004608
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions tools/cli/internal/cli/flag/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ const (
Spec = "spec"
SpecShort = "s"
Environment = "env"
GitSha = "sha"
)
8 changes: 8 additions & 0 deletions tools/cli/internal/cli/merge/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type Opts struct {
basePath string
outputPath string
format string
gitSha string
externalPaths []string
}

Expand All @@ -41,6 +42,12 @@ func (o *Opts) Run() error {
return err
}

if o.gitSha != "" {
federated.Info.Extensions = map[string]interface{}{
"x-xgen-sha": o.gitSha,
}
}

federatedBytes, err := json.MarshalIndent(*federated, "", " ")
if err != nil {
return err
Expand Down Expand Up @@ -97,6 +104,7 @@ func Builder() *cobra.Command {

cmd.Flags().StringVarP(&opts.basePath, flag.Base, flag.BaseShort, "", usage.Base)
cmd.Flags().StringArrayVarP(&opts.externalPaths, flag.External, flag.ExternalShort, nil, usage.External)
cmd.Flags().StringVar(&opts.gitSha, flag.GitSha, "", usage.GitSha)
cmd.Flags().StringVarP(&opts.outputPath, flag.Output, flag.OutputShort, "", usage.Output)
cmd.Flags().StringVarP(&opts.format, flag.Format, flag.FormatShort, "json", usage.Format)

Expand Down
1 change: 1 addition & 0 deletions tools/cli/internal/cli/usage/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ const (
Versions = "Boolean flag that defines wether to split the OAS into multiple versions."
Spec = "Path to the OAS file."
Environment = "Environment to consider when generating the versioned OAS."
GitSha = "GitSHA to use as identifier (x-xgen-sha) of the generated specification."
)

0 comments on commit 8004608

Please sign in to comment.