Skip to content

Commit

Permalink
Merge branch 'main' into history-service
Browse files Browse the repository at this point in the history
  • Loading branch information
dmjb authored Jun 19, 2024
2 parents 1a85fc8 + 7541461 commit 6e32039
Show file tree
Hide file tree
Showing 16 changed files with 244 additions and 101 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/image-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0
- name: Test build on x86
id: docker_build
uses: docker/build-push-action@c382f710d39a5bb4e430307530a720f50c2d3318 # v6.0.0
uses: docker/build-push-action@94f8f8c2eec4bc3f1d78c1755580779804cb87b2 # v6.0.1
with:
context: .
file: ./docker/minder/Dockerfile
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-docs-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
echo "commit_date=$COMMIT_DATE" >> $GITHUB_OUTPUT
echo "commit_author=$COMMIT_AUTHOR" >> $GITHUB_OUTPUT
- name: Commit and push changes
uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e # v6.0.5
uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6.1.0
with:
commit-message: Update documentation
committer: GitHub <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-docs-dbschema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
echo "commit_date=$COMMIT_DATE" >> $GITHUB_OUTPUT
echo "commit_author=$COMMIT_AUTHOR" >> $GITHUB_OUTPUT
- name: Commit and push changes
uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e # v6.0.5
uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6.1.0
with:
commit-message: Update DB schema
committer: GitHub <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-docs-helm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
echo "commit_date=$COMMIT_DATE" >> $GITHUB_OUTPUT
echo "commit_author=$COMMIT_AUTHOR" >> $GITHUB_OUTPUT
- name: Commit and push changes
uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e # v6.0.5
uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6.1.0
with:
commit-message: Update helm documentation
committer: GitHub <[email protected]>
Expand Down
48 changes: 32 additions & 16 deletions cmd/cli/app/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/stacklok/minder/internal/config"
clientconfig "github.com/stacklok/minder/internal/config/client"
"github.com/stacklok/minder/internal/constants"
"github.com/stacklok/minder/internal/util"
"github.com/stacklok/minder/internal/util/cli"
)

Expand Down Expand Up @@ -73,7 +74,7 @@ Configuration options include:
- identity.cli.issuer_url
- identity.cli.client_id
By default, we look for the file as $PWD/config.yaml. You can specify a custom path via the --config flag, or by setting the MINDER_CONFIG environment variable.`,
By default, we look for the file as $PWD/config.yaml and $XDG_CONFIG_PATH/minder/config.yaml. You can specify a custom path via the --config flag, or by setting the MINDER_CONFIG environment variable.`,
}
)

