Skip to content

adopt sub spec structure #24631

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions eng/tools/generator/cmd/v2/common/fileProcessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func ChangeConfigWithLocalPath(path, readmeFile, readmeGoFile string) error {
}

// replace repo URL and commit id in autorest.md file
func ChangeConfigWithCommitID(path, repoURL, commitID, specRPName string) error {
func ChangeConfigWithCommitID(path, repoURL, commitID, specRPName, specSubRPName string) error {
log.Printf("Replacing repo URL and commit id in autorest.md ...")
b, err := os.ReadFile(path)
if err != nil {
Expand All @@ -203,7 +203,9 @@ func ChangeConfigWithCommitID(path, repoURL, commitID, specRPName string) error
indexReadme := strings.Index(line, autorest_md_file_suffix)
resourceManagerPath := []byte(line)
resourceManagerPath = resourceManagerPath[indexResourceManager : indexReadme-1]

if specSubRPName != "" {
resourceManagerPath = append(resourceManagerPath, []byte("/"+specSubRPName)...)
}
lines[i] = fmt.Sprintf("- %s/blob/%s/specification/%s/%s/readme.md", repoURL, commitID, specRPName, resourceManagerPath)
lines[i+1] = fmt.Sprintf("- %s/blob/%s/specification/%s/%s/readme.go.md", repoURL, commitID, specRPName, resourceManagerPath)
break
Expand Down
3 changes: 2 additions & 1 deletion eng/tools/generator/cmd/v2/common/generation.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type GenerateParam struct {
SpecificVersion string
SpecificPackageTitle string
SpecRPName string
SpecSubRPName string
ReleaseDate string
SkipGenerateExample bool
GoVersion string
Expand Down Expand Up @@ -232,7 +233,7 @@ func (t *SwaggerCommonGenerator) PreGenerate(generateParam *GenerateParam) error
} else {
log.Printf("Change swagger config in `autorest.md` according to repo URL and commit ID...")
autorestMdPath := filepath.Join(packagePath, "autorest.md")
if err := ChangeConfigWithCommitID(autorestMdPath, t.SpecRepoURL, t.SpecCommitHash, generateParam.SpecRPName); err != nil {
if err := ChangeConfigWithCommitID(autorestMdPath, t.SpecRepoURL, t.SpecCommitHash, generateParam.SpecRPName, generateParam.SpecSubRPName); err != nil {
return err
}
}
Expand Down
4 changes: 4 additions & 0 deletions eng/tools/generator/cmd/v2/release/releaseCmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type Flags struct {
PackageTitle string
SDKRepo string
SpecRPName string
SpecSubRPName string
ReleaseDate string
SkipCreateBranch bool
SkipGenerateExample bool
Expand All @@ -85,6 +86,7 @@ func BindFlags(flagSet *pflag.FlagSet) {
flagSet.String("sdk-repo", "https://github.com/Azure/azure-sdk-for-go", "Specifies the sdk repo URL for generation")
flagSet.String("spec-repo", "https://github.com/Azure/azure-rest-api-specs", "Specifies the swagger repo URL for generation")
flagSet.String("spec-rp-name", "", "Specifies the swagger spec RP name, default is RP name")
flagSet.String("spec-sub-rp-name", "", "Specifies the swagger spec sub RP name")
flagSet.String("release-date", "", "Specifies the release date in changelog")
flagSet.Bool("skip-create-branch", false, "Skip create release branch after generation")
flagSet.Bool("skip-generate-example", false, "Skip generate example for SDK in the same time")
Expand All @@ -103,6 +105,7 @@ func ParseFlags(flagSet *pflag.FlagSet) Flags {
SDKRepo: flags.GetString(flagSet, "sdk-repo"),
SwaggerRepo: flags.GetString(flagSet, "spec-repo"),
SpecRPName: flags.GetString(flagSet, "spec-rp-name"),
SpecSubRPName: flags.GetString(flagSet, "spec-sub-rp-name"),
ReleaseDate: flags.GetString(flagSet, "release-date"),
SkipCreateBranch: flags.GetBool(flagSet, "skip-create-branch"),
SkipGenerateExample: flags.GetBool(flagSet, "skip-generate-example"),
Expand Down Expand Up @@ -195,6 +198,7 @@ func (c *commandContext) generate(sdkRepo repo.SDKRepository, specCommitHash str
ReleaseDate: c.flags.ReleaseDate,
SkipGenerateExample: c.flags.SkipGenerateExample,
GoVersion: c.flags.GoVersion,
SpecSubRPName: c.flags.SpecSubRPName,
})
if len(errs) > 0 {
// GenerateFromSwagger is a batch run function, one error means one package is failed.
Expand Down