@@ -27,32 +27,12 @@ const (
2727)
2828
2929var (
30- v2BeginRegex = regexp .MustCompile ("^```\\ s*yaml\\ s*\\ $\\ (go\\ )\\ s*&&\\ s*\\ $\\ ((track2|v2)\\ )" )
31- v2EndRegex = regexp .MustCompile ("^\\ s*```\\ s*$" )
32- newClientMethodNameRegex = regexp .MustCompile ("^New.*Client$" )
33- versionLineRegex = regexp .MustCompile (`moduleVersion\s*=\s*\".*v.+"` )
34- changelogPosWithPreviewRegex = regexp .MustCompile (`##\s*(?P<version>.+)\s*\((\d{4}-\d{2}-\d{2}|Unreleased)\)` )
35- changelogPosWithoutPreviewRegex = regexp .MustCompile (`##\s*(?P<version>\d+\.\d+\.\d+)\s*\((\d{4}-\d{2}-\d{2}|Unreleased)\)` )
36- packageConfigRegex = regexp .MustCompile (`\$\((package-.+)\)` )
30+ v2BeginRegex = regexp .MustCompile ("^```\\ s*yaml\\ s*\\ $\\ (go\\ )\\ s*&&\\ s*\\ $\\ ((track2|v2)\\ )" )
31+ v2EndRegex = regexp .MustCompile ("^\\ s*```\\ s*$" )
32+ newClientMethodNameRegex = regexp .MustCompile ("^New.*Client$" )
33+ packageConfigRegex = regexp .MustCompile (`\$\((package-.+)\)` )
3734)
3835
39- // paramsToString converts a parameter list to a comma-delimited string with names and types
40- func paramsToString (params []exports.Param ) string {
41- if len (params ) == 0 {
42- return ""
43- }
44-
45- var parts []string
46- for _ , p := range params {
47- if p .Name != "" {
48- parts = append (parts , p .Name + " " + p .Type )
49- } else {
50- parts = append (parts , p .Type )
51- }
52- }
53- return strings .Join (parts , ", " )
54- }
55-
5636// hasExpectedClientParams checks if params match the expected ARM client constructor signature
5737func hasExpectedClientParams (params []exports.Param ) bool {
5838 expectedTypes := []string {"string" , "azcore.TokenCredential" , "*arm.ClientOptions" }
@@ -260,7 +240,7 @@ func GetSpecRpName(packageRootPath string) (string, error) {
260240 }
261241 }
262242 }
263- return "" , fmt .Errorf ("cannot get sepc rp name from config" )
243+ return "" , fmt .Errorf ("cannot get spec rp name from config" )
264244}
265245
266246// ReplaceNewClientNamePlaceholder replaces `{{NewClientName}}` placeholder in README.md by first func name according to `^New.+Method$` pattern
@@ -431,9 +411,9 @@ func UpdateReadmeClientFactory(path string) error {
431411 }
432412 noOptionalFactoryReg := regexp .MustCompile (`NewClientFactory\((.*?)(?:,\s*)?cred,\s*nil\)` )
433413 withOptionalFactoryReg := regexp .MustCompile (`NewClientFactory\((.*?)(?:,\s*)?cred,\s*&options\)` )
434- oldnoOptionalFactory := noOptionalFactoryReg .FindString (string (readmeFile ))
435- oldwithOptionalFactory := withOptionalFactoryReg .FindString (string (readmeFile ))
436- if oldnoOptionalFactory == "" && oldwithOptionalFactory == "" {
414+ oldNoOptionalFactory := noOptionalFactoryReg .FindString (string (readmeFile ))
415+ oldWithOptionalFactory := withOptionalFactoryReg .FindString (string (readmeFile ))
416+ if oldNoOptionalFactory == "" && oldWithOptionalFactory == "" {
437417 return nil
438418 }
439419 clientFactoryFile , err := os .ReadFile (filepath .Join (path , utils .ClientFactoryFileName ))
@@ -469,10 +449,10 @@ func UpdateReadmeClientFactory(path string) error {
469449 withOptionsParams := append (factoryParams , []string {"cred" , "&options" }... )
470450 newNoOptionalFactory := fmt .Sprintf ("NewClientFactory(%s)" , strings .Join (noOptionsParams , ", " ))
471451 newWithOptionalFactory := fmt .Sprintf ("NewClientFactory(%s)" , strings .Join (withOptionsParams , ", " ))
472- if oldnoOptionalFactory == newNoOptionalFactory && oldwithOptionalFactory == newWithOptionalFactory {
452+ if oldNoOptionalFactory == newNoOptionalFactory && oldWithOptionalFactory == newWithOptionalFactory {
473453 return nil
474454 }
475- content := strings .ReplaceAll (string (readmeFile ), oldnoOptionalFactory , newNoOptionalFactory )
476- content = strings .ReplaceAll (content , oldwithOptionalFactory , newWithOptionalFactory )
455+ content := strings .ReplaceAll (string (readmeFile ), oldNoOptionalFactory , newNoOptionalFactory )
456+ content = strings .ReplaceAll (content , oldWithOptionalFactory , newWithOptionalFactory )
477457 return os .WriteFile (readmePath , []byte (content ), 0644 )
478458}
0 commit comments