This repository has been archived by the owner on Jun 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(logs): fixed labels that are used for log collecting and added at…
…tribute (#68) * fix(charts): added checking if newer version of the chart are available * fix(logs): fixed labels that are used for log collecting * fix(log): added attribute to log
- Loading branch information
Showing
10 changed files
with
122 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
internal/bundle/application/applications/ambassador/logs/logs.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
internal/bundle/application/applications/grafana/logs/logs.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
internal/bundle/application/applications/kubestatemetrics/logs/logs.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package fetch | ||
|
||
import ( | ||
"io/ioutil" | ||
"os" | ||
"path/filepath" | ||
"strconv" | ||
"strings" | ||
|
||
"github.com/caos/boom/internal/helper" | ||
"github.com/caos/orbiter/mntr" | ||
"gopkg.in/yaml.v3" | ||
) | ||
|
||
type index struct { | ||
APIVersion string `yaml:"apiVersion"` | ||
Entries map[string][]entry `yaml:"entries"` | ||
} | ||
|
||
type entry struct { | ||
Version string `yaml:"version"` | ||
AppVersion string `yaml:"appVersion"` | ||
} | ||
|
||
func CompareVersions(monitor mntr.Monitor, basePath string, charts []*ChartInfo) error { | ||
|
||
indexFolderPathAbs, err := helper.GetAbsPath(basePath, "helm", "repository", "cache") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
indexFiles := make(map[string]*index, 0) | ||
err = filepath.Walk(indexFolderPathAbs, func(path string, info os.FileInfo, err error) error { | ||
if info.IsDir() { | ||
return nil | ||
} | ||
|
||
data, err := ioutil.ReadFile(path) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
var indexFile index | ||
if err := yaml.Unmarshal(data, &indexFile); err != nil { | ||
return err | ||
} | ||
|
||
indexFiles[strings.TrimSuffix(info.Name(), "-index.yaml")] = &indexFile | ||
// for k, v := range indexFile.Entries { | ||
// indexFiles[strings.TrimSuffix(info.Name(), "-index.yaml")].Entries[k] = v | ||
// } | ||
return nil | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
for _, chart := range charts { | ||
indexFile := indexFiles[chart.IndexName] | ||
for _, entry := range indexFile.Entries[chart.Name] { | ||
entryParts := strings.Split(entry.Version, ".") | ||
entryPartsInt := make([]int, 3) | ||
for k, v := range entryParts { | ||
entryPartsInt[k], _ = strconv.Atoi(v) | ||
} | ||
|
||
chartParts := strings.Split(chart.Version, ".") | ||
chartPartsInt := make([]int, 3) | ||
for k, v := range chartParts { | ||
chartPartsInt[k], _ = strconv.Atoi(v) | ||
} | ||
if entryPartsInt[0] > chartPartsInt[0] || | ||
(entryPartsInt[0] == chartPartsInt[0] && entryPartsInt[1] > chartPartsInt[1]) || | ||
(entryPartsInt[0] == chartPartsInt[0] && entryPartsInt[1] == chartPartsInt[1] && entryPartsInt[2] > chartPartsInt[2]) { | ||
|
||
logFields := map[string]interface{}{ | ||
"oldVersion": chart.Version, | ||
"newVersion": entry.Version, | ||
"index": chart.IndexName, | ||
"chart": chart.Name, | ||
"newAppVersion": entry.AppVersion, | ||
} | ||
monitor.WithFields(logFields).Info("Tshere is a newer version") | ||
} | ||
} | ||
} | ||
|
||
return nil | ||
} |