Add to_directory method to relevant object classes
[oam.git] / code / network-topology-parser / yaml.go
1 /************************************************************************
2 * Copyright 2022 highstreet technologies GmbH
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 ************************************************************************/
16
17 package main
18
19 // Config is the entire docker-compose YAML object
20 type Config struct {
21     Version  string
22     CommonEnvs map[string]string `yaml:"x-common_env,anchor=common_env"`
23     DuEnv map[string]string `yaml:"x-du_env,anchor=du_env"`
24     RuEnv map[string]string `yaml:"x-ru_env,anchor=ru_env"`
25     TopoEnv map[string]string `yaml:"x-topo_env,anchor=topo_env"`
26     CommonNfs CommonNf `yaml:"x-nf,anchor=common_nf"`
27     Networks map[string]Network
28     Volumes  map[string]Volume `yaml:",omitempty"`
29     Services map[string]Service
30 }
31
32 // CommonNf is the common network function alias
33 type CommonNf struct {
34     StopGracePeriod     string `yaml:"stop_grace_period"`
35     CapAdd              []string `yaml:"cap_add"`
36 }
37
38 // Network is the network YAML object
39 type Network struct {
40     Driver          string `yaml:",omitempty"`
41     DriverOpts      map[string]string `yaml:"driver_opts,omitempty"`
42     External        map[string]string `yaml:",omitempty"`
43 }
44
45 // Volume is the volume YAML object
46 type Volume struct {
47     Driver, External string
48     DriverOpts       map[string]string `yaml:"driver_opts"`
49 }
50
51 // Service is the service YAML object
52 type Service struct {
53     *Service `yaml:",inline,alias=common_nf"`
54     ContainerName                     string `yaml:"container_name"`
55     Image                             string
56     Networks, Ports, Volumes, Command, Links []string `yaml:",omitempty"`
57     VolumesFrom                       []string `yaml:"volumes_from,omitempty"`
58     DependsOn                         []string `yaml:"depends_on,omitempty"`
59     CapAdd                            []string `yaml:"cap_add,omitempty"`
60     Build                             struct{ Context, Dockerfile string } `yaml:",omitempty"`
61     Environment                       Env `yaml:"environment"`
62     Hostname                          string
63 }
64
65 // Env is the environment YAML object
66 type Env struct {
67     *CommonEnv `yaml:",omitempty,inline,alias=common_env"`
68     *DuEnv `yaml:",omitempty,inline,alias=du_env"`
69     *RuEnv `yaml:",omitempty,inline,alias=ru_env"`
70     *TopoEnv `yaml:",omitempty,inline,alias=topo_env"`
71 }
72
73 // CommonEnv is the common_env anchor
74 type CommonEnv struct {
75     *CommonEnv `yaml:",omitempty,inline,alias=common_env"`
76 }
77
78 // DuEnv is the du_env anchor
79 type DuEnv struct {
80     *DuEnv `yaml:",omitempty,inline,alias=du_env"`
81 }
82
83 // RuEnv is the ru_env anchor
84 type RuEnv struct {
85     *RuEnv `yaml:",omitempty,inline,alias=ru_env"`
86 }
87
88 // TopoEnv is the topo_env anchor
89 type TopoEnv struct {
90     *TopoEnv `yaml:",omitempty,inline,alias=topo_env"`
91 }