From a97913235ac7a2450f4af29a7dbc277269050bc5 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Wed, 3 Jan 2018 11:35:18 -0700 Subject: [PATCH] Add description to things --- apis/cluster.cattle.io/v3/schema/schema.go | 5 ++- apis/management.cattle.io/v3/authz_types.go | 6 ++- apis/management.cattle.io/v3/catalog_types.go | 1 + apis/management.cattle.io/v3/machine_types.go | 2 +- apis/project.cattle.io/v3/schema/schema.go | 27 ++++++++---- .../v3/schema/schema_secrets.go | 5 ++- apis/project.cattle.io/v3/types.go | 43 +++++++++++-------- 7 files changed, 59 insertions(+), 30 deletions(-) diff --git a/apis/cluster.cattle.io/v3/schema/schema.go b/apis/cluster.cattle.io/v3/schema/schema.go index 3a16c1d3..967d304d 100644 --- a/apis/cluster.cattle.io/v3/schema/schema.go +++ b/apis/cluster.cattle.io/v3/schema/schema.go @@ -55,6 +55,7 @@ func NodeTypes(version *types.APIVersion, schemas *types.Schemas) *types.Schemas "unschedulable": "ru", }}). AddMapperForType(version, v1.Node{}, + &m.AnnotationField{Field: "description"}, &m.Embed{Field: "status"}, ). MustImport(version, v1.NodeStatus{}, struct { @@ -62,7 +63,9 @@ func NodeTypes(version *types.APIVersion, schemas *types.Schemas) *types.Schemas Hostname string Info NodeInfo }{}). - MustImport(version, v1.Node{}) + MustImport(version, v1.Node{}, struct { + Description string `json:"description"` + }{}) } func volumeTypes(schemas *types.Schemas) *types.Schemas { diff --git a/apis/management.cattle.io/v3/authz_types.go b/apis/management.cattle.io/v3/authz_types.go index e7bf0f62..4999572e 100644 --- a/apis/management.cattle.io/v3/authz_types.go +++ b/apis/management.cattle.io/v3/authz_types.go @@ -44,6 +44,7 @@ type ProjectCondition struct { type ProjectSpec struct { DisplayName string `json:"displayName,omitempty" norman:"required"` + Description string `json:"description"` ClusterName string `json:"clusterName,omitempty" norman:"required,type=reference[cluster]"` PodSecurityPolicyTemplateName string `json:"podSecurityPolicyTemplateName,omitempty" norman:"type=reference[podSecurityPolicyTemplate]"` } @@ -53,6 +54,7 @@ type GlobalRole struct { metav1.ObjectMeta `json:"metadata,omitempty"` DisplayName string `json:"displayName,omitempty" norman:"required"` + Description string `json:"description"` Rules []rbacv1.PolicyRule `json:"rules,omitempty"` Builtin bool `json:"builtin"` } @@ -70,6 +72,7 @@ type RoleTemplate struct { metav1.ObjectMeta `json:"metadata,omitempty"` DisplayName string `json:"displayName,omitempty" norman:"required"` + Description string `json:"description"` Rules []rbacv1.PolicyRule `json:"rules,omitempty"` Builtin bool `json:"builtin"` External bool `json:"external"` @@ -81,7 +84,8 @@ type PodSecurityPolicyTemplate struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - Spec extv1.PodSecurityPolicySpec `json:"spec,omitempty"` + Description string `json:"description"` + Spec extv1.PodSecurityPolicySpec `json:"spec,omitempty"` } type ProjectRoleTemplateBinding struct { diff --git a/apis/management.cattle.io/v3/catalog_types.go b/apis/management.cattle.io/v3/catalog_types.go index 920ac2a5..f0295b4f 100644 --- a/apis/management.cattle.io/v3/catalog_types.go +++ b/apis/management.cattle.io/v3/catalog_types.go @@ -16,6 +16,7 @@ type Catalog struct { } type CatalogSpec struct { + Description string `json:"description"` URL string `json:"url,omitempty"` Branch string `json:"branch,omitempty"` CatalogKind string `json:"catalogKind,omitempty"` diff --git a/apis/management.cattle.io/v3/machine_types.go b/apis/management.cattle.io/v3/machine_types.go index a05327c3..8ad0f8aa 100644 --- a/apis/management.cattle.io/v3/machine_types.go +++ b/apis/management.cattle.io/v3/machine_types.go @@ -93,12 +93,12 @@ type MachineCondition struct { type MachineSpec struct { NodeSpec v1.NodeSpec `json:"nodeSpec"` + Description string `json:"description,omitempty"` DisplayName string `json:"displayName,omitempty"` RequestedHostname string `json:"requestedHostname,omitempty" norman:"noupdate"` RequestedClusterName string `json:"requestedClusterName,omitempty" norman:"type=reference[cluster],noupdate"` RequestedRoles []string `json:"requestedRoles,omitempty" norman:"noupdate"` MachineTemplateName string `json:"machineTemplateName,omitempty" norman:"type=reference[machineTemplate],noupdate"` - Description string `json:"description,omitempty"` } type MachineCommonParams struct { diff --git a/apis/project.cattle.io/v3/schema/schema.go b/apis/project.cattle.io/v3/schema/schema.go index 55e71479..027a10ad 100644 --- a/apis/project.cattle.io/v3/schema/schema.go +++ b/apis/project.cattle.io/v3/schema/schema.go @@ -51,6 +51,7 @@ func NamespaceTypes(version *types.APIVersion, schemas *types.Schemas) *types.Sc &m.Drop{Field: "finalizers"}, ). AddMapperForType(version, v1.Namespace{}, + &m.AnnotationField{Field: "description"}, &m.AnnotationField{Field: "projectId"}, &m.AnnotationField{Field: "externalId"}, &m.AnnotationField{Field: "templates", Object: true}, @@ -58,12 +59,13 @@ func NamespaceTypes(version *types.APIVersion, schemas *types.Schemas) *types.Sc &m.AnnotationField{Field: "answers", Object: true}, ). MustImport(version, v1.Namespace{}, struct { - ProjectID string `norman:"type=reference[/v3/schemas/project]"` - Templates map[string]string `json:"templates"` - Answers map[string]interface{} `json:"answers"` - Prune bool `json:"prune"` - ExternalID string `json:"externalId"` - Tags []string `json:"tags"` + Description string `json:"description"` + ProjectID string `norman:"type=reference[/v3/schemas/project]"` + Templates map[string]string `json:"templates"` + Answers map[string]interface{} `json:"answers"` + Prune bool `json:"prune"` + ExternalID string `json:"externalId"` + Tags []string `json:"tags"` }{}) } @@ -284,6 +286,9 @@ func podTypes(schemas *types.Schemas) *types.Schemas { AddMapperForType(&Version, v1.ResourceRequirements{}, mapper.PivotMapper{Plural: true}, ). + AddMapperForType(&Version, v1.Pod{}, + &m.AnnotationField{Field: "description"}, + ). // Must import handlers before Container MustImport(&Version, v1.Capabilities{}, struct { Add []string `norman:"type=array[enum],options=AUDIT_CONTROL|AUDIT_WRITE|BLOCK_SUSPEND|CHOWN|DAC_OVERRIDE|DAC_READ_SEARCH|FOWNER|FSETID|IPC_LOCK|IPC_OWNER|KILL|LEASE|LINUX_IMMUTABLE|MAC_ADMIN|MAC_OVERRIDE|MKNOD|NET_ADMIN|NET_BIND_SERVICE|NET_BROADCAST|NET_RAW|SETFCAP|SETGID|SETPCAP|SETUID|SYSLOG|SYS_ADMIN|SYS_BOOT|SYS_CHROOT|SYS_MODULE|SYS_NICE|SYS_PACCT|SYS_PTRACE|SYS_RAWIO|SYS_RESOURCE|SYS_TIME|SYS_TTY_CONFIG|WAKE_ALARM"` @@ -305,7 +310,8 @@ func podTypes(schemas *types.Schemas) *types.Schemas { IPC string }{}). MustImport(&Version, v1.Pod{}, projectOverride{}, struct { - WorkloadID string `norman:"type=reference[workload]"` + Description string `json:"description"` + WorkloadID string `norman:"type=reference[workload]"` }{}) } @@ -348,6 +354,7 @@ func addServiceOrDNSRecord(dns bool) types.SchemasInitFunc { AddMapperForType(&Version, v1.Service{}, &m.Drop{Field: "status"}, &m.LabelField{Field: "workloadId"}, + &m.AnnotationField{Field: "description"}, &m.AnnotationField{Field: "ipAddresses", List: true}, &m.AnnotationField{Field: "targetWorkloadIds", List: true}, &m.AnnotationField{Field: "targetDnsRecordIds", List: true}, @@ -380,6 +387,7 @@ func addServiceOrDNSRecord(dns bool) types.SchemasInitFunc { }) } }, projectOverride{}, struct { + Description string `json:"description"` IPAddresses []string `json:"ipAddresses"` WorkloadID string `json:"workloadId" norman:"type=reference[workload],nocreate,noupdate"` TargetWorkloadIDs string `json:"targetWorkloadIds" norman:"type=array[reference[workload]]"` @@ -400,6 +408,7 @@ func ingressTypes(schemas *types.Schemas) *types.Schemas { &m.Embed{Field: "http"}, ). AddMapperForType(&Version, v1beta1.Ingress{}, + &m.AnnotationField{Field: "description"}, &m.Move{From: "backend", To: "defaultBackend"}, ). AddMapperForType(&Version, v1beta1.IngressTLS{}, @@ -421,7 +430,9 @@ func ingressTypes(schemas *types.Schemas) *types.Schemas { MustImport(&Version, v1beta1.IngressTLS{}, struct { SecretName string `norman:"type=reference[certificate]"` }{}). - MustImport(&Version, v1beta1.Ingress{}, projectOverride{}) + MustImport(&Version, v1beta1.Ingress{}, projectOverride{}, struct { + Description string `json:"description"` + }{}) } func volumeTypes(schemas *types.Schemas) *types.Schemas { diff --git a/apis/project.cattle.io/v3/schema/schema_secrets.go b/apis/project.cattle.io/v3/schema/schema_secrets.go index fdc2fc1e..f92fbbc7 100644 --- a/apis/project.cattle.io/v3/schema/schema_secrets.go +++ b/apis/project.cattle.io/v3/schema/schema_secrets.go @@ -11,6 +11,7 @@ import ( func secretTypes(schemas *types.Schemas) *types.Schemas { return schemas. AddMapperForType(&Version, v1.Secret{}, + &m.AnnotationField{Field: "description"}, m.AnnotationField{Field: "projectId", IgnoreDefinition: true}, m.SetValue{ Field: "type", @@ -218,7 +219,9 @@ func secretTypes(schemas *types.Schemas) *types.Schemas { } return f }) - }, projectOverride{}). + }, projectOverride{}, struct { + Description string `json:"description"` + }{}). Init(func(schemas *types.Schemas) *types.Schemas { return addSecretSubtypes(schemas, v3.ServiceAccountToken{}, diff --git a/apis/project.cattle.io/v3/types.go b/apis/project.cattle.io/v3/types.go index c75f9450..ef271281 100644 --- a/apis/project.cattle.io/v3/types.go +++ b/apis/project.cattle.io/v3/types.go @@ -7,6 +7,7 @@ import ( ) type WorkloadSpec struct { + Description string `json:"description"` DeployConfig DeployConfig `json:"deployConfig"` Template v1.PodTemplateSpec `json:"template"` ServiceLinks []Link `json:"serviceLinks"` @@ -70,6 +71,7 @@ type ServiceAccountToken struct { AccountName string `json:"accountName"` AccountUID string `json:"accountUid"` + Description string `json:"description"` Token string `json:"token" norman:"writeOnly"` CACRT string `json:"caCrt"` } @@ -81,14 +83,16 @@ type DockerCredential struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - Registries map[string]RegistryCredential `json:"registries"` + Description string `json:"description"` + Registries map[string]RegistryCredential `json:"registries"` } type NamespacedDockerCredential DockerCredential type RegistryCredential struct { - Username string `json:"username"` - Password string `json:"password" norman:"writeOnly"` - Auth string `json:"auth" norman:"writeOnly"` + Description string `json:"description"` + Username string `json:"username"` + Password string `json:"password" norman:"writeOnly"` + Auth string `json:"auth" norman:"writeOnly"` } type Certificate struct { @@ -97,19 +101,20 @@ type Certificate struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - Certs string `json:"certs"` - Key string `json:"key" norman:"writeOnly"` + Description string `json:"description"` + Certs string `json:"certs"` + Key string `json:"key" norman:"writeOnly"` - CertFingerprint string `json:"certFingerprint" norman:"nocreate,noupdate"` - CN string `json:"cn" norman:"nocreate,noupdate"` - Version string `json:"version" norman:"nocreate,noupdate"` - ExpiresAt string `json:"expiresAt" norman:"nocreate,noupdate"` - Issuer string `json:"issuer" norman:"nocreate,noupdate"` - IssuedAt string `json:"issuedAt" norman:"nocreate,noupdate"` - Algorithm string `json:"algorithm" norman:"nocreate,noupdate"` - SerialNumber string `json:"serialNumber" norman:"nocreate,noupdate"` - KeySize string `json:"keySize" norman:"nocreate,noupdate"` - SubjectAlternativeNames string `json:"subjectAlternativeNames" norman:"nocreate,noupdate"` + CertFingerprint string `json:"certFingerprint" norman:"nocreate,noupdate"` + CN string `json:"cn" norman:"nocreate,noupdate"` + Version string `json:"version" norman:"nocreate,noupdate"` + ExpiresAt string `json:"expiresAt" norman:"nocreate,noupdate"` + Issuer string `json:"issuer" norman:"nocreate,noupdate"` + IssuedAt string `json:"issuedAt" norman:"nocreate,noupdate"` + Algorithm string `json:"algorithm" norman:"nocreate,noupdate"` + SerialNumber string `json:"serialNumber" norman:"nocreate,noupdate"` + KeySize string `json:"keySize" norman:"nocreate,noupdate"` + SubjectAlternativeNames []string `json:"subjectAlternativeNames" norman:"nocreate,noupdate"` } type NamespacedCertificate Certificate @@ -119,8 +124,9 @@ type BasicAuth struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - Username string `json:"username"` - Password string `json:"password" norman:"writeOnly"` + Description string `json:"description"` + Username string `json:"username"` + Password string `json:"password" norman:"writeOnly"` } type NamespacedBasicAuth BasicAuth @@ -130,6 +136,7 @@ type SSHAuth struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` + Description string `json:"description"` PrivateKey string `json:"privateKey" norman:"writeOnly"` Fingerprint string `json:"certFingerprint" norman:"nocreate,noupdate"` }