From 6e026b4d43b424b1e6d981800d03ca12815ca82d Mon Sep 17 00:00:00 2001 From: "Dr. Stefan Schimanski" Date: Thu, 6 Apr 2017 09:21:27 +0200 Subject: [PATCH] Clean up staging/godeps-json-updater.go --- hack/update-staging-godeps.sh | 2 +- staging/copy.sh | 2 +- staging/godeps-json-updater.go | 17 ++++++++--------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/hack/update-staging-godeps.sh b/hack/update-staging-godeps.sh index e6d9e8c3bc..4c4c0b9ddd 100755 --- a/hack/update-staging-godeps.sh +++ b/hack/update-staging-godeps.sh @@ -68,7 +68,7 @@ function updateGodepManifest() { GOPATH="${TMP_GOPATH}:${GOPATH}:${KUBE_ROOT}/staging" godep save ${V} ./... 2>&1 | sed 's/^/ /' echo "Rewriting Godeps.json to remove commits that don't really exist because we haven't pushed the prereqs yet" - go run "${KUBE_ROOT}/staging/godeps-json-updater.go" --godeps-file="${TMP_GOPATH}/src/k8s.io/${repo}/Godeps/Godeps.json" --client-go-import-path="k8s.io/${repo}" + go run "${KUBE_ROOT}/staging/godeps-json-updater.go" --godeps-file="${TMP_GOPATH}/src/k8s.io/${repo}/Godeps/Godeps.json" --override-import-path="k8s.io/${repo}" # commit so that following repos do not see this repo as dirty git add vendor >/dev/null diff --git a/staging/copy.sh b/staging/copy.sh index dac66ebb0e..91ef7d238a 100755 --- a/staging/copy.sh +++ b/staging/copy.sh @@ -147,7 +147,7 @@ echo "rewriting Godeps.json" # The entries for k8s.io/apimahcinery are not removed from Godeps.json, though # they contain the invalid commit revision. The publish robot will set the # correct commit revision. -go run "${KUBE_ROOT}/staging/godeps-json-updater.go" --godeps-file="${CLIENT_REPO_TEMP}/Godeps/Godeps.json" --client-go-import-path="${CLIENT_REPO_FROM_SRC}" --ignored-prefixes="k8s.io/client-go,k8s.io/kubernetes" --rewritten-prefixes="k8s.io/apimachinery" +go run "${KUBE_ROOT}/staging/godeps-json-updater.go" --godeps-file="${CLIENT_REPO_TEMP}/Godeps/Godeps.json" --override-import-path="${CLIENT_REPO_FROM_SRC}" --ignored-prefixes="k8s.io/client-go,k8s.io/kubernetes" --rewritten-prefixes="k8s.io/apimachinery" echo "rewriting imports" grep -Rl "\"${MAIN_REPO_FROM_SRC}" "${CLIENT_REPO_TEMP}" | \ diff --git a/staging/godeps-json-updater.go b/staging/godeps-json-updater.go index 77a3fb5642..56c2b2bbd3 100644 --- a/staging/godeps-json-updater.go +++ b/staging/godeps-json-updater.go @@ -18,6 +18,7 @@ package main import ( "encoding/json" + "fmt" "log" "os" "strings" @@ -26,10 +27,10 @@ import ( ) var ( - godepsFile = flag.String("godeps-file", "", "absolute path to Godeps.json") - clientRepoImportPath = flag.String("client-go-import-path", "", "import path to a version of client-go, e.g., k8s.io/client-go/1.4") - ignoredPrefixes = flag.StringSlice("ignored-prefixes", []string{"k8s.io/"}, "any godep entry prefixed with the ignored-prefix will be deleted from Godeps.json") - rewrittenPrefixes = flag.StringSlice("rewritten-prefixes", []string{}, "any godep entry prefixed with the rewritten-prefix will be filled will dummy rev; overridden by ignored-prefixes") + godepsFile = flag.String("godeps-file", "", "absolute path to Godeps.json") + overrideImportPath = flag.String("override-import-path", "", "import path to be written into the Godeps.json, e.g., k8s.io/client-go") + ignoredPrefixes = flag.StringSlice("ignored-prefixes", []string{"k8s.io/"}, "any godep entry prefixed with the ignored-prefix will be deleted from Godeps.json") + rewrittenPrefixes = flag.StringSlice("rewritten-prefixes", []string{}, fmt.Sprintf("any godep entry prefixed with the rewritten-prefix will be filled will dummy rev %q; overridden by ignored-prefixes", dummyRev)) ) const dummyRev = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" @@ -55,9 +56,6 @@ func main() { if len(*godepsFile) == 0 { log.Fatalf("absolute path to Godeps.json is required") } - if len(*clientRepoImportPath) == 0 { - log.Fatalf("import path to a version of client-go is required") - } f, err := os.OpenFile(*godepsFile, os.O_RDWR, 0666) if err != nil { log.Fatalf("cannot open file %q: %v", *godepsFile, err) @@ -67,8 +65,9 @@ func main() { if err != nil { log.Fatalf("Unable to parse %q: %v", *godepsFile, err) } - // rewrites the Godeps.ImportPath - g.ImportPath = *clientRepoImportPath + if len(*overrideImportPath) != 0 { + g.ImportPath = *overrideImportPath + } // removes the Deps whose ImportPath contains "k8s.io/kubernetes" i := 0 for _, dep := range g.Deps {