diff --git a/Gopkg.lock b/Gopkg.lock index 2b6609df..dc4f4430 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -927,7 +927,7 @@ [[projects]] branch = "master" - digest = "1:07df09a3b0f6d02733f09c9739ea9561f63e6cc5a2692cf17f05cd4bd3611b08" + digest = "1:109be9502d5b6e9be46426641dd7f7b1328788d85cd22f314ac812489d874f30" name = "knative.dev/pkg" packages = [ "apis", @@ -946,7 +946,7 @@ "metrics/metricskey", ] pruneopts = "T" - revision = "972acd413fb96750dc6a4b98e4ba344c594a385b" + revision = "e8df94bc5a75081fe081548c261203467448857b" [[projects]] branch = "master" @@ -957,7 +957,7 @@ "tools/dep-collector", ] pruneopts = "UT" - revision = "17f2331e80ad0d3e170ea2bae45c3922744f83af" + revision = "a6aed31ed1097dbfaaf1d056b5d89499f64c7235" [solve-meta] analyzer-name = "dep" diff --git a/vendor/knative.dev/pkg/Gopkg.lock b/vendor/knative.dev/pkg/Gopkg.lock index 0d2c8c46..2ac5db23 100644 --- a/vendor/knative.dev/pkg/Gopkg.lock +++ b/vendor/knative.dev/pkg/Gopkg.lock @@ -311,17 +311,6 @@ pruneopts = "NUT" revision = "f2b4162afba35581b6d4a50d3b8f34e33c144682" -[[projects]] - branch = "master" - digest = "1:68050b4ce26531655bac0f6e109d04eb0a4550ead73e320119ed3c628ced4a0a" - name = "github.com/knative/test-infra" - packages = [ - "scripts", - "tools/dep-collector", - ] - pruneopts = "UT" - revision = "0cc427ae355abc72227fc2effaf017c9ded669b4" - [[projects]] digest = "1:56dbf15e091bf7926cb33a57cb6bdfc658fc6d3498d2f76f10a97ce7856f1fde" name = "github.com/markbates/inflect" @@ -1130,6 +1119,17 @@ pruneopts = "NUT" revision = "33be087ad058f99c78e067996202b60230737e49" +[[projects]] + branch = "master" + digest = "1:68050b4ce26531655bac0f6e109d04eb0a4550ead73e320119ed3c628ced4a0a" + name = "knative.dev/test-infra" + packages = [ + "scripts", + "tools/dep-collector", + ] + pruneopts = "UT" + revision = "17f2331e80ad0d3e170ea2bae45c3922744f83af" + [solve-meta] analyzer-name = "dep" analyzer-version = 1 @@ -1147,8 +1147,6 @@ "github.com/google/go-cmp/cmp/cmpopts", "github.com/google/uuid", "github.com/gorilla/websocket", - "github.com/knative/test-infra/scripts", - "github.com/knative/test-infra/tools/dep-collector", "github.com/markbates/inflect", "github.com/mattbaird/jsonpatch", "github.com/openzipkin/zipkin-go", @@ -1235,6 +1233,8 @@ "k8s.io/gengo/namer", "k8s.io/gengo/types", "k8s.io/klog", + "knative.dev/test-infra/scripts", + "knative.dev/test-infra/tools/dep-collector", ] solver-name = "gps-cdcl" solver-version = 1 diff --git a/vendor/knative.dev/pkg/Gopkg.toml b/vendor/knative.dev/pkg/Gopkg.toml index fe99cab6..d1e06392 100644 --- a/vendor/knative.dev/pkg/Gopkg.toml +++ b/vendor/knative.dev/pkg/Gopkg.toml @@ -9,8 +9,8 @@ required = [ "k8s.io/code-generator/cmd/lister-gen", "k8s.io/code-generator/cmd/informer-gen", "github.com/evanphx/json-patch", - "github.com/knative/test-infra/scripts", - "github.com/knative/test-infra/tools/dep-collector", + "knative.dev/test-infra/scripts", + "knative.dev/test-infra/tools/dep-collector", "github.com/pkg/errors", ] @@ -58,7 +58,7 @@ required = [ version = "v0.12.2" [[constraint]] - name = "github.com/knative/test-infra" + name = "knative.dev/test-infra" branch = "master" [prune] @@ -72,5 +72,5 @@ required = [ non-go = false [[prune.project]] - name = "github.com/knative/test-infra" + name = "knative.dev/test-infra" non-go = false diff --git a/vendor/knative.dev/pkg/hack/update-codegen.sh b/vendor/knative.dev/pkg/hack/update-codegen.sh index 4adf2ead..75be4714 100755 --- a/vendor/knative.dev/pkg/hack/update-codegen.sh +++ b/vendor/knative.dev/pkg/hack/update-codegen.sh @@ -18,7 +18,7 @@ set -o errexit set -o nounset set -o pipefail -source $(dirname $0)/../vendor/github.com/knative/test-infra/scripts/library.sh +source $(dirname $0)/../vendor/knative.dev/test-infra/scripts/library.sh CODEGEN_PKG=${CODEGEN_PKG:-$(cd ${REPO_ROOT_DIR}; ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo ../code-generator)} diff --git a/vendor/knative.dev/pkg/hack/update-deps.sh b/vendor/knative.dev/pkg/hack/update-deps.sh index 27e26454..97b1cfef 100755 --- a/vendor/knative.dev/pkg/hack/update-deps.sh +++ b/vendor/knative.dev/pkg/hack/update-deps.sh @@ -15,7 +15,7 @@ # limitations under the License. readonly ROOT_DIR=$(dirname $0)/.. -source ${ROOT_DIR}/vendor/github.com/knative/test-infra/scripts/library.sh +source ${ROOT_DIR}/vendor/knative.dev/test-infra/scripts/library.sh set -o errexit set -o nounset diff --git a/vendor/knative.dev/pkg/hack/verify-codegen.sh b/vendor/knative.dev/pkg/hack/verify-codegen.sh index 18bbe693..c3c322d8 100755 --- a/vendor/knative.dev/pkg/hack/verify-codegen.sh +++ b/vendor/knative.dev/pkg/hack/verify-codegen.sh @@ -18,7 +18,7 @@ set -o errexit set -o nounset set -o pipefail -source $(dirname $0)/../vendor/github.com/knative/test-infra/scripts/library.sh +source $(dirname $0)/../vendor/knative.dev/test-infra/scripts/library.sh readonly TMP_DIFFROOT="$(mktemp -d ${REPO_ROOT_DIR}/tmpdiffroot.XXXXXX)" diff --git a/vendor/knative.dev/pkg/injection/sharedmain/main.go b/vendor/knative.dev/pkg/injection/sharedmain/main.go index eada5b7c..73dab84a 100644 --- a/vendor/knative.dev/pkg/injection/sharedmain/main.go +++ b/vendor/knative.dev/pkg/injection/sharedmain/main.go @@ -19,7 +19,11 @@ package sharedmain import ( "context" "flag" + "fmt" "log" + "os" + "os/user" + "path/filepath" "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" @@ -35,6 +39,34 @@ import ( "knative.dev/pkg/system" ) +// GetConfig returns a rest.Config to be used for kubernetes client creation. +// It does so in the following order: +// 1. Use the passed kubeconfig/masterURL. +// 2. Fallback to the KUBECONFIG environment variable. +// 3. Fallback to in-cluster config. +// 4. Fallback to the ~/.kube/config. +func GetConfig(masterURL, kubeconfig string) (*rest.Config, error) { + if kubeconfig == "" { + kubeconfig = os.Getenv("KUBECONFIG") + } + // If we have an explicit indication of where the kubernetes config lives, read that. + if kubeconfig != "" { + return clientcmd.BuildConfigFromFlags(masterURL, kubeconfig) + } + // If not, try the in-cluster config. + if c, err := rest.InClusterConfig(); err == nil { + return c, nil + } + // If no in-cluster config, try the default location in the user's home directory. + if usr, err := user.Current(); err == nil { + if c, err := clientcmd.BuildConfigFromFlags("", filepath.Join(usr.HomeDir, ".kube", "config")); err == nil { + return c, nil + } + } + + return nil, fmt.Errorf("could not create a valid kubeconfig") +} + func Main(component string, ctors ...injection.ControllerConstructor) { // Set up signals so we handle the first shutdown signal gracefully. MainWithContext(signals.NewContext(), component, ctors...) @@ -47,7 +79,7 @@ func MainWithContext(ctx context.Context, component string, ctors ...injection.C ) flag.Parse() - cfg, err := clientcmd.BuildConfigFromFlags(*masterURL, *kubeconfig) + cfg, err := GetConfig(*masterURL, *kubeconfig) if err != nil { log.Fatal("Error building kubeconfig", err) } diff --git a/vendor/knative.dev/pkg/test/presubmit-tests.sh b/vendor/knative.dev/pkg/test/presubmit-tests.sh index c3861911..03a40737 100755 --- a/vendor/knative.dev/pkg/test/presubmit-tests.sh +++ b/vendor/knative.dev/pkg/test/presubmit-tests.sh @@ -22,7 +22,7 @@ # in a net-negative contributor experience. export DISABLE_MD_LINTING=1 -source $(dirname $0)/../vendor/github.com/knative/test-infra/scripts/presubmit-tests.sh +source $(dirname $0)/../vendor/knative.dev/test-infra/scripts/presubmit-tests.sh # TODO(#17): Write integration tests.