Expand Down Expand Up @@ -116,33 +117,48 @@ func initConfig() {
viper.SetEnvPrefix("minder")
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_", "-", "_"))

cfgFile := viper.GetString("config")
cfgFileData, err := config.GetConfigFileData(cfgFile, filepath.Join(".", "config.yaml"))
if err != nil {
RootCmd.PrintErrln(err)
os.Exit(1)
//nolint:errcheck // ignore error as we are just checking if the file exists
cfgDirPath, _ := util.GetConfigDirPath()

var xdgConfigPath string
if cfgDirPath != "" {
xdgConfigPath = filepath.Join(cfgDirPath, "config.yaml")
}

keysWithNullValue := config.GetKeysWithNullValueFromYAML(cfgFileData, "")
if len(keysWithNullValue) > 0 {
RootCmd.PrintErrln("Error: The following configuration keys are missing values:")
for _, key := range keysWithNullValue {
RootCmd.PrintErrln("Null Value at: " + key)
cfgFile := viper.GetString("config")
cfgFilePath := config.GetRelevantCfgPath(append([]string{cfgFile},
filepath.Join(".", "config.yaml"),
xdgConfigPath,
))
if cfgFilePath != "" {
cfgFileData, err := config.GetConfigFileData(cfgFilePath)
if err != nil {
RootCmd.PrintErrln(err)
os.Exit(1)
}
os.Exit(1)
}

if cfgFile != "" {
viper.SetConfigFile(cfgFile)
keysWithNullValue := config.GetKeysWithNullValueFromYAML(cfgFileData, "")
if len(keysWithNullValue) > 0 {
RootCmd.PrintErrln("Error: The following configuration keys are missing values:")
for _, key := range keysWithNullValue {
RootCmd.PrintErrln("Null Value at: " + key)
}
os.Exit(1)
}

viper.SetConfigFile(cfgFilePath)
} else {
// use defaults
viper.SetConfigName("config")
viper.AddConfigPath(".")
if cfgDirPath != "" {
viper.AddConfigPath(cfgDirPath)
}
}
viper.SetConfigType("yaml")
viper.AutomaticEnv()

if err = viper.ReadInConfig(); err != nil {
if err := viper.ReadInConfig(); err != nil {
if _, ok := err.(viper.ConfigFileNotFoundError); ok {
// Config file not found; use default values
RootCmd.PrintErrln("No config file present, using default values.")
Expand Down
31 changes: 17 additions & 14 deletions cmd/reminder/app/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,25 @@ func init() {

func initConfig() {
cfgFile := viper.GetString("config")
cfgFileData, err := config.GetConfigFileData(cfgFile, filepath.Join(".", configFileName))
if err != nil {
log.Fatal().Err(err).Msg("Error reading config file")
}
cfgFilePath := config.GetRelevantCfgPath(append([]string{cfgFile},
filepath.Join(".", configFileName),
))
if cfgFilePath != "" {
cfgFileData, err := config.GetConfigFileData(cfgFilePath)
if err != nil {
log.Fatal().Err(err).Msg("Error reading config file")
}

keysWithNullValue := config.GetKeysWithNullValueFromYAML(cfgFileData, "")
if len(keysWithNullValue) > 0 {
RootCmd.PrintErrln("Error: The following configuration keys are missing values:")
for _, key := range keysWithNullValue {
RootCmd.PrintErrln("Null Value at: " + key)
keysWithNullValue := config.GetKeysWithNullValueFromYAML(cfgFileData, "")
if len(keysWithNullValue) > 0 {
RootCmd.PrintErrln("Error: The following configuration keys are missing values:")
for _, key := range keysWithNullValue {
RootCmd.PrintErrln("Null Value at: " + key)
}
os.Exit(1)
}
os.Exit(1)
}

if cfgFile != "" {
viper.SetConfigFile(cfgFile)
viper.SetConfigFile(cfgFilePath)
} else {
// use defaults
viper.SetConfigName(strings.TrimSuffix(configFileName, filepath.Ext(configFileName)))
Expand All @@ -91,7 +94,7 @@ func initConfig() {
viper.SetConfigType("yaml")
viper.AutomaticEnv()

if err = viper.ReadInConfig(); err != nil {
if err := viper.ReadInConfig(); err != nil {
fmt.Println("Error reading config file:", err)
}
}
33 changes: 18 additions & 15 deletions cmd/server/app/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,26 @@ func initConfig() {
serverconfig.SetViperDefaults(viper.GetViper())

cfgFile := viper.GetString("config")
cfgFileData, err := config.GetConfigFileData(cfgFile, filepath.Join(".", "server-config.yaml"))
if err != nil {
RootCmd.PrintErrln(err)
os.Exit(1)
}
cfgFilePath := config.GetRelevantCfgPath(append([]string{cfgFile},
filepath.Join(".", "server-config.yaml"),
))
if cfgFilePath != "" {
cfgFileData, err := config.GetConfigFileData(cfgFilePath)
if err != nil {
RootCmd.PrintErrln(err)
os.Exit(1)
}

keysWithNullValue := config.GetKeysWithNullValueFromYAML(cfgFileData, "")
if len(keysWithNullValue) > 0 {
RootCmd.PrintErrln("Error: The following configuration keys are missing values:")
for _, key := range keysWithNullValue {
RootCmd.PrintErrln("Null Value at: " + key)
keysWithNullValue := config.GetKeysWithNullValueFromYAML(cfgFileData, "")
if len(keysWithNullValue) > 0 {
RootCmd.PrintErrln("Error: The following configuration keys are missing values:")
for _, key := range keysWithNullValue {
RootCmd.PrintErrln("Null Value at: " + key)
}
os.Exit(1)
}
os.Exit(1)
}

if cfgFile != "" {
viper.SetConfigFile(cfgFile)
viper.SetConfigFile(cfgFilePath)
} else {
// use defaults
viper.SetConfigName("server-config")
Expand All @@ -92,7 +95,7 @@ func initConfig() {
viper.SetConfigType("yaml")
viper.AutomaticEnv()

if err = viper.ReadInConfig(); err != nil {
if err := viper.ReadInConfig(); err != nil {
fmt.Println("Error reading config file:", err)
}
}
2 changes: 1 addition & 1 deletion docker/minder/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM golang:1.22.3@sha256:f43c6f049f04cbbaeb28f0aad3eea15274a7d0a7899a617d0037aec48d7ab010 AS builder
FROM golang:1.22.4@sha256:c2010b9c2342431a24a2e64e33d9eb2e484af49e72c820e200d332d214d5e61f AS builder
ENV APP_ROOT=/opt/app-root
ENV GOPATH=$APP_ROOT

Expand Down
2 changes: 1 addition & 1 deletion docker/reminder/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM golang:1.22.3@sha256:f43c6f049f04cbbaeb28f0aad3eea15274a7d0a7899a617d0037aec48d7ab010 AS builder
FROM golang:1.22.4@sha256:c2010b9c2342431a24a2e64e33d9eb2e484af49e72c820e200d332d214d5e61f AS builder
ENV APP_ROOT=/opt/app-root
ENV GOPATH=$APP_ROOT

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/ref/cli/minder_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Configuration options include:
- identity.cli.issuer_url
- identity.cli.client_id

By default, we look for the file as $PWD/config.yaml. You can specify a custom path via the --config flag, or by setting the MINDER_CONFIG environment variable.
By default, we look for the file as $PWD/config.yaml and $XDG_CONFIG_PATH/minder/config.yaml. You can specify a custom path via the --config flag, or by setting the MINDER_CONFIG environment variable.

### Options

Expand Down
19 changes: 11 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/stacklok/minder

go 1.22.3
go 1.22.4

require (
github.com/ThreeDotsLabs/watermill v1.3.5
Expand Down Expand Up @@ -39,7 +39,7 @@ require (
github.com/open-feature/go-sdk-contrib/providers/go-feature-flag v0.1.37
github.com/open-policy-agent/opa v0.65.0
github.com/openfga/go-sdk v0.5.0
github.com/openfga/openfga v1.5.4
github.com/openfga/openfga v1.5.5
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
github.com/prometheus/client_golang v1.19.1
github.com/puzpuzpuz/xsync/v3 v3.1.0
Expand All @@ -53,7 +53,7 @@ require (
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.19.0
github.com/sqlc-dev/pqtype v0.3.0
github.com/stacklok/frizbee v0.0.19
github.com/stacklok/frizbee v0.0.20
github.com/stacklok/trusty-sdk-go v0.1.0
github.com/stretchr/testify v1.9.0
github.com/styrainc/regal v0.23.1
Expand Down Expand Up @@ -99,12 +99,14 @@ require (
github.com/charmbracelet/x/input v0.1.0 // indirect
github.com/charmbracelet/x/term v0.1.1 // indirect
github.com/charmbracelet/x/windows v0.1.0 // indirect
github.com/containerd/containerd v1.7.17 // indirect
github.com/containerd/containerd v1.7.18 // indirect
github.com/containerd/errdefs v0.1.0 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/containerd/typeurl/v2 v2.1.1 // indirect
github.com/cpuguy83/dockercfg v0.3.1 // indirect
github.com/deckarep/golang-set/v2 v2.6.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
github.com/distribution/reference v0.5.0 // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/envoyproxy/protoc-gen-validate v1.0.4 // indirect
Expand Down Expand Up @@ -135,6 +137,7 @@ require (
github.com/mattn/go-localereader v0.0.1 // indirect
github.com/mfridman/interpolate v0.0.2 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/moby/buildkit v0.14.0 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/patternmatcher v0.6.0 // indirect
github.com/moby/sys/sequential v0.5.0 // indirect
Expand All @@ -148,7 +151,7 @@ require (
github.com/natefinch/wrap v0.2.0 // indirect
github.com/nikunjy/rules v1.5.0 // indirect
github.com/oklog/ulid/v2 v2.1.0 // indirect
github.com/openfga/api/proto v0.0.0-20240529184453-5b0b4941f3e0 // indirect
github.com/openfga/api/proto v0.0.0-20240612172407-db6f98774490 // indirect
github.com/openfga/language/pkg/go v0.0.0-20240409225820-a53ea2892d6d // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/pressly/goose/v3 v3.20.0 // indirect
Expand Down Expand Up @@ -204,9 +207,9 @@ require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/digitorus/pkcs7 v0.0.0-20230818184609-3a137a874352 // indirect
github.com/digitorus/timestamp v0.0.0-20231217203849-220c5c2851b7 // indirect
github.com/docker/cli v26.0.1+incompatible // indirect
github.com/docker/cli v26.1.4+incompatible // indirect
github.com/docker/distribution v2.8.3+incompatible // indirect
github.com/docker/docker v26.0.2+incompatible // indirect
github.com/docker/docker v26.1.4+incompatible // indirect
github.com/docker/docker-credential-helpers v0.8.1 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
Expand Down
Loading

0 comments on commit 6e32039

Please sign in to comment.