aboutsummaryrefslogtreecommitdiff
path: root/utils/ipam/yaml_model
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2024-10-29 21:13:43 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2024-10-29 21:13:43 +0100
commit0f51c7d542227f1f4c9895db36007b9d95963d99 (patch)
treea7d57e15a783b5dd3180e8923f88cfb0a8bc8bab /utils/ipam/yaml_model
parent19822dde9f01d54776233fe153b6ea5d5b21c454 (diff)
downloadinfra-0f51c7d542227f1f4c9895db36007b9d95963d99.tar.gz
infra-0f51c7d542227f1f4c9895db36007b9d95963d99.tar.bz2
infra-0f51c7d542227f1f4c9895db36007b9d95963d99.tar.xz
infra-0f51c7d542227f1f4c9895db36007b9d95963d99.zip
utils: networks
Diffstat (limited to 'utils/ipam/yaml_model')
-rw-r--r--utils/ipam/yaml_model/yaml_model.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/utils/ipam/yaml_model/yaml_model.go b/utils/ipam/yaml_model/yaml_model.go
new file mode 100644
index 0000000..6e5b0f8
--- /dev/null
+++ b/utils/ipam/yaml_model/yaml_model.go
@@ -0,0 +1,36 @@
+package yaml_model
+
+import "gopkg.in/yaml.v3"
+
+type Ipam struct {
+ Ipam6 Ipam6 `yaml:"ipam6,omitempty"`
+ Routers []Router `yaml:"routers,omitempty"`
+}
+
+type Ipam6 struct {
+ Networks map[string]Network6Yaml `yaml:"networks"`
+}
+
+type Network6Yaml struct {
+ Range string `yaml:"range"`
+ Hosts map[string]string `yaml:"hosts"`
+}
+
+type Router struct {
+ As string `yaml:"as,omitempty"`
+ Peer []Peer `yaml:"peer,omitempty"`
+}
+
+type Peer struct {
+ Name string `yaml:"name"`
+}
+
+func Parse(bs []byte) (Ipam, error) {
+ var ipam Ipam
+ err := yaml.Unmarshal(bs, &ipam)
+ if err != nil {
+ return Ipam{}, err
+ }
+
+ return ipam, nil
+}