aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/go-openapi/spec/expander.go
diff options
context:
space:
mode:
authorGravatar Yong Tang <yong.tang.github@outlook.com> 2018-01-03 19:11:28 +0800
committerGravatar Miek Gieben <miek@miek.nl> 2018-01-03 11:11:28 +0000
commit7fe5b0bb1f34735859d611e170fa8709adac73ea (patch)
tree9757c7e2a724a0e1ed885ef7bca470c56075e4a6 /vendor/github.com/go-openapi/spec/expander.go
parentbce7f5fbecbc68950dfb2b96b5f85d03a8bf07eb (diff)
downloadcoredns-7fe5b0bb1f34735859d611e170fa8709adac73ea.tar.gz
coredns-7fe5b0bb1f34735859d611e170fa8709adac73ea.tar.zst
coredns-7fe5b0bb1f34735859d611e170fa8709adac73ea.zip
Update k8s client-go to v6.0.0 (#1340)
* Update k8s client-go to v6.0.0 This fix updates k8s client-go to v6.0.0 as CoreDNS is supported in 1.9 and v6.0.0 is the recommended version. There are quite some massive changes that need to be made: 1. k8s.io/client-go/pkg/api/v1 has been changed to k8s.io/api/v1 (repo changed from `client-go` to `api`) 2. kubernetes.Clientset adds one extra layer, so that `kubernetes.Clientset.Services()` and like has been changed to `kubernetes.Clientset.CoreV1().Services()` Also, we have to stick with specific commits of `k8s.io/apimachinery` and the newly introduced `k8s.io/api` because go dep still could not figure out the right version to fetch. Signed-off-by: Yong Tang <yong.tang.github@outlook.com> * Update vendor with `dep ensure --update` and `dep prune` Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Diffstat (limited to 'vendor/github.com/go-openapi/spec/expander.go')
-rw-r--r--vendor/github.com/go-openapi/spec/expander.go25
1 files changed, 16 insertions, 9 deletions
diff --git a/vendor/github.com/go-openapi/spec/expander.go b/vendor/github.com/go-openapi/spec/expander.go
index 140daf6e8..59a227059 100644
--- a/vendor/github.com/go-openapi/spec/expander.go
+++ b/vendor/github.com/go-openapi/spec/expander.go
@@ -91,7 +91,7 @@ func ResolveRefWithBase(root interface{}, ref *Ref, opts *ExpandOptions) (*Schem
return nil, err
}
specBasePath := ""
- if opts != nil {
+ if opts != nil && opts.RelativeBase != "" {
specBasePath, _ = absPath(opts.RelativeBase)
}
@@ -466,7 +466,7 @@ func ExpandSpec(spec *Swagger, options *ExpandOptions) error {
// getting the base path of the spec to adjust all subsequent reference resolutions
specBasePath := ""
- if options != nil {
+ if options != nil && options.RelativeBase != "" {
specBasePath, _ = absPath(options.RelativeBase)
}
@@ -535,6 +535,7 @@ func ExpandSchema(schema *Schema, root interface{}, cache ResolutionCache) error
if err != nil {
return err
}
+ defer os.Remove(file.Name())
switch r := root.(type) {
case *Schema:
@@ -561,8 +562,12 @@ func ExpandSchemaWithBasePath(schema *Schema, cache ResolutionCache, opts *Expan
}
if opts == nil {
- return errors.New("cannot expand schema without a basPath")
+ return errors.New("cannot expand schema without a base path")
}
+ if opts.RelativeBase == "" {
+ return errors.New("cannot expand schema with empty base path")
+ }
+
basePath, _ := absPath(opts.RelativeBase)
resolver, err := defaultSchemaLoader(nil, opts, cache)
@@ -647,14 +652,16 @@ func expandSchema(target Schema, parentRefs []string, resolver *schemaLoader, ba
/* Ref also changes the resolution scope of children expandSchema */
if target.Ref.String() != "" {
/* Here the resolution scope is changed because a $ref was encountered */
- newRef := normalizeFileRef(&target.Ref, basePath)
- newBasePath := newRef.RemoteURI()
+ normalizedRef := normalizeFileRef(&target.Ref, basePath)
+ normalizedBasePath := normalizedRef.RemoteURI()
+
/* this means there is a circle in the recursion tree */
/* return the Ref */
- if swag.ContainsStringsCI(parentRefs, newRef.String()) {
- target.Ref = *newRef
+ if basePath != "" && swag.ContainsStringsCI(parentRefs, normalizedRef.String()) {
+ target.Ref = *normalizedRef
return &target, nil
}
+
debugLog("\nbasePath: %s", basePath)
b, _ := json.Marshal(target)
debugLog("calling Resolve with target: %s", string(b))
@@ -663,8 +670,8 @@ func expandSchema(target Schema, parentRefs []string, resolver *schemaLoader, ba
}
if t != nil {
- parentRefs = append(parentRefs, newRef.String())
- return expandSchema(*t, parentRefs, resolver, newBasePath)
+ parentRefs = append(parentRefs, normalizedRef.String())
+ return expandSchema(*t, parentRefs, resolver, normalizedBasePath)
}
}