Skip to content

Commit 3d91c08

Browse files
adopt sub package
1 parent 01706b0 commit 3d91c08

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

eng/tools/generator/cmd/v2/common/fileProcessor.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ func ChangeConfigWithLocalPath(path, readmeFile, readmeGoFile string) error {
189189
}
190190

191191
// replace repo URL and commit id in autorest.md file
192-
func ChangeConfigWithCommitID(path, repoURL, commitID, specRPName string) error {
192+
func ChangeConfigWithCommitID(path, repoURL, commitID, specRPName, specSubRPName string) error {
193193
log.Printf("Replacing repo URL and commit id in autorest.md ...")
194194
b, err := os.ReadFile(path)
195195
if err != nil {
@@ -203,7 +203,9 @@ func ChangeConfigWithCommitID(path, repoURL, commitID, specRPName string) error
203203
indexReadme := strings.Index(line, autorest_md_file_suffix)
204204
resourceManagerPath := []byte(line)
205205
resourceManagerPath = resourceManagerPath[indexResourceManager : indexReadme-1]
206-
206+
if specSubRPName != "" {
207+
resourceManagerPath = append(resourceManagerPath, []byte("/"+specSubRPName)...)
208+
}
207209
lines[i] = fmt.Sprintf("- %s/blob/%s/specification/%s/%s/readme.md", repoURL, commitID, specRPName, resourceManagerPath)
208210
lines[i+1] = fmt.Sprintf("- %s/blob/%s/specification/%s/%s/readme.go.md", repoURL, commitID, specRPName, resourceManagerPath)
209211
break

eng/tools/generator/cmd/v2/common/generation.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ type GenerateParam struct {
4949
SpecificVersion string
5050
SpecificPackageTitle string
5151
SpecRPName string
52+
SpecSubRPName string
5253
ReleaseDate string
5354
SkipGenerateExample bool
5455
GoVersion string
@@ -225,7 +226,7 @@ func (t *SwaggerCommonGenerator) PreGenerate(generateParam *GenerateParam) error
225226
log.Printf("Change swagger config in `autorest.md` according to repo URL and commit ID...")
226227
autorestMdPath := filepath.Join(packagePath, "autorest.md")
227228
if t.UpdateSpecVersion {
228-
if err := ChangeConfigWithCommitID(autorestMdPath, t.SpecRepoURL, t.SpecCommitHash, generateParam.SpecRPName); err != nil {
229+
if err := ChangeConfigWithCommitID(autorestMdPath, t.SpecRepoURL, t.SpecCommitHash, generateParam.SpecRPName, generateParam.SpecSubRPName); err != nil {
229230
return err
230231
}
231232
}

eng/tools/generator/cmd/v2/release/releaseCmd.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ type Flags struct {
6969
PackageTitle string
7070
SDKRepo string
7171
SpecRPName string
72+
SpecSubRPName string
7273
ReleaseDate string
7374
SkipCreateBranch bool
7475
SkipGenerateExample bool
@@ -88,6 +89,7 @@ func BindFlags(flagSet *pflag.FlagSet) {
8889
flagSet.String("sdk-repo", "https://github.com/Azure/azure-sdk-for-go", "Specifies the sdk repo URL for generation")
8990
flagSet.String("spec-repo", "https://github.com/Azure/azure-rest-api-specs", "Specifies the swagger repo URL for generation")
9091
flagSet.String("spec-rp-name", "", "Specifies the swagger spec RP name, default is RP name")
92+
flagSet.String("spec-sub-rp-name", "", "Specifies the swagger spec sub RP name")
9193
flagSet.String("release-date", "", "Specifies the release date in changelog")
9294
flagSet.Bool("skip-create-branch", false, "Skip create release branch after generation")
9395
flagSet.Bool("skip-generate-example", false, "Skip generate example for SDK in the same time")
@@ -108,6 +110,7 @@ func ParseFlags(flagSet *pflag.FlagSet) Flags {
108110
SDKRepo: flags.GetString(flagSet, "sdk-repo"),
109111
SwaggerRepo: flags.GetString(flagSet, "spec-repo"),
110112
SpecRPName: flags.GetString(flagSet, "spec-rp-name"),
113+
SpecSubRPName: flags.GetString(flagSet, "spec-sub-rp-name"),
111114
ReleaseDate: flags.GetString(flagSet, "release-date"),
112115
SkipCreateBranch: flags.GetBool(flagSet, "skip-create-branch"),
113116
SkipGenerateExample: flags.GetBool(flagSet, "skip-generate-example"),
@@ -208,6 +211,7 @@ func (c *commandContext) generate(sdkRepo repo.SDKRepository, specCommitHash str
208211
SkipGenerateExample: c.flags.SkipGenerateExample,
209212
GoVersion: c.flags.GoVersion,
210213
ForceStableVersion: c.flags.ForceStableVersion,
214+
SpecSubRPName: c.flags.SpecSubRPName,
211215
})
212216
}
213217
if err != nil {

0 commit comments

Comments
 (0)