From 3dc479aacdfb10033ca7a00973fc66360b0a19bb Mon Sep 17 00:00:00 2001 From: ArcturusZhang Date: Wed, 2 Jun 2021 08:40:59 +0800 Subject: [PATCH 1/7] add the missing $ --- specification/compute/resource-manager/readme.go.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/compute/resource-manager/readme.go.md b/specification/compute/resource-manager/readme.go.md index 5144774ed3b6..438b239c3ce1 100644 --- a/specification/compute/resource-manager/readme.go.md +++ b/specification/compute/resource-manager/readme.go.md @@ -2,7 +2,7 @@ These settings apply only when `--go` is specified on the command line. -```yaml $(go) && !(track2) +```yaml $(go) && !$(track2) go: license-header: MICROSOFT_MIT_NO_VERSION clear-output-folder: true From 21814920c684277d256b1cfa8eee9a1d8c378ff4 Mon Sep 17 00:00:00 2001 From: ArcturusZhang Date: Wed, 2 Jun 2021 10:51:53 +0800 Subject: [PATCH 2/7] remove one useless directive --- specification/compute/resource-manager/readme.go.md | 9 --------- 1 file changed, 9 deletions(-) diff --git a/specification/compute/resource-manager/readme.go.md b/specification/compute/resource-manager/readme.go.md index 438b239c3ce1..3e94b0f32e6a 100644 --- a/specification/compute/resource-manager/readme.go.md +++ b/specification/compute/resource-manager/readme.go.md @@ -16,15 +16,6 @@ directive: $.push('DummyOrchestrationServiceName'); } return $; - - - from: source-file-go - where: $ - transform: >- - return $. - replace(/\/\/ DummyOrchestrationServiceName .../g,''). - replace(/DummyOrchestrationServiceName OrchestrationServiceNames = "DummyOrchestrationServiceName"\n/g,''). - replace(/,DummyOrchestrationServiceName/,''). - replace(/, 'DummyOrchestrationServiceName'/,''); ``` ``` yaml $(go) && $(track2) From 67dbeba3aea4b2c162c174c409b93511bf40060b Mon Sep 17 00:00:00 2001 From: ArcturusZhang Date: Wed, 2 Jun 2021 10:57:13 +0800 Subject: [PATCH 3/7] fix --- specification/compute/resource-manager/readme.go.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/specification/compute/resource-manager/readme.go.md b/specification/compute/resource-manager/readme.go.md index 3e94b0f32e6a..16c9ff2b14e0 100644 --- a/specification/compute/resource-manager/readme.go.md +++ b/specification/compute/resource-manager/readme.go.md @@ -26,6 +26,15 @@ output-folder: $(go-sdk-folder)/$(module-name) azure-arm: true directive: + # dynamically add a DummyOrchestrationServiceName value to the enum + - from: compute.json + where: $..enum + transform: >- + if( $.length === 1 && $[0] === "AutomaticRepairs") { + $.push('DummyOrchestrationServiceName'); + } + return $; + - from: disk.json where: "$.definitions.PurchasePlan" transform: > From 4be9c5e9b045127cfd1332be394d272ab7d40f1f Mon Sep 17 00:00:00 2001 From: ArcturusZhang Date: Wed, 30 Jun 2021 08:34:15 +0800 Subject: [PATCH 4/7] remove the hack for track 2 and add comments for reasons --- specification/compute/resource-manager/readme.go.md | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/specification/compute/resource-manager/readme.go.md b/specification/compute/resource-manager/readme.go.md index 16c9ff2b14e0..0368d99bb83c 100644 --- a/specification/compute/resource-manager/readme.go.md +++ b/specification/compute/resource-manager/readme.go.md @@ -8,7 +8,7 @@ go: clear-output-folder: true directive: - # dynamically add a DummyOrchestrationServiceName value to the enum + # dynamically add a DummyOrchestrationServiceName value to the enum to avoid the generator generates the code by hard-coding the single entried enum value - from: compute.json where: $..enum transform: >- @@ -26,15 +26,7 @@ output-folder: $(go-sdk-folder)/$(module-name) azure-arm: true directive: - # dynamically add a DummyOrchestrationServiceName value to the enum - - from: compute.json - where: $..enum - transform: >- - if( $.length === 1 && $[0] === "AutomaticRepairs") { - $.push('DummyOrchestrationServiceName'); - } - return $; - + # we do not need to hack to add a dummy enum entry in track 2 - from: disk.json where: "$.definitions.PurchasePlan" transform: > From 90982d09ba597bf95f445704281ccef682bbc8a1 Mon Sep 17 00:00:00 2001 From: ArcturusZhang Date: Mon, 2 Aug 2021 10:15:04 +0800 Subject: [PATCH 5/7] add one of the directive back to readme.go.md --- specification/compute/resource-manager/readme.go.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/specification/compute/resource-manager/readme.go.md b/specification/compute/resource-manager/readme.go.md index 0368d99bb83c..320bcacbc91b 100644 --- a/specification/compute/resource-manager/readme.go.md +++ b/specification/compute/resource-manager/readme.go.md @@ -16,6 +16,15 @@ directive: $.push('DummyOrchestrationServiceName'); } return $; + + - from: source-file-go + where: $ + transform: >- + return $. + replace(/\/\/ DummyOrchestrationServiceName .../g,''). + replace(/DummyOrchestrationServiceName OrchestrationServiceNames = "DummyOrchestrationServiceName"\n/g,''). + replace(/,DummyOrchestrationServiceName/,''). + replace(/, 'DummyOrchestrationServiceName'/,''); ``` ``` yaml $(go) && $(track2) From ecf713fa862d7d23a52dbb2be54e37b06946011b Mon Sep 17 00:00:00 2001 From: ArcturusZhang Date: Mon, 2 Aug 2021 10:17:32 +0800 Subject: [PATCH 6/7] add some comment to explain this more --- specification/compute/resource-manager/readme.go.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/specification/compute/resource-manager/readme.go.md b/specification/compute/resource-manager/readme.go.md index 320bcacbc91b..eb3892472e57 100644 --- a/specification/compute/resource-manager/readme.go.md +++ b/specification/compute/resource-manager/readme.go.md @@ -8,7 +8,8 @@ go: clear-output-folder: true directive: - # dynamically add a DummyOrchestrationServiceName value to the enum to avoid the generator generates the code by hard-coding the single entried enum value + # dynamically add a DummyOrchestrationServiceName value to the enum and then remove it from the generated code to avoid the generator generates the code by hard-coding the single-entry enum value + # this directive adds a DummyOrchestrationServiceName to the enum type - from: compute.json where: $..enum transform: >- @@ -17,6 +18,7 @@ directive: } return $; + # this directive removes the DummyOrchestrationServiceName from the generated code, so that we still have only one enum entry in this enum type. - from: source-file-go where: $ transform: >- @@ -35,7 +37,7 @@ output-folder: $(go-sdk-folder)/$(module-name) azure-arm: true directive: - # we do not need to hack to add a dummy enum entry in track 2 + # we do not need to hack to add a dummy enum entry in track 2, because track 2 generator will generate the enum type even if it only has on entry - from: disk.json where: "$.definitions.PurchasePlan" transform: > From 7d45eb63829295137cbfdea008cf35a531776e54 Mon Sep 17 00:00:00 2001 From: ArcturusZhang Date: Mon, 2 Aug 2021 12:10:34 +0800 Subject: [PATCH 7/7] fix --- specification/compute/resource-manager/readme.go.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/specification/compute/resource-manager/readme.go.md b/specification/compute/resource-manager/readme.go.md index eb3892472e57..9718cedf2f5f 100644 --- a/specification/compute/resource-manager/readme.go.md +++ b/specification/compute/resource-manager/readme.go.md @@ -23,10 +23,10 @@ directive: where: $ transform: >- return $. - replace(/\/\/ DummyOrchestrationServiceName .../g,''). - replace(/DummyOrchestrationServiceName OrchestrationServiceNames = "DummyOrchestrationServiceName"\n/g,''). - replace(/,DummyOrchestrationServiceName/,''). - replace(/, 'DummyOrchestrationServiceName'/,''); + replace(/\/\/ (OrchestrationServiceNames)?DummyOrchestrationServiceName .../g,''). + replace(/(OrchestrationServiceNames)?DummyOrchestrationServiceName OrchestrationServiceNames = "DummyOrchestrationServiceName"\n/g,''). + replace(/,(OrchestrationServiceNames)?DummyOrchestrationServiceName/,''). + replace(/, '(OrchestrationServiceNames)?DummyOrchestrationServiceName'/,''); ``` ``` yaml $(go) && $(track2)