|
| 1 | +package v1alpha1 |
| 2 | + |
| 3 | +import ( |
| 4 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 5 | + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" |
| 6 | +) |
| 7 | + |
| 8 | +const ( |
| 9 | + MetalStackFirewallDeploymentKind = "MetalStackFirewallDeployment" |
| 10 | + // FirewallDeploymentFinalizer allows to clean up resources associated with before removing it from the apiserver. |
| 11 | + FirewallDeploymentFinalizer = "metal-stack.infrastructure.cluster.x-k8s.io/firewall-deployment" |
| 12 | + |
| 13 | + TagFirewallDeploymentResource = "metal-stack.infrastructure.cluster.x-k8s.io/firewall-deployment-resource" |
| 14 | + |
| 15 | + ClusterFirewallDeploymentEnsured clusterv1.ConditionType = "ClusterFirewallDeploymentEnsured" |
| 16 | +) |
| 17 | + |
| 18 | +// MetalStackFirewallDeploymentSpec defines the desired state of MetalStackFirewallDeployment |
| 19 | +type MetalStackFirewallDeploymentSpec struct { |
| 20 | + // FirewallTemplateRef references the MetalStackFirewallTemplate to use for the firewall deployment. |
| 21 | + FirewallTemplateRef MetalStackFirewallTemplateRef `json:"firewallTemplateRef"` |
| 22 | + // ManagedResourceRef references the resource that represents the firewall deployment. At this moment it is a metal-stack firewall id. |
| 23 | + // It is planned to reference a FirewallDeployment. |
| 24 | + // +optional |
| 25 | + ManagedResourceRef *MetalStackManagedResourceRef `json:"managedResourceRef,omitempty"` |
| 26 | + |
| 27 | + // AutoUpdate defines the behavior for automatic updates. |
| 28 | + AutoUpdate *MetalStackFirewallAutoUpdate `json:"autoUpdate,omitempty"` |
| 29 | +} |
| 30 | + |
| 31 | +type MetalStackFirewallAutoUpdate struct { |
| 32 | + MachineImage bool `json:"machineImage,omitempty"` |
| 33 | +} |
| 34 | + |
| 35 | +// MetalStackManagedResourceRef references a MetalStackManagedResource. |
| 36 | +type MetalStackManagedResourceRef struct { |
| 37 | + // Name of the MetalStackManagedResource. |
| 38 | + Name string `json:"name"` |
| 39 | +} |
| 40 | + |
| 41 | +// MetalStackFirewallTemplateRef references a MetalStackFirewallTemplate. |
| 42 | +type MetalStackFirewallTemplateRef struct { |
| 43 | + // Name of the MetalStackFirewallTemplate. |
| 44 | + Name string `json:"name"` |
| 45 | +} |
| 46 | + |
| 47 | +// MetalStackFirewallDeploymentStatus defines the observed state of MetalStackFirewallDeployment |
| 48 | +type MetalStackFirewallDeploymentStatus struct { |
| 49 | + // +kubebuilder:default=false |
| 50 | + Ready bool `json:"ready"` |
| 51 | + |
| 52 | + // Conditions defines current service state of the MetalStackCluster. |
| 53 | + // +optional |
| 54 | + Conditions clusterv1.Conditions `json:"conditions,omitempty"` |
| 55 | +} |
| 56 | + |
| 57 | +// +kubebuilder:object:root=true |
| 58 | +// +kubebuilder:subresource:status |
| 59 | +// +kubebuilder:resource:scope=Namespaced,categories=cluster-api,shortName=msfwdeploy |
| 60 | +// +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".metadata.labels.cluster\\.x-k8s\\.io/cluster-name",description="Cluster to which this MetalStackCluster belongs" |
| 61 | +// +kubebuilder:printcolumn:name="Template",type="string",JSONPath=".spec.firewallTemplateRef.name",description="Name of the MetalStackFirewallTemplate used" |
| 62 | +// +kubebuilder:printcolumn:name="Deployment",type="string",JSONPath=".spec.managedResourceRef.name",description="Name of the managed FirewallDeployment" |
| 63 | +// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.ready",description="Indicates if the MetalStackFirewallDeployment is ready" |
| 64 | +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Age of the MetalStackFirewallDeployment" |
| 65 | + |
| 66 | +// MetalStackFirewallDeployment is the Schema for the MetalStackFirewallDeployments API |
| 67 | +type MetalStackFirewallDeployment struct { |
| 68 | + metav1.TypeMeta `json:",inline"` |
| 69 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 70 | + |
| 71 | + Spec MetalStackFirewallDeploymentSpec `json:"spec,omitzero"` |
| 72 | + Status MetalStackFirewallDeploymentStatus `json:"status,omitempty"` |
| 73 | +} |
| 74 | + |
| 75 | +// +kubebuilder:object:root=true |
| 76 | + |
| 77 | +type MetalStackFirewallDeploymentList struct { |
| 78 | + metav1.TypeMeta `json:",inline"` |
| 79 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 80 | + Items []MetalStackFirewallDeployment `json:"items"` |
| 81 | +} |
| 82 | + |
| 83 | +func init() { |
| 84 | + SchemeBuilder.Register(&MetalStackFirewallDeployment{}, &MetalStackFirewallDeploymentList{}) |
| 85 | +} |
| 86 | + |
| 87 | +func (c *MetalStackFirewallDeployment) GetConditions() clusterv1.Conditions { |
| 88 | + return c.Status.Conditions |
| 89 | +} |
| 90 | + |
| 91 | +func (c *MetalStackFirewallDeployment) SetConditions(conditions clusterv1.Conditions) { |
| 92 | + c.Status.Conditions = conditions |
| 93 | +} |
0 commit comments