Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firewall Specs #60

Merged
merged 3 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions apis/civo/firewall/v1alpha1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
Copyright 2024 The Crossplane Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package v1alpha1 contains the v1alpha1 group Sample resources of the Template provider.
// +kubebuilder:object:generate=true
// +groupName=firewall.civo.crossplane.io
// +versionName=v1alpha1
package v1alpha1
50 changes: 50 additions & 0 deletions apis/civo/firewall/v1alpha1/register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
Copyright 2020 The Crossplane Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
"reflect"

"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

// Package type metadata.
const (
Group = "firewall.civo.crossplane.io"
Version = "v1alpha1"
)

var (
// SchemeGroupVersion is group version used to register these objects
SchemeGroupVersion = schema.GroupVersion{Group: Group, Version: Version}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion}
)

// CivoFirewall type metadata.
var (
CivoFirewallKind = reflect.TypeOf(CivoFirewall{}).Name()
CivoFirewallGroupKind = schema.GroupKind{Group: Group, Kind: CivoFirewallKind}.String()
CivoFirewallKindAPIVersion = CivoFirewallKind + "." + SchemeGroupVersion.String()
CivoFirewallGroupVersionKind = SchemeGroupVersion.WithKind(CivoFirewallKind)
)

func init() {
SchemeBuilder.Register(&CivoFirewall{}, &CivoFirewallList{})
}
85 changes: 85 additions & 0 deletions apis/civo/firewall/v1alpha1/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package v1alpha1

import (
xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// CivoFirewallSpec holds the specs for firewall resource
type CivoFirewallSpec struct {
xpv1.ResourceSpec `json:",inline"`

// Name that you wish to use to refer to this firewall.
// +required
// +immutable
// +kubebuilder:validation:Required
Name string `json:"name"`

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

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about FirewallRules?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// 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"`
}

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

// +kubebuilder:object:root=true

// CivoFirewall is the Schema for the CivoFirewalls API
// +kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status"
// +kubebuilder:printcolumn:name="MESSAGE",type="string",JSONPath=".status.atProvider.state"
// Please replace `PROVIDER-NAME` with your actual provider name, like `aws`, `azure`, `gcp`, `alibaba`
// +kubebuilder:resource:scope=Cluster,categories={crossplane,managed,civo}
// +kubebuilder:subresource:status
type CivoFirewall struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec CivoFirewallSpec `json:"spec"`
Status CivoFirewallStatus `json:"status,omitempty"`
}

// SetManagementPolicies sets up management policies.
func (mg *CivoFirewall) SetManagementPolicies(r xpv1.ManagementPolicies) {}

// GetManagementPolicies gets management policies.
func (mg *CivoFirewall) GetManagementPolicies() xpv1.ManagementPolicies {
// Note: Crossplane runtime reconciler should leave handling of
// ManagementPolicies to the provider controller. This is a temporary hack
// until we remove the ManagementPolicy field from the Provider Kubernetes
// Object in favor of the one in the ResourceSpec.
return []xpv1.ManagementAction{xpv1.ManagementActionAll}
}

// SetPublishConnectionDetailsTo sets up connection details.
func (mg *CivoFirewall) SetPublishConnectionDetailsTo(r *xpv1.PublishConnectionDetailsTo) {
mg.Spec.PublishConnectionDetailsTo = r
}

// GetPublishConnectionDetailsTo gets publish connection details.
func (mg *CivoFirewall) GetPublishConnectionDetailsTo() *xpv1.PublishConnectionDetailsTo {
return mg.Spec.PublishConnectionDetailsTo
}

// +kubebuilder:object:root=true

// CivoFirewallList contains a list of CivoFirewall
type CivoFirewallList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []CivoFirewall `json:"items"`
}
138 changes: 138 additions & 0 deletions 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.

76 changes: 76 additions & 0 deletions apis/civo/firewall/v1alpha1/zz_generated.managed.go

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

Loading
Loading