This commit is contained in:
115
api/v1alpha1/gitlabjobrunner_types.go
Normal file
115
api/v1alpha1/gitlabjobrunner_types.go
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
Copyright 2025.
|
||||
|
||||
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 (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// 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.
|
||||
|
||||
// GitlabJobRunnerSpec defines the desired state of GitlabJobRunner
|
||||
type GitlabJobRunnerSpec struct {
|
||||
// schedule in Cron format for recurring execution. If empty, runs as one-time Job
|
||||
// +optional
|
||||
Schedule string `json:"schedule,omitempty"`
|
||||
|
||||
// gitlabSecretRef references a Secret containing GitLab credentials
|
||||
// Expected keys: GITLAB_URL, GITLAB_TOKEN
|
||||
// +required
|
||||
GitlabSecretRef string `json:"gitlabSecretRef"`
|
||||
|
||||
// repositoryURL is the GitLab repository to clone
|
||||
// +required
|
||||
RepositoryURL string `json:"repositoryURL"`
|
||||
|
||||
// branch to checkout, defaults to "main"
|
||||
// +optional
|
||||
Branch string `json:"branch,omitempty"`
|
||||
|
||||
// scriptPath is the relative path to the script in the repository
|
||||
// +required
|
||||
ScriptPath string `json:"scriptPath"`
|
||||
|
||||
// image is the container image to use for execution
|
||||
// +optional
|
||||
Image string `json:"image,omitempty"`
|
||||
|
||||
// serviceAccountName to use for the Job/CronJob pods
|
||||
// +optional
|
||||
ServiceAccountName string `json:"serviceAccountName,omitempty"`
|
||||
|
||||
// suspend pauses scheduled execution (only for CronJobs)
|
||||
// +optional
|
||||
Suspend bool `json:"suspend,omitempty"`
|
||||
|
||||
// concurrencyPolicy defines how to handle concurrent executions
|
||||
// +optional
|
||||
// +kubebuilder:default:=Forbid
|
||||
ConcurrencyPolicy string `json:"concurrencyPolicy,omitempty"`
|
||||
}
|
||||
|
||||
// GitlabJobRunnerStatus defines the observed state of GitlabJobRunner.
|
||||
type GitlabJobRunnerStatus struct {
|
||||
// conditions represent the current state of the GitlabJobRunner resource.
|
||||
// +listType=map
|
||||
// +listMapKey=type
|
||||
// +optional
|
||||
Conditions []metav1.Condition `json:"conditions,omitempty"`
|
||||
|
||||
// lastScheduleTime is the last time a Job was scheduled
|
||||
// +optional
|
||||
LastScheduleTime *metav1.Time `json:"lastScheduleTime,omitempty"`
|
||||
|
||||
// activeJobName is the name of the currently running Job
|
||||
// +optional
|
||||
ActiveJobName string `json:"activeJobName,omitempty"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
// +kubebuilder:subresource:status
|
||||
|
||||
// GitlabJobRunner is the Schema for the gitlabjobrunners API
|
||||
type GitlabJobRunner struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
|
||||
// metadata is a standard object metadata
|
||||
// +optional
|
||||
metav1.ObjectMeta `json:"metadata,omitzero"`
|
||||
|
||||
// spec defines the desired state of GitlabJobRunner
|
||||
// +required
|
||||
Spec GitlabJobRunnerSpec `json:"spec"`
|
||||
|
||||
// status defines the observed state of GitlabJobRunner
|
||||
// +optional
|
||||
Status GitlabJobRunnerStatus `json:"status,omitzero"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
|
||||
// GitlabJobRunnerList contains a list of GitlabJobRunner
|
||||
type GitlabJobRunnerList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitzero"`
|
||||
Items []GitlabJobRunner `json:"items"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(&GitlabJobRunner{}, &GitlabJobRunnerList{})
|
||||
}
|
||||
36
api/v1alpha1/groupversion_info.go
Normal file
36
api/v1alpha1/groupversion_info.go
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
Copyright 2025.
|
||||
|
||||
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 API Schema definitions for the batch v1alpha1 API group.
|
||||
// +kubebuilder:object:generate=true
|
||||
// +groupName=batch.rml.ru
|
||||
package v1alpha1
|
||||
|
||||
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: "batch.rml.ru", Version: "v1alpha1"}
|
||||
|
||||
// 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
|
||||
)
|
||||
126
api/v1alpha1/zz_generated.deepcopy.go
Normal file
126
api/v1alpha1/zz_generated.deepcopy.go
Normal file
@@ -0,0 +1,126 @@
|
||||
//go:build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright 2025.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// Code generated by controller-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *GitlabJobRunner) DeepCopyInto(out *GitlabJobRunner) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
out.Spec = in.Spec
|
||||
in.Status.DeepCopyInto(&out.Status)
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GitlabJobRunner.
|
||||
func (in *GitlabJobRunner) DeepCopy() *GitlabJobRunner {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(GitlabJobRunner)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *GitlabJobRunner) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *GitlabJobRunnerList) DeepCopyInto(out *GitlabJobRunnerList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]GitlabJobRunner, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GitlabJobRunnerList.
|
||||
func (in *GitlabJobRunnerList) DeepCopy() *GitlabJobRunnerList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(GitlabJobRunnerList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *GitlabJobRunnerList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *GitlabJobRunnerSpec) DeepCopyInto(out *GitlabJobRunnerSpec) {
|
||||
*out = *in
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GitlabJobRunnerSpec.
|
||||
func (in *GitlabJobRunnerSpec) DeepCopy() *GitlabJobRunnerSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(GitlabJobRunnerSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *GitlabJobRunnerStatus) DeepCopyInto(out *GitlabJobRunnerStatus) {
|
||||
*out = *in
|
||||
if in.Conditions != nil {
|
||||
in, out := &in.Conditions, &out.Conditions
|
||||
*out = make([]v1.Condition, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
if in.LastScheduleTime != nil {
|
||||
in, out := &in.LastScheduleTime, &out.LastScheduleTime
|
||||
*out = (*in).DeepCopy()
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GitlabJobRunnerStatus.
|
||||
func (in *GitlabJobRunnerStatus) DeepCopy() *GitlabJobRunnerStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(GitlabJobRunnerStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
Reference in New Issue
Block a user