Skip to content

Commit 03ac5a3

Browse files
authored
fix: support in-cluster config (#9)
1 parent d77daa0 commit 03ac5a3

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

helm/templates/service.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ spec:
5959
image: "{{ .Values.image.repo }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
6060
imagePullPolicy: {{ .Values.image.pullPolicy }}
6161
command:
62-
- /coder-xray scan
62+
- /coder-xray
63+
- scan
6364
env:
6465
- name: CODER_URL
6566
value: {{ .Values.coder.url }}

root.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/spf13/cobra"
99
"golang.org/x/xerrors"
1010
"k8s.io/client-go/kubernetes"
11+
restclient "k8s.io/client-go/rest"
1112
"k8s.io/client-go/tools/clientcmd"
1213

1314
"cdr.dev/slog"
@@ -59,7 +60,10 @@ func root() *cobra.Command {
5960
return xerrors.New("--artifactory-token is required")
6061
}
6162

62-
config, err := clientcmd.BuildConfigFromFlags("", kubeConfig)
63+
config, err := restclient.InClusterConfig()
64+
if xerrors.Is(err, restclient.ErrNotInCluster) {
65+
config, err = clientcmd.BuildConfigFromFlags("", kubeConfig)
66+
}
6367
if err != nil {
6468
return xerrors.Errorf("build kubeconfig: %w", err)
6569
}

0 commit comments

Comments
 (0)