deterministic ordering of output.
This commit is contained in:
parent
eba04ec132
commit
d85baf3beb
@ -173,6 +173,7 @@ func LoadConfig(file string) (*Config, error) {
|
|||||||
dec := yaml.NewDecoder(bytes.NewReader(yamlFile),
|
dec := yaml.NewDecoder(bytes.NewReader(yamlFile),
|
||||||
yaml.UseJSONUnmarshaler(),
|
yaml.UseJSONUnmarshaler(),
|
||||||
yaml.DisallowUnknownField(),
|
yaml.DisallowUnknownField(),
|
||||||
|
yaml.UseOrderedMap(),
|
||||||
)
|
)
|
||||||
var config Config
|
var config Config
|
||||||
err = dec.Decode(&config)
|
err = dec.Decode(&config)
|
||||||
|
@ -72,12 +72,10 @@ func Generate(writer io.Writer, generator Generator, config *Config) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Loop over all applications and gather the ingress and egress for each application
|
// Loop over all applications and gather the ingress and egress for each application
|
||||||
var applications = make(map[string]*Application)
|
|
||||||
var ingresses = make(map[string]*Ingress)
|
var ingresses = make(map[string]*Ingress)
|
||||||
var egresses = make(map[string]*Egress)
|
var egresses = make(map[string]*Egress)
|
||||||
for _, ns := range config.Namespaces {
|
for _, ns := range config.Namespaces {
|
||||||
for _, app := range ns.Applications {
|
for _, app := range ns.Applications {
|
||||||
applications[app.Name] = app
|
|
||||||
if ingresses[app.Name] == nil {
|
if ingresses[app.Name] == nil {
|
||||||
ingresses[app.Name] = &Ingress{}
|
ingresses[app.Name] = &Ingress{}
|
||||||
}
|
}
|
||||||
@ -149,15 +147,18 @@ func Generate(writer io.Writer, generator Generator, config *Config) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// loop over all apps and configure them
|
// loop over all apps and configure them
|
||||||
for app, ingress := range ingresses {
|
for _, ns := range config.Namespaces {
|
||||||
egress := egresses[app]
|
for _, app := range ns.Applications {
|
||||||
|
ingress := ingresses[app.Name]
|
||||||
|
egress := egresses[app.Name]
|
||||||
if !ingress.Empty() || !egress.Empty() {
|
if !ingress.Empty() || !egress.Empty() {
|
||||||
err := generator.GenerateCommunicationRule(writer, applications[app], ingress, egress)
|
err := generator.GenerateCommunicationRule(writer, app, ingress, egress)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user