Update vendor files to point to K8S 1.12.0

This PR updates vendor files to point to K8S 1.12.0.
This commit is contained in:
Xing Yang
2018-10-02 11:19:52 -07:00
parent 9620c4362e
commit ec088551b7
26 changed files with 1895 additions and 1596 deletions

View File

@@ -3,6 +3,6 @@ language: go
go_import_path: k8s.io/client-go
go:
- 1.8.1
- 1.10.2
script: go build ./...

View File

@@ -272,335 +272,335 @@
},
{
"ImportPath": "k8s.io/api/admissionregistration/v1alpha1",
"Rev": "0527d9f2238346a310e6cf1e6afe2422f329cc3d"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/admissionregistration/v1beta1",
"Rev": "0527d9f2238346a310e6cf1e6afe2422f329cc3d"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/apps/v1",
"Rev": "0527d9f2238346a310e6cf1e6afe2422f329cc3d"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/apps/v1beta1",
"Rev": "0527d9f2238346a310e6cf1e6afe2422f329cc3d"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/apps/v1beta2",
"Rev": "0527d9f2238346a310e6cf1e6afe2422f329cc3d"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/authentication/v1",
"Rev": "0527d9f2238346a310e6cf1e6afe2422f329cc3d"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/authentication/v1beta1",
"Rev": "0527d9f2238346a310e6cf1e6afe2422f329cc3d"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/authorization/v1",
"Rev": "0527d9f2238346a310e6cf1e6afe2422f329cc3d"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/authorization/v1beta1",
"Rev": "0527d9f2238346a310e6cf1e6afe2422f329cc3d"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/autoscaling/v1",
"Rev": "0527d9f2238346a310e6cf1e6afe2422f329cc3d"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/autoscaling/v2beta1",
"Rev": "0527d9f2238346a310e6cf1e6afe2422f329cc3d"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/autoscaling/v2beta2",
"Rev": "0527d9f2238346a310e6cf1e6afe2422f329cc3d"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/batch/v1",
"Rev": "0527d9f2238346a310e6cf1e6afe2422f329cc3d"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/batch/v1beta1",
"Rev": "0527d9f2238346a310e6cf1e6afe2422f329cc3d"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/batch/v2alpha1",
"Rev": "0527d9f2238346a310e6cf1e6afe2422f329cc3d"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/certificates/v1beta1",
"Rev": "0527d9f2238346a310e6cf1e6afe2422f329cc3d"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/coordination/v1beta1",
"Rev": "0527d9f2238346a310e6cf1e6afe2422f329cc3d"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/core/v1",
"Rev": "0527d9f2238346a310e6cf1e6afe2422f329cc3d"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/events/v1beta1",
"Rev": "0527d9f2238346a310e6cf1e6afe2422f329cc3d"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/extensions/v1beta1",
"Rev": "0527d9f2238346a310e6cf1e6afe2422f329cc3d"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/imagepolicy/v1alpha1",
"Rev": "0527d9f2238346a310e6cf1e6afe2422f329cc3d"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/networking/v1",
"Rev": "0527d9f2238346a310e6cf1e6afe2422f329cc3d"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/policy/v1beta1",
"Rev": "0527d9f2238346a310e6cf1e6afe2422f329cc3d"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/rbac/v1",
"Rev": "0527d9f2238346a310e6cf1e6afe2422f329cc3d"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/rbac/v1alpha1",
"Rev": "0527d9f2238346a310e6cf1e6afe2422f329cc3d"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/rbac/v1beta1",
"Rev": "0527d9f2238346a310e6cf1e6afe2422f329cc3d"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/scheduling/v1alpha1",
"Rev": "0527d9f2238346a310e6cf1e6afe2422f329cc3d"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/scheduling/v1beta1",
"Rev": "0527d9f2238346a310e6cf1e6afe2422f329cc3d"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/settings/v1alpha1",
"Rev": "0527d9f2238346a310e6cf1e6afe2422f329cc3d"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/storage/v1",
"Rev": "0527d9f2238346a310e6cf1e6afe2422f329cc3d"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/storage/v1alpha1",
"Rev": "0527d9f2238346a310e6cf1e6afe2422f329cc3d"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/storage/v1beta1",
"Rev": "0527d9f2238346a310e6cf1e6afe2422f329cc3d"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/apitesting",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/apitesting/fuzzer",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/apitesting/roundtrip",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/equality",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/errors",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/meta",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/resource",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/fuzzer",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/internalversion",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1beta1",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/conversion",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/conversion/queryparams",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/fields",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/labels",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/schema",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/json",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/protobuf",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/recognizer",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/streaming",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/versioning",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/selection",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/types",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/cache",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/clock",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/diff",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/errors",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/framer",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream/spdy",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/intstr",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/json",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/mergepatch",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/naming",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/net",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/remotecommand",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/runtime",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/sets",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/strategicpatch",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/validation",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/validation/field",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/wait",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/yaml",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/version",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/watch",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/json",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/netutil",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/reflect",
"Rev": "63dd81ab0848cd58da3257a806f599808708029c"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/kube-openapi/pkg/util/proto",

6
vendor/k8s.io/client-go/INSTALL.md generated vendored
View File

@@ -63,7 +63,7 @@ To install `client-go` and place its dependencies in your `$GOPATH`:
```sh
go get k8s.io/client-go/...
cd $GOPATH/src/k8s.io/client-go
git checkout v6.0.0
git checkout v9.0.0 # replace v9.0.0 with the required version
# cd 1.5 # only necessary with 1.5 and 1.4 clients.
godep restore ./...
```
@@ -99,7 +99,7 @@ your project:
package: ( your project's import path ) # e.g. github.com/foo/bar
import:
- package: k8s.io/client-go
version: v6.0.0
version: v9.0.0 # replace v9.0.0 with the required version
```
Second, add a Go file that imports `client-go` somewhere in your project,
@@ -132,7 +132,7 @@ requests can override the version manually in `glide.yaml`. For example:
package: ( your project's import path ) # e.g. github.com/foo/bar
import:
- package: k8s.io/client-go
version: v6.0.0
version: v9.0.0 # replace v9.0.0 with the required version
# Use a newer version of go-spew even though client-go wants an old one.
- package: github.com/davecgh/go-spew
version: v1.1.0

View File

@@ -174,7 +174,13 @@ func parseScopes(gcpConfig map[string]string) []string {
}
func (g *gcpAuthProvider) WrapTransport(rt http.RoundTripper) http.RoundTripper {
return &conditionalTransport{&oauth2.Transport{Source: g.tokenSource, Base: rt}, g.persister}
var resetCache map[string]string
if cts, ok := g.tokenSource.(*cachedTokenSource); ok {
resetCache = cts.baseCache()
} else {
resetCache = make(map[string]string)
}
return &conditionalTransport{&oauth2.Transport{Source: g.tokenSource, Base: rt}, g.persister, resetCache}
}
func (g *gcpAuthProvider) Login() error { return nil }
@@ -247,6 +253,19 @@ func (t *cachedTokenSource) update(tok *oauth2.Token) map[string]string {
return ret
}
// baseCache is the base configuration value for this TokenSource, without any cached ephemeral tokens.
func (t *cachedTokenSource) baseCache() map[string]string {
t.lk.Lock()
defer t.lk.Unlock()
ret := map[string]string{}
for k, v := range t.cache {
ret[k] = v
}
delete(ret, "access-token")
delete(ret, "expiry")
return ret
}
type commandTokenSource struct {
cmd string
args []string
@@ -337,6 +356,7 @@ func parseJSONPath(input interface{}, name, template string) (string, error) {
type conditionalTransport struct {
oauthTransport *oauth2.Transport
persister restclient.AuthProviderConfigPersister
resetCache map[string]string
}
var _ net.RoundTripperWrapper = &conditionalTransport{}
@@ -354,8 +374,7 @@ func (t *conditionalTransport) RoundTrip(req *http.Request) (*http.Response, err
if res.StatusCode == 401 {
glog.V(4).Infof("The credentials that were supplied are invalid for the target cluster")
emptyCache := make(map[string]string)
t.persister.Persist(emptyCache)
t.persister.Persist(t.resetCache)
}
return res, nil

View File

@@ -442,37 +442,61 @@ func (t *MockTransport) RoundTrip(req *http.Request) (*http.Response, error) {
return t.res, nil
}
func TestClearingCredentials(t *testing.T) {
func Test_cmdTokenSource_roundTrip(t *testing.T) {
accessToken := "fakeToken"
fakeExpiry := time.Now().Add(time.Hour)
cache := map[string]string{
"access-token": "fakeToken",
"expiry": fakeExpiry.String(),
fakeExpiryStr := fakeExpiry.Format(time.RFC3339Nano)
fs := &fakeTokenSource{
token: &oauth2.Token{
AccessToken: accessToken,
Expiry: fakeExpiry,
},
}
cts := cachedTokenSource{
source: nil,
accessToken: cache["access-token"],
expiry: fakeExpiry,
persister: nil,
cache: nil,
cmdCache := map[string]string{
"cmd-path": "/path/to/tokensource/cmd",
"cmd-args": "--output=json",
}
cmdCacheUpdated := map[string]string{
"cmd-path": "/path/to/tokensource/cmd",
"cmd-args": "--output=json",
"access-token": accessToken,
"expiry": fakeExpiryStr,
}
simpleCacheUpdated := map[string]string{
"access-token": accessToken,
"expiry": fakeExpiryStr,
}
tests := []struct {
name string
res http.Response
cache map[string]string
name string
res http.Response
baseCache, expectedCache map[string]string
}{
{
"Unauthorized",
http.Response{StatusCode: 401},
make(map[string]string),
make(map[string]string),
},
{
"Unauthorized, nonempty defaultCache",
http.Response{StatusCode: 401},
cmdCache,
cmdCache,
},
{
"Authorized",
http.Response{StatusCode: 200},
cache,
make(map[string]string),
simpleCacheUpdated,
},
{
"Authorized, nonempty defaultCache",
http.Response{StatusCode: 200},
cmdCache,
cmdCacheUpdated,
},
}
@@ -480,17 +504,23 @@ func TestClearingCredentials(t *testing.T) {
req := http.Request{Header: http.Header{}}
for _, tc := range tests {
authProvider := gcpAuthProvider{&cts, persister}
cts, err := newCachedTokenSource(accessToken, fakeExpiry.String(), persister, fs, tc.baseCache)
if err != nil {
t.Fatalf("unexpected error from newCachedTokenSource: %v", err)
}
authProvider := gcpAuthProvider{cts, persister}
fakeTransport := MockTransport{&tc.res}
transport := (authProvider.WrapTransport(&fakeTransport))
persister.Persist(cache)
// call Token to persist/update cache
if _, err := cts.Token(); err != nil {
t.Fatalf("unexpected error from cachedTokenSource.Token(): %v", err)
}
transport.RoundTrip(&req)
if got := persister.read(); !reflect.DeepEqual(got, tc.cache) {
t.Errorf("got cache %v, want %v", got, tc.cache)
if got := persister.read(); !reflect.DeepEqual(got, tc.expectedCache) {
t.Errorf("got cache %v, want %v", got, tc.expectedCache)
}
}

View File

@@ -455,17 +455,9 @@ func (r *Request) URL() *url.URL {
// finalURLTemplate is similar to URL(), but will make all specific parameter values equal
// - instead of name or namespace, "{name}" and "{namespace}" will be used, and all query
// parameters will be reset. This creates a copy of the request so as not to change the
// underlying object. This means some useful request info (like the types of field
// selectors in use) will be lost.
// TODO: preserve field selector keys
// parameters will be reset. This creates a copy of the url so as not to change the
// underlying object.
func (r Request) finalURLTemplate() url.URL {
if len(r.resourceName) != 0 {
r.resourceName = "{name}"
}
if r.namespaceSet && len(r.namespace) != 0 {
r.namespace = "{namespace}"
}
newParams := url.Values{}
v := []string{"{value}"}
for k := range r.params {
@@ -473,6 +465,59 @@ func (r Request) finalURLTemplate() url.URL {
}
r.params = newParams
url := r.URL()
segments := strings.Split(r.URL().Path, "/")
groupIndex := 0
index := 0
if r.URL() != nil && r.baseURL != nil && strings.Contains(r.URL().Path, r.baseURL.Path) {
groupIndex += len(strings.Split(r.baseURL.Path, "/"))
}
if groupIndex >= len(segments) {
return *url
}
const CoreGroupPrefix = "api"
const NamedGroupPrefix = "apis"
isCoreGroup := segments[groupIndex] == CoreGroupPrefix
isNamedGroup := segments[groupIndex] == NamedGroupPrefix
if isCoreGroup {
// checking the case of core group with /api/v1/... format
index = groupIndex + 2
} else if isNamedGroup {
// checking the case of named group with /apis/apps/v1/... format
index = groupIndex + 3
} else {
// this should not happen that the only two possibilities are /api... and /apis..., just want to put an
// outlet here in case more API groups are added in future if ever possible:
// https://kubernetes.io/docs/concepts/overview/kubernetes-api/#api-groups
// if a wrong API groups name is encountered, return the {prefix} for url.Path
url.Path = "/{prefix}"
url.RawQuery = ""
return *url
}
//switch segLength := len(segments) - index; segLength {
switch {
// case len(segments) - index == 1:
// resource (with no name) do nothing
case len(segments)-index == 2:
// /$RESOURCE/$NAME: replace $NAME with {name}
segments[index+1] = "{name}"
case len(segments)-index == 3:
if segments[index+2] == "finalize" || segments[index+2] == "status" {
// /$RESOURCE/$NAME/$SUBRESOURCE: replace $NAME with {name}
segments[index+1] = "{name}"
} else {
// /namespace/$NAMESPACE/$RESOURCE: replace $NAMESPACE with {namespace}
segments[index+1] = "{namespace}"
}
case len(segments)-index >= 4:
segments[index+1] = "{namespace}"
// /namespace/$NAMESPACE/$RESOURCE/$NAME: replace $NAMESPACE with {namespace}, $NAME with {name}
if segments[index+3] != "finalize" && segments[index+3] != "status" {
// /$RESOURCE/$NAME/$SUBRESOURCE: replace $NAME with {name}
segments[index+3] = "{name}"
}
}
url.Path = path.Join(segments...)
return *url
}

View File

@@ -340,21 +340,169 @@ func TestResultIntoWithNoBodyReturnsErr(t *testing.T) {
}
func TestURLTemplate(t *testing.T) {
uri, _ := url.Parse("http://localhost")
r := NewRequest(nil, "POST", uri, "", ContentConfig{GroupVersion: &schema.GroupVersion{Group: "test"}}, Serializers{}, nil, nil, 0)
r.Prefix("pre1").Resource("r1").Namespace("ns").Name("nm").Param("p0", "v0")
full := r.URL()
if full.String() != "http://localhost/pre1/namespaces/ns/r1/nm?p0=v0" {
t.Errorf("unexpected initial URL: %s", full)
uri, _ := url.Parse("http://localhost/some/base/url/path")
testCases := []struct {
Request *Request
ExpectedFullURL string
ExpectedFinalURL string
}{
{
// non dynamic client
Request: NewRequest(nil, "POST", uri, "", ContentConfig{GroupVersion: &schema.GroupVersion{Group: "test"}}, Serializers{}, nil, nil, 0).
Prefix("api", "v1").Resource("r1").Namespace("ns").Name("nm").Param("p0", "v0"),
ExpectedFullURL: "http://localhost/some/base/url/path/api/v1/namespaces/ns/r1/nm?p0=v0",
ExpectedFinalURL: "http://localhost/some/base/url/path/api/v1/namespaces/%7Bnamespace%7D/r1/%7Bname%7D?p0=%7Bvalue%7D",
},
{
// non dynamic client with wrong api group
Request: NewRequest(nil, "POST", uri, "", ContentConfig{GroupVersion: &schema.GroupVersion{Group: "test"}}, Serializers{}, nil, nil, 0).
Prefix("pre1", "v1").Resource("r1").Namespace("ns").Name("nm").Param("p0", "v0"),
ExpectedFullURL: "http://localhost/some/base/url/path/pre1/v1/namespaces/ns/r1/nm?p0=v0",
ExpectedFinalURL: "http://localhost/%7Bprefix%7D",
},
{
// dynamic client with core group + namespace + resourceResource (with name)
// /api/$RESOURCEVERSION/namespaces/$NAMESPACE/$RESOURCE/%NAME
Request: NewRequest(nil, "DELETE", uri, "", ContentConfig{GroupVersion: &schema.GroupVersion{Group: "test"}}, Serializers{}, nil, nil, 0).
Prefix("/api/v1/namespaces/ns/r1/name1"),
ExpectedFullURL: "http://localhost/some/base/url/path/api/v1/namespaces/ns/r1/name1",
ExpectedFinalURL: "http://localhost/some/base/url/path/api/v1/namespaces/%7Bnamespace%7D/r1/%7Bname%7D",
},
{
// dynamic client with named group + namespace + resourceResource (with name)
// /apis/$NAMEDGROUPNAME/$RESOURCEVERSION/namespaces/$NAMESPACE/$RESOURCE/%NAME
Request: NewRequest(nil, "DELETE", uri, "", ContentConfig{GroupVersion: &schema.GroupVersion{Group: "test"}}, Serializers{}, nil, nil, 0).
Prefix("/apis/g1/v1/namespaces/ns/r1/name1"),
ExpectedFullURL: "http://localhost/some/base/url/path/apis/g1/v1/namespaces/ns/r1/name1",
ExpectedFinalURL: "http://localhost/some/base/url/path/apis/g1/v1/namespaces/%7Bnamespace%7D/r1/%7Bname%7D",
},
{
// dynamic client with core group + namespace + resourceResource (with NO name)
// /api/$RESOURCEVERSION/namespaces/$NAMESPACE/$RESOURCE
Request: NewRequest(nil, "DELETE", uri, "", ContentConfig{GroupVersion: &schema.GroupVersion{Group: "test"}}, Serializers{}, nil, nil, 0).
Prefix("/api/v1/namespaces/ns/r1"),
ExpectedFullURL: "http://localhost/some/base/url/path/api/v1/namespaces/ns/r1",
ExpectedFinalURL: "http://localhost/some/base/url/path/api/v1/namespaces/%7Bnamespace%7D/r1",
},
{
// dynamic client with named group + namespace + resourceResource (with NO name)
// /apis/$NAMEDGROUPNAME/$RESOURCEVERSION/namespaces/$NAMESPACE/$RESOURCE
Request: NewRequest(nil, "DELETE", uri, "", ContentConfig{GroupVersion: &schema.GroupVersion{Group: "test"}}, Serializers{}, nil, nil, 0).
Prefix("/apis/g1/v1/namespaces/ns/r1"),
ExpectedFullURL: "http://localhost/some/base/url/path/apis/g1/v1/namespaces/ns/r1",
ExpectedFinalURL: "http://localhost/some/base/url/path/apis/g1/v1/namespaces/%7Bnamespace%7D/r1",
},
{
// dynamic client with core group + resourceResource (with name)
// /api/$RESOURCEVERSION/$RESOURCE/%NAME
Request: NewRequest(nil, "DELETE", uri, "", ContentConfig{GroupVersion: &schema.GroupVersion{Group: "test"}}, Serializers{}, nil, nil, 0).
Prefix("/api/v1/r1/name1"),
ExpectedFullURL: "http://localhost/some/base/url/path/api/v1/r1/name1",
ExpectedFinalURL: "http://localhost/some/base/url/path/api/v1/r1/%7Bname%7D",
},
{
// dynamic client with named group + resourceResource (with name)
// /apis/$NAMEDGROUPNAME/$RESOURCEVERSION/$RESOURCE/%NAME
Request: NewRequest(nil, "DELETE", uri, "", ContentConfig{GroupVersion: &schema.GroupVersion{Group: "test"}}, Serializers{}, nil, nil, 0).
Prefix("/apis/g1/v1/r1/name1"),
ExpectedFullURL: "http://localhost/some/base/url/path/apis/g1/v1/r1/name1",
ExpectedFinalURL: "http://localhost/some/base/url/path/apis/g1/v1/r1/%7Bname%7D",
},
{
// dynamic client with named group + namespace + resourceResource (with name) + subresource
// /apis/$NAMEDGROUPNAME/$RESOURCEVERSION/namespaces/$NAMESPACE/$RESOURCE/%NAME/$SUBRESOURCE
Request: NewRequest(nil, "DELETE", uri, "", ContentConfig{GroupVersion: &schema.GroupVersion{Group: "test"}}, Serializers{}, nil, nil, 0).
Prefix("/apis/namespaces/namespaces/namespaces/namespaces/namespaces/namespaces/finalize"),
ExpectedFullURL: "http://localhost/some/base/url/path/apis/namespaces/namespaces/namespaces/namespaces/namespaces/namespaces/finalize",
ExpectedFinalURL: "http://localhost/some/base/url/path/apis/namespaces/namespaces/namespaces/%7Bnamespace%7D/namespaces/%7Bname%7D/finalize",
},
{
// dynamic client with named group + namespace + resourceResource (with name)
// /apis/$NAMEDGROUPNAME/$RESOURCEVERSION/namespaces/$NAMESPACE/$RESOURCE/%NAME
Request: NewRequest(nil, "DELETE", uri, "", ContentConfig{GroupVersion: &schema.GroupVersion{Group: "test"}}, Serializers{}, nil, nil, 0).
Prefix("/apis/namespaces/namespaces/namespaces/namespaces/namespaces/namespaces"),
ExpectedFullURL: "http://localhost/some/base/url/path/apis/namespaces/namespaces/namespaces/namespaces/namespaces/namespaces",
ExpectedFinalURL: "http://localhost/some/base/url/path/apis/namespaces/namespaces/namespaces/%7Bnamespace%7D/namespaces/%7Bname%7D",
},
{
// dynamic client with named group + namespace + resourceResource (with NO name) + subresource
// /apis/$NAMEDGROUPNAME/$RESOURCEVERSION/namespaces/$NAMESPACE/$RESOURCE/%SUBRESOURCE
Request: NewRequest(nil, "DELETE", uri, "", ContentConfig{GroupVersion: &schema.GroupVersion{Group: "test"}}, Serializers{}, nil, nil, 0).
Prefix("/apis/namespaces/namespaces/namespaces/namespaces/namespaces/finalize"),
ExpectedFullURL: "http://localhost/some/base/url/path/apis/namespaces/namespaces/namespaces/namespaces/namespaces/finalize",
ExpectedFinalURL: "http://localhost/some/base/url/path/apis/namespaces/namespaces/namespaces/%7Bnamespace%7D/namespaces/finalize",
},
{
// dynamic client with named group + namespace + resourceResource (with NO name) + subresource
// /apis/$NAMEDGROUPNAME/$RESOURCEVERSION/namespaces/$NAMESPACE/$RESOURCE/%SUBRESOURCE
Request: NewRequest(nil, "DELETE", uri, "", ContentConfig{GroupVersion: &schema.GroupVersion{Group: "test"}}, Serializers{}, nil, nil, 0).
Prefix("/apis/namespaces/namespaces/namespaces/namespaces/namespaces/status"),
ExpectedFullURL: "http://localhost/some/base/url/path/apis/namespaces/namespaces/namespaces/namespaces/namespaces/status",
ExpectedFinalURL: "http://localhost/some/base/url/path/apis/namespaces/namespaces/namespaces/%7Bnamespace%7D/namespaces/status",
},
{
// dynamic client with named group + namespace + resourceResource (with no name)
// /apis/$NAMEDGROUPNAME/$RESOURCEVERSION/namespaces/$NAMESPACE/$RESOURCE/%NAME
Request: NewRequest(nil, "DELETE", uri, "", ContentConfig{GroupVersion: &schema.GroupVersion{Group: "test"}}, Serializers{}, nil, nil, 0).
Prefix("/apis/namespaces/namespaces/namespaces/namespaces/namespaces"),
ExpectedFullURL: "http://localhost/some/base/url/path/apis/namespaces/namespaces/namespaces/namespaces/namespaces",
ExpectedFinalURL: "http://localhost/some/base/url/path/apis/namespaces/namespaces/namespaces/%7Bnamespace%7D/namespaces",
},
{
// dynamic client with named group + resourceResource (with name) + subresource
// /apis/$NAMEDGROUPNAME/$RESOURCEVERSION/namespaces/$NAMESPACE/$RESOURCE/%NAME
Request: NewRequest(nil, "DELETE", uri, "", ContentConfig{GroupVersion: &schema.GroupVersion{Group: "test"}}, Serializers{}, nil, nil, 0).
Prefix("/apis/namespaces/namespaces/namespaces/namespaces/finalize"),
ExpectedFullURL: "http://localhost/some/base/url/path/apis/namespaces/namespaces/namespaces/namespaces/finalize",
ExpectedFinalURL: "http://localhost/some/base/url/path/apis/namespaces/namespaces/namespaces/%7Bname%7D/finalize",
},
{
// dynamic client with named group + resourceResource (with name) + subresource
// /apis/$NAMEDGROUPNAME/$RESOURCEVERSION/namespaces/$NAMESPACE/$RESOURCE/%NAME
Request: NewRequest(nil, "DELETE", uri, "", ContentConfig{GroupVersion: &schema.GroupVersion{Group: "test"}}, Serializers{}, nil, nil, 0).
Prefix("/apis/namespaces/namespaces/namespaces/namespaces/status"),
ExpectedFullURL: "http://localhost/some/base/url/path/apis/namespaces/namespaces/namespaces/namespaces/status",
ExpectedFinalURL: "http://localhost/some/base/url/path/apis/namespaces/namespaces/namespaces/%7Bname%7D/status",
},
{
// dynamic client with named group + resourceResource (with name)
// /apis/$NAMEDGROUPNAME/$RESOURCEVERSION/$RESOURCE/%NAME
Request: NewRequest(nil, "DELETE", uri, "", ContentConfig{GroupVersion: &schema.GroupVersion{Group: "test"}}, Serializers{}, nil, nil, 0).
Prefix("/apis/namespaces/namespaces/namespaces/namespaces"),
ExpectedFullURL: "http://localhost/some/base/url/path/apis/namespaces/namespaces/namespaces/namespaces",
ExpectedFinalURL: "http://localhost/some/base/url/path/apis/namespaces/namespaces/namespaces/%7Bname%7D",
},
{
// dynamic client with named group + resourceResource (with no name)
// /apis/$NAMEDGROUPNAME/$RESOURCEVERSION/$RESOURCE/%NAME
Request: NewRequest(nil, "DELETE", uri, "", ContentConfig{GroupVersion: &schema.GroupVersion{Group: "test"}}, Serializers{}, nil, nil, 0).
Prefix("/apis/namespaces/namespaces/namespaces"),
ExpectedFullURL: "http://localhost/some/base/url/path/apis/namespaces/namespaces/namespaces",
ExpectedFinalURL: "http://localhost/some/base/url/path/apis/namespaces/namespaces/namespaces",
},
{
// dynamic client with wrong api group + namespace + resourceResource (with name) + subresource
// /apis/$NAMEDGROUPNAME/$RESOURCEVERSION/namespaces/$NAMESPACE/$RESOURCE/%NAME/$SUBRESOURCE
Request: NewRequest(nil, "DELETE", uri, "", ContentConfig{GroupVersion: &schema.GroupVersion{Group: "test"}}, Serializers{}, nil, nil, 0).
Prefix("/pre1/namespaces/namespaces/namespaces/namespaces/namespaces/namespaces/finalize"),
ExpectedFullURL: "http://localhost/some/base/url/path/pre1/namespaces/namespaces/namespaces/namespaces/namespaces/namespaces/finalize",
ExpectedFinalURL: "http://localhost/%7Bprefix%7D",
},
}
actualURL := r.finalURLTemplate()
actual := actualURL.String()
expected := "http://localhost/pre1/namespaces/%7Bnamespace%7D/r1/%7Bname%7D?p0=%7Bvalue%7D"
if actual != expected {
t.Errorf("unexpected URL template: %s %s", actual, expected)
}
if r.URL().String() != full.String() {
t.Errorf("creating URL template changed request: %s -> %s", full.String(), r.URL().String())
for i, testCase := range testCases {
r := testCase.Request
full := r.URL()
if full.String() != testCase.ExpectedFullURL {
t.Errorf("%d: unexpected initial URL: %s %s", i, full, testCase.ExpectedFullURL)
}
actualURL := r.finalURLTemplate()
actual := actualURL.String()
if actual != testCase.ExpectedFinalURL {
t.Errorf("%d: unexpected URL template: %s %s", i, actual, testCase.ExpectedFinalURL)
}
if r.URL().String() != full.String() {
t.Errorf("%d, creating URL template changed request: %s -> %s", i, full.String(), r.URL().String())
}
}
}