forked from wagoodman/dive
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathci.go
39 lines (30 loc) · 694 Bytes
/
ci.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
package cmd
import (
"bytes"
"fmt"
"io/ioutil"
"os"
"strconv"
"github.com/spf13/viper"
)
func configureCi() (bool, *viper.Viper, error) {
isCiFromEnv, _ := strconv.ParseBool(os.Getenv("CI"))
isCi = isCi || isCiFromEnv
if isCi {
ciConfig.SetConfigType("yaml")
if _, err := os.Stat(ciConfigFile); !os.IsNotExist(err) {
fmt.Printf(" Using CI config: %s\n", ciConfigFile)
fileBytes, err := ioutil.ReadFile(ciConfigFile)
if err != nil {
return isCi, nil, err
}
err = ciConfig.ReadConfig(bytes.NewBuffer(fileBytes))
if err != nil {
return isCi, nil, err
}
} else {
fmt.Println(" Using default CI config")
}
}
return isCi, ciConfig, nil
}