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
f645d77f
Commit
f645d77f
authored
Nov 23, 2015
by
Tim St. Clair
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clarify when pointers are used for optional types
parent
315b9000
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
+4
-2
api-conventions.md
docs/devel/api-conventions.md
+4
-2
No files found.
docs/devel/api-conventions.md
View file @
f645d77f
...
@@ -387,7 +387,8 @@ Fields must be either optional or required.
...
@@ -387,7 +387,8 @@ Fields must be either optional or required.
Optional fields have the following properties:
Optional fields have the following properties:
-
They have
`omitempty`
struct tag in Go.
-
They have
`omitempty`
struct tag in Go.
-
They are a pointer type in the Go definition (e.g.
`bool *awesomeFlag`
).
-
They are a pointer type in the Go definition (e.g.
`bool *awesomeFlag`
) or have a built-in
`nil`
value (e.g. maps and slices).
-
The API server should allow POSTing and PUTing a resource with this field unset.
-
The API server should allow POSTing and PUTing a resource with this field unset.
Required fields have the opposite properties, namely:
Required fields have the opposite properties, namely:
...
@@ -409,7 +410,8 @@ codebase. However:
...
@@ -409,7 +410,8 @@ codebase. However:
-
having a pointer consistently imply optional is clearer for users of the Go language client, and any
-
having a pointer consistently imply optional is clearer for users of the Go language client, and any
other clients that use corresponding types
other clients that use corresponding types
Therefore, we ask that pointers always be used with optional fields.
Therefore, we ask that pointers always be used with optional fields that do not have a built-in
`nil`
value.
## Defaulting
## Defaulting
...
...
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