Skip to content

Commit

Permalink
removing crypto key for now
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacobbrewer1 committed Nov 12, 2024
1 parent 63f831d commit 985e652
Show file tree
Hide file tree
Showing 168 changed files with 30,476 additions and 12 deletions.
23 changes: 23 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package main

import (
"flag"
"fmt"

"github.com/spf13/viper"
)

var (
configLocation = flag.String("config", "config.json", "The location of the config file")
)

func getConfig() (*viper.Viper, error) {
v := viper.New()
v.SetConfigFile(*configLocation)

if err := v.ReadInConfig(); err != nil {
return nil, fmt.Errorf("error reading config file: %w", err)
}

return v, nil
}
9 changes: 9 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/google/wire v0.6.0
github.com/hashicorp/vault/api v1.15.0
github.com/jacobbrewer1/workerpool v0.0.2
github.com/spf13/viper v1.15.0
k8s.io/api v0.31.2
k8s.io/apimachinery v0.31.2
k8s.io/client-go v0.31.2
Expand All @@ -19,6 +20,7 @@ require (
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/go-jose/go-jose/v4 v4.0.1 // indirect
github.com/go-logr/logr v1.4.2 // indirect
Expand All @@ -43,21 +45,27 @@ require (
github.com/imdario/mergo v0.3.6 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.55.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/ryanuber/go-glob v1.0.0 // indirect
github.com/spf13/afero v1.9.3 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/stretchr/testify v1.9.0 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
github.com/x448/float16 v0.8.4 // indirect
golang.org/x/crypto v0.24.0 // indirect
golang.org/x/net v0.26.0 // indirect
Expand All @@ -68,6 +76,7 @@ require (
golang.org/x/time v0.3.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
Expand Down
418 changes: 413 additions & 5 deletions go.sum

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package main

import (
"context"
"flag"
"log/slog"
"os"

"github.com/jacobbrewer1/vault-unseal/encryption"
"github.com/spf13/viper"
"k8s.io/client-go/kubernetes"
)

Expand All @@ -16,25 +17,24 @@ type App interface {
type app struct {
ctx context.Context
client *kubernetes.Clientset
config *viper.Viper
deployedNamespace string
namespace string
targetService string
cryptoKey string
unsealKeys []string
}

func newApp(
ctx context.Context,
client *kubernetes.Clientset,
config *viper.Viper,
) App {
return &app{
ctx: ctx,
client: client,
config: config,
deployedNamespace: getDeployedNamespace(),
namespace: getVaultNamespace(),
targetService: getTargetService(),
cryptoKey: encryption.GetCryptoKey(),
unsealKeys: make([]string, 0),
}
}

Expand All @@ -43,6 +43,7 @@ func (a *app) Start() {
}

func init() {
flag.Parse()
initializeLogger()
}

Expand Down
3 changes: 2 additions & 1 deletion vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ func generateVaultAddress(ports []core.ContainerPort, ip string) string {
}

func (a *app) unsealVault(vc *api.Client) error {
for _, key := range a.unsealKeys {
keys := a.config.GetStringSlice("unseal_keys")
for _, key := range keys {
resp, err := vc.Sys().Unseal(key)
if err != nil {
return fmt.Errorf("error unsealing vault: %w", err)
Expand Down
12 changes: 12 additions & 0 deletions vendor/github.com/fsnotify/fsnotify/.editorconfig

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/github.com/fsnotify/fsnotify/.gitattributes

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions vendor/github.com/fsnotify/fsnotify/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions vendor/github.com/fsnotify/fsnotify/.mailmap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 985e652

Please sign in to comment.