Skip to content

Commit

Permalink
MAJOR: crd: add v1 crd and deprecate alpha2
Browse files Browse the repository at this point in the history
with this change, v1 of backends, defaults and global are introduced, and at the same time alpha2 versions are deprecated

Co-authored-by: Helene Durand <[email protected]>
  • Loading branch information
oktalz and hdurand0710 committed Dec 18, 2023
1 parent 72314fd commit c01d3b3
Show file tree
Hide file tree
Showing 137 changed files with 9,854 additions and 6,453 deletions.
16 changes: 16 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@ diff:
script:
- test -z "$(git diff 2> /dev/null)" || exit "Documentation is not generated, issue \`cd documentation/gen && go run .\` and commit the result"
- test -z "$(git ls-files --others --exclude-standard 2> /dev/null)" || exit "Documentation created untracked files, cannot proceed"
diff-crd:
stage: diff
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_PIPELINE_SOURCE == 'push'
image:
name: $CI_REGISTRY_GO/golang:$GO_VERSION
entrypoint: [ "" ]
tags:
- go
before_script:
- make cr_generate
script:
- git diff
- test -z "$(git diff 2> /dev/null)" || exit "CRD generation was not generated, issue \`make cr_generate\` and commit the result"
- test -z "$(git ls-files --others --exclude-standard 2> /dev/null)" || exit "CRD generation created untracked files, cannot proceed"
tidy:
stage: lint
needs: []
Expand Down
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ publish:
.PHONY: cr_generate
cr_generate:
crs/code-generator.sh
grep -lir defaultses crs/* | xargs sed -i 's/Defaultses/Defaults/g'
grep -lir defaultses crs/* | xargs sed -i 's/defaultses/defaults/g'

.PHONY: gofumpt
gofumpt:
Expand Down
56 changes: 56 additions & 0 deletions crs/api/ingress/v1/backend.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright 2019 HAProxy Technologies
//
// 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 v1

import (
"github.com/haproxytech/client-native/v5/models"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:metadata:annotations="haproxy.org/client-native=v5.0.3"

// Backend is a specification for a Backend resource
type Backend struct {
Spec BackendSpec `json:"spec"`
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
}

// BackendSpec defines the desired state of Backend
type BackendSpec struct {
Config *models.Backend `json:"config"`
}

// DeepCopyInto deepcopying the receiver into out. in must be non-nil.
func (in *BackendSpec) DeepCopyInto(out *BackendSpec) {
*out = *in
if in.Config != nil {
b, _ := in.Config.MarshalBinary()
_ = out.Config.UnmarshalBinary(b)
}
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// BackendList is a list of Backend resources
type BackendList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`

Items []Backend `json:"items"`
}
56 changes: 56 additions & 0 deletions crs/api/ingress/v1/defaults.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright 2019 HAProxy Technologies
//
// 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 v1

import (
"github.com/haproxytech/client-native/v5/models"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:metadata:annotations="haproxy.org/client-native=v5.0.3"

// Defaults is a specification for a Defaults resource
type Defaults struct {
Spec DefaultsSpec `json:"spec"`
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
}

// DefaultsSpec defines the desired state of Defaults
type DefaultsSpec struct {
Config *models.Defaults `json:"config"`
}

// DeepCopyInto deepcopying the receiver into out. in must be non-nil.
func (in *DefaultsSpec) DeepCopyInto(out *DefaultsSpec) {
*out = *in
if in.Config != nil {
b, _ := in.Config.MarshalBinary()
_ = out.Config.UnmarshalBinary(b)
}
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// DefaultsList is a list of Defaults resources
type DefaultsList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`

Items []Defaults `json:"items"`
}
5 changes: 5 additions & 0 deletions crs/api/ingress/v1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Package v1 contains the core v1 API group
//
// +k8s:deepcopy-gen=package
// +groupName=ingress.v1.haproxy.org
package v1
68 changes: 68 additions & 0 deletions crs/api/ingress/v1/global.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// Copyright 2019 HAProxy Technologies
//
// 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 v1

import (
"github.com/haproxytech/client-native/v5/models"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:metadata:annotations="haproxy.org/client-native=v5.0.3"
// +kubebuilder:validation:XValidation:rule="!has(self.spec.config.default_path)", message="spec.config.default_path is set by ingress controller internally"
// +kubebuilder:validation:XValidation:rule="!has(self.spec.config.master__dash__worker)", message="spec.config.master-worker is set by ingress controller internally"
// +kubebuilder:validation:XValidation:rule="!has(self.spec.config.pidfile)", message="spec.config.pidfile is set by ingress controller internally"
// +kubebuilder:validation:XValidation:rule="!has(self.spec.config.localpeer)", message="spec.config.localpeer is set by ingress controller internally"

// Global is a specification for a Global resource
type Global struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec GlobalSpec `json:"spec"`
}

// GlobalSpec defines the desired state of Global
type GlobalSpec struct {
Config *models.Global `json:"config"`
LogTargets models.LogTargets `json:"log_targets,omitempty"` //nolint:tagliatelle
}

// DeepCopyInto deepcopying the receiver into out. in must be non-nil.
func (in *GlobalSpec) DeepCopyInto(out *GlobalSpec) {
if in.Config != nil {
b, _ := in.Config.MarshalBinary()
_ = out.Config.UnmarshalBinary(b)
}
if in.LogTargets != nil {
out.LogTargets = make([]*models.LogTarget, len(in.LogTargets))
for i, v := range in.LogTargets {
b, _ := v.MarshalBinary()
_ = out.LogTargets[i].UnmarshalBinary(b)
}
}
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// GlobalList is a list of Global resources
type GlobalList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`

Items []Global `json:"items"`
}
Loading

0 comments on commit c01d3b3

Please sign in to comment.