-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1847 from rancher/config-v1-updates
Config v1 updates
- Loading branch information
Showing
10 changed files
with
2,515 additions
and
976 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package v1 | ||
|
||
import ( | ||
configv1 "github.com/rancher/opni/pkg/config/v1" | ||
opnimeta "github.com/rancher/opni/pkg/util/meta" | ||
"google.golang.org/protobuf/proto" | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
) | ||
|
||
type GatewaySpec struct { | ||
Replicas *int32 `json:"replicas,omitempty"` | ||
Image *opnimeta.ImageSpec `json:"image,omitempty"` | ||
AgentImageTagOverride string `json:"agentImageTagOverride,omitempty"` | ||
NatsRef corev1.LocalObjectReference `json:"natsCluster"` | ||
ServiceType corev1.ServiceType `json:"serviceType,omitempty"` | ||
ServiceAnnotations map[string]string `json:"serviceAnnotations,omitempty"` | ||
NodeSelector map[string]string `json:"nodeSelector,omitempty"` | ||
Tolerations []corev1.Toleration `json:"tolerations,omitempty"` | ||
Affinity *corev1.Affinity `json:"affinity,omitempty"` | ||
ExtraVolumeMounts []opnimeta.ExtraVolumeMount `json:"extraVolumeMounts,omitempty"` | ||
ExtraEnvVars []corev1.EnvVar `json:"extraEnvVars,omitempty"` | ||
|
||
//+kubebuilder:validation:Schemaless | ||
//+kubebuilder:pruning:PreserveUnknownFields | ||
//+kubebuilder:validation:Type=object | ||
Config *configv1.GatewayConfigSpec `json:"config,omitempty"` | ||
} | ||
|
||
type GatewayStatus struct { | ||
Image string `json:"image,omitempty"` | ||
ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"` | ||
ServiceName string `json:"serviceName,omitempty"` | ||
LoadBalancer *corev1.LoadBalancerIngress `json:"loadBalancer,omitempty"` | ||
Endpoints []corev1.EndpointAddress `json:"endpoints,omitempty"` | ||
Ready bool `json:"ready,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
// +kubebuilder:subresource:status | ||
type Gateway struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
Spec GatewaySpec `json:"spec,omitempty"` | ||
Status GatewayStatus `json:"status,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
type GatewayList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []Gateway `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register( | ||
&Gateway{}, &GatewayList{}, | ||
) | ||
} | ||
|
||
type ValueStoreMethods struct{} | ||
|
||
// ControllerReference implements crds.ValueStoreMethods. | ||
func (m ValueStoreMethods) ControllerReference() (client.Object, bool) { | ||
return nil, false // Gateway is a top-level object | ||
} | ||
|
||
// FillConfigFromObject implements crds.ValueStoreMethods. | ||
func (ValueStoreMethods) FillConfigFromObject(obj *Gateway, conf *configv1.GatewayConfigSpec) { | ||
proto.Merge(conf, obj.Spec.Config) | ||
} | ||
|
||
// FillObjectFromConfig implements crds.ValueStoreMethods. | ||
func (ValueStoreMethods) FillObjectFromConfig(obj *Gateway, conf *configv1.GatewayConfigSpec) { | ||
obj.Spec.Config = conf | ||
obj.Spec.Config.Revision = nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// +kubebuilder:object:generate=true | ||
// +groupName=core.opni.io | ||
package v1 | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
"sigs.k8s.io/controller-runtime/pkg/scheme" | ||
) | ||
|
||
var ( | ||
// GroupVersion is group version used to register these objects | ||
GroupVersion = schema.GroupVersion{Group: "core.opni.io", Version: "v1"} | ||
|
||
// SchemeBuilder is used to add go types to the GroupVersionKind scheme | ||
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} | ||
|
||
// AddToScheme adds the types in this group-version to the given scheme. | ||
AddToScheme = SchemeBuilder.AddToScheme | ||
) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.