Skip to content

Commit

Permalink
Generated Go code for YAML Kind schemas.
Browse files Browse the repository at this point in the history
Signed-off-by: Rule Timothy (VM/EMT3) <Timothy.Rule@de.bosch.com>
  • Loading branch information
timrulebosch committed Feb 20, 2024
1 parent b2c2102 commit 57dc9ed
Show file tree
Hide file tree
Showing 15 changed files with 1,043 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ dist:

_generate_clean:
-@rm -rf $(DOC_SCHEMA_YAML_DIR)
$(MAKE) -C code/go/dse clean

generate: _generate_clean $(DOC_YAML_SCHEMAS)
for d in $(DOC_YAML_SCHEMAS) ;\
Expand All @@ -158,6 +159,8 @@ generate: _generate_clean $(DOC_YAML_SCHEMAS)
done;
cp doc/templates/yaml/_index.md $(DOC_SCHEMA_YAML_DIR)/_index.md

$(MAKE) -C code/go/dse generate

test:

install:
Expand Down
602 changes: 602 additions & 0 deletions code/go/dse/LICENSE

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions code/go/dse/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2024 Robert Bosch GmbH
#
# SPDX-License-Identifier: Apache-2.0


KIND_YAML_DIR = ../../../schemas/yaml
KIND_YAML_FILES = $(shell ls $(KIND_YAML_DIR)/*.yaml)


.PHONY: generate
generate: kind

kind: $(KIND_YAML_FILES)

.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

.PHONY: clean
clean:
@rm -rf kind
6 changes: 6 additions & 0 deletions code/go/dse/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package: kind
generate:
models: true
import-mapping:
metadata.yaml: delete_this_line
channel.yaml: delete_this_line
3 changes: 3 additions & 0 deletions code/go/dse/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/boschglobal/dse.schemas/code/go/dse

go 1.21.6
71 changes: 71 additions & 0 deletions code/go/dse/kind/Manifest.yaml.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 ModelInstance 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 []ModelInstance `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"`
}
40 changes: 40 additions & 0 deletions code/go/dse/kind/Model.yaml.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package kind

import ()

const (
ModelKindModel ModelKind = "Model"
)

type ExecutableSpec struct {
Annotations *Annotations `yaml:"annotations,omitempty"`
Arch *string `yaml:"arch,omitempty"`
Libs *[]string `yaml:"libs,omitempty"`
Os *string `yaml:"os,omitempty"`
}
type GatewaySpec struct {
Annotations *Annotations `yaml:"annotations,omitempty"`
}
type LibrarySpec struct {
Annotations *Annotations `yaml:"annotations,omitempty"`
Arch *string `yaml:"arch,omitempty"`
Libs *[]string `yaml:"libs,omitempty"`
Os *string `yaml:"os,omitempty"`
Path string `yaml:"path"`
Variant *string `yaml:"variant,omitempty"`
}
type Model struct {
Kind ModelKind `yaml:"kind"`
Metadata *ObjectMetadata `yaml:"metadata,omitempty"`
Spec ModelSpec `yaml:"spec"`
}
type ModelKind string
type ModelSpec struct {
Channels *[]Channel `yaml:"channels,omitempty"`
Runtime *struct {
Dynlib *[]LibrarySpec `yaml:"dynlib,omitempty"`
Executable *[]ExecutableSpec `yaml:"executable,omitempty"`
Gateway *GatewaySpec `yaml:"gateway,omitempty"`
Mcl *[]LibrarySpec `yaml:"mcl,omitempty"`
} `yaml:"runtime,omitempty"`
}
34 changes: 34 additions & 0 deletions code/go/dse/kind/Network.yaml.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 *[]Signal `yaml:"signals,omitempty"`
}
type Network struct {
Kind NetworkKind `yaml:"kind"`
Metadata *ObjectMetadata `yaml:"metadata,omitempty"`
Spec NetworkSpec `yaml:"spec"`
}
type NetworkKind string
type NetworkSpec struct {
Messages []Message `yaml:"messages"`
}
type Signal struct {
Annotations *Annotations `yaml:"annotations,omitempty"`
Signal string `yaml:"signal"`
}
22 changes: 22 additions & 0 deletions code/go/dse/kind/ParameterSet.yaml.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package kind

import ()

const (
ParameterSetKindParameterSet ParameterSetKind = "ParameterSet"
)

type Parameter struct {
Annotations *Annotations `yaml:"annotations,omitempty"`
Parameter string `yaml:"parameter"`
Value *string `yaml:"value,omitempty"`
}
type ParameterSet struct {
Kind ParameterSetKind `yaml:"kind"`
Metadata *ObjectMetadata `yaml:"metadata,omitempty"`
Spec ParameterSetSpec `yaml:"spec"`
}
type ParameterSetKind string
type ParameterSetSpec struct {
Parameters []Parameter `yaml:"parameters"`
}
47 changes: 47 additions & 0 deletions code/go/dse/kind/Propagator.yaml.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package kind

import ()

const (
PropagatorKindPropagator PropagatorKind = "Propagator"
)
const (
Both PropagatorSpecOptionsDirection = "both"
Forward PropagatorSpecOptionsDirection = "forward"
Reverse PropagatorSpecOptionsDirection = "reverse"
)

type Propagator struct {
Kind PropagatorKind `yaml:"kind"`
Metadata *ObjectMetadata `yaml:"metadata,omitempty"`
Spec PropagatorSpec `yaml:"spec"`
}
type PropagatorKind string
type PropagatorSpec struct {
Options *struct {
Direction *PropagatorSpecOptionsDirection `yaml:"direction,omitempty"`
} `yaml:"options,omitempty"`
Signals *[]SignalEncoding `yaml:"signals,omitempty"`
}
type PropagatorSpecOptionsDirection string
type SignalEncoding struct {
Encoding *struct {
Linear *struct {
Factor *float32 `yaml:"factor,omitempty"`
Max *float32 `yaml:"max,omitempty"`
Min *float32 `yaml:"min,omitempty"`
Offset *float32 `yaml:"offset,omitempty"`
} `yaml:"linear,omitempty"`
Mapping *[]struct {
Name *string `yaml:"name,omitempty"`
Range *struct {
Max *float32 `yaml:"max,omitempty"`
Min *float32 `yaml:"min,omitempty"`
} `yaml:"range,omitempty"`
Source *float32 `yaml:"source,omitempty"`
Target *float32 `yaml:"target,omitempty"`
} `yaml:"mapping,omitempty"`
} `yaml:"encoding,omitempty"`
Signal string `yaml:"signal"`
Target *string `yaml:"target,omitempty"`
}
21 changes: 21 additions & 0 deletions code/go/dse/kind/Runnable.yaml.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package kind

import ()

const (
RunnableKindRunnable RunnableKind = "Runnable"
)

type Runnable struct {
Kind RunnableKind `yaml:"kind"`
Metadata *ObjectMetadata `yaml:"metadata,omitempty"`
Spec RunnableSpec `yaml:"spec"`
}
type RunnableKind string
type RunnableSpec struct {
Tasks []Task `yaml:"tasks"`
}
type Task struct {
Function string `yaml:"function"`
Schedule int `yaml:"schedule"`
}
21 changes: 21 additions & 0 deletions code/go/dse/kind/SignalGroup.yaml.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package kind

import ()

const (
SignalGroupKindSignalGroup SignalGroupKind = "SignalGroup"
)

type Signal struct {
Annotations *Annotations `yaml:"annotations,omitempty"`
Signal string `yaml:"signal"`
}
type SignalGroup struct {
Kind SignalGroupKind `yaml:"kind"`
Metadata *ObjectMetadata `yaml:"metadata,omitempty"`
Spec SignalGroupSpec `yaml:"spec"`
}
type SignalGroupKind string
type SignalGroupSpec struct {
Signals []Signal `yaml:"signals"`
}
Loading

0 comments on commit 57dc9ed

Please sign in to comment.