Skip to content

Commit

Permalink
Reworked Go code generation.
Browse files Browse the repository at this point in the history
Signed-off-by: Rule Timothy (VM/EMT3) <[email protected]>
  • Loading branch information
timrulebosch committed Feb 21, 2024
1 parent 92c6f02 commit bea66c6
Show file tree
Hide file tree
Showing 14 changed files with 129 additions and 11 deletions.
20 changes: 10 additions & 10 deletions code/go/dse/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ KIND_YAML_FILES = $(shell ls $(KIND_YAML_DIR)/*.yaml)


.PHONY: generate
generate: kind
generate: clean kind

kind: $(KIND_YAML_FILES)
@echo "package kind" > kind/kind.go

.PHONY: $(KIND_YAML_FILES)
$(KIND_YAML_FILES):
@echo $$(basename $@)
@mkdir -p kind
@~/go/bin/oapi-codegen -config config.yaml $@ > kind/$$(basename $@).go
@sed -i '/delete_this_line/d' kind/$$(basename $@).go
@sed -i '/\/\//d' kind/$$(basename $@).go
@sed -i '/./!d' kind/$$(basename $@).go
@sed -i -e 's/externalRef[[:digit:]]*\.//g' kind/$$(basename $@).go
@sed -i -e 's/`json:"/`yaml:"/g' kind/$$(basename $@).go
@go fmt kind/$$(basename $@).go
@~/go/bin/oapi-codegen -config kind/config.yaml $@ > kind/$$(basename $@ .yaml).go
@sed -i '/delete_this_line/d' kind/$$(basename $@ .yaml).go
@sed -i '/\/\//d' kind/$$(basename $@ .yaml).go
@sed -i '/./!d' kind/$$(basename $@ .yaml).go
@sed -i -e 's/externalRef[[:digit:]]*\.//g' kind/$$(basename $@ .yaml).go
@sed -i -e 's/`json:"/`yaml:"/g' kind/$$(basename $@ .yaml).go
@go fmt kind/$$(basename $@ .yaml).go

.PHONY: clean
clean:
@rm -rf kind
@rm -f kind/*.go
13 changes: 13 additions & 0 deletions code/go/dse/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## Install the Module

```bash
# Latest version.
$ export GOPRIVATE=github.com/boschglobal
$ go get github.com/boschglobal/dse.schemas/code/go/dse

# Specific tagged version.
$ go get github.com/boschglobal/dse.schemas/code/go/[email protected]

# Debug for go get command
$ go get -x github.com/boschglobal/dse.schemas/code/go/dse
```
71 changes: 71 additions & 0 deletions code/go/dse/kind/Manifest.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package kind

import ()

const (
ManifestKindManifest ManifestKind = "Manifest"
)
const (
Redispubsub SimulationParametersTransport = "redispubsub"
)

type File struct {
Generate *string `yaml:"generate,omitempty"`
Modelc *bool `yaml:"modelc,omitempty"`
Name string `yaml:"name"`
Processing *string `yaml:"processing,omitempty"`
Repo *string `yaml:"repo,omitempty"`
Uri *string `yaml:"uri,omitempty"`
}
type Manifest struct {
Kind ManifestKind `yaml:"kind"`
Metadata *ObjectMetadata `yaml:"metadata,omitempty"`
Spec ManifestSpec `yaml:"spec"`
}
type ManifestKind string
type ManifestSpec struct {
Documentation *[]File `yaml:"documentation,omitempty"`
Models []Model `yaml:"models"`
Repos []Repo `yaml:"repos"`
Simulations []Simulation `yaml:"simulations"`
Tools []Tool `yaml:"tools"`
}
type Model struct {
Arch *string `yaml:"arch,omitempty"`
Channels *[]Channel `yaml:"channels,omitempty"`
Name string `yaml:"name"`
Repo string `yaml:"repo"`
Schema *string `yaml:"schema,omitempty"`
Version string `yaml:"version"`
}
type ModelInstanceDefinition struct {
Channels []Channel `yaml:"channels"`
Files *[]File `yaml:"files,omitempty"`
Model string `yaml:"model"`
Name string `yaml:"name"`
}
type Repo struct {
Name string `yaml:"name"`
Path *string `yaml:"path,omitempty"`
Registry *string `yaml:"registry,omitempty"`
Repo *string `yaml:"repo,omitempty"`
Token string `yaml:"token"`
User string `yaml:"user"`
}
type Simulation struct {
Files *[]File `yaml:"files,omitempty"`
Models []ModelInstanceDefinition `yaml:"models"`
Name string `yaml:"name"`
Parameters *struct {
Environment *map[string]string `yaml:"environment,omitempty"`
Transport SimulationParametersTransport `yaml:"transport"`
} `yaml:"parameters,omitempty"`
}
type SimulationParametersTransport string
type Tool struct {
Arch *[]string `yaml:"arch,omitempty"`
Name string `yaml:"name"`
Repo *string `yaml:"repo,omitempty"`
Schema *string `yaml:"schema,omitempty"`
Version string `yaml:"version"`
}
File renamed without changes.
34 changes: 34 additions & 0 deletions code/go/dse/kind/Network.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package kind

import ()

const (
NetworkKindNetwork NetworkKind = "Network"
)

type Function struct {
Annotations *Annotations `yaml:"annotations,omitempty"`
Function string `yaml:"function"`
}
type Message struct {
Annotations *Annotations `yaml:"annotations,omitempty"`
Functions *struct {
Decode *[]Function `yaml:"decode,omitempty"`
Encode *[]Function `yaml:"encode,omitempty"`
} `yaml:"functions,omitempty"`
Message string `yaml:"message"`
Signals *[]NetworkSignal `yaml:"signals,omitempty"`
}
type Network struct {
Kind NetworkKind `yaml:"kind"`
Metadata *ObjectMetadata `yaml:"metadata,omitempty"`
Spec NetworkSpec `yaml:"spec"`
}
type NetworkKind string
type NetworkSignal struct {
Annotations *Annotations `yaml:"annotations,omitempty"`
Signal string `yaml:"signal"`
}
type NetworkSpec struct {
Messages []Message `yaml:"messages"`
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion code/go/dse/kind/kind.go
Original file line number Diff line number Diff line change
@@ -1 +1 @@
package kind
package kind
File renamed without changes.

0 comments on commit bea66c6

Please sign in to comment.