Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
12 changes: 12 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,16 @@ resources:
conversion: true
defaulting: true
webhookVersion: v1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: eiffel-community.github.io
group: etos
kind: Iut
path: github.com/eiffel-community/etos/api/v1alpha2
version: v1alpha2
webhooks:
defaulting: true
webhookVersion: v1
version: "3"
3 changes: 3 additions & 0 deletions api/v1alpha1/provider_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ type ProviderSpec struct {
// and don't muddle up the yaml with empty data.
JSONTas *JSONTas `json:"jsontas,omitempty"`
JSONTasSource *VarSource `json:"jsontasSource,omitempty"`

// Image describes the docker image to run when providing a resource.
Image string `json:"image,omitempty"`
}

// ProviderStatus defines the observed state of Provider
Expand Down
36 changes: 36 additions & 0 deletions api/v1alpha2/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright Axis Communications AB.
//
// For a full list of individual contributors, please see the commit history.
//
// 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 v1alpha2 contains API Schema definitions for the etos v1alpha2 API group.
// +kubebuilder:object:generate=true
// +groupName=etos.eiffel-community.github.io
package v1alpha2

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: "etos.eiffel-community.github.io", Version: "v1alpha2"}

// 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
)
107 changes: 107 additions & 0 deletions api/v1alpha2/iut_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
// Copyright Axis Communications AB.
//
// For a full list of individual contributors, please see the commit history.
//
// 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 v1alpha2

import (
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// IutSpec defines the desired state of Iut
type IutSpec struct {
// ID is the ID for the IUT. The ID is a UUID, any version, and regex matches that.
// +kubebuilder:validation:Pattern="^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
// +required
ID string `json:"id"`

// Identity is the PackageURL definition of the IUT.
// +required
Identity string `json:"identity"`

// EnvironmentRequest is the name of the environmentrequest which requested this IUT.
// +required
EnvironmentRequest string `json:"environmentRequest"`

// ProviderID is the name of the Provider used to create this Iut.
// +required
ProviderID string `json:"provider_id"`

// ProviderData is specific data provided by the IUT providers
// +optional
ProviderData *apiextensionsv1.JSON `json:"provider_data,omitempty"`
}

// IutStatus defines the observed state of Iut.
type IutStatus struct {
// For Kubernetes API conventions, see:
// https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties

// conditions represent the current state of the Iut resource.
// Each condition has a unique type and reflects the status of a specific aspect of the resource.
//
// Standard condition types include:
// - "Available": the resource is fully functional
// - "Progressing": the resource is being created or updated
// - "Degraded": the resource failed to reach or maintain its desired state
//
// The status of each condition is one of True, False, or Unknown.
// +listType=map
// +listMapKey=type
// +optional
Conditions []metav1.Condition `json:"conditions,omitempty"`

CompletionTime *metav1.Time `json:"completionTime,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status

// Iut is the Schema for the iuts API
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type==\"Active\")].status"
// +kubebuilder:printcolumn:name="Reason",type="string",JSONPath=".status.conditions[?(@.type==\"Active\")].reason"
// +kubebuilder:printcolumn:name="Description",type="string",JSONPath=".status.conditions[?(@.type==\"Active\")].message"
// +kubebuilder:printcolumn:name="Provider",type="string",JSONPath=.spec.provider_id
// +kubebuilder:printcolumn:name="Environment",type="string",JSONPath=".metadata.ownerReferences[?(@.kind==\"Environment\")].name"
// +kubebuilder:printcolumn:name="TestRun",type="string",JSONPath=.metadata.labels.etos\.eiffel-community\.github\.io/id
type Iut struct {
metav1.TypeMeta `json:",inline"`

// metadata is a standard object metadata
// +optional
metav1.ObjectMeta `json:"metadata,omitempty,omitzero"`

// spec defines the desired state of Iut
// +required
Spec IutSpec `json:"spec"`

// status defines the observed state of Iut
// +optional
Status IutStatus `json:"status,omitempty,omitzero"`
}

// +kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&Iut{}, &IutList{})
}
132 changes: 132 additions & 0 deletions api/v1alpha2/zz_generated.deepcopy.go

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

17 changes: 17 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ import (
"sigs.k8s.io/controller-runtime/pkg/webhook"

etosv1alpha1 "github.com/eiffel-community/etos/api/v1alpha1"
etosv1alpha2 "github.com/eiffel-community/etos/api/v1alpha2"
"github.com/eiffel-community/etos/internal/controller"
webhooketosv1alpha1 "github.com/eiffel-community/etos/internal/webhook/v1alpha1"
webhookv1alpha2 "github.com/eiffel-community/etos/internal/webhook/v1alpha2"
// +kubebuilder:scaffold:imports
)

Expand All @@ -53,6 +55,7 @@ func init() {
utilruntime.Must(clientgoscheme.AddToScheme(scheme))

utilruntime.Must(etosv1alpha1.AddToScheme(scheme))
utilruntime.Must(etosv1alpha2.AddToScheme(scheme))
// +kubebuilder:scaffold:scheme
}

Expand Down Expand Up @@ -261,6 +264,20 @@ func main() {
os.Exit(1)
}
}
if err := (&controller.IutReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "Iut")
os.Exit(1)
}
// nolint:goconst
if os.Getenv("ENABLE_WEBHOOKS") != "false" {
if err := webhookv1alpha2.SetupIutWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "Iut")
os.Exit(1)
}
}
// +kubebuilder:scaffold:builder

if metricsCertWatcher != nil {
Expand Down
Loading
Loading