This commit is contained in:
2025-03-25 23:39:38 +02:00
parent 567935bf7f
commit ae058f92e6
23 changed files with 1395 additions and 44 deletions

View 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 server-manager v1alpha1 API group
// +kubebuilder:object:generate=true
// +groupName=server-manager.acooldomain.co
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: "server-manager.acooldomain.co", 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
)

View File

@@ -0,0 +1,98 @@
/*
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 (
corev1 "k8s.io/api/core/v1"
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.
type BrowserStatus struct {
Url string `json:"url,omitempty"`
Running bool `json:"running,omitempty"`
}
type Port struct {
Protocol corev1.Protocol `json:"protocol,omitempty"`
Port int32 `json:"port,omitempty"`
}
type ServerStatus struct {
Domain string `json:"domain,omitempty"`
Running bool `json:"running,omitempty"`
HostPorts []Port `json:"host_ports,omitempty"`
}
type ServerSpec struct {
Image string `json:"image,omitempty"`
WorkingDir string `json:"working_dir,omitempty"`
Command []string `json:"command,omitempty"`
Args []string `json:"args,omitempty"`
On bool `json:"on,omitempty"`
Ports []Port `json:"ports,omitempty"`
}
type BrowserSpec struct {
Image string `json:"image,omitempty"`
On bool `json:"on,omitempty"`
Port Port `json:"port,omitempty"`
}
// ServerManagerSpec defines the desired state of ServerManager
type ServerManagerSpec struct {
Id string `json:"id,omitempty"`
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file
Server ServerSpec `json:"server,omitempty"`
Browser BrowserSpec `json:"browser,omitempty"`
}
// ServerManagerStatus defines the observed state of ServerManager
type ServerManagerStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
Server ServerStatus `json:"server,omitempty"`
Browser BrowserStatus `json:"browser,omitempty"`
}
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// ServerManager is the Schema for the servermanagers API
type ServerManager struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec ServerManagerSpec `json:"spec,omitempty"`
Status ServerManagerStatus `json:"status,omitempty"`
}
// +kubebuilder:object:root=true
// ServerManagerList contains a list of ServerManager
type ServerManagerList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ServerManager `json:"items"`
}
func init() {
SchemeBuilder.Register(&ServerManager{}, &ServerManagerList{})
}

View File

@@ -0,0 +1,204 @@
//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 (
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 *BrowserSpec) DeepCopyInto(out *BrowserSpec) {
*out = *in
out.Port = in.Port
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BrowserSpec.
func (in *BrowserSpec) DeepCopy() *BrowserSpec {
if in == nil {
return nil
}
out := new(BrowserSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *BrowserStatus) DeepCopyInto(out *BrowserStatus) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BrowserStatus.
func (in *BrowserStatus) DeepCopy() *BrowserStatus {
if in == nil {
return nil
}
out := new(BrowserStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Port) DeepCopyInto(out *Port) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Port.
func (in *Port) DeepCopy() *Port {
if in == nil {
return nil
}
out := new(Port)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ServerManager) DeepCopyInto(out *ServerManager) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
in.Status.DeepCopyInto(&out.Status)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServerManager.
func (in *ServerManager) DeepCopy() *ServerManager {
if in == nil {
return nil
}
out := new(ServerManager)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ServerManager) 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 *ServerManagerList) DeepCopyInto(out *ServerManagerList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]ServerManager, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServerManagerList.
func (in *ServerManagerList) DeepCopy() *ServerManagerList {
if in == nil {
return nil
}
out := new(ServerManagerList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ServerManagerList) 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 *ServerManagerSpec) DeepCopyInto(out *ServerManagerSpec) {
*out = *in
in.Server.DeepCopyInto(&out.Server)
out.Browser = in.Browser
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServerManagerSpec.
func (in *ServerManagerSpec) DeepCopy() *ServerManagerSpec {
if in == nil {
return nil
}
out := new(ServerManagerSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ServerManagerStatus) DeepCopyInto(out *ServerManagerStatus) {
*out = *in
in.Server.DeepCopyInto(&out.Server)
out.Browser = in.Browser
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServerManagerStatus.
func (in *ServerManagerStatus) DeepCopy() *ServerManagerStatus {
if in == nil {
return nil
}
out := new(ServerManagerStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ServerSpec) DeepCopyInto(out *ServerSpec) {
*out = *in
if in.Ports != nil {
in, out := &in.Ports, &out.Ports
*out = make([]Port, len(*in))
copy(*out, *in)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServerSpec.
func (in *ServerSpec) DeepCopy() *ServerSpec {
if in == nil {
return nil
}
out := new(ServerSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ServerStatus) DeepCopyInto(out *ServerStatus) {
*out = *in
if in.HostPorts != nil {
in, out := &in.HostPorts, &out.HostPorts
*out = make([]Port, len(*in))
copy(*out, *in)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServerStatus.
func (in *ServerStatus) DeepCopy() *ServerStatus {
if in == nil {
return nil
}
out := new(ServerStatus)
in.DeepCopyInto(out)
return out
}