Skip to content

Commit

Permalink
Remove patchPriority as now sorting on priority
Browse files Browse the repository at this point in the history
  • Loading branch information
adamarnold-msm committed Dec 8, 2021
1 parent e691a2b commit a9b0ff8
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 21 deletions.
1 change: 0 additions & 1 deletion examples/example-spec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
stateFiles:
- path: examples/example.yaml
priority: -10
- path: examples/minimal-example.yaml
- path: examples/minimal-example.toml
5 changes: 0 additions & 5 deletions internal/app/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ func (c *cli) readState(s *state) error {
for _, val := range sp.StateFiles {
fo := fileOption{}
fo.name = val.Path
fo.priority = val.Priority
if err := isValidFile(fo.name, validManifestFiles); err != nil {
return fmt.Errorf("invalid -spec file: %w", err)
}
Expand All @@ -281,10 +280,6 @@ func (c *cli) readState(s *state) error {
return err
}

if f.priority != 0 {
fileState.patchPriority(f.priority)
}

log.Infof("Parsed [[ %s ]] successfully and found [ %d ] apps", f.name, len(fileState.Apps))
// Merge Apps that already existed in the state
for appName, app := range fileState.Apps {
Expand Down
16 changes: 3 additions & 13 deletions internal/app/spec_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ import (
"gopkg.in/yaml.v2"
)

type SpecConfig struct {
Path string `yaml:"path"`
Priority int `yaml:"priority"`
type StatePath struct {
Path string `yaml:"path"`
}

type StateFiles struct {
StateFiles []SpecConfig `yaml:"stateFiles"`
StateFiles []StatePath `yaml:"stateFiles"`
}

// fromYAML reads a yaml file and decodes it to a state type.
Expand All @@ -32,12 +31,3 @@ func (pc *StateFiles) specFromYAML(file string) error {

return nil
}

func (s *state) patchPriority(priority int) error {
for app, _ := range s.Apps {
if s.Apps[app].Priority > priority {
s.Apps[app].Priority = priority
}
}
return nil
}
3 changes: 1 addition & 2 deletions internal/app/spec_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func Test_specFromYAML(t *testing.T) {

func Test_specFileSort(t *testing.T) {
type args struct {
files fileOptionArray
files fileOptionArray
}
tests := []struct {
name string
Expand Down Expand Up @@ -88,4 +88,3 @@ func Test_specFileSort(t *testing.T) {
})
}
}

0 comments on commit a9b0ff8

Please sign in to comment.