-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scan.go
57 lines (50 loc) · 1.03 KB
/
scan.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package ezdeploy
import (
"os"
"path/filepath"
)
const (
SubdirHelm = "_helm"
)
type ScanResult struct {
Charts map[string]Chart
Namespaces []string
}
func Scan(root string) (result ScanResult, err error) {
// charts
if result.Charts, err = scanCharts(filepath.Join(root, SubdirHelm)); err != nil {
return
}
// namespaces
if result.Namespaces, err = readDirNames(root); err != nil {
return
}
return
}
func scanCharts(dir string) (charts map[string]Chart, err error) {
charts = make(map[string]Chart)
var names []string
if names, err = readDirNames(dir); err != nil {
if os.IsNotExist(err) {
err = nil
}
return
}
for _, name := range names {
chart := Chart{
Name: name,
Path: filepath.Join(dir, name),
}
if _, err = os.Stat(filepath.Join(chart.Path, "Chart.yaml")); err != nil {
return
}
if _, err = os.Stat(filepath.Join(chart.Path, "values.yaml")); err != nil {
return
}
if chart.Checksum, err = checksumDir(chart.Path); err != nil {
return
}
charts[chart.Name] = chart
}
return
}