Skip to content

Commit

Permalink
feat: add v1beta2 api
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon committed Jan 9, 2024
1 parent e9f7faa commit 5b85a14
Show file tree
Hide file tree
Showing 45 changed files with 7,222 additions and 160 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Image URL to use all building/pushing image targets
IMG ?= controller:latest
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=false"
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false"

CONTROLLER_NAMESPACE ?= lagoon-builddeploy

Expand Down
6 changes: 6 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ domain: lagoon.sh
multigroup: true
repo: github.com/uselagoon/remote-controller
resources:
- group: crd
kind: LagoonBuild
version: v1beta2
- group: crd
kind: LagoonTask
version: v1beta2
- group: crd
kind: LagoonBuild
version: v1beta1
Expand Down
43 changes: 22 additions & 21 deletions apis/lagoon/v1beta1/lagoonbuild_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,28 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// +kubebuilder:object:root=true
// +kubebuilder:deprecatedversion:warning="use lagoonbuilds.crd.lagoon.sh/v1beta2"

// LagoonBuild is the Schema for the lagoonbuilds API
type LagoonBuild struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec LagoonBuildSpec `json:"spec,omitempty"`
Status LagoonBuildStatus `json:"status,omitempty"`
StatusMessages *LagoonStatusMessages `json:"statusMessages,omitempty"`
}

// +kubebuilder:object:root=true

// LagoonBuildList contains a list of LagoonBuild
type LagoonBuildList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []LagoonBuild `json:"items"`
}

// BuildStatusType const for the status type
type BuildStatusType string

Expand Down Expand Up @@ -83,27 +105,6 @@ type LagoonBuildConditions struct {
// Condition string `json:"condition"`
}

// +kubebuilder:object:root=true

// LagoonBuild is the Schema for the lagoonbuilds API
type LagoonBuild struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec LagoonBuildSpec `json:"spec,omitempty"`
Status LagoonBuildStatus `json:"status,omitempty"`
StatusMessages *LagoonStatusMessages `json:"statusMessages,omitempty"`
}

// +kubebuilder:object:root=true

// LagoonBuildList contains a list of LagoonBuild
type LagoonBuildList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []LagoonBuild `json:"items"`
}

func init() {
SchemeBuilder.Register(&LagoonBuild{}, &LagoonBuildList{})
}
Expand Down
43 changes: 22 additions & 21 deletions apis/lagoon/v1beta1/lagoontask_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,28 @@ import (
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// +kubebuilder:object:root=true
// +kubebuilder:deprecatedversion:warning="use lagoontasks.crd.lagoon.sh/v1beta2"

// LagoonTask is the Schema for the lagoontasks API
type LagoonTask struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec LagoonTaskSpec `json:"spec,omitempty"`
Status LagoonTaskStatus `json:"status,omitempty"`
StatusMessages *LagoonStatusMessages `json:"statusMessages,omitempty"`
}

// +kubebuilder:object:root=true

// LagoonTaskList contains a list of LagoonTask
type LagoonTaskList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []LagoonTask `json:"items"`
}

// TaskStatusType const for the status type
type TaskStatusType string

Expand Down Expand Up @@ -152,27 +174,6 @@ type LagoonTaskConditions struct {
// Condition string `json:"condition"`
}

// +kubebuilder:object:root=true

// LagoonTask is the Schema for the lagoontasks API
type LagoonTask struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec LagoonTaskSpec `json:"spec,omitempty"`
Status LagoonTaskStatus `json:"status,omitempty"`
StatusMessages *LagoonStatusMessages `json:"statusMessages,omitempty"`
}

// +kubebuilder:object:root=true

// LagoonTaskList contains a list of LagoonTask
type LagoonTaskList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []LagoonTask `json:"items"`
}

func init() {
SchemeBuilder.Register(&LagoonTask{}, &LagoonTaskList{})
}
Expand Down
35 changes: 35 additions & 0 deletions apis/lagoon/v1beta2/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
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 v1beta1 contains API Schema definitions for the lagoon v1beta1 API group
// +kubebuilder:object:generate=true
// +groupName=crd.lagoon.sh
package v1beta2

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: "crd.lagoon.sh", Version: "v1beta2"}

// 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
)
105 changes: 105 additions & 0 deletions apis/lagoon/v1beta2/helpers_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package v1beta2

import (
"testing"
)

func TestCheckLagoonVersion(t *testing.T) {
type args struct {
build *LagoonBuild
checkVersion string
}
tests := []struct {
name string
args args
want bool
}{
{
name: "test1",
args: args{
build: &LagoonBuild{
Spec: LagoonBuildSpec{
Project: Project{
Variables: LagoonVariables{
Project: []byte(`[{"name":"LAGOON_SYSTEM_CORE_VERSION","value":"v2.12.0","scope":"internal_system"}]`),
},
},
},
},
checkVersion: "2.12.0",
},
want: true,
},
{
name: "test2",
args: args{
build: &LagoonBuild{
Spec: LagoonBuildSpec{
Project: Project{
Variables: LagoonVariables{
Project: []byte(`[{"name":"LAGOON_SYSTEM_CORE_VERSION","value":"v2.11.0","scope":"internal_system"}]`),
},
},
},
},
checkVersion: "2.12.0",
},
want: false,
},
{
name: "test3",
args: args{
build: &LagoonBuild{
Spec: LagoonBuildSpec{
Project: Project{
Variables: LagoonVariables{
Project: []byte(`[]`),
},
},
},
},
checkVersion: "2.12.0",
},
want: false,
},
{
name: "test4",
args: args{
build: &LagoonBuild{
Spec: LagoonBuildSpec{
Project: Project{
Variables: LagoonVariables{
Project: []byte(`[{"name":"LAGOON_SYSTEM_CORE_VERSION","value":"v2.12.0","scope":"internal_system"}]`),
},
},
},
},
checkVersion: "v2.12.0",
},
want: true,
},
{
name: "test5",
args: args{
build: &LagoonBuild{
Spec: LagoonBuildSpec{
Project: Project{
Variables: LagoonVariables{
Project: []byte(`[{"name":"LAGOON_SYSTEM_CORE_VERSION","value":"v2.11.0","scope":"internal_system"}]`),
},
},
},
},
checkVersion: "v2.12.0",
},
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := CheckLagoonVersion(tt.args.build, tt.args.checkVersion); got != tt.want {
t.Errorf("CheckLagoonVersion() = %v, want %v", got, tt.want)
}
})
}
}
Loading

0 comments on commit 5b85a14

Please sign in to comment.