-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0128560
Showing
12 changed files
with
569 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build-and-push: | ||
uses: ls1intum/.github/.github/workflows/build-and-push-docker-image.yml@feat/docker-run-network | ||
with: | ||
docker-file: Dockerfile | ||
image-name: ghcr.io/ls1intum/theia/garbage-collector | ||
docker-context: . | ||
tags: "2024-12-02" | ||
network: "host" | ||
secrets: inherit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM golang:1.23.3 | ||
LABEL authors="iyannsch" | ||
|
||
WORKDIR /app | ||
COPY go.mod go.sum ./ | ||
|
||
RUN go mod download | ||
|
||
COPY api/ api/ | ||
COPY clientset/ clientset/ | ||
COPY *.go ./ | ||
|
||
RUN go build -o /garbage-collector | ||
|
||
ENTRYPOINT ["/garbage-collector"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package v1beta5 | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/runtime" | ||
) | ||
|
||
// Required for the K8s API to accept the CRDs as types | ||
|
||
// DeepCopyInto copies all properties of this object into another object of the | ||
// same type that is provided as a pointer. | ||
func (in *Workspace) DeepCopyInto(out *Workspace) { | ||
out.TypeMeta = in.TypeMeta | ||
out.ObjectMeta = in.ObjectMeta | ||
out.Spec = WorkspaceSpec{ | ||
Name: in.Spec.Name, | ||
Label: in.Spec.Label, | ||
AppDefinition: in.Spec.AppDefinition, | ||
User: in.Spec.User, | ||
Storage: in.Spec.Storage, | ||
Options: in.Spec.Options, | ||
} | ||
} | ||
|
||
// DeepCopyObject returns a generically typed copy of an object | ||
func (in *Workspace) DeepCopyObject() runtime.Object { | ||
out := Workspace{} | ||
in.DeepCopyInto(&out) | ||
|
||
return &out | ||
} | ||
|
||
// DeepCopyObject returns a generically typed copy of an object | ||
func (in *WorkspaceList) DeepCopyObject() runtime.Object { | ||
out := WorkspaceList{} | ||
out.TypeMeta = in.TypeMeta | ||
out.ListMeta = in.ListMeta | ||
|
||
if in.Items != nil { | ||
out.Items = make([]Workspace, len(in.Items)) | ||
for i := range in.Items { | ||
in.Items[i].DeepCopyInto(&out.Items[i]) | ||
} | ||
} | ||
|
||
return &out | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package v1beta5 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
) | ||
|
||
const GroupName = "theia.cloud" | ||
const GroupVersion = "v1beta5" | ||
|
||
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: GroupVersion} | ||
|
||
var ( | ||
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) | ||
AddToScheme = SchemeBuilder.AddToScheme | ||
) | ||
|
||
func addKnownTypes(scheme *runtime.Scheme) error { | ||
scheme.AddKnownTypes(SchemeGroupVersion, | ||
&Workspace{}, | ||
&WorkspaceList{}, | ||
) | ||
|
||
metav1.AddToGroupVersion(scheme, SchemeGroupVersion) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package v1beta5 | ||
|
||
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
// WorkspaceSpec defines the desired state of Workspace | ||
type WorkspaceSpec struct { | ||
Name string `json:"name,omitempty"` | ||
Label string `json:"label,omitempty"` | ||
AppDefinition string `json:"appDefinition,omitempty"` | ||
User string `json:"user,omitempty"` | ||
Storage string `json:"storage,omitempty"` | ||
Options map[string]string `json:"options,omitempty"` | ||
} | ||
|
||
// WorkspaceStatus defines the observed state of Workspace | ||
type WorkspaceStatus struct { | ||
OperatorStatus string `json:"operatorStatus,omitempty"` | ||
OperatorMessage string `json:"operatorMessage,omitempty"` | ||
VolumeClaim struct { | ||
Status string `json:"status,omitempty"` | ||
Message string `json:"message,omitempty"` | ||
} `json:"volumeClaim,omitempty"` | ||
VolumeAttach struct { | ||
Status string `json:"status,omitempty"` | ||
Message string `json:"message,omitempty"` | ||
} `json:"volumeAttach,omitempty"` | ||
Error string `json:"error,omitempty"` | ||
} | ||
|
||
// Workspace is the Schema for the Workspaces API | ||
type Workspace struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
Spec WorkspaceSpec `json:"spec,omitempty"` | ||
Status WorkspaceStatus `json:"status,omitempty"` | ||
} | ||
|
||
// WorkspaceList contains a list of Workspace | ||
type WorkspaceList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []Workspace `json:"items"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package v1beta5 | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
"k8s.io/client-go/kubernetes/scheme" | ||
"k8s.io/client-go/rest" | ||
"theia-workspace-garbage-collector/api/types/v1beta5" | ||
) | ||
|
||
type V1Beta5Interface interface { | ||
Workspace(namespace string) WorkspaceInterface | ||
} | ||
|
||
type V1Beta5Client struct { | ||
restClient rest.Interface | ||
} | ||
|
||
func NewForConfig(c *rest.Config) (*V1Beta5Client, error) { | ||
config := *c | ||
config.ContentConfig.GroupVersion = &schema.GroupVersion{Group: v1beta5.GroupName, Version: v1beta5.GroupVersion} | ||
config.APIPath = "/apis" | ||
config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() | ||
config.UserAgent = rest.DefaultKubernetesUserAgent() | ||
|
||
client, err := rest.RESTClientFor(&config) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &V1Beta5Client{restClient: client}, nil | ||
} | ||
|
||
func (c *V1Beta5Client) Workspaces(namespace string) WorkspaceInterface { | ||
return &workspaceClient{ | ||
restClient: c.restClient, | ||
ns: namespace, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package v1beta5 | ||
|
||
import ( | ||
"context" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/client-go/kubernetes/scheme" | ||
"k8s.io/client-go/rest" | ||
"theia-workspace-garbage-collector/api/types/v1beta5" | ||
) | ||
|
||
type WorkspaceInterface interface { | ||
List(opts metav1.ListOptions) (*v1beta5.WorkspaceList, error) | ||
Get(name string, opts metav1.GetOptions) (*v1beta5.Workspace, error) | ||
Delete(name string, opts metav1.DeleteOptions) error | ||
} | ||
|
||
type workspaceClient struct { | ||
restClient rest.Interface | ||
ns string | ||
} | ||
|
||
func (c *workspaceClient) List(opts metav1.ListOptions) (*v1beta5.WorkspaceList, error) { | ||
result := v1beta5.WorkspaceList{} | ||
err := c.restClient. | ||
Get(). | ||
Namespace(c.ns). | ||
Resource("workspaces"). | ||
VersionedParams(&opts, scheme.ParameterCodec). | ||
Do(context.TODO()). | ||
Into(&result) | ||
|
||
return &result, err | ||
} | ||
|
||
func (c *workspaceClient) Get(name string, opts metav1.GetOptions) (*v1beta5.Workspace, error) { | ||
result := v1beta5.Workspace{} | ||
err := c.restClient. | ||
Get(). | ||
Namespace(c.ns). | ||
Resource("workspaces"). | ||
Name(name). | ||
VersionedParams(&opts, scheme.ParameterCodec). | ||
Do(context.TODO()). | ||
Into(&result) | ||
|
||
return &result, err | ||
} | ||
|
||
func (c *workspaceClient) Delete(name string, opts metav1.DeleteOptions) error { | ||
return c.restClient. | ||
Delete(). | ||
Namespace(c.ns). | ||
Resource("workspaces"). | ||
Name(name). | ||
VersionedParams(&opts, scheme.ParameterCodec). | ||
Do(context.TODO()). | ||
Error() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
module theia-workspace-garbage-collector | ||
|
||
go 1.23.3 | ||
|
||
require ( | ||
github.com/beorn7/perks v1.0.1 // indirect | ||
github.com/cespare/xxhash/v2 v2.3.0 // indirect | ||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect | ||
github.com/emicklei/go-restful/v3 v3.11.0 // indirect | ||
github.com/evanphx/json-patch/v5 v5.9.0 // indirect | ||
github.com/fsnotify/fsnotify v1.7.0 // indirect | ||
github.com/fxamacker/cbor/v2 v2.7.0 // indirect | ||
github.com/go-logr/logr v1.4.2 // indirect | ||
github.com/go-openapi/jsonpointer v0.19.6 // indirect | ||
github.com/go-openapi/jsonreference v0.20.2 // indirect | ||
github.com/go-openapi/swag v0.22.4 // indirect | ||
github.com/gogo/protobuf v1.3.2 // indirect | ||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect | ||
github.com/golang/protobuf v1.5.4 // indirect | ||
github.com/google/gnostic-models v0.6.8 // indirect | ||
github.com/google/go-cmp v0.6.0 // indirect | ||
github.com/google/gofuzz v1.2.0 // indirect | ||
github.com/google/uuid v1.6.0 // indirect | ||
github.com/imdario/mergo v0.3.6 // indirect | ||
github.com/josharian/intern v1.0.0 // indirect | ||
github.com/json-iterator/go v1.1.12 // indirect | ||
github.com/mailru/easyjson v0.7.7 // indirect | ||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | ||
github.com/modern-go/reflect2 v1.0.2 // indirect | ||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect | ||
github.com/pkg/errors v0.9.1 // indirect | ||
github.com/prometheus/client_golang v1.19.1 // indirect | ||
github.com/prometheus/client_model v0.6.1 // indirect | ||
github.com/prometheus/common v0.55.0 // indirect | ||
github.com/prometheus/procfs v0.15.1 // indirect | ||
github.com/spf13/pflag v1.0.5 // indirect | ||
github.com/x448/float16 v0.8.4 // indirect | ||
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect | ||
golang.org/x/net v0.26.0 // indirect | ||
golang.org/x/oauth2 v0.21.0 // indirect | ||
golang.org/x/sys v0.21.0 // indirect | ||
golang.org/x/term v0.21.0 // indirect | ||
golang.org/x/text v0.16.0 // indirect | ||
golang.org/x/time v0.3.0 // indirect | ||
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect | ||
google.golang.org/protobuf v1.34.2 // indirect | ||
gopkg.in/inf.v0 v0.9.1 // indirect | ||
gopkg.in/yaml.v2 v2.4.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
k8s.io/api v0.31.3 // indirect | ||
k8s.io/apiextensions-apiserver v0.31.0 // indirect | ||
k8s.io/apimachinery v0.31.3 // indirect | ||
k8s.io/client-go v0.31.3 // indirect | ||
k8s.io/klog/v2 v2.130.1 // indirect | ||
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect | ||
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect | ||
sigs.k8s.io/controller-runtime v0.19.2 // indirect | ||
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect | ||
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect | ||
sigs.k8s.io/yaml v1.4.0 // indirect | ||
) |
Oops, something went wrong.