github.com/tilt-dev/tilt@v0.33.15-0.20240515162809-0a22ed45d8a0/scripts/api-new-type-boilerplate.go.txt (about) 1 /* 2 Copyright 2021 The Tilt Dev Authors 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package v1alpha1 18 19 import ( 20 "context" 21 22 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 23 "k8s.io/apimachinery/pkg/runtime" 24 "k8s.io/apimachinery/pkg/runtime/schema" 25 "k8s.io/apimachinery/pkg/util/validation/field" 26 27 "github.com/tilt-dev/tilt-apiserver/pkg/server/builder/resource" 28 "github.com/tilt-dev/tilt-apiserver/pkg/server/builder/resource/resourcestrategy" 29 ) 30 31 // +genclient 32 // +genclient:nonNamespaced 33 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 34 35 // Manifest 36 // +k8s:openapi-gen=true 37 type Manifest struct { 38 metav1.TypeMeta `json:",inline"` 39 metav1.ObjectMeta `json:"metadata,omitempty"` 40 41 Spec ManifestSpec `json:"spec,omitempty"` 42 Status ManifestStatus `json:"status,omitempty"` 43 } 44 45 // ManifestList 46 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 47 type ManifestList struct { 48 metav1.TypeMeta `json:",inline"` 49 metav1.ListMeta `json:"metadata,omitempty"` 50 51 Items []Manifest `json:"items"` 52 } 53 54 // ManifestSpec defines the desired state of Manifest 55 type ManifestSpec struct { 56 } 57 58 var _ resource.Object = &Manifest{} 59 var _ resourcestrategy.Validater = &Manifest{} 60 61 func (in *Manifest) GetObjectMeta() *metav1.ObjectMeta { 62 return &in.ObjectMeta 63 } 64 65 func (in *Manifest) NamespaceScoped() bool { 66 return false 67 } 68 69 func (in *Manifest) New() runtime.Object { 70 return &Manifest{} 71 } 72 73 func (in *Manifest) NewList() runtime.Object { 74 return &ManifestList{} 75 } 76 77 func (in *Manifest) GetGroupVersionResource() schema.GroupVersionResource { 78 return schema.GroupVersionResource{ 79 Group: "tilt.dev", 80 Version: "v1alpha1", 81 Resource: "manifests", 82 } 83 } 84 85 func (in *Manifest) IsStorageVersion() bool { 86 return true 87 } 88 89 func (in *Manifest) Validate(ctx context.Context) field.ErrorList { 90 // TODO(user): Modify it, adding your API validation here. 91 return nil 92 } 93 94 var _ resource.ObjectList = &ManifestList{} 95 96 func (in *ManifestList) GetListMeta() *metav1.ListMeta { 97 return &in.ListMeta 98 } 99 100 // ManifestStatus defines the observed state of Manifest 101 type ManifestStatus struct { 102 } 103 104 // Manifest implements ObjectWithStatusSubResource interface. 105 var _ resource.ObjectWithStatusSubResource = &Manifest{} 106 107 func (in *Manifest) GetStatus() resource.StatusSubResource { 108 return in.Status 109 } 110 111 // ManifestStatus{} implements StatusSubResource interface. 112 var _ resource.StatusSubResource = &ManifestStatus{} 113 114 func (in ManifestStatus) CopyTo(parent resource.ObjectWithStatusSubResource) { 115 parent.(*Manifest).Status = in 116 }