Bumping k8s dependencies to 1.13

This commit is contained in:
Cheng Xing
2018-11-16 14:08:25 -08:00
parent 305407125c
commit b4c0b68ec7
8002 changed files with 884099 additions and 276228 deletions

View File

@@ -18,3 +18,4 @@ linters:
disable:
- maligned
- unparam
- lll

View File

@@ -1,18 +1,18 @@
language: go
after_success:
- bash <(curl -s https://codecov.io/bash)
go:
- 1.7
- 1.8
- 1.9
- '1.9'
- 1.10.x
- 1.11.x
install:
- go get -u github.com/stretchr/testify
- go get -u github.com/go-openapi/swag
- go get -u gopkg.in/yaml.v2
- go get -u github.com/go-openapi/jsonpointer
- go get -u github.com/go-openapi/jsonreference
script:
- go test -v -race -cover -coverprofile=coverage.txt -covermode=atomic ./...
after_success:
- bash <(curl -s https://codecov.io/bash)
language: go
notifications:
slack:
secure: QUWvCkBBK09GF7YtEvHHVt70JOkdlNBG0nIKu/5qc4/nW5HP8I2w0SEf/XR2je0eED1Qe3L/AfMCWwrEj+IUZc3l4v+ju8X8R3Lomhme0Eb0jd1MTMCuPcBT47YCj0M7RON7vXtbFfm1hFJ/jLe5+9FXz0hpXsR24PJc5ZIi/ogNwkaPqG4BmndzecpSh0vc2FJPZUD9LT0I09REY/vXR0oQAalLkW0asGD5taHZTUZq/kBpsNxaAFrLM23i4mUcf33M5fjLpvx5LRICrX/57XpBrDh2TooBU6Qj3CgoY0uPRYUmSNxbVx1czNzl2JtEpb5yjoxfVPQeg0BvQM00G8LJINISR+ohrjhkZmAqchDupAX+yFrxTtORa78CtnIL6z/aTNlgwwVD8kvL/1pFA/JWYmKDmz93mV/+6wubGzNSQCstzjkFA4/iZEKewKUoRIAi/fxyscP6L/rCpmY/4llZZvrnyTqVbt6URWpopUpH4rwYqreXAtJxJsfBJIeSmUIiDIOMGkCTvyTEW3fWGmGoqWtSHLoaWDyAIGb7azb+KvfpWtEcoPFWfSWU+LGee0A/YsUhBl7ADB9A0CJEuR8q4BPpKpfLwPKSiKSAXL7zDkyjExyhtgqbSl2jS+rKIHOZNL8JkCcTP2MKMVd563C5rC5FMKqu3S9m2b6380E=
script:
- go test -v -race -cover -coverprofile=coverage.txt -covermode=atomic ./...

View File

@@ -32,9 +32,10 @@ import (
// ExpandOptions provides options for expand.
type ExpandOptions struct {
RelativeBase string
SkipSchemas bool
ContinueOnError bool
RelativeBase string
SkipSchemas bool
ContinueOnError bool
AbsoluteCircularRef bool
}
// ResolutionCache a cache for resolving urls
@@ -444,7 +445,7 @@ func normalizeFileRef(ref *Ref, relativeBase string) *Ref {
return &r
}
debugLog("normalizing %s against %s (%s)", ref.String(), relativeBase, ref.GetURL().String())
debugLog("normalizing %s against %s", ref.String(), relativeBase)
s := normalizePaths(ref.String(), relativeBase)
r, _ := NewRef(s)
@@ -607,25 +608,35 @@ func shouldStopOnError(err error, opts *ExpandOptions) bool {
return false
}
// ExpandSchema expands the refs in the schema object with reference to the root object
// go-openapi/validate uses this function
// notice that it is impossible to reference a json scema in a different file other than root
func ExpandSchema(schema *Schema, root interface{}, cache ResolutionCache) error {
// Only save the root to a tmp file if it isn't nil.
var base string
// baseForRoot loads in the cache the root document and produces a fake "root" base path entry
// for further $ref resolution
func baseForRoot(root interface{}, cache ResolutionCache) string {
// cache the root document to resolve $ref's
const rootBase = "root"
if root != nil {
base, _ = absPath("root")
base, _ := absPath(rootBase)
normalizedBase := normalizeAbsPath(base)
debugLog("setting root doc in cache at: %s", normalizedBase)
if cache == nil {
cache = resCache
}
cache.Set(normalizeAbsPath(base), root)
base = "root"
cache.Set(normalizedBase, root)
return rootBase
}
return ""
}
// ExpandSchema expands the refs in the schema object with reference to the root object
// go-openapi/validate uses this function
// notice that it is impossible to reference a json schema in a different file other than root
func ExpandSchema(schema *Schema, root interface{}, cache ResolutionCache) error {
opts := &ExpandOptions{
RelativeBase: base,
// when a root is specified, cache the root as an in-memory document for $ref retrieval
RelativeBase: baseForRoot(root, cache),
SkipSchemas: false,
ContinueOnError: false,
// when no base path is specified, remaining $ref (circular) are rendered with an absolute path
AbsoluteCircularRef: true,
}
return ExpandSchemaWithBasePath(schema, cache, opts)
}
@@ -734,6 +745,7 @@ func expandSchema(target Schema, parentRefs []string, resolver *schemaLoader, ba
otherwise the basePath should inherit the parent's */
// important: ID can be relative path
if target.ID != "" {
debugLog("schema has ID: %s", target.ID)
// handling the case when id is a folder
// remember that basePath has to be a file
refPath := target.ID
@@ -757,11 +769,13 @@ func expandSchema(target Schema, parentRefs []string, resolver *schemaLoader, ba
// this means there is a cycle in the recursion tree: return the Ref
// - circular refs cannot be expanded. We leave them as ref.
// - denormalization means that a new local file ref is set relative to the original basePath
debugLog("shortcut circular ref")
debugLog("basePath: %s", basePath)
debugLog("normalized basePath: %s", normalizedBasePath)
debugLog("normalized ref: %s", normalizedRef.String())
target.Ref = *denormalizeFileRef(normalizedRef, normalizedBasePath, resolver.context.basePath)
debugLog("shortcut circular ref: basePath: %s, normalizedPath: %s, normalized ref: %s",
basePath, normalizedBasePath, normalizedRef.String())
if !resolver.options.AbsoluteCircularRef {
target.Ref = *denormalizeFileRef(normalizedRef, normalizedBasePath, resolver.context.basePath)
} else {
target.Ref = *normalizedRef
}
return &target, nil
}
@@ -1015,19 +1029,40 @@ func transitiveResolver(basePath string, ref Ref, resolver *schemaLoader) (*sche
return resolver, nil
}
// ExpandResponseWithRoot expands a response based on a root document, not a fetchable document
func ExpandResponseWithRoot(response *Response, root interface{}, cache ResolutionCache) error {
opts := &ExpandOptions{
RelativeBase: baseForRoot(root, cache),
SkipSchemas: false,
ContinueOnError: false,
// when no base path is specified, remaining $ref (circular) are rendered with an absolute path
AbsoluteCircularRef: true,
}
resolver, err := defaultSchemaLoader(root, opts, nil, nil)
if err != nil {
return err
}
return expandResponse(response, resolver, opts.RelativeBase)
}
// ExpandResponse expands a response based on a basepath
// This is the exported version of expandResponse
// all refs inside response will be resolved relative to basePath
func ExpandResponse(response *Response, basePath string) error {
var specBasePath string
if basePath != "" {
specBasePath, _ = absPath(basePath)
}
opts := &ExpandOptions{
RelativeBase: basePath,
RelativeBase: specBasePath,
}
resolver, err := defaultSchemaLoader(nil, opts, nil, nil)
if err != nil {
return err
}
return expandResponse(response, resolver, basePath)
return expandResponse(response, resolver, opts.RelativeBase)
}
func derefResponse(response *Response, parentRefs []string, resolver *schemaLoader, basePath string) error {
@@ -1058,7 +1093,6 @@ func expandResponse(response *Response, resolver *schemaLoader, basePath string)
if response == nil {
return nil
}
parentRefs := []string{}
if err := derefResponse(response, parentRefs, resolver, basePath); shouldStopOnError(err, resolver.options) {
return err
@@ -1094,19 +1128,40 @@ func expandResponse(response *Response, resolver *schemaLoader, basePath string)
return nil
}
// ExpandParameterWithRoot expands a parameter based on a root document, not a fetchable document
func ExpandParameterWithRoot(parameter *Parameter, root interface{}, cache ResolutionCache) error {
opts := &ExpandOptions{
RelativeBase: baseForRoot(root, cache),
SkipSchemas: false,
ContinueOnError: false,
// when no base path is specified, remaining $ref (circular) are rendered with an absolute path
AbsoluteCircularRef: true,
}
resolver, err := defaultSchemaLoader(root, opts, nil, nil)
if err != nil {
return err
}
return expandParameter(parameter, resolver, opts.RelativeBase)
}
// ExpandParameter expands a parameter based on a basepath
// This is the exported version of expandParameter
// all refs inside parameter will be resolved relative to basePath
func ExpandParameter(parameter *Parameter, basePath string) error {
var specBasePath string
if basePath != "" {
specBasePath, _ = absPath(basePath)
}
opts := &ExpandOptions{
RelativeBase: basePath,
RelativeBase: specBasePath,
}
resolver, err := defaultSchemaLoader(nil, opts, nil, nil)
if err != nil {
return err
}
return expandParameter(parameter, resolver, basePath)
return expandParameter(parameter, resolver, opts.RelativeBase)
}
func derefParameter(parameter *Parameter, parentRefs []string, resolver *schemaLoader, basePath string) error {

View File

@@ -32,6 +32,10 @@ import (
"github.com/stretchr/testify/assert"
)
var (
rex = regexp.MustCompile(`"\$ref":\s*"(.+)"`)
)
func jsonDoc(path string) (json.RawMessage, error) {
data, err := swag.LoadFromFileOrHTTP(path)
if err != nil {
@@ -286,6 +290,39 @@ func TestExportedResponseExpansion(t *testing.T) {
// assert.Equal(t, expected, resp)
}
func TestExpandResponseAndParamWithRoot(t *testing.T) {
specDoc, err := jsonDoc("fixtures/bugs/1614/gitea.json")
if !assert.NoError(t, err) {
t.FailNow()
return
}
var spec Swagger
_ = json.Unmarshal(specDoc, &spec)
// check responses with $ref
resp := spec.Paths.Paths["/admin/users"].Post.Responses.StatusCodeResponses[201]
err = ExpandResponseWithRoot(&resp, spec, nil)
assert.NoError(t, err)
jazon, _ := json.MarshalIndent(resp, "", " ")
m := rex.FindAllStringSubmatch(string(jazon), -1)
assert.Nil(t, m)
resp = spec.Paths.Paths["/admin/users"].Post.Responses.StatusCodeResponses[403]
err = ExpandResponseWithRoot(&resp, spec, nil)
assert.NoError(t, err)
jazon, _ = json.MarshalIndent(resp, "", " ")
m = rex.FindAllStringSubmatch(string(jazon), -1)
assert.Nil(t, m)
// check param with $ref
param := spec.Paths.Paths["/admin/users"].Post.Parameters[0]
err = ExpandParameterWithRoot(&param, spec, nil)
assert.NoError(t, err)
jazon, _ = json.MarshalIndent(param, "", " ")
m = rex.FindAllStringSubmatch(string(jazon), -1)
assert.Nil(t, m)
}
func TestIssue3(t *testing.T) {
spec := new(Swagger)
specDoc, err := jsonDoc("fixtures/expansion/overflow.json")
@@ -428,7 +465,6 @@ func Test_MoreCircular(t *testing.T) {
fixturePath := "fixtures/more_circulars/spec.json"
jazon := expandThisOrDieTrying(t, fixturePath)
rex := regexp.MustCompile(`"\$ref":\s*"(.+)"`)
m := rex.FindAllStringSubmatch(jazon, -1)
if assert.NotNil(t, m) {
for _, matched := range m {
@@ -440,7 +476,6 @@ func Test_MoreCircular(t *testing.T) {
fixturePath = "fixtures/more_circulars/spec2.json"
jazon = expandThisOrDieTrying(t, fixturePath)
rex = regexp.MustCompile(`"\$ref":\s*"(.+)"`)
m = rex.FindAllStringSubmatch(jazon, -1)
if assert.NotNil(t, m) {
for _, matched := range m {
@@ -452,7 +487,6 @@ func Test_MoreCircular(t *testing.T) {
fixturePath = "fixtures/more_circulars/spec3.json"
jazon = expandThisOrDieTrying(t, fixturePath)
rex = regexp.MustCompile(`"\$ref":\s*"(.+)"`)
m = rex.FindAllStringSubmatch(jazon, -1)
if assert.NotNil(t, m) {
for _, matched := range m {
@@ -464,7 +498,6 @@ func Test_MoreCircular(t *testing.T) {
fixturePath = "fixtures/more_circulars/spec4.json"
jazon = expandThisOrDieTrying(t, fixturePath)
rex = regexp.MustCompile(`"\$ref":\s*"(.+)"`)
m = rex.FindAllStringSubmatch(jazon, -1)
if assert.NotNil(t, m) {
for _, matched := range m {
@@ -481,7 +514,6 @@ func Test_Issue957(t *testing.T) {
if assert.NotEmpty(t, jazon) {
assert.NotContainsf(t, jazon, "fixture-957.json#/",
"expected %s to be expanded with stripped circular $ref", fixturePath)
rex := regexp.MustCompile(`"\$ref":\s*"(.+)"`)
m := rex.FindAllStringSubmatch(jazon, -1)
if assert.NotNil(t, m) {
for _, matched := range m {
@@ -499,7 +531,6 @@ func Test_Bitbucket(t *testing.T) {
fixturePath := "fixtures/more_circulars/bitbucket.json"
jazon := expandThisOrDieTrying(t, fixturePath)
rex := regexp.MustCompile(`"\$ref":\s*"(.+)"`)
m := rex.FindAllStringSubmatch(jazon, -1)
if assert.NotNil(t, m) {
for _, matched := range m {
@@ -514,7 +545,6 @@ func Test_ExpandJSONSchemaDraft4(t *testing.T) {
fixturePath := filepath.Join("schemas", "jsonschema-draft-04.json")
jazon := expandThisSchemaOrDieTrying(t, fixturePath)
// assert all $ref maches "$ref": "http://json-schema.org/draft-04/something"
rex := regexp.MustCompile(`"\$ref":\s*"(.+)"`)
m := rex.FindAllStringSubmatch(jazon, -1)
if assert.NotNil(t, m) {
for _, matched := range m {
@@ -529,7 +559,6 @@ func Test_ExpandSwaggerSchema(t *testing.T) {
fixturePath := filepath.Join("schemas", "v2", "schema.json")
jazon := expandThisSchemaOrDieTrying(t, fixturePath)
// assert all $ref maches "$ref": "#/definitions/something"
rex := regexp.MustCompile(`"\$ref":\s*"(.+)"`)
m := rex.FindAllStringSubmatch(jazon, -1)
if assert.NotNil(t, m) {
for _, matched := range m {
@@ -1412,6 +1441,77 @@ func TestResolveForTransitiveRefs(t *testing.T) {
assert.NoError(t, err)
}
const (
withoutSchemaID = "removed"
withSchemaID = "schema"
)
func TestExpandSchemaWithRoot(t *testing.T) {
root := new(Swagger)
_ = json.Unmarshal(PetStoreJSONMessage, root)
// 1. remove ID from root definition
origPet := root.Definitions["Pet"]
newPet := origPet
newPet.ID = ""
root.Definitions["Pet"] = newPet
expandRootWithID(t, root, withoutSchemaID)
// 2. put back ID in Pet definition
// nested $ref should fail
//Debug = true
root.Definitions["Pet"] = origPet
expandRootWithID(t, root, withSchemaID)
}
func expandRootWithID(t *testing.T, root *Swagger, testcase string) {
t.Logf("case: expanding $ref to schema without ID, with nested $ref with %s ID", testcase)
sch := &Schema{
SchemaProps: SchemaProps{
Ref: MustCreateRef("#/definitions/newPet"),
},
}
err := ExpandSchema(sch, root, nil)
if testcase == withSchemaID {
assert.Errorf(t, err, "expected %s NOT to expand properly because of the ID in the parent schema", sch.Ref.String())
} else {
assert.NoErrorf(t, err, "expected %s to expand properly", sch.Ref.String())
}
if Debug {
bbb, _ := json.MarshalIndent(sch, "", " ")
t.Log(string(bbb))
}
t.Log("case: expanding $ref to schema without nested $ref")
sch = &Schema{
SchemaProps: SchemaProps{
Ref: MustCreateRef("#/definitions/Category"),
},
}
err = ExpandSchema(sch, root, nil)
assert.NoErrorf(t, err, "expected %s to expand properly", sch.Ref.String())
if Debug {
bbb, _ := json.MarshalIndent(sch, "", " ")
t.Log(string(bbb))
}
t.Logf("case: expanding $ref to schema with %s ID and nested $ref", testcase)
sch = &Schema{
SchemaProps: SchemaProps{
Ref: MustCreateRef("#/definitions/Pet"),
},
}
err = ExpandSchema(sch, root, nil)
if testcase == withSchemaID {
assert.Errorf(t, err, "expected %s NOT to expand properly because of the ID in the parent schema", sch.Ref.String())
} else {
assert.NoErrorf(t, err, "expected %s to expand properly", sch.Ref.String())
}
if Debug {
bbb, _ := json.MarshalIndent(sch, "", " ")
t.Log(string(bbb))
}
}
// PetStoreJSONMessage json raw message for Petstore20
var PetStoreJSONMessage = json.RawMessage([]byte(PetStore20))

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,618 @@
definitions:
# Generic response model
V4GenericResponse:
type: object
properties:
message:
type: string
description: A human readable message
code:
type: string
description: |
A machine readable [response code](https://github.com/giantswarm/api-spec/blob/master/details/RESPONSE_CODES.md) like e. g. `INVALID_CREDENTIALS`
# Info resposne
V4InfoResponse:
type: object
properties:
general:
description: General information
type: object
properties:
installation_name:
description: Unique name of the installation
type: string
provider:
description: The technical provider used in this installation. Either "kvm", "aws", or "azure".
type: string
datacenter:
description: Identifier of the datacenter or cloud provider region, e. g. "eu-west-1"
type: string
workers:
description: Information related to worker nodes
type: object
properties:
count_per_cluster:
description: Number of workers per cluster
type: object
properties:
max:
description: Maximum number of worker a cluster can have
type: number
default:
description: Default number of workers in a new cluster will have, if not specifiec otherwise
type: number
instance_type:
description: Instance types to be used for worker nodes. Only available for AWS clusters.
type: object
properties:
options:
description: List of available instance types
type: array
items:
type: string
default:
description: The instance type used in new cluster, if not specified
type: string
vm_size:
description: Azure Virtual Machine size to be used for worker nodes. Only available for Azure clusters.
type: object
properties:
options:
description: List of available instance types
type: array
items:
type: string
default:
description: The instance type used in new cluster, if not specified
type: string
# Request to create a new cluster
V4AddClusterRequest:
type: object
required:
- owner
description: Request model for creating a new cluster
properties:
owner:
type: string
description: Name of the organization owning the cluster
name:
type: string
description: Cluster name
release_version:
type: string
description: |
The [release](https://docs.giantswarm.io/api/#tag/releases) version
to use in the new cluster
kubernetes_version:
type: string
description: |
Kubernetes version number (deprecated). Doesn't have any effect.
This attribute is going to be removed in future API versions.
workers:
type: array
items:
$ref: '#/definitions/V4NodeDefinition'
V4ModifyClusterRequest:
type: object
required: []
description: Request body for cluster modification
properties:
name:
type: string
description: Name for the cluster
owner:
type: string
description: Name of the organization owning the cluster
release_version:
type: string
description: Release version to use after an upgrade
workers:
type: array
description: Worker node array
items:
$ref: '#/definitions/V4NodeDefinition'
# Details on existing cluster
V4ClusterDetailsResponse:
type: object
description: Response model showing details of a cluster
properties:
id:
type: string
description: Unique cluster identifier
api_endpoint:
type: string
description: URI of the Kubernetes API endpoint
create_date:
type: string
description: Date/time of cluster creation
owner:
type: string
description: Name of the organization owning the cluster
name:
type: string
description: Cluster name
release_version:
type: string
description: |
The [release](https://docs.giantswarm.io/api/#tag/releases) version
currently running this cluster.
kubernetes_version:
type: string
description: Deprecated. Will be removed in a future API version.
workers:
type: array
items:
$ref: '#/definitions/V4NodeDefinition'
kvm:
type: object
description: Attributes specific to clusters running on KVM (on-prem) installations.
properties:
port_mappings:
type: array
description: |
Reveals the ports on the host cluster that are mapped to this guest cluster's ingress
and which protocol that port supports. Only shown and relevant on our on-prem KVM clusters.
items:
type: object
properties:
port:
description: |
The port on the host cluster that will forward traffic to the guest cluster
type: integer
protocol:
description: |
The protocol this port mapping is made for.
type: string
# Definition of a cluster node
V4NodeDefinition:
type: object
properties:
aws:
type: object
description: |
Attributes specific to nodes running on Amazon Web Services (AWS)
properties:
instance_type:
type: string
description: |
EC2 instance type name. Must be the same for all worker nodes
of a cluster.
azure:
type: object
description: |
Attributes specific to nodes running on Microsoft Azure
properties:
vm_size:
type: string
description: |
Azure Virtual Machine size. Must be the same for all worker nodes
of a cluster.
memory:
type: object
properties:
size_gb:
type: number
description: RAM size in GB. Can be an integer or float.
storage:
type: object
properties:
size_gb:
type: number
description: Node storage size in GB. Can be an integer or float.
cpu:
type: object
properties:
cores:
type: integer
description: Number of CPU cores
labels:
type: object
additionalProperties: true
# List of key pairs
V4GetKeyPairsResponse:
type: array
description: Array of sparse key pair objects
items:
type: object
properties:
id:
type: string
description: Unique identifier of the key pair
description:
type: string
description: Free text information about the key pair
ttl_hours:
type: integer
description: Expiration time (from creation) in hours
create_date:
type: string
description: Date/time of creation
common_name:
type: string
description: The common name of the certificate subject.
certificate_organizations:
type: string
description: The certificate subject's `organization` fields.
# Add key pair request
V4AddKeyPairRequest:
type: object
required:
- description
properties:
description:
type: string
description: Free text information about the key pair
ttl_hours:
type: integer
format: int32
description: Expiration time (from creation) in hours
cn_prefix:
type: string
description: The common name prefix of the certificate subject. This only allows characters that are usable in domain names (`a-z`, `0-9`, and `.-`, where `.-` must not occur at either the start or the end).
certificate_organizations:
type: string
description: |
This will set the certificate subject's `organization` fields.
Use a comma seperated list of values.
V4AddKeyPairResponse:
type: object
properties:
id:
type: string
description: Unique identifier of the key pair
description:
type: string
description: Free text information about the key pair
ttl_hours:
type: integer
description: Expiration time (from creation) in hours
create_date:
type: string
description: Date/time of creation
certificate_authority_data:
type: string
description: PEM-encoded CA certificate of the cluster
client_key_data:
type: string
description: PEM-encoded RSA private key
client_certificate_data:
type: string
description: PEM-encoded certificate
# cluster metrics
V4GetClusterMetricsResponse:
description: Response for the getClusterMetrics operation
type: object
properties:
workers:
description: Group of metrics regarding workers
type: array
items:
$ref: '#/definitions/V4NodeMetrics'
V4NodeMetrics:
type: object
properties:
id:
description: String identifying the node
type: string
metrics:
description: Container object for all metrics available for the node
type: object
properties:
container_count:
type: object
properties:
timestamp:
description: Time when the given value has been recorded
type: string
value:
description: The value for the metric. Can be an integer or float.
type: number
pod_count:
type: object
properties:
timestamp:
description: Time when the given value has been recorded
type: string
value:
description: The value for the metric. Can be an integer or float.
type: number
cpu_used:
type: object
properties:
timestamp:
description: Time when the given value has been recorded
type: string
value:
description: The value for the metric. Can be an integer or float.
type: number
ram_free:
type: object
properties:
timestamp:
description: Time when the given value has been recorded
type: string
value:
description: The value for the metric. Can be an integer or float.
type: number
ram_available:
type: object
properties:
timestamp:
description: Time when the given value has been recorded
type: string
value:
description: The value for the metric. Can be an integer or float.
type: number
ram_cached:
type: object
properties:
timestamp:
description: Time when the given value has been recorded
type: string
value:
description: The value for the metric. Can be an integer or float.
type: number
ram_buffers:
type: object
properties:
timestamp:
description: Time when the given value has been recorded
type: string
value:
description: The value for the metric. Can be an integer or float.
type: number
ram_mapped:
type: object
properties:
timestamp:
description: Time when the given value has been recorded
type: string
value:
description: The value for the metric. Can be an integer or float.
type: number
node_storage_used:
type: object
properties:
timestamp:
description: Time when the given value has been recorded
type: string
value:
description: The value for the metric. Can be an integer or float.
type: number
network_rx:
type: object
properties:
timestamp:
description: Time when the given value has been recorded
type: string
value:
description: The value for the metric. Can be an integer or float.
type: number
network_tx:
type: object
properties:
timestamp:
description: Time when the given value has been recorded
type: string
value:
description: The value for the metric. Can be an integer or float.
type: number
resource_cpu_requests:
type: object
properties:
timestamp:
description: Time when the given value has been recorded
type: string
value:
description: The value for the metric. Can be an integer or float.
type: number
resource_cpu_limits:
type: object
properties:
timestamp:
description: Time when the given value has been recorded
type: string
value:
description: The value for the metric. Can be an integer or float.
type: number
resource_ram_requests:
type: object
properties:
timestamp:
description: Time when the given value has been recorded
type: string
value:
description: The value for the metric. Can be an integer or float.
type: number
resource_ram_limits:
type: object
properties:
timestamp:
description: Time when the given value has been recorded
type: string
value:
description: The value for the metric. Can be an integer or float.
type: number
# a complete organization object
V4Organization:
type: object
properties:
id:
type: string
description: Unique name/identifier of the organization
members:
type: array
description: List of members that belong to this organization
items:
$ref: '#/definitions/V4OrganizationMember'
# An organization as returned by getOrganizations as an array item
V4OrganizationListItem:
type: object
properties:
id:
type: string
description: Unique name/identifier of the organization
# A user that belongs to an organization
V4OrganizationMember:
type: object
properties:
email:
type: string
description: Email address of the user
# One of the users in the array as returned by getUsers
V4UserListItem:
type: object
properties:
email:
type: string
description: Email address of the user
created:
type: string
description: The date and time that this account was created
expiry:
type: string
description: The date and time when this account will expire
# A cluster array item, as return by getClusters
V4ClusterListItem:
type: object
properties:
id:
type: string
description: Unique cluster identifier
create_date:
type: string
description: Date/time of cluster creation
name:
type: string
description: Cluster name
owner:
type: string
description: Name of the organization owning the cluster
release_version:
type: string
description: The semantic version number of this cluster
# A cluster array item, as return by getClusters
V4ReleaseListItem:
type: object
required: ["version", "timestamp", "changelog", "components"]
properties:
version:
type: string
description: The semantic version number
timestamp:
type: string
description: Date and time of the release creation
active:
type: boolean
description: |
If true, the version is available for new clusters and cluster
upgrades. Older versions become unavailable and thus have the
value `false` here.
changelog:
description: |
Structured list of changes in this release, in comparison to the
previous version, with respect to the contained components.
type: array
items:
type: object
properties:
component:
type: string
description: |
If the changed item was a component, this attribute is the
name of the component.
description:
type: string
description: Human-friendly description of the change
components:
description: |
List of components and their version contained in the release
type: array
items:
type: object
required: ["name", "version"]
properties:
name:
type: string
description: Name of the component
version:
type: string
description: Version number of the component
V4CreateUserRequest:
type: object
required:
- password
description: Request model for creating a new user
properties:
password:
type: string
description: A Base64 encoded password
expiry:
type: string
description: The date and time when this account will expire
V4AddCredentialsRequest:
type: object
required:
- provider
description: Request model for adding a set of credentials
properties:
provider:
type: string
aws:
type: object
description: Credentials specific to an AWS account
required:
- roles
properties:
roles:
type: object
description: IAM roles to assume by certain entities
required:
- awsoperator
- admin
properties:
admin:
type: string
description: ARN of the IAM role to assume by Giant Swarm support staff
awsoperator:
type: string
description: ARN of the IAM role to assume by the software operating clusters
# A request for an auth token
V4CreateAuthTokenRequest:
type: object
properties:
email:
type: string
description: Your email address
password_base64:
type: string
description: Your password as a base64 encoded string
# A response to a successful auth token request
V4CreateAuthTokenResponse:
type: object
properties:
auth_token:
type: string
description: The newly created API token

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,61 @@
parameters:
RequiredGiantSwarmAuthorizationHeader:
name: Authorization
type: string
in: header
required: true
description: As described in the [authentication](#section/Authentication) section
ClusterIdPathParameter:
name: cluster_id
in: path
required: true
type: string
description: Cluster ID
UserEmailPathParameter:
name: email
in: path
required: true
type: string
description: The user's email address
OrganizationIdPathParameter:
name: organization_id
in: path
required: true
type: string
description: |
An ID for the organization.
This ID must be unique and match this regular
expression: ^[a-z0-9_]{4,30}$
XRequestIDHeader:
name: X-Request-ID
in: header
type: string
required: false
description: |
A randomly generated key that can be used to track a request throughout
services of Giant Swarm.
XGiantSwarmActivityHeader:
name: X-Giant-Swarm-Activity
in: header
type: string
required: false
description: |
Name of an activity to track, like "list-clusters". This allows to
analyze several API requests sent in context and gives an idea on
the purpose.
XGiantSwarmCmdLineHeader:
name: X-Giant-Swarm-CmdLine
in: header
type: string
required: false
description: |
If activity has been issued by a CLI, this header can contain the
command line

View File

@@ -0,0 +1,13 @@
responses:
V4Generic401Response:
description: Permission denied
schema:
$ref: "./definitions.yaml#/definitions/V4GenericResponse"
examples:
application/json:
{
"code": "PERMISSION_DENIED",
"message": "The requested resource cannot be accessed using the provided authentication details."
}

16
vendor/github.com/go-openapi/spec/go.mod generated vendored Normal file
View File

@@ -0,0 +1,16 @@
module github.com/go-openapi/spec
require (
github.com/PuerkitoBio/purell v1.1.0 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-openapi/jsonpointer v0.17.0
github.com/go-openapi/jsonreference v0.17.0
github.com/go-openapi/swag v0.17.0
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/testify v1.2.2
golang.org/x/net v0.0.0-20181005035420-146acd28ed58 // indirect
golang.org/x/text v0.3.0 // indirect
gopkg.in/yaml.v2 v2.2.1
)

22
vendor/github.com/go-openapi/spec/go.sum generated vendored Normal file
View File

@@ -0,0 +1,22 @@
github.com/PuerkitoBio/purell v1.1.0 h1:rmGxhojJlM0tuKtfdvliR84CFHljx9ag64t2xmVkjK4=
github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M=
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-openapi/jsonpointer v0.17.0 h1:Bpl2DtZ6k7wKqfFs7e+4P08+M9I3FQgn09a1UsRUQbk=
github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0=
github.com/go-openapi/jsonreference v0.17.0 h1:d/o7/fsLWWQZACbihvZxcyLQ59jfUVs7WOJv/ak7T7A=
github.com/go-openapi/jsonreference v0.17.0/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg=
github.com/go-openapi/swag v0.17.0 h1:7wu+dZ5k83kvUWeAb+WUkFiUhDzwGqzTR/NhWzeo1JU=
github.com/go-openapi/swag v0.17.0/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I=
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329 h1:2gxZ0XQIU/5z3Z3bUBu+FXuk2pFbkN6tcwi/pjyaDic=
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
golang.org/x/net v0.0.0-20181005035420-146acd28ed58 h1:otZG8yDCO4LVps5+9bxOeNiCvgmOyt96J3roHTYs7oE=
golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

View File

@@ -16,6 +16,7 @@ package spec_test
import (
"encoding/json"
"os"
"path/filepath"
"regexp"
"strings"
@@ -27,7 +28,10 @@ import (
)
// mimics what the go-openapi/load does
var yamlLoader = swag.YAMLDoc
var (
yamlLoader = swag.YAMLDoc
rex = regexp.MustCompile(`"\$ref":\s*"(.+)"`)
)
func loadOrFail(t *testing.T, path string) *spec.Swagger {
raw, erl := yamlLoader(path)
@@ -60,8 +64,6 @@ func Test_Issue1429(t *testing.T) {
t.FailNow()
return
}
//bbb, _ := json.MarshalIndent(sp, "", " ")
//t.Log(string(bbb))
// assert well expanded
if !assert.Truef(t, (sp.Paths != nil && sp.Paths.Paths != nil), "expected paths to be available in fixture") {
@@ -185,7 +187,6 @@ func Test_Issue69(t *testing.T) {
jazon, _ := json.MarshalIndent(sp, "", " ")
// assert all $ref maches "$ref": "#/definitions/something"
rex := regexp.MustCompile(`"\$ref":\s*"(.+)"`)
m := rex.FindAllStringSubmatch(string(jazon), -1)
if assert.NotNil(t, m) {
for _, matched := range m {
@@ -195,3 +196,74 @@ func Test_Issue69(t *testing.T) {
}
}
}
func Test_Issue1621(t *testing.T) {
prevPathLoader := spec.PathLoader
defer func() {
spec.PathLoader = prevPathLoader
}()
spec.PathLoader = yamlLoader
path := filepath.Join("fixtures", "bugs", "1621", "fixture-1621.yaml")
// expand with relative path
// load and expand
sp := loadOrFail(t, path)
err := spec.ExpandSpec(sp, &spec.ExpandOptions{RelativeBase: path, SkipSchemas: false})
if !assert.NoError(t, err) {
t.FailNow()
return
}
// asserts all $ref expanded
jazon, _ := json.MarshalIndent(sp, "", " ")
m := rex.FindAllStringSubmatch(string(jazon), -1)
assert.Nil(t, m)
}
func Test_Issue1614(t *testing.T) {
path := filepath.Join("fixtures", "bugs", "1614", "gitea.json")
// expand with relative path
// load and expand
sp := loadOrFail(t, path)
err := spec.ExpandSpec(sp, &spec.ExpandOptions{RelativeBase: path, SkipSchemas: false})
if !assert.NoError(t, err) {
t.FailNow()
return
}
// asserts all $ref expanded
jazon, _ := json.MarshalIndent(sp, "", " ")
// assert all $ref maches "$ref": "#/definitions/something"
m := rex.FindAllStringSubmatch(string(jazon), -1)
if assert.NotNil(t, m) {
for _, matched := range m {
subMatch := matched[1]
assert.True(t, strings.HasPrefix(subMatch, "#/definitions/"),
"expected $ref to be inlined, got: %s", matched[0])
}
}
// now with option CircularRefAbsolute
sp = loadOrFail(t, path)
err = spec.ExpandSpec(sp, &spec.ExpandOptions{RelativeBase: path, SkipSchemas: false, AbsoluteCircularRef: true})
if !assert.NoError(t, err) {
t.FailNow()
return
}
// asserts all $ref expanded
jazon, _ = json.MarshalIndent(sp, "", " ")
// assert all $ref maches "$ref": "{file path}#/definitions/something"
refPath, _ := os.Getwd()
refPath = filepath.Join(refPath, path)
m = rex.FindAllStringSubmatch(string(jazon), -1)
if assert.NotNil(t, m) {
for _, matched := range m {
subMatch := matched[1]
assert.True(t, strings.HasPrefix(subMatch, refPath+"#/definitions/"),
"expected $ref to be inlined, got: %s", matched[0])
}
}
}