Skip to content

Commit

Permalink
kubeconfig fallback
Browse files Browse the repository at this point in the history
Signed-off-by: asamonik <[email protected]>
  • Loading branch information
asamonik committed Aug 13, 2024
1 parent 0db3b71 commit 5183b86
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions keptn-gateway/internal/gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
_ "github.com/joho/godotenv/autoload"

Check failure on line 13 in keptn-gateway/internal/gateway/gateway.go

View workflow job for this annotation

GitHub Actions / Check Spelling

`godotenv` is not a recognized word. (unrecognized-spelling)

Check failure on line 13 in keptn-gateway/internal/gateway/gateway.go

View workflow job for this annotation

GitHub Actions / Check Spelling

`joho` is not a recognized word. (unrecognized-spelling)
"go.uber.org/zap"

Check failure on line 14 in keptn-gateway/internal/gateway/gateway.go

View workflow job for this annotation

GitHub Actions / Check Spelling

`uber` is not a recognized word. (unrecognized-spelling)
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"

Check failure on line 17 in keptn-gateway/internal/gateway/gateway.go

View workflow job for this annotation

GitHub Actions / Check Spelling

`clientcmd` is not a recognized word. (unrecognized-spelling)
"k8s.io/client-go/util/homedir"
)
Expand All @@ -31,19 +32,15 @@ func NewGateway() *Gateway {
}

// kubernetes clientset in cluster
/*
config, err := rest.InClusterConfig()
config, err := rest.InClusterConfig()
if err != nil {
// if error fallback to .kube/config
home := homedir.HomeDir()
kubeconfig := filepath.Join(home, ".kube", "config")
config, err = clientcmd.BuildConfigFromFlags("", kubeconfig)

Check failure on line 40 in keptn-gateway/internal/gateway/gateway.go

View workflow job for this annotation

GitHub Actions / Check Spelling

`clientcmd` is not a recognized word. (unrecognized-spelling)
if err != nil {
panic(err.Error())
}
*/

// alternative not in cluster config
home := homedir.HomeDir()
kubeconfig := filepath.Join(home, ".kube", "config")
config, err := clientcmd.BuildConfigFromFlags("", kubeconfig)
if err != nil {
return nil
}

client, err := kubernetes.NewForConfig(config)
Expand Down

0 comments on commit 5183b86

Please sign in to comment.