Skip to content

Commit

Permalink
Update Firewall Specs
Browse files Browse the repository at this point in the history
Signed-off-by: uzair <uzaxirr@gmail.com>
  • Loading branch information
uzaxirr committed Apr 13, 2024
1 parent 0454b77 commit 4b40c42
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 25 deletions.
67 changes: 54 additions & 13 deletions apis/civo/firewall/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,79 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// CivoFirewallSpec holds the specs for firewall resource
// CivoFirewallSpec defines the desired state of a Firewall.
type CivoFirewallSpec struct {
xpv1.ResourceSpec `json:",inline"`

// Name that you wish to use to refer to this firewall.
// +required
// +immutable
// Name is the name of the Firewall within Civo.
// +kubebuilder:validation:Required
// +immutable
Name string `json:"name"`

// NetworkID for the network with which the firewall is to be associated.
// +required
// NetworkID is the identifier for the network associated with the Firewall.
// +kubebuilder:validation:Required
// +immutable
NetworkID string `json:"networkId"`

// Region is the identifier for the region in which the Firewall is deployed.
// +kubebuilder:validation:Required
NetworkID string `json:"network_id"`
Region string `json:"region"`

// Rules are the set of rules applied to the firewall.
// +optional
Rules []FirewallRule `json:"rules,omitempty"`

// ProviderReference holds configs (region, API key etc) for the crossplane provider that is being used.
ProviderReference *xpv1.Reference `json:"providerReference"`
}

// CivoFirewallObservation observation fields
type CivoFirewallObservation struct {
ID string `json:"id"`
Name string `json:"name,omitempty"`
// FirewallRule defines the rules applied to the Firewall.
type FirewallRule struct {
// Protocol used by the rule (TCP, UDP, ICMP).
// +kubebuilder:validation:Enum=TCP;UDP;ICMP
// +kubebuilder:validation:Required
Protocol string `json:"protocol"`

// StartPort is the starting port of the range.
// +kubebuilder:validation:Required
StartPort int `json:"startPort"`

// EndPort is the ending port of the range.
// +optional
EndPort *int `json:"endPort,omitempty"`

// CIDR is the IP address range that is applicable for the rule.
// +kubebuilder:validation:Required
CIDR string `json:"cidr"`

// Direction indicates whether the rule is for inbound or outbound traffic.
// +kubebuilder:validation:Enum=ingress;egress
// +kubebuilder:validation:Required
Direction string `json:"direction"`

// Label is an optional identifier for the rule.
// +optional
Label string `json:"label,omitempty"`
}

// CivoFirewallStatus status of the resource
// CivoFirewallStatus defines the observed state of CivoFirewall.
type CivoFirewallStatus struct {
xpv1.ResourceStatus `json:",inline"`
AtProvider CivoFirewallObservation `json:"atProvider,omitempty"`
}

// CivoFirewallObservation is used to reflect the observed state of the firewall.
type CivoFirewallObservation struct {
// ID is the Civo ID of the Firewall.
ID string `json:"id,omitempty"`

// InstanceCount shows how many instances are using this firewall.
InstanceCount *int `json:"instanceCount,omitempty"`

// RulesCount shows how many rules are associated with this firewall.
RulesCount int `json:"rulesCount"`
}

// +kubebuilder:object:root=true

// CivoFirewall is the Schema for the CivoFirewalls API
Expand Down Expand Up @@ -77,7 +118,7 @@ func (mg *CivoFirewall) GetPublishConnectionDetailsTo() *xpv1.PublishConnectionD

// +kubebuilder:object:root=true

// CivoFirewallList contains a list of CivoFirewall
// CivoFirewallList contains a list of CivoFirewall.
type CivoFirewallList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Expand Down
34 changes: 33 additions & 1 deletion apis/civo/firewall/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 63 additions & 11 deletions package/crds/firewall.civo.crossplane.io_civofirewalls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ spec:
metadata:
type: object
spec:
description: CivoFirewallSpec holds the specs for firewall resource
description: CivoFirewallSpec defines the desired state of a Firewall.
properties:
deletionPolicy:
default: Delete
Expand Down Expand Up @@ -94,11 +94,11 @@ spec:
type: string
type: array
name:
description: Name that you wish to use to refer to this firewall.
description: Name is the name of the Firewall within Civo.
type: string
network_id:
description: NetworkID for the network with which the firewall is
to be associated.
networkId:
description: NetworkID is the identifier for the network associated
with the Firewall.
type: string
providerConfigRef:
default:
Expand Down Expand Up @@ -251,6 +251,49 @@ spec:
required:
- name
type: object
region:
description: Region is the identifier for the region in which the
Firewall is deployed.
type: string
rules:
description: Rules are the set of rules applied to the firewall.
items:
description: FirewallRule defines the rules applied to the Firewall.
properties:
cidr:
description: CIDR is the IP address range that is applicable
for the rule.
type: string
direction:
description: Direction indicates whether the rule is for inbound
or outbound traffic.
enum:
- ingress
- egress
type: string
endPort:
description: EndPort is the ending port of the range.
type: integer
label:
description: Label is an optional identifier for the rule.
type: string
protocol:
description: Protocol used by the rule (TCP, UDP, ICMP).
enum:
- TCP
- UDP
- ICMP
type: string
startPort:
description: StartPort is the starting port of the range.
type: integer
required:
- cidr
- direction
- protocol
- startPort
type: object
type: array
writeConnectionSecretToRef:
description: |-
WriteConnectionSecretToReference specifies the namespace and name of a
Expand All @@ -274,21 +317,30 @@ spec:
type: object
required:
- name
- network_id
- networkId
- providerReference
- region
type: object
status:
description: CivoFirewallStatus status of the resource
description: CivoFirewallStatus defines the observed state of CivoFirewall.
properties:
atProvider:
description: CivoFirewallObservation observation fields
description: CivoFirewallObservation is used to reflect the observed
state of the firewall.
properties:
id:
description: ID is the Civo ID of the Firewall.
type: string
name:
type: string
instanceCount:
description: InstanceCount shows how many instances are using
this firewall.
type: integer
rulesCount:
description: RulesCount shows how many rules are associated with
this firewall.
type: integer
required:
- id
- rulesCount
type: object
conditions:
description: Conditions of the resource.
Expand Down

0 comments on commit 4b40c42

Please sign in to comment.