Skip to content

Commit 323740e

Browse files
authored
Merge pull request #8 from barney-s/template-claim
Adding SandboxTemplate and SandboxClaim CRDs
2 parents e58c01e + e3ec105 commit 323740e

File tree

7 files changed

+4280
-1
lines changed

7 files changed

+4280
-1
lines changed

codegen.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@
1616

1717
package agentsandbox
1818

19-
//go:generate go tool -modfile=tools.mod sigs.k8s.io/controller-tools/cmd/controller-gen object crd:maxDescLen=0 paths="./..." output:crd:dir=k8s/crds output:rbac:dir=k8s rbac:roleName=agent-sandbox-controller,fileName=rbac.generated.yaml
19+
// Generate CRDs and RBAC rules
20+
//go:generate go tool -modfile=tools.mod sigs.k8s.io/controller-tools/cmd/controller-gen object crd:maxDescLen=0 paths="./api/..." output:crd:dir=k8s/crds output:rbac:dir=k8s rbac:roleName=agent-sandbox-controller,fileName=rbac.generated.yaml
21+
//go:generate go tool -modfile=tools.mod sigs.k8s.io/controller-tools/cmd/controller-gen object crd:maxDescLen=0 paths="./extensions/..." output:crd:dir=k8s/crds output:rbac:dir=k8s rbac:roleName=agent-sandbox-controller,fileName=rbac.generated.yaml
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2025 The Kubernetes Authors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// Package v1alpha1 contains API Schema definitions for the agents v1alpha1 API group.
16+
// +kubebuilder:object:generate=true
17+
// +groupName=extensions.agents.x-k8s.io
18+
package v1alpha1
19+
20+
import (
21+
"k8s.io/apimachinery/pkg/runtime/schema"
22+
"sigs.k8s.io/controller-runtime/pkg/scheme"
23+
)
24+
25+
var (
26+
// GroupVersion is group version used to register these objects.
27+
GroupVersion = schema.GroupVersion{Group: "extensions.agents.x-k8s.io", Version: "v1alpha1"}
28+
29+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
30+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
31+
32+
// AddToScheme adds the types in this group-version to the given scheme.
33+
AddToScheme = SchemeBuilder.AddToScheme
34+
)
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
// Copyright 2025 The Kubernetes Authors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
/*
16+
Copyright 2025.
17+
18+
Licensed under the Apache License, Version 2.0 (the "License");
19+
you may not use this file except in compliance with the License.
20+
You may obtain a copy of the License at
21+
22+
http://www.apache.org/licenses/LICENSE-2.0
23+
24+
Unless required by applicable law or agreed to in writing, software
25+
distributed under the License is distributed on an "AS IS" BASIS,
26+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27+
See the License for the specific language governing permissions and
28+
limitations under the License.
29+
*/
30+
31+
package v1alpha1
32+
33+
import (
34+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
35+
)
36+
37+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
38+
// Important: Run "make" to regenerate code after modifying this file
39+
40+
// SandboxTemmplateRef references a SandboxTemplate
41+
type SandboxTemplateRef struct {
42+
// name of the SandboxTemplate
43+
// +kubebuilder:validation:Required
44+
Name string `json:"name,omitempty" protobuf:"bytes,1,name=name"`
45+
}
46+
47+
// SandboxClaimSpec defines the desired state of Sandbox
48+
type SandboxClaimSpec struct {
49+
// SandboxTemplateRefName - name of the SandboxTemplate to be used for creating a Sandbox
50+
// +kubebuilder:validation:Required
51+
TemplateRef SandboxTemplateRef `json:"sandboxTemplateRef,omitempty" protobuf:"bytes,3,name=sandboxTemplateRef"`
52+
}
53+
54+
// SandboxClaimStatus defines the observed state of Sandbox.
55+
type SandboxClaimStatus struct {
56+
}
57+
58+
// +kubebuilder:object:root=true
59+
// +kubebuilder:subresource:status
60+
// +kubebuilder:resource:scope=Namespaced,shortName=sandboxclaim
61+
// SandboxClaim is the Schema for the sandbox Claim API
62+
type SandboxClaim struct {
63+
metav1.TypeMeta `json:",inline"`
64+
65+
// metadata is a standard object metadata
66+
// +optional
67+
metav1.ObjectMeta `json:"metadata,omitempty,omitzero"`
68+
69+
// spec defines the desired state of Sandbox
70+
// +required
71+
Spec SandboxClaimSpec `json:"spec"`
72+
73+
// status defines the observed state of Sandbox
74+
// +optional
75+
Status SandboxClaimStatus `json:"status,omitempty,omitzero"`
76+
}
77+
78+
// +kubebuilder:object:root=true
79+
80+
// SandboxList contains a list of Sandbox
81+
type SandboxClaimList struct {
82+
metav1.TypeMeta `json:",inline"`
83+
metav1.ListMeta `json:"metadata,omitempty"`
84+
Items []SandboxClaim `json:"items"`
85+
}
86+
87+
func init() {
88+
SchemeBuilder.Register(&SandboxClaim{}, &SandboxClaimList{})
89+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
// Copyright 2025 The Kubernetes Authors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
/*
16+
Copyright 2025.
17+
18+
Licensed under the Apache License, Version 2.0 (the "License");
19+
you may not use this file except in compliance with the License.
20+
You may obtain a copy of the License at
21+
22+
http://www.apache.org/licenses/LICENSE-2.0
23+
24+
Unless required by applicable law or agreed to in writing, software
25+
distributed under the License is distributed on an "AS IS" BASIS,
26+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27+
See the License for the specific language governing permissions and
28+
limitations under the License.
29+
*/
30+
31+
package v1alpha1
32+
33+
import (
34+
corev1 "k8s.io/api/core/v1"
35+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
36+
)
37+
38+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
39+
// Important: Run "make" to regenerate code after modifying this file
40+
41+
// SandboxTemplateSpec defines the desired state of Sandbox
42+
type SandboxTemplateSpec struct {
43+
// template is the object that describes the pod spec that will be used to create
44+
// an agent sandbox.
45+
// +kubebuilder:validation:Required
46+
PodTemplate corev1.PodTemplateSpec `json:"podTemplate" protobuf:"bytes,3,opt,name=podTemplate"`
47+
}
48+
49+
// SandboxTemplateStatus defines the observed state of Sandbox.
50+
type SandboxTemplateStatus struct {
51+
}
52+
53+
// +kubebuilder:object:root=true
54+
// +kubebuilder:subresource:status
55+
// +kubebuilder:resource:scope=Namespaced,shortName=sandboxtemplate
56+
// SandboxTemplate is the Schema for the sandboxe template API
57+
type SandboxTemplate struct {
58+
metav1.TypeMeta `json:",inline"`
59+
60+
// metadata is a standard object metadata
61+
// +optional
62+
metav1.ObjectMeta `json:"metadata,omitempty,omitzero"`
63+
64+
// spec defines the desired state of Sandbox
65+
// +required
66+
Spec SandboxTemplateSpec `json:"spec"`
67+
68+
// status defines the observed state of Sandbox
69+
// +optional
70+
Status SandboxTemplateStatus `json:"status,omitempty,omitzero"`
71+
}
72+
73+
// +kubebuilder:object:root=true
74+
75+
// SandboxTemplateList contains a list of Sandbox
76+
type SandboxTemplateList struct {
77+
metav1.TypeMeta `json:",inline"`
78+
metav1.ListMeta `json:"metadata,omitempty"`
79+
Items []SandboxTemplate `json:"items"`
80+
}
81+
82+
func init() {
83+
SchemeBuilder.Register(&SandboxTemplate{}, &SandboxTemplateList{})
84+
}

0 commit comments

Comments
 (0)