From 602ca280c51c61a901d2329f33c0d78799a45266 Mon Sep 17 00:00:00 2001 From: David Eads Date: Thu, 8 Nov 2018 16:09:47 -0500 Subject: [PATCH 1/3] generated --- config/v1/types_swagger_doc_generated.go | 30 ++ config/v1/zz_generated.deepcopy.go | 61 ++++ operator/v1/types_swagger_doc_generated.go | 155 +++++++++ operator/v1/zz_generated.deepcopy.go | 355 +++++++++++++++++++++ 4 files changed, 601 insertions(+) create mode 100644 operator/v1/types_swagger_doc_generated.go create mode 100644 operator/v1/zz_generated.deepcopy.go diff --git a/config/v1/types_swagger_doc_generated.go b/config/v1/types_swagger_doc_generated.go index 7dfb4cd69f8..1fd8c16e8ac 100644 --- a/config/v1/types_swagger_doc_generated.go +++ b/config/v1/types_swagger_doc_generated.go @@ -69,6 +69,24 @@ func (ConfigMapReference) SwaggerDoc() map[string]string { return map_ConfigMapReference } +var map_DelegatedAuthentication = map[string]string{ + "": "DelegatedAuthentication allows authentication to be disabled.", + "disabled": "disabled indicates that authentication should be disabled. By default it will use delegated authentication.", +} + +func (DelegatedAuthentication) SwaggerDoc() map[string]string { + return map_DelegatedAuthentication +} + +var map_DelegatedAuthorization = map[string]string{ + "": "DelegatedAuthorization allows authorization to be disabled.", + "disabled": "disabled indicates that authorization should be disabled. By default it will use delegated authorization.", +} + +func (DelegatedAuthorization) SwaggerDoc() map[string]string { + return map_DelegatedAuthorization +} + var map_EtcdConnectionInfo = map[string]string{ "": "EtcdConnectionInfo holds information necessary for connecting to an etcd server", "urls": "URLs are the URLs for etcd", @@ -99,6 +117,18 @@ func (GenericAPIServerConfig) SwaggerDoc() map[string]string { return map_GenericAPIServerConfig } +var map_GenericControllerConfig = map[string]string{ + "": "GenericControllerConfig provides information to configure a controller", + "servingInfo": "ServingInfo is the HTTP serving information for the controller's endpoints", + "leaderElection": "leaderElection provides information to elect a leader. Only override this if you have a specific need", + "authentication": "authentication allows configuration of authentication for the endpoints", + "authorization": "authorization allows configuration of authentication for the endpoints", +} + +func (GenericControllerConfig) SwaggerDoc() map[string]string { + return map_GenericControllerConfig +} + var map_HTTPServingInfo = map[string]string{ "": "HTTPServingInfo holds configuration for serving HTTP", "maxRequestsInFlight": "MaxRequestsInFlight is the number of concurrent requests allowed to the server. If zero, no limit.", diff --git a/config/v1/zz_generated.deepcopy.go b/config/v1/zz_generated.deepcopy.go index e4af30f2ffd..382a5c362c6 100644 --- a/config/v1/zz_generated.deepcopy.go +++ b/config/v1/zz_generated.deepcopy.go @@ -507,6 +507,38 @@ func (in *DNSStatus) DeepCopy() *DNSStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DelegatedAuthentication) DeepCopyInto(out *DelegatedAuthentication) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DelegatedAuthentication. +func (in *DelegatedAuthentication) DeepCopy() *DelegatedAuthentication { + if in == nil { + return nil + } + out := new(DelegatedAuthentication) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DelegatedAuthorization) DeepCopyInto(out *DelegatedAuthorization) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DelegatedAuthorization. +func (in *DelegatedAuthorization) DeepCopy() *DelegatedAuthorization { + if in == nil { + return nil + } + out := new(DelegatedAuthorization) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *EtcdConnectionInfo) DeepCopyInto(out *EtcdConnectionInfo) { *out = *in @@ -580,6 +612,35 @@ func (in *GenericAPIServerConfig) DeepCopy() *GenericAPIServerConfig { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GenericControllerConfig) DeepCopyInto(out *GenericControllerConfig) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ServingInfo.DeepCopyInto(&out.ServingInfo) + out.LeaderElection = in.LeaderElection + out.Authentication = in.Authentication + out.Authorization = in.Authorization + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericControllerConfig. +func (in *GenericControllerConfig) DeepCopy() *GenericControllerConfig { + if in == nil { + return nil + } + out := new(GenericControllerConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *GenericControllerConfig) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HTTPServingInfo) DeepCopyInto(out *HTTPServingInfo) { *out = *in diff --git a/operator/v1/types_swagger_doc_generated.go b/operator/v1/types_swagger_doc_generated.go new file mode 100644 index 00000000000..f7a40af60ed --- /dev/null +++ b/operator/v1/types_swagger_doc_generated.go @@ -0,0 +1,155 @@ +package v1 + +// This file contains a collection of methods that can be used from go-restful to +// generate Swagger API documentation for its models. Please read this PR for more +// information on the implementation: https://github.com/emicklei/go-restful/pull/215 +// +// TODOs are ignored from the parser (e.g. TODO(andronat):... || TODO:...) if and only if +// they are on one line! For multiple line or blocks that you want to ignore use ---. +// Any context after a --- is ignored. +// +// Those methods can be generated by using hack/update-generated-swagger-docs.sh + +// AUTO-GENERATED FUNCTIONS START HERE +var map_CapnsLogConfig = map[string]string{ + "level": "level is passed to capnslog: critical, error, warning, notice, info, debug, trace", +} + +func (CapnsLogConfig) SwaggerDoc() map[string]string { + return map_CapnsLogConfig +} + +var map_GenerationStatus = map[string]string{ + "": "GenerationStatus keeps track of the generation for a given resource so that decisions about forced updates can be made.", + "group": "group is the group of the thing you're tracking", + "resource": "resource is the resource type of the thing you're tracking", + "namespace": "namespace is where the thing you're tracking is", + "name": "name is the name of the thing you're tracking", + "lastGeneration": "lastGeneration is the last generation of the workload controller involved", + "hash": "hash is an optional field set for resources without generation that are content sensitive like secrets and configmaps", +} + +func (GenerationStatus) SwaggerDoc() map[string]string { + return map_GenerationStatus +} + +var map_GlogConfig = map[string]string{ + "": "GlogConfig holds information about configuring logging", + "level": "level is passed to glog.", + "vmodule": "vmodule is passed to glog.", +} + +func (GlogConfig) SwaggerDoc() map[string]string { + return map_GlogConfig +} + +var map_JavaLog = map[string]string{ + "level": "level is passed to jsr47: fatal, error, warning, info, fine, finer, finest", +} + +func (JavaLog) SwaggerDoc() map[string]string { + return map_JavaLog +} + +var map_LoggingConfig = map[string]string{ + "": "LoggingConfig holds information about configuring logging", +} + +func (LoggingConfig) SwaggerDoc() map[string]string { + return map_LoggingConfig +} + +var map_MyOperatorResource = map[string]string{ + "": "MyOperatorResource is an example operator configuration type", +} + +func (MyOperatorResource) SwaggerDoc() map[string]string { + return map_MyOperatorResource +} + +var map_NodeStatus = map[string]string{ + "": "NodeStatus provides information about the current state of a particular node managed by this operator.", + "nodeName": "nodeName is the name of the node", + "currentDeploymentGeneration": "currentDeploymentGeneration is the generation of the most recently successful deployment", + "targetDeploymentGeneration": "targetDeploymentGeneration is the generation of the deployment we're trying to apply", + "lastFailedDeploymentGeneration": "lastFailedDeploymentGeneration is the generation of the deployment we tried and failed to deploy.", + "lastFailedDeploymentErrors": "lastFailedDeploymentGenerationErrors is a list of the errors during the failed deployment referenced in lastFailedDeploymentGeneration", +} + +func (NodeStatus) SwaggerDoc() map[string]string { + return map_NodeStatus +} + +var map_OperandContainerSpec = map[string]string{ + "name": "name is the name of the container to modify", + "resources": "resources are the requests and limits to place in the container. Nil means to accept the defaults.", + "logging": "logging contains parameters for setting log values on the operand. Nil means to accept the defaults.", +} + +func (OperandContainerSpec) SwaggerDoc() map[string]string { + return map_OperandContainerSpec +} + +var map_OperandSpec = map[string]string{ + "": "OperandSpec holds information for customization of a particular functional unit - logically maps to a workload", + "name": "name is the name of this unit. The operator must be aware of it.", + "operandContainerSpecs": "operandContainerSpecs are per-container options", + "unsupportedResourcePatches": "unsupportedResourcePatches are applied to the workload resource for this unit. This is an unsupported workaround if anything needs to be modified on the workload that is not otherwise configurable.", +} + +func (OperandSpec) SwaggerDoc() map[string]string { + return map_OperandSpec +} + +var map_OperatorCondition = map[string]string{ + "": "OperatorCondition is just the standard condition fields.", +} + +func (OperatorCondition) SwaggerDoc() map[string]string { + return map_OperatorCondition +} + +var map_OperatorSpec = map[string]string{ + "": "OperatorSpec contains common fields operators need. It is intended to be anonymous included inside of the Spec struct for your particular operator.", + "managementState": "managementState indicates whether and how the operator should manage the component", + "operandSpecs": "operandSpecs provide customization for functional units within the component", + "unsupportedConfigOverrides": "unsupportedConfigOverrides holds a sparse config that will override any previously set options. It only needs to be the fields to override it will end up overlaying in the following order: 1. hardcoded defaults 2. observedConfig 3. unsupportedConfigOverrides", + "observedConfig": "observedConfig holds a sparse config that controller has observed from the cluster state. It exists in spec because it is an input to the level for the operator", +} + +func (OperatorSpec) SwaggerDoc() map[string]string { + return map_OperatorSpec +} + +var map_OperatorStatus = map[string]string{ + "conditions": "conditions is a list of conditions and their status", + "version": "version is the level this availability applies to", + "readyReplicas": "readyReplicas indicates how many replicas are ready and at the desired state", + "generations": "generations are used to determine when an item needs to be reconciled or has changed in a way that needs a reaction.", +} + +func (OperatorStatus) SwaggerDoc() map[string]string { + return map_OperatorStatus +} + +var map_ResourcePatch = map[string]string{ + "": "ResourcePatch is a way to represent the patch you would issue to `kubectl patch` in the API", + "type": "type is the type of patch to apply: jsonmerge, strategicmerge", + "patch": "patch the patch itself", +} + +func (ResourcePatch) SwaggerDoc() map[string]string { + return map_ResourcePatch +} + +var map_StaticPodOperatorStatus = map[string]string{ + "": "StaticPodOperatorStatus is status for controllers that manage static pods. There are different needs because individual node status must be tracked.", + "latestAvailableDeploymentGeneration": "latestAvailableDeploymentGeneration is the deploymentID of the most recent deployment", + "nodeStatuses": "nodeStatuses track the deployment values and errors across individual nodes", +} + +func (StaticPodOperatorStatus) SwaggerDoc() map[string]string { + return map_StaticPodOperatorStatus +} + +// AUTO-GENERATED FUNCTIONS END HERE diff --git a/operator/v1/zz_generated.deepcopy.go b/operator/v1/zz_generated.deepcopy.go new file mode 100644 index 00000000000..828676a5d45 --- /dev/null +++ b/operator/v1/zz_generated.deepcopy.go @@ -0,0 +1,355 @@ +// +build !ignore_autogenerated + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1 + +import ( + core_v1 "k8s.io/api/core/v1" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CapnsLogConfig) DeepCopyInto(out *CapnsLogConfig) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CapnsLogConfig. +func (in *CapnsLogConfig) DeepCopy() *CapnsLogConfig { + if in == nil { + return nil + } + out := new(CapnsLogConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GenerationStatus) DeepCopyInto(out *GenerationStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenerationStatus. +func (in *GenerationStatus) DeepCopy() *GenerationStatus { + if in == nil { + return nil + } + out := new(GenerationStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GlogConfig) DeepCopyInto(out *GlogConfig) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GlogConfig. +func (in *GlogConfig) DeepCopy() *GlogConfig { + if in == nil { + return nil + } + out := new(GlogConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *JavaLog) DeepCopyInto(out *JavaLog) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JavaLog. +func (in *JavaLog) DeepCopy() *JavaLog { + if in == nil { + return nil + } + out := new(JavaLog) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LoggingConfig) DeepCopyInto(out *LoggingConfig) { + *out = *in + if in.Glog != nil { + in, out := &in.Glog, &out.Glog + if *in == nil { + *out = nil + } else { + *out = new(GlogConfig) + **out = **in + } + } + if in.CapnsLog != nil { + in, out := &in.CapnsLog, &out.CapnsLog + if *in == nil { + *out = nil + } else { + *out = new(CapnsLogConfig) + **out = **in + } + } + if in.Java != nil { + in, out := &in.Java, &out.Java + if *in == nil { + *out = nil + } else { + *out = new(JavaLog) + **out = **in + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoggingConfig. +func (in *LoggingConfig) DeepCopy() *LoggingConfig { + if in == nil { + return nil + } + out := new(LoggingConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MyOperatorResource) DeepCopyInto(out *MyOperatorResource) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MyOperatorResource. +func (in *MyOperatorResource) DeepCopy() *MyOperatorResource { + if in == nil { + return nil + } + out := new(MyOperatorResource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MyOperatorResourceSpec) DeepCopyInto(out *MyOperatorResourceSpec) { + *out = *in + in.OperatorSpec.DeepCopyInto(&out.OperatorSpec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MyOperatorResourceSpec. +func (in *MyOperatorResourceSpec) DeepCopy() *MyOperatorResourceSpec { + if in == nil { + return nil + } + out := new(MyOperatorResourceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MyOperatorResourceStatus) DeepCopyInto(out *MyOperatorResourceStatus) { + *out = *in + in.OperatorStatus.DeepCopyInto(&out.OperatorStatus) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MyOperatorResourceStatus. +func (in *MyOperatorResourceStatus) DeepCopy() *MyOperatorResourceStatus { + if in == nil { + return nil + } + out := new(MyOperatorResourceStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodeStatus) DeepCopyInto(out *NodeStatus) { + *out = *in + if in.LastFailedDeploymentErrors != nil { + in, out := &in.LastFailedDeploymentErrors, &out.LastFailedDeploymentErrors + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeStatus. +func (in *NodeStatus) DeepCopy() *NodeStatus { + if in == nil { + return nil + } + out := new(NodeStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OperandContainerSpec) DeepCopyInto(out *OperandContainerSpec) { + *out = *in + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + if *in == nil { + *out = nil + } else { + *out = new(core_v1.ResourceRequirements) + (*in).DeepCopyInto(*out) + } + } + in.Logging.DeepCopyInto(&out.Logging) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperandContainerSpec. +func (in *OperandContainerSpec) DeepCopy() *OperandContainerSpec { + if in == nil { + return nil + } + out := new(OperandContainerSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OperandSpec) DeepCopyInto(out *OperandSpec) { + *out = *in + if in.OperandContainerSpecs != nil { + in, out := &in.OperandContainerSpecs, &out.OperandContainerSpecs + *out = make([]OperandContainerSpec, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.UnsupportedResourcePatches != nil { + in, out := &in.UnsupportedResourcePatches, &out.UnsupportedResourcePatches + *out = make([]ResourcePatch, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperandSpec. +func (in *OperandSpec) DeepCopy() *OperandSpec { + if in == nil { + return nil + } + out := new(OperandSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OperatorCondition) DeepCopyInto(out *OperatorCondition) { + *out = *in + in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorCondition. +func (in *OperatorCondition) DeepCopy() *OperatorCondition { + if in == nil { + return nil + } + out := new(OperatorCondition) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OperatorSpec) DeepCopyInto(out *OperatorSpec) { + *out = *in + if in.OperandSpecs != nil { + in, out := &in.OperandSpecs, &out.OperandSpecs + *out = make([]OperandSpec, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + in.UnsupportedConfigOverrides.DeepCopyInto(&out.UnsupportedConfigOverrides) + in.ObservedConfig.DeepCopyInto(&out.ObservedConfig) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorSpec. +func (in *OperatorSpec) DeepCopy() *OperatorSpec { + if in == nil { + return nil + } + out := new(OperatorSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OperatorStatus) DeepCopyInto(out *OperatorStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]OperatorCondition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Generations != nil { + in, out := &in.Generations, &out.Generations + *out = make([]GenerationStatus, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorStatus. +func (in *OperatorStatus) DeepCopy() *OperatorStatus { + if in == nil { + return nil + } + out := new(OperatorStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ResourcePatch) DeepCopyInto(out *ResourcePatch) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourcePatch. +func (in *ResourcePatch) DeepCopy() *ResourcePatch { + if in == nil { + return nil + } + out := new(ResourcePatch) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StaticPodOperatorStatus) DeepCopyInto(out *StaticPodOperatorStatus) { + *out = *in + in.OperatorStatus.DeepCopyInto(&out.OperatorStatus) + if in.NodeStatuses != nil { + in, out := &in.NodeStatuses, &out.NodeStatuses + *out = make([]NodeStatus, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StaticPodOperatorStatus. +func (in *StaticPodOperatorStatus) DeepCopy() *StaticPodOperatorStatus { + if in == nil { + return nil + } + out := new(StaticPodOperatorStatus) + in.DeepCopyInto(out) + return out +} From 8453618a27455c744d5ecba07fc43da868d5615a Mon Sep 17 00:00:00 2001 From: David Eads Date: Thu, 8 Nov 2018 16:09:43 -0500 Subject: [PATCH 2/3] provide a basic operator v1 API --- config/v1/register.go | 1 + config/v1/types.go | 30 ++++++ hack/lib/init.sh | 1 + hack/update-deepcopy.sh | 2 +- operator/install.go | 3 +- operator/v1/doc.go | 6 ++ operator/v1/register.go | 37 +++++++ operator/v1/types.go | 210 ++++++++++++++++++++++++++++++++++++++++ 8 files changed, 288 insertions(+), 2 deletions(-) create mode 100644 operator/v1/doc.go create mode 100644 operator/v1/register.go create mode 100644 operator/v1/types.go diff --git a/config/v1/register.go b/config/v1/register.go index 2e40fbfa4fb..b890ed0eede 100644 --- a/config/v1/register.go +++ b/config/v1/register.go @@ -38,6 +38,7 @@ func addKnownTypes(scheme *runtime.Scheme) error { &ConsoleList{}, &DNS{}, &DNSList{}, + &GenericControllerConfig{}, &IdentityProvider{}, &IdentityProviderList{}, &Image{}, diff --git a/config/v1/types.go b/config/v1/types.go index 727db57b364..370c265c08f 100644 --- a/config/v1/types.go +++ b/config/v1/types.go @@ -244,3 +244,33 @@ type ClientConnectionOverrides struct { // burst allows extra queries to accumulate when a client is exceeding its rate. Burst int32 `json:"burst"` } + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// GenericControllerConfig provides information to configure a controller +type GenericControllerConfig struct { + metav1.TypeMeta `json:",inline"` + + // ServingInfo is the HTTP serving information for the controller's endpoints + ServingInfo HTTPServingInfo `json:"servingInfo,omitempty"` + + // leaderElection provides information to elect a leader. Only override this if you have a specific need + LeaderElection LeaderElection `json:"leaderElection,omitempty"` + + // authentication allows configuration of authentication for the endpoints + Authentication DelegatedAuthentication `json:"authentication,omitempty"` + // authorization allows configuration of authentication for the endpoints + Authorization DelegatedAuthorization `json:"authorization,omitempty"` +} + +// DelegatedAuthentication allows authentication to be disabled. +type DelegatedAuthentication struct { + // disabled indicates that authentication should be disabled. By default it will use delegated authentication. + Disabled bool `json:"disabled,omitempty"` +} + +// DelegatedAuthorization allows authorization to be disabled. +type DelegatedAuthorization struct { + // disabled indicates that authorization should be disabled. By default it will use delegated authorization. + Disabled bool `json:"disabled,omitempty"` +} diff --git a/hack/lib/init.sh b/hack/lib/init.sh index d73436af885..ecda5d0cb8c 100644 --- a/hack/lib/init.sh +++ b/hack/lib/init.sh @@ -20,6 +20,7 @@ legacyconfig/v1 \ network/v1 \ oauth/v1 \ openshiftcontrolplane/v1 \ +operator/v1 \ operator/v1alpha1 \ project/v1 \ quota/v1 \ diff --git a/hack/update-deepcopy.sh b/hack/update-deepcopy.sh index 46ec87b9c53..c159baea754 100755 --- a/hack/update-deepcopy.sh +++ b/hack/update-deepcopy.sh @@ -10,6 +10,6 @@ verify="${VERIFY:-}" ${CODEGEN_PKG}/generate-groups.sh "deepcopy" \ github.com/openshift/api/generated \ github.com/openshift/api \ - "apps:v1 authorization:v1 build:v1 config:v1 image:v1,docker10,dockerpre012 kubecontrolplane:v1 legacyconfig:v1 network:v1 oauth:v1 openshiftcontrolplane:v1 operator:v1alpha1 osin:v1 project:v1 quota:v1 route:v1 security:v1 servicecertsigner:v1alpha1 template:v1 user:v1 webconsole:v1" \ + "apps:v1 authorization:v1 build:v1 config:v1 image:v1,docker10,dockerpre012 kubecontrolplane:v1 legacyconfig:v1 network:v1 oauth:v1 openshiftcontrolplane:v1 operator:v1 operator:v1alpha1 osin:v1 project:v1 quota:v1 route:v1 security:v1 servicecertsigner:v1alpha1 template:v1 user:v1 webconsole:v1" \ --go-header-file ${SCRIPT_ROOT}/hack/empty.txt \ ${verify} diff --git a/operator/install.go b/operator/install.go index 0cc76ff5557..9cbf25a4bba 100644 --- a/operator/install.go +++ b/operator/install.go @@ -4,6 +4,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" + operatorv1 "github.com/openshift/api/operator/v1" operatorv1alpha1 "github.com/openshift/api/operator/v1alpha1" ) @@ -12,7 +13,7 @@ const ( ) var ( - schemeBuilder = runtime.NewSchemeBuilder(operatorv1alpha1.Install) + schemeBuilder = runtime.NewSchemeBuilder(operatorv1alpha1.Install, operatorv1.Install) // Install is a function which adds every version of this group to a scheme Install = schemeBuilder.AddToScheme ) diff --git a/operator/v1/doc.go b/operator/v1/doc.go new file mode 100644 index 00000000000..349ba71e0a5 --- /dev/null +++ b/operator/v1/doc.go @@ -0,0 +1,6 @@ +// +k8s:deepcopy-gen=package,register +// +k8s:defaulter-gen=TypeMeta +// +k8s:openapi-gen=true + +// +groupName=operator.openshift.io +package v1 diff --git a/operator/v1/register.go b/operator/v1/register.go new file mode 100644 index 00000000000..032b41290d1 --- /dev/null +++ b/operator/v1/register.go @@ -0,0 +1,37 @@ +package v1 + +import ( + configv1 "github.com/openshift/api/config/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +var ( + GroupName = "operator.openshift.io" + GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"} + schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes, configv1.Install) + // Install is a function which adds this version to a scheme + Install = schemeBuilder.AddToScheme + + // SchemeGroupVersion generated code relies on this name + // Deprecated + SchemeGroupVersion = GroupVersion + // AddToScheme exists solely to keep the old generators creating valid code + // DEPRECATED + AddToScheme = schemeBuilder.AddToScheme +) + +// Resource generated code relies on this being here, but it logically belongs to the group +// DEPRECATED +func Resource(resource string) schema.GroupResource { + return schema.GroupResource{Group: GroupName, Resource: resource} +} + +func addKnownTypes(scheme *runtime.Scheme) error { + metav1.AddToGroupVersion(scheme, GroupVersion) + + scheme.AddKnownTypes(GroupVersion) + + return nil +} diff --git a/operator/v1/types.go b/operator/v1/types.go new file mode 100644 index 00000000000..ca9cb5a8d54 --- /dev/null +++ b/operator/v1/types.go @@ -0,0 +1,210 @@ +package v1 + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// MyOperatorResource is an example operator configuration type +type MyOperatorResource struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata"` + + Spec MyOperatorResourceSpec `json:"spec"` + Status MyOperatorResourceStatus `json:"status"` +} + +type MyOperatorResourceSpec struct { + OperatorSpec `json:",inline"` +} + +type MyOperatorResourceStatus struct { + OperatorStatus `json:",inline"` +} + +type ManagementState string + +var ( + // Force means that the operator is actively managing its resources and ignoring unmet prereqs + Force ManagementState = "Force" + // Managed means that the operator is actively managing its resources and trying to keep the component active + Managed ManagementState = "Managed" + // Unmanaged means that the operator is not taking any action related to the component + Unmanaged ManagementState = "Unmanaged" + // Removed means that the operator is actively managing its resources and trying to remove all traces of the component + Removed ManagementState = "Removed" +) + +// OperatorSpec contains common fields for an operator to need. It is intended to be anonymous included +// inside of the Spec struct for you particular operator. +type OperatorSpec struct { + // managementState indicates whether and how the operator should manage the component + ManagementState ManagementState `json:"managementState"` + + // operandSpecs provide information about customization for particular units + OperandSpecs []OperandSpec `json:"operandSpecs"` + + // unsupportedConfigOverrides holds a sparse config that will override any previously set options. It only needs to be the fields to override + // it will end up overlaying in the following order: + // 1. hardcoded defaults + // 2. observedConfig + // 3. unsupportedConfigOverrides + UnsupportedConfigOverrides runtime.RawExtension `json:"unsupportedConfigOverrides"` + + // observedConfig holds a sparse config that controller has observed from the cluster state. It exists in spec because + // it is an input to the level for the operator + ObservedConfig runtime.RawExtension `json:"observedConfig"` +} + +// ResourcePatch is a way to represent the patch you would issue to `kubectl patch` in the API +type ResourcePatch struct { + // type is the type of patch to apply: jsonmerge, strategicmerge + Type string `json:"type"` + // patch the patch itself + Patch string `json:"patch"` +} + +// OperandSpec holds information for customatization of a particular unit (logical pod) +type OperandSpec struct { + // name is the name of this unit. The operator must be aware of it. + Name string `json:"name"` + + // operandContainerSpecs are per-container options + OperandContainerSpecs []OperandContainerSpec `json:"operandContainerSpecs"` + + // Alternatively, we could simply include a RawExtension which is used in place of the "normal" default manifest + UnsupportedResourcePatches []ResourcePatch `json:"unsupportedResourcePatches"` +} + +type OperandContainerSpec struct { + // name is the name of the container to modify + Name string `json:"name"` + + // resources are the requests and limits to place in the container. Nil means to accept the defaults. + Resources *corev1.ResourceRequirements `json:"resources,omitempty"` + + // logging contains parameters for setting log values on the operand. Nil means to accept the defaults. + Logging LoggingConfig `json:"logging,omitempty"` +} + +// LoggingConfig holds information about configuring logging +type LoggingConfig struct { + Type string `json:"type"` + + Glog *GlogConfig `json:"glog,omitempty"` + CapnsLog *CapnsLogConfig `json:"capnsLog,omitempty"` + Java *JavaLog `json:"java,omitempty"` +} + +// GlogConfig holds information about configuring logging +type GlogConfig struct { + // level is passed to glog. + Level int64 `json:"level"` + + // vmodule is passed to glog. + Vmodule string `json:"vmodule"` +} + +type CapnsLogConfig struct { + // level is passed to capnslog: critical, error, warning, notice, info, debug, trace + Level string `json:"level"` + + // There is some kind of repo/package level thing for this +} + +type JavaLog struct { + // level is passed to jsr47: fatal, error, warning, info, fine, finer, finest + Level string `json:"level"` + + // There is some kind of repo/package level thing for this. might end up hierarchical +} + +type OperatorStatus struct { + // conditions is a list of conditions and their status + Conditions []OperatorCondition `json:"conditions,omitempty"` + + // version is the level this availability applies to + Version string `json:"version"` + + // readyReplicas indicates how many replicas are ready and at the desired state + ReadyReplicas int32 `json:"readyReplicas"` + + // generations are used to determine when an item needs to be reconciled or has changed in a way that needs a reaction. + Generations []GenerationStatus `json:"generations"` +} + +// GenerationStatus keeps track of the generation for a given resource so that decisions about forced updated can be made. +type GenerationStatus struct { + // group is the group of the thing you're tracking + Group string `json:"group"` + // resource is the resource type of the thing you're tracking + Resource string `json:"resource"` + // namespace is where the thing you're tracking is + Namespace string `json:"namespace"` + // name is the name of the thing you're tracking + Name string `json:"name"` + // lastGeneration is the last generation of the workload controller involved + LastGeneration int64 `json:"lastGeneration"` + // hash is an optional field set for resources without generation that are content sensitive like secrets and configmaps + Hash string `json:"hash"` +} + +var ( + // Available indicates that the operand is present and accessible in the cluster + OperatorStatusTypeAvailable = "Available" + // Progressing indicates that the operator is trying to transition the operand to a different state + OperatorStatusTypeProgressing = "Progressing" + // Failing indicates that the operator (not the operand) is unable to fulfill the user intent + OperatorStatusTypeFailing = "Failing" + // PrereqsSatisfied indicates that the things this operator depends on are present and at levels compatible with the + // current and desired states. + OperatorStatusTypePrereqsSatisfied = "PrereqsSatisfied" + // Upgradeable indicates that the operator configuration itself (not prereqs) can be auto-upgraded by the CVO + OperatorStatusTypeUpgradeable = "Upgradeable" +) + +// OperatorCondition is just the standard condition fields. +type OperatorCondition struct { + Type string `json:"type"` + Status ConditionStatus `json:"status"` + LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"` + Reason string `json:"reason,omitempty"` + Message string `json:"message,omitempty"` +} + +type ConditionStatus string + +const ( + ConditionTrue ConditionStatus = "True" + ConditionFalse ConditionStatus = "False" + ConditionUnknown ConditionStatus = "Unknown" +) + +// StaticPodOperatorStatus is status for controllers that manage static pods. There are different needs because individual +// node status must be tracked. +type StaticPodOperatorStatus struct { + OperatorStatus `json:",inline"` + + // latestAvailableDeploymentGeneration is the deploymentID of the most recent deployment + LatestAvailableDeploymentGeneration int32 `json:"latestAvailableDeploymentGeneration"` + + // nodeStatuses track the deployment values and errors across individual nodes + NodeStatuses []NodeStatus `json:"nodeStatuses"` +} + +// NodeStatus provides information about the current state of a particular node managed by this operator. +type NodeStatus struct { + // nodeName is the name of the node + NodeName string `json:"nodeName"` + + // currentDeploymentGeneration is the generation of the most recently successful deployment + CurrentDeploymentGeneration int32 `json:"currentDeploymentGeneration"` + // targetDeploymentGeneration is the generation of the deployment we're trying to apply + TargetDeploymentGeneration int32 `json:"targetDeploymentGeneration"` + // lastFailedDeploymentGeneration is the generation of the deployment we tried and failed to deploy. + LastFailedDeploymentGeneration int32 `json:"lastFailedDeploymentGeneration"` + + // lastFailedDeploymentGenerationErrors is a list of the errors during the failed deployment referenced in lastFailedDeploymentGeneration + LastFailedDeploymentErrors []string `json:"lastFailedDeploymentErrors"` +} From 0c2282702604b0a59c2e2213947650e10993e216 Mon Sep 17 00:00:00 2001 From: Jessica Forrester Date: Thu, 8 Nov 2018 21:43:15 -0500 Subject: [PATCH 3/3] Added detail to some comments and marked the open TODOs --- operator/v1/register.go | 2 +- operator/v1/types.go | 26 +++++++++++++++----------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/operator/v1/register.go b/operator/v1/register.go index 032b41290d1..bcb1e4b5c4c 100644 --- a/operator/v1/register.go +++ b/operator/v1/register.go @@ -9,7 +9,7 @@ import ( var ( GroupName = "operator.openshift.io" - GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"} + GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1"} schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes, configv1.Install) // Install is a function which adds this version to a scheme Install = schemeBuilder.AddToScheme diff --git a/operator/v1/types.go b/operator/v1/types.go index ca9cb5a8d54..d1a16fe8134 100644 --- a/operator/v1/types.go +++ b/operator/v1/types.go @@ -26,23 +26,25 @@ type MyOperatorResourceStatus struct { type ManagementState string var ( - // Force means that the operator is actively managing its resources and ignoring unmet prereqs + // Force means that the operator is actively managing its resources but will not block an upgrade + // if unmet prereqs exist. This state puts the operator at risk for unsuccessful upgrades Force ManagementState = "Force" - // Managed means that the operator is actively managing its resources and trying to keep the component active + // Managed means that the operator is actively managing its resources and trying to keep the component active. + // It will only upgrade the component if it is safe to do so Managed ManagementState = "Managed" - // Unmanaged means that the operator is not taking any action related to the component + // Unmanaged means that the operator will not take any action related to the component Unmanaged ManagementState = "Unmanaged" // Removed means that the operator is actively managing its resources and trying to remove all traces of the component Removed ManagementState = "Removed" ) -// OperatorSpec contains common fields for an operator to need. It is intended to be anonymous included -// inside of the Spec struct for you particular operator. +// OperatorSpec contains common fields operators need. It is intended to be anonymous included +// inside of the Spec struct for your particular operator. type OperatorSpec struct { // managementState indicates whether and how the operator should manage the component ManagementState ManagementState `json:"managementState"` - // operandSpecs provide information about customization for particular units + // operandSpecs provide customization for functional units within the component OperandSpecs []OperandSpec `json:"operandSpecs"` // unsupportedConfigOverrides holds a sparse config that will override any previously set options. It only needs to be the fields to override @@ -65,7 +67,7 @@ type ResourcePatch struct { Patch string `json:"patch"` } -// OperandSpec holds information for customatization of a particular unit (logical pod) +// OperandSpec holds information for customization of a particular functional unit - logically maps to a workload type OperandSpec struct { // name is the name of this unit. The operator must be aware of it. Name string `json:"name"` @@ -73,7 +75,9 @@ type OperandSpec struct { // operandContainerSpecs are per-container options OperandContainerSpecs []OperandContainerSpec `json:"operandContainerSpecs"` - // Alternatively, we could simply include a RawExtension which is used in place of the "normal" default manifest + // unsupportedResourcePatches are applied to the workload resource for this unit. This is an unsupported + // workaround if anything needs to be modified on the workload that is not otherwise configurable. + // TODO Decide: alternatively, we could simply include a RawExtension which is used in place of the "normal" default manifest UnsupportedResourcePatches []ResourcePatch `json:"unsupportedResourcePatches"` } @@ -110,14 +114,14 @@ type CapnsLogConfig struct { // level is passed to capnslog: critical, error, warning, notice, info, debug, trace Level string `json:"level"` - // There is some kind of repo/package level thing for this + // TODO There is some kind of repo/package level thing for this } type JavaLog struct { // level is passed to jsr47: fatal, error, warning, info, fine, finer, finest Level string `json:"level"` - // There is some kind of repo/package level thing for this. might end up hierarchical + // TODO There is some kind of repo/package level thing for this. might end up hierarchical } type OperatorStatus struct { @@ -134,7 +138,7 @@ type OperatorStatus struct { Generations []GenerationStatus `json:"generations"` } -// GenerationStatus keeps track of the generation for a given resource so that decisions about forced updated can be made. +// GenerationStatus keeps track of the generation for a given resource so that decisions about forced updates can be made. type GenerationStatus struct { // group is the group of the thing you're tracking Group string `json:"group"`