mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
[Docs] Add enum type (#1364)
This commit is contained in:
parent
89499203eb
commit
7d513cca72
5 changed files with 686 additions and 684 deletions
2
Makefile
2
Makefile
|
@ -624,6 +624,8 @@ set-api-version/%:
|
|||
| cut -d ':' -f 1 | sort | uniq \
|
||||
| xargs -n 1 $(SED) -i "s#ReplicationV[A-Za-z0-9]\+()\.#ReplicationV$(API_VERSION)().#g"
|
||||
|
||||
synchronize: synchronize-v2alpha1-with-v1
|
||||
|
||||
synchronize-v2alpha1-with-v1:
|
||||
@rm -f pkg/apis/deployment/v1/zz_generated.deepcopy.go pkg/apis/deployment/v2alpha1/zz_generated.deepcopy.go
|
||||
@for file in $$(find "$(ROOT)/pkg/apis/deployment/v1/" -type f -exec $(REALPATH) --relative-to "$(ROOT)/pkg/apis/deployment/v1/" {} \;); do if [ ! -d "$(ROOT)/pkg/apis/deployment/v2alpha1/$$(dirname $${file})" ]; then mkdir -p "$(ROOT)/pkg/apis/deployment/v2alpha1/$$(dirname $${file})"; fi; done
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -53,8 +53,9 @@ func (d DocDefinitions) Render(t *testing.T) []byte {
|
|||
|
||||
if len(el.Docs) > 0 {
|
||||
for _, doc := range el.Docs {
|
||||
write(t, out, "%s\n\n", doc)
|
||||
write(t, out, "%s\n", doc)
|
||||
}
|
||||
write(t, out, "\n")
|
||||
}
|
||||
|
||||
if len(el.Links) > 0 {
|
||||
|
@ -83,11 +84,31 @@ func (d DocDefinitions) Render(t *testing.T) []byte {
|
|||
write(t, out, "```\n\n")
|
||||
}
|
||||
|
||||
if d := el.Default; d != nil {
|
||||
write(t, out, "Default Value: %s\n\n", *d)
|
||||
if len(el.Enum) > 0 {
|
||||
write(t, out, "Possible Values: \n")
|
||||
for id, enum := range el.Enum {
|
||||
z := strings.Split(enum, "|")
|
||||
|
||||
if id == 0 {
|
||||
z[0] = fmt.Sprintf("%s (default)", z[0])
|
||||
}
|
||||
|
||||
if len(z) == 1 {
|
||||
write(t, out, "* %s\n", z[0])
|
||||
} else if len(z) == 2 {
|
||||
write(t, out, "* %s - %s\n", z[0], z[1])
|
||||
} else {
|
||||
require.Fail(t, "Invalid enum format")
|
||||
}
|
||||
}
|
||||
write(t, out, "\n")
|
||||
} else {
|
||||
if d := el.Default; d != nil {
|
||||
write(t, out, "Default Value: %s\n\n", *d)
|
||||
}
|
||||
}
|
||||
|
||||
write(t, out, "Code Reference: [%s:%d](/%s#L%d)\n\n", filepath.Base(el.File), el.Line, el.File, el.Line)
|
||||
write(t, out, "[Code Reference](/%s#L%d)\n\n", el.File, el.Line)
|
||||
}
|
||||
|
||||
return out.Bytes()
|
||||
|
@ -104,6 +125,8 @@ type DocDefinition struct {
|
|||
|
||||
Links []string
|
||||
|
||||
Enum []string
|
||||
|
||||
Default *string
|
||||
Example []string
|
||||
}
|
||||
|
@ -172,6 +195,10 @@ func generateDocs(t *testing.T, objects map[string]map[string]interface{}, paths
|
|||
def.Example = example
|
||||
}
|
||||
|
||||
if enum, ok := extract(field, "enum"); ok {
|
||||
def.Enum = enum
|
||||
}
|
||||
|
||||
if docs, ok := extractNotTags(field); !ok {
|
||||
println(def.Path, " is missing documentation!")
|
||||
} else {
|
||||
|
|
|
@ -111,15 +111,20 @@ const (
|
|||
|
||||
// DeploymentSpec contains the spec part of a ArangoDeployment resource.
|
||||
type DeploymentSpec struct {
|
||||
Mode *DeploymentMode `json:"mode,omitempty"`
|
||||
Environment *Environment `json:"environment,omitempty"`
|
||||
StorageEngine *StorageEngine `json:"storageEngine,omitempty"`
|
||||
Image *string `json:"image,omitempty"`
|
||||
ImagePullPolicy *core.PullPolicy `json:"imagePullPolicy,omitempty"`
|
||||
ImagePullSecrets []string `json:"imagePullSecrets,omitempty"`
|
||||
Mode *DeploymentMode `json:"mode,omitempty"`
|
||||
Environment *Environment `json:"environment,omitempty"`
|
||||
StorageEngine *StorageEngine `json:"storageEngine,omitempty"`
|
||||
Image *string `json:"image,omitempty"`
|
||||
ImagePullPolicy *core.PullPolicy `json:"imagePullPolicy,omitempty"`
|
||||
ImagePullSecrets []string `json:"imagePullSecrets,omitempty"`
|
||||
|
||||
// ImageDiscoveryMode specifies the image discovery mode.
|
||||
// +doc/enum: kubelet|Use sha256 of the discovered image in the pods
|
||||
// +doc/enum: direct|Use image provided in the spec.image directly in the pods
|
||||
ImageDiscoveryMode *DeploymentImageDiscoveryModeSpec `json:"imageDiscoveryMode,omitempty"`
|
||||
DowntimeAllowed *bool `json:"downtimeAllowed,omitempty"`
|
||||
DisableIPv6 *bool `json:"disableIPv6,omitempty"`
|
||||
|
||||
DowntimeAllowed *bool `json:"downtimeAllowed,omitempty"`
|
||||
DisableIPv6 *bool `json:"disableIPv6,omitempty"`
|
||||
|
||||
Upgrade *DeploymentUpgradeSpec `json:"upgrade,omitempty"`
|
||||
|
||||
|
|
|
@ -111,15 +111,20 @@ const (
|
|||
|
||||
// DeploymentSpec contains the spec part of a ArangoDeployment resource.
|
||||
type DeploymentSpec struct {
|
||||
Mode *DeploymentMode `json:"mode,omitempty"`
|
||||
Environment *Environment `json:"environment,omitempty"`
|
||||
StorageEngine *StorageEngine `json:"storageEngine,omitempty"`
|
||||
Image *string `json:"image,omitempty"`
|
||||
ImagePullPolicy *core.PullPolicy `json:"imagePullPolicy,omitempty"`
|
||||
ImagePullSecrets []string `json:"imagePullSecrets,omitempty"`
|
||||
Mode *DeploymentMode `json:"mode,omitempty"`
|
||||
Environment *Environment `json:"environment,omitempty"`
|
||||
StorageEngine *StorageEngine `json:"storageEngine,omitempty"`
|
||||
Image *string `json:"image,omitempty"`
|
||||
ImagePullPolicy *core.PullPolicy `json:"imagePullPolicy,omitempty"`
|
||||
ImagePullSecrets []string `json:"imagePullSecrets,omitempty"`
|
||||
|
||||
// ImageDiscoveryMode specifies the image discovery mode.
|
||||
// +doc/enum: kubelet|Use sha256 of the discovered image in the pods
|
||||
// +doc/enum: direct|Use image provided in the spec.image directly in the pods
|
||||
ImageDiscoveryMode *DeploymentImageDiscoveryModeSpec `json:"imageDiscoveryMode,omitempty"`
|
||||
DowntimeAllowed *bool `json:"downtimeAllowed,omitempty"`
|
||||
DisableIPv6 *bool `json:"disableIPv6,omitempty"`
|
||||
|
||||
DowntimeAllowed *bool `json:"downtimeAllowed,omitempty"`
|
||||
DisableIPv6 *bool `json:"disableIPv6,omitempty"`
|
||||
|
||||
Upgrade *DeploymentUpgradeSpec `json:"upgrade,omitempty"`
|
||||
|
||||
|
|
Loading…
Reference in a new issue