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
6ba271b9
Commit
6ba271b9
authored
Sep 01, 2016
by
mbohlool
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Customize OpenAPI definition types
customize intstr, unversioned.time, and quantity OpenAPI definitions.
parent
54fee8c2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
0 deletions
+43
-0
quantity.go
pkg/api/resource/quantity.go
+14
-0
time.go
pkg/api/unversioned/time.go
+14
-0
intstr.go
pkg/util/intstr/intstr.go
+15
-0
No files found.
pkg/api/resource/quantity.go
View file @
6ba271b9
...
...
@@ -27,7 +27,9 @@ import (
flag
"github.com/spf13/pflag"
"github.com/go-openapi/spec"
inf
"gopkg.in/inf.v0"
"k8s.io/kubernetes/cmd/libs/go2idl/openapi-gen/generators/common"
)
// Quantity is a fixed-point representation of a number.
...
...
@@ -395,6 +397,18 @@ func (q Quantity) DeepCopy() Quantity {
return
q
}
// OpenAPIDefinition returns openAPI definition for this type.
func
(
_
Quantity
)
OpenAPIDefinition
()
common
.
OpenAPIDefinition
{
return
common
.
OpenAPIDefinition
{
Schema
:
spec
.
Schema
{
SchemaProps
:
spec
.
SchemaProps
{
Type
:
[]
string
{
"string"
},
Format
:
""
,
},
},
}
}
// CanonicalizeBytes returns the canonical form of q and its suffix (see comment on Quantity).
//
// Note about BinarySI:
...
...
pkg/api/unversioned/time.go
View file @
6ba271b9
...
...
@@ -20,6 +20,9 @@ import (
"encoding/json"
"time"
"k8s.io/kubernetes/cmd/libs/go2idl/openapi-gen/generators/common"
"github.com/go-openapi/spec"
"github.com/google/gofuzz"
)
...
...
@@ -142,6 +145,17 @@ func (t Time) MarshalJSON() ([]byte, error) {
return
json
.
Marshal
(
t
.
UTC
()
.
Format
(
time
.
RFC3339
))
}
func
(
_
Time
)
OpenAPIDefinition
()
common
.
OpenAPIDefinition
{
return
common
.
OpenAPIDefinition
{
Schema
:
spec
.
Schema
{
SchemaProps
:
spec
.
SchemaProps
{
Type
:
[]
string
{
"string"
},
Format
:
"date-time"
,
},
},
}
}
// MarshalQueryParameter converts to a URL query parameter value
func
(
t
Time
)
MarshalQueryParameter
()
(
string
,
error
)
{
if
t
.
IsZero
()
{
...
...
pkg/util/intstr/intstr.go
View file @
6ba271b9
...
...
@@ -23,6 +23,9 @@ import (
"strconv"
"strings"
"k8s.io/kubernetes/cmd/libs/go2idl/openapi-gen/generators/common"
"github.com/go-openapi/spec"
"github.com/google/gofuzz"
)
...
...
@@ -34,6 +37,7 @@ import (
//
// +protobuf=true
// +protobuf.options.(gogoproto.goproto_stringer)=false
// +k8s:openapi-gen=true
type
IntOrString
struct
{
Type
Type
`protobuf:"varint,1,opt,name=type,casttype=Type"`
IntVal
int32
`protobuf:"varint,2,opt,name=intVal"`
...
...
@@ -101,6 +105,17 @@ func (intstr IntOrString) MarshalJSON() ([]byte, error) {
}
}
func
(
_
IntOrString
)
OpenAPIDefinition
()
common
.
OpenAPIDefinition
{
return
common
.
OpenAPIDefinition
{
Schema
:
spec
.
Schema
{
SchemaProps
:
spec
.
SchemaProps
{
Type
:
[]
string
{
"string"
},
Format
:
"int-or-string"
,
},
},
}
}
func
(
intstr
*
IntOrString
)
Fuzz
(
c
fuzz
.
Continue
)
{
if
intstr
==
nil
{
return
...
...
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