-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add patch for generated file kind/Stack.go to support YAML for connec…
…tion objects. Signed-off-by: Timothy Rule (VM/EMT3) <Timothy.Rule@de.bosch.com>
- Loading branch information
1 parent
1edc136
commit 9e8478d
Showing
3 changed files
with
84 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,51 @@ | ||
# Copyright 2024 Robert Bosch GmbH | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
|
||
YAML_DIR = ../../../schemas/yaml | ||
KIND_YAML_FILES = $(shell cd $(YAML_DIR); ls *.yaml) | ||
KIND_YAML_FILES := $(filter-out Simulation.yaml, $(KIND_YAML_FILES)) | ||
KIND_GO_FILES = $(subst .yaml,.go, $(KIND_YAML_FILES)) | ||
KIND_FILES = $(addprefix kind/, $(KIND_GO_FILES)) | ||
AST_FILES = ast/Simulation.go ast/metadata.go | ||
|
||
|
||
.PHONY: generate | ||
generate: clean kind ast | ||
|
||
|
||
kind: $(KIND_FILES) | ||
@echo "package kind" > kind/kind.go | ||
kind/%.go: $(YAML_DIR)/%.yaml | ||
@echo "$$(basename $<) --> $@" | ||
@~/go/bin/oapi-codegen -config $(@D)/config.yaml $< > $@ | ||
@sed -i '/delete_this_line/d' $@ | ||
@sed -i '/\/\//d' $@ | ||
@sed -i '/./!d' $@ | ||
@sed -i -e 's/externalRef[[:digit:]]*\.//g' $@ | ||
@sed -i -e 's/`json:"/`yaml:"/g' $@ | ||
@go fmt $@ | ||
|
||
ast: $(AST_FILES) | ||
@echo "package ast" > ast/ast.go | ||
ast/%.go: $(YAML_DIR)/%.yaml | ||
@echo "$$(basename $<) --> $@" | ||
@~/go/bin/oapi-codegen -config $(@D)/config.yaml $< > $@ | ||
@sed -i '/delete_this_line/d' $@ | ||
@sed -i '/\/\//d' $@ | ||
@sed -i '/./!d' $@ | ||
@sed -i -e 's/externalRef[[:digit:]]*\.//g' $@ | ||
@sed -i -e 's/`json:"/`yaml:"/g' $@ | ||
@go fmt $@ | ||
|
||
|
||
.PHONY: clean | ||
clean: | ||
@rm -f kind/*.go | ||
@rm -f ast/*.go | ||
# Copyright 2024 Robert Bosch GmbH | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
|
||
YAML_DIR = ../../../schemas/yaml | ||
KIND_YAML_FILES = $(shell cd $(YAML_DIR); ls *.yaml) | ||
KIND_YAML_FILES := $(filter-out Simulation.yaml, $(KIND_YAML_FILES)) | ||
KIND_GO_FILES = $(subst .yaml,.go, $(KIND_YAML_FILES)) | ||
KIND_FILES = $(addprefix kind/, $(KIND_GO_FILES)) | ||
AST_FILES = ast/Simulation.go ast/metadata.go | ||
PATCH_FILES = patch/marshal_yaml.patch | ||
|
||
.PHONY: generate | ||
generate: clean kind ast patch | ||
|
||
|
||
kind: $(KIND_FILES) | ||
@echo "package kind" > kind/kind.go | ||
kind/%.go: $(YAML_DIR)/%.yaml | ||
@echo "$$(basename $<) --> $@" | ||
@~/go/bin/oapi-codegen -config $(@D)/config.yaml $< > $@ | ||
@sed -i '/delete_this_line/d' $@ | ||
@sed -i '/\/\//d' $@ | ||
@sed -i '/./!d' $@ | ||
@sed -i -e 's/externalRef[[:digit:]]*\.//g' $@ | ||
@sed -i -e 's/`json:"/`yaml:"/g' $@ | ||
@go fmt $@ | ||
|
||
ast: $(AST_FILES) | ||
@echo "package ast" > ast/ast.go | ||
ast/%.go: $(YAML_DIR)/%.yaml | ||
@echo "$$(basename $<) --> $@" | ||
@~/go/bin/oapi-codegen -config $(@D)/config.yaml $< > $@ | ||
@sed -i '/delete_this_line/d' $@ | ||
@sed -i '/\/\//d' $@ | ||
@sed -i '/./!d' $@ | ||
@sed -i -e 's/externalRef[[:digit:]]*\.//g' $@ | ||
@sed -i -e 's/`json:"/`yaml:"/g' $@ | ||
@go fmt $@ | ||
|
||
.PHONY: $(PATCH_FILES) | ||
patch: $(PATCH_FILES) | ||
$(PATCH_FILES): | ||
@echo "Apply Patch: $@ --> " | ||
@git apply $@ | ||
|
||
.PHONY: clean | ||
clean: | ||
@rm -f kind/*.go | ||
@rm -f ast/*.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
diff --git a/code/go/dse/kind/Stack.go b/code/go/dse/kind/Stack.go | ||
index 2022842..d3b0fb8 100644 | ||
--- a/code/go/dse/kind/Stack.go | ||
+++ b/code/go/dse/kind/Stack.go | ||
@@ -2,6 +2,8 @@ package kind | ||
|
||
import ( | ||
"encoding/json" | ||
+ "strings" | ||
+ | ||
"github.com/oapi-codegen/runtime" | ||
) | ||
|
||
@@ -135,3 +137,10 @@ func (t *StackSpec_Connection_Transport) UnmarshalJSON(b []byte) error { | ||
err := t.union.UnmarshalJSON(b) | ||
return err | ||
} | ||
+func (t StackSpec_Connection_Transport) MarshalYAML() (interface{}, error) { | ||
+ b, err := t.union.MarshalJSON() | ||
+ b = []byte(strings.ToLower(string(b))) | ||
+ r := make(map[string]interface{}) | ||
+ json.Unmarshal(b, &r) | ||
+ return r, err | ||
+} |