Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
88cc794c
Commit
88cc794c
authored
Jan 19, 2017
by
Dr. Stefan Schimanski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
genericapiserver: get rid of pkg/genericapiserver/server/openapi/common
parent
3d9449a3
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
5 additions
and
203 deletions
+5
-203
BUILD
pkg/apis/meta/v1/BUILD
+1
-1
time.go
pkg/apis/meta/v1/time.go
+3
-3
BUILD
pkg/genericapiserver/server/openapi/BUILD
+1
-4
.readonly
pkg/genericapiserver/server/openapi/common/.readonly
+0
-0
BUILD
pkg/genericapiserver/server/openapi/common/BUILD
+0
-34
common.go
pkg/genericapiserver/server/openapi/common/common.go
+0
-143
doc.go
pkg/genericapiserver/server/openapi/common/doc.go
+0
-18
No files found.
pkg/apis/meta/v1/BUILD
View file @
88cc794c
...
@@ -12,9 +12,9 @@ go_library(
...
@@ -12,9 +12,9 @@ go_library(
srcs = ["time.go"],
srcs = ["time.go"],
tags = ["automanaged"],
tags = ["automanaged"],
deps = [
deps = [
"//pkg/genericapiserver/server/openapi/common:go_default_library",
"//vendor:github.com/go-openapi/spec",
"//vendor:github.com/go-openapi/spec",
"//vendor:github.com/google/gofuzz",
"//vendor:github.com/google/gofuzz",
"//vendor:k8s.io/apimachinery/pkg/openapi",
],
],
)
)
...
...
pkg/apis/meta/v1/time.go
View file @
88cc794c
...
@@ -20,7 +20,7 @@ import (
...
@@ -20,7 +20,7 @@ import (
"encoding/json"
"encoding/json"
"time"
"time"
"k8s.io/
kubernetes/pkg/genericapiserver/server/openapi/common
"
"k8s.io/
apimachinery/pkg/openapi
"
"github.com/go-openapi/spec"
"github.com/go-openapi/spec"
"github.com/google/gofuzz"
"github.com/google/gofuzz"
...
@@ -145,8 +145,8 @@ func (t Time) MarshalJSON() ([]byte, error) {
...
@@ -145,8 +145,8 @@ func (t Time) MarshalJSON() ([]byte, error) {
return
json
.
Marshal
(
t
.
UTC
()
.
Format
(
time
.
RFC3339
))
return
json
.
Marshal
(
t
.
UTC
()
.
Format
(
time
.
RFC3339
))
}
}
func
(
_
Time
)
OpenAPIDefinition
()
common
.
OpenAPIDefinition
{
func
(
_
Time
)
OpenAPIDefinition
()
openapi
.
OpenAPIDefinition
{
return
common
.
OpenAPIDefinition
{
return
openapi
.
OpenAPIDefinition
{
Schema
:
spec
.
Schema
{
Schema
:
spec
.
Schema
{
SchemaProps
:
spec
.
SchemaProps
{
SchemaProps
:
spec
.
SchemaProps
{
Type
:
[]
string
{
"string"
},
Type
:
[]
string
{
"string"
},
...
...
pkg/genericapiserver/server/openapi/BUILD
View file @
88cc794c
...
@@ -48,9 +48,6 @@ filegroup(
...
@@ -48,9 +48,6 @@ filegroup(
filegroup(
filegroup(
name = "all-srcs",
name = "all-srcs",
srcs = [
srcs = [":package-srcs"],
":package-srcs",
"//pkg/genericapiserver/server/openapi/common:all-srcs",
],
tags = ["automanaged"],
tags = ["automanaged"],
)
)
pkg/genericapiserver/server/openapi/common/.readonly
deleted
100644 → 0
View file @
3d9449a3
pkg/genericapiserver/server/openapi/common/BUILD
deleted
100644 → 0
View file @
3d9449a3
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"common.go",
"doc.go",
],
tags = ["automanaged"],
deps = [
"//vendor:github.com/emicklei/go-restful",
"//vendor:github.com/go-openapi/spec",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
)
pkg/genericapiserver/server/openapi/common/common.go
deleted
100644 → 0
View file @
3d9449a3
/*
Copyright 2016 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
common
import
(
"github.com/emicklei/go-restful"
"github.com/go-openapi/spec"
)
// OpenAPIDefinition describes single type. Normally these definitions are auto-generated using gen-openapi.
type
OpenAPIDefinition
struct
{
Schema
spec
.
Schema
Dependencies
[]
string
}
// OpenAPIDefinitions is collection of all definitions.
type
OpenAPIDefinitions
map
[
string
]
OpenAPIDefinition
// OpenAPIDefinitionGetter gets openAPI definitions for a given type. If a type implements this interface,
// the definition returned by it will be used, otherwise the auto-generated definitions will be used. See
// GetOpenAPITypeFormat for more information about trade-offs of using this interface or GetOpenAPITypeFormat method when
// possible.
type
OpenAPIDefinitionGetter
interface
{
OpenAPIDefinition
()
*
OpenAPIDefinition
}
// Config is set of configuration for openAPI spec generation.
type
Config
struct
{
// List of supported protocols such as https, http, etc.
ProtocolList
[]
string
// Info is general information about the API.
Info
*
spec
.
Info
// DefaultResponse will be used if an operation does not have any responses listed. It
// will show up as ... "responses" : {"default" : $DefaultResponse} in the spec.
DefaultResponse
*
spec
.
Response
// CommonResponses will be added as a response to all operation specs. This is a good place to add common
// responses such as authorization failed.
CommonResponses
map
[
int
]
spec
.
Response
// List of webservice's path prefixes to ignore
IgnorePrefixes
[]
string
// OpenAPIDefinitions should provide definition for all models used by routes. Failure to provide this map
// or any of the models will result in spec generation failure.
Definitions
*
OpenAPIDefinitions
// GetOperationIDAndTags returns operation id and tags for a restful route. It is an optional function to customize operation IDs.
GetOperationIDAndTags
func
(
servePath
string
,
r
*
restful
.
Route
)
(
string
,
[]
string
,
error
)
// SecurityDefinitions is list of all security definitions for OpenAPI service. If this is not nil, the user of config
// is responsible to provide DefaultSecurity and (maybe) add unauthorized response to CommonResponses.
SecurityDefinitions
*
spec
.
SecurityDefinitions
// DefaultSecurity for all operations. This will pass as spec.SwaggerProps.Security to OpenAPI.
// For most cases, this will be list of acceptable definitions in SecurityDefinitions.
DefaultSecurity
[]
map
[
string
][]
string
}
// This function is a reference for converting go (or any custom type) to a simple open API type,format pair. There are
// two ways to customize spec for a type. If you add it here, a type will be converted to a simple type and the type
// comment (the comment that is added before type definition) will be lost. The spec will still have the property
// comment. The second way is to implement OpenAPIDefinitionGetter interface. That function can customize the spec (so
// the spec does not need to be simple type,format) or can even return a simple type,format (e.g. IntOrString). For simple
// type formats, the benefit of adding OpenAPIDefinitionGetter interface is to keep both type and property documentation.
// Example:
// type Sample struct {
// ...
// // port of the server
// port IntOrString
// ...
// }
// // IntOrString documentation...
// type IntOrString { ... }
//
// Adding IntOrString to this function:
// "port" : {
// format: "string",
// type: "int-or-string",
// Description: "port of the server"
// }
//
// Implement OpenAPIDefinitionGetter for IntOrString:
//
// "port" : {
// $Ref: "#/definitions/IntOrString"
// Description: "port of the server"
// }
// ...
// definitions:
// {
// "IntOrString": {
// format: "string",
// type: "int-or-string",
// Description: "IntOrString documentation..." // new
// }
// }
//
func
GetOpenAPITypeFormat
(
typeName
string
)
(
string
,
string
)
{
schemaTypeFormatMap
:=
map
[
string
][]
string
{
"uint"
:
{
"integer"
,
"int32"
},
"uint8"
:
{
"integer"
,
"byte"
},
"uint16"
:
{
"integer"
,
"int32"
},
"uint32"
:
{
"integer"
,
"int64"
},
"uint64"
:
{
"integer"
,
"int64"
},
"int"
:
{
"integer"
,
"int32"
},
"int8"
:
{
"integer"
,
"byte"
},
"int16"
:
{
"integer"
,
"int32"
},
"int32"
:
{
"integer"
,
"int32"
},
"int64"
:
{
"integer"
,
"int64"
},
"byte"
:
{
"integer"
,
"byte"
},
"float64"
:
{
"number"
,
"double"
},
"float32"
:
{
"number"
,
"float"
},
"bool"
:
{
"boolean"
,
""
},
"time.Time"
:
{
"string"
,
"date-time"
},
"string"
:
{
"string"
,
""
},
"integer"
:
{
"integer"
,
""
},
"number"
:
{
"number"
,
""
},
"boolean"
:
{
"boolean"
,
""
},
"[]byte"
:
{
"string"
,
"byte"
},
// base64 encoded characters
}
mapped
,
ok
:=
schemaTypeFormatMap
[
typeName
]
if
!
ok
{
return
""
,
""
}
return
mapped
[
0
],
mapped
[
1
]
}
pkg/genericapiserver/server/openapi/common/doc.go
deleted
100644 → 0
View file @
3d9449a3
/*
Copyright 2016 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// package common holds shared codes and types between open API code generator and spec generator.
package
common
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment