/
recipe_types.go
148 lines (113 loc) · 5.08 KB
/
recipe_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/*
Copyright 2023.
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 v1alpha3
import (
"net/http"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// RecipeSpec defines the desired state of Recipe
type RecipeSpec struct {
// Type is the type of resource to create. eg: 'Applications.Datastores/redisCaches'.
// +kubebuilder:validation:Required
Type string `json:"type,omitempty"`
// SecretName is the name of a Kubernetes secret to create once the resource is created.
// +kubebuilder:validation:Optional
SecretName string `json:"secretName,omitempty"`
// Environment is the name of the Radius environment to use. If unset the value 'default' will be
// used as the environment name.
Environment string `json:"environment,omitempty"`
// Application is the name of the Radius application to use. If unset the namespace of the
// Recipe will be used as the application name.
Application string `json:"application,omitempty"`
}
// RecipePhrase is a string representation of the current status of a Recipe.
type RecipePhrase string
const (
// PhraseUpdating indicates that the Recipe is being updated.
PhraseUpdating RecipePhrase = "Updating"
// PhraseReady indicates that the Recipe is ready.
PhraseReady RecipePhrase = "Ready"
// PhraseFailed indicates that the Recipe has failed.
PhraseFailed RecipePhrase = "Failed"
// PhraseDeleting indicates that the Recipe is being deleted.
PhraseDeleting RecipePhrase = "Deleting"
// PhraseDeleted indicates that the Recipe has been deleted.
PhraseDeleted RecipePhrase = "Deleted"
)
// RecipeStatus defines the observed state of Recipe
type RecipeStatus struct {
// ObservedGeneration is the most recent generation observed for this Recipe. It corresponds to the
// Recipe's generation, which is updated on mutation by the API Server.
// +kubebuilder:validation:Optional
ObservedGeneration int64 `json:"observedGeneration,omitempty" protobuf:"varint,1,opt,name=observedGeneration"`
// Application is the resource ID of the application.
// +kubebuilder:validation:Optional
Application string `json:"application,omitempty"`
// Environment is the resource ID of the environment.
// +kubebuilder:validation:Optional
Environment string `json:"environment,omitempty"`
// Scope is the resource ID of the scope.
// +kubebuilder:validation:Optional
Scope string `json:"scope,omitempty"`
// Resource is the resource ID of the resource.
// +kubebuilder:validation:Optional
Resource string `json:"resource,omitempty"`
// Operation tracks the status of an in-progress provisioning operation.
// +kubebuilder:validation:Optional
Operation *ResourceOperation `json:"operation,omitempty"`
// Phrase indicates the current status of the Recipe.
// +kubebuilder:validation:Optional
Phrase RecipePhrase `json:"phrase,omitempty"`
// Secret specifies a reference to the secret being managed by this Recipe.
// +kubebuilder:validation:Optional
Secret corev1.ObjectReference `json:"secret,omitempty"`
}
// ResourceOperation describes the status of an in-progress provisioning operation.
type ResourceOperation struct {
// ResumeToken is a token that can be used to resume an in-progress provisioning operation.
ResumeToken string `json:"resumeToken,omitempty"`
// OperationKind describes the type of operation being performed.
OperationKind OperationKind `json:"operationKind,omitempty"`
}
// OperationKind is the type of operation being performed.
type OperationKind string
const (
// OperationKindPut is a PUT (create or update) operation.
OperationKindPut = http.MethodPut
// OperationKindDelete is a DELETE operation.
OperationKindDelete = http.MethodDelete
)
//+kubebuilder:object:root=true
//+kubebuilder:resource:categories={"all","radius"}
//+kubebuilder:printcolumn:name="Type",type="string",JSONPath=".spec.type",description="Type of resource the recipe should create"
//+kubebuilder:printcolumn:name="Secret",type="string",JSONPath=".spec.secretName",description="Name of the secret to create"
//+kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.phrase",description="Status of the resource"
//+kubebuilder:subresource:status
// Recipe is the Schema for the recipes API
type Recipe struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec RecipeSpec `json:"spec,omitempty"`
Status RecipeStatus `json:"status,omitempty"`
}
//+kubebuilder:object:root=true
// RecipeList contains a list of Recipe
type RecipeList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Recipe `json:"items"`
}
func init() {
SchemeBuilder.Register(&Recipe{}, &RecipeList{})
}