dive-zfs/cmd/ci.go
zachary-walters ae996cd718 Updated the deprecated ioutil dependency
The ioutil package has been deprecated as of Go v1.16: https://go.dev/doc/go1.16#ioutil

This commit replaces ioutil functions with their respective io/os functions.
2023-07-06 10:41:54 -04:00

39 lines
677 B
Go

package cmd
import (
"bytes"
"fmt"
"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 := os.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
}