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 0c44796
Show file tree
Hide file tree
Showing 36 changed files with 7,251 additions and 38 deletions.
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
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 0c44796

Please sign in to comment.