-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #560 from jetstack/venconn
Feedback from #552
- Loading branch information
Showing
5 changed files
with
158 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,14 +70,14 @@ jobs: | |
packages: write | ||
id-token: write | ||
steps: | ||
- uses: webfactory/[email protected] | ||
with: | ||
ssh-private-key: ${{ secrets.DEPLOY_KEY_READ_VENAFI_CONNECTION_LIB }} | ||
- name: Install Tools | ||
# Installing 'bash' because it's required by the 'cosign-installer' action | ||
# and 'coreutils' because the 'slsa-provenance-action' requires a version | ||
# of 'base64' that supports the -w flag. | ||
run: apk add --update make git jq rsync curl bash coreutils go | ||
- uses: webfactory/[email protected] | ||
with: | ||
ssh-private-key: ${{ secrets.DEPLOY_KEY_READ_VENAFI_CONNECTION_LIB }} | ||
- name: Adding github workspace as safe directory | ||
# See issue https://github.com/actions/checkout/issues/760 | ||
run: git config --global --add safe.directory $GITHUB_WORKSPACE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package kubeconfig | ||
|
||
import ( | ||
"github.com/pkg/errors" | ||
"k8s.io/client-go/rest" | ||
"k8s.io/client-go/tools/clientcmd" | ||
) | ||
|
||
// LoadRESTConfig loads the kube config from the provided path. If the path is | ||
// empty, the kube config will be loaded from KUBECONFIG, and if KUBECONFIG | ||
// isn't set, the in-cluster config will be used. | ||
func LoadRESTConfig(path string) (*rest.Config, error) { | ||
switch path { | ||
// If the kubeconfig path is not provided, use the default loading rules | ||
// so we read the regular KUBECONFIG variable or create a non-interactive | ||
// client for agents running in cluster | ||
case "": | ||
loadingrules := clientcmd.NewDefaultClientConfigLoadingRules() | ||
cfg, err := clientcmd.NewNonInteractiveDeferredLoadingClientConfig( | ||
loadingrules, &clientcmd.ConfigOverrides{}).ClientConfig() | ||
if err != nil { | ||
return nil, errors.WithStack(err) | ||
} | ||
return cfg, nil | ||
// Otherwise use the explicitly named kubeconfig file. | ||
default: | ||
cfg, err := clientcmd.NewNonInteractiveDeferredLoadingClientConfig( | ||
&clientcmd.ClientConfigLoadingRules{ExplicitPath: path}, | ||
&clientcmd.ConfigOverrides{}).ClientConfig() | ||
if err != nil { | ||
return nil, errors.WithStack(err) | ||
} | ||
return cfg, nil | ||
} | ||
} |