Recorder CRD, Records API, Redis deployment (#818)
This commit is contained in:
committed by
Ta-Ching Chen
parent
07ca5df8d0
commit
74a3a54543
@@ -311,6 +311,17 @@ type (
|
||||
ContentType string `json:"contentType"`
|
||||
}
|
||||
|
||||
// RecorderSpec defines a policy for recording requests and responses
|
||||
// to a function, that can be later inspected or replayed.
|
||||
RecorderSpec struct {
|
||||
Name string `json:"name"`
|
||||
Function string `json:"function"`
|
||||
Triggers []string `json:"triggers"`
|
||||
RetentionPolicy string `json:"retentionPolicy"`
|
||||
EvictionPolicy string `json:"evictionPolicy"`
|
||||
Enabled bool `json:"enabled"`
|
||||
}
|
||||
|
||||
// TimeTrigger invokes the specific function at a time or
|
||||
// times specified by a cron string.
|
||||
TimeTriggerSpec struct {
|
||||
|
||||
@@ -152,6 +152,21 @@ type (
|
||||
|
||||
Items []MessageQueueTrigger `json:"items"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
Recorder struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
Metadata metav1.ObjectMeta `json:"metadata"`
|
||||
Spec RecorderSpec `json:"spec"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
RecorderList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
Metadata metav1.ListMeta `json:"metadata"`
|
||||
|
||||
Items []Recorder `json:"items"`
|
||||
}
|
||||
)
|
||||
|
||||
// Each CRD type needs:
|
||||
@@ -185,6 +200,10 @@ func (p *Package) GetObjectKind() schema.ObjectKind {
|
||||
return &p.TypeMeta
|
||||
}
|
||||
|
||||
func (r *Recorder) GetObjectKind() schema.ObjectKind {
|
||||
return &r.TypeMeta
|
||||
}
|
||||
|
||||
func (f *Function) GetObjectMeta() metav1.Object {
|
||||
return &f.Metadata
|
||||
}
|
||||
@@ -207,6 +226,10 @@ func (p *Package) GetObjectMeta() metav1.Object {
|
||||
return &p.Metadata
|
||||
}
|
||||
|
||||
func (r *Recorder) GetObjectMeta() metav1.Object {
|
||||
return &r.Metadata
|
||||
}
|
||||
|
||||
func (fl *FunctionList) GetObjectKind() schema.ObjectKind {
|
||||
return &fl.TypeMeta
|
||||
}
|
||||
@@ -228,6 +251,9 @@ func (ml *MessageQueueTriggerList) GetObjectKind() schema.ObjectKind {
|
||||
func (pl *PackageList) GetObjectKind() schema.ObjectKind {
|
||||
return &pl.TypeMeta
|
||||
}
|
||||
func (rl *RecorderList) GetObjectKind() schema.ObjectKind {
|
||||
return &rl.TypeMeta
|
||||
}
|
||||
|
||||
func (fl *FunctionList) GetListMeta() metav1.ListInterface {
|
||||
return &fl.Metadata
|
||||
@@ -250,6 +276,9 @@ func (ml *MessageQueueTriggerList) GetListMeta() metav1.ListInterface {
|
||||
func (pl *PackageList) GetListMeta() metav1.ListInterface {
|
||||
return &pl.Metadata
|
||||
}
|
||||
func (rl *RecorderList) GetListMeta() metav1.ListInterface {
|
||||
return &rl.Metadata
|
||||
}
|
||||
|
||||
func validateMetadata(field string, m metav1.ObjectMeta) error {
|
||||
return ValidateKubeReference(field, m.Name, m.Namespace)
|
||||
@@ -382,3 +411,13 @@ func (ml *MessageQueueTriggerList) Validate() error {
|
||||
}
|
||||
return result.ErrorOrNil()
|
||||
}
|
||||
|
||||
func (r *Recorder) Validate() error {
|
||||
var result *multierror.Error
|
||||
|
||||
result = multierror.Append(result,
|
||||
validateMetadata("Recorder", r.Metadata),
|
||||
r.Spec.Validate())
|
||||
|
||||
return result.ErrorOrNil()
|
||||
}
|
||||
|
||||
@@ -446,6 +446,33 @@ func (spec MessageQueueTriggerSpec) Validate() error {
|
||||
return result.ErrorOrNil()
|
||||
}
|
||||
|
||||
func (spec RecorderSpec) Validate() error {
|
||||
var result *multierror.Error
|
||||
|
||||
// TODO: Function validation
|
||||
//if len(spec.Function.Name) != 0 {
|
||||
// result = multierror.Append(result, spec.Function.Validate())
|
||||
//}
|
||||
|
||||
// TODO: Triggers validation
|
||||
//for _, trigger := range spec.Triggers {
|
||||
// result = multierror.Append(result, trigger.Validate())
|
||||
//}
|
||||
|
||||
if len(spec.Name) == 0 {
|
||||
result = multierror.Append(result, MakeValidationErr(ErrorInvalidValue, "RecorderSpec.Name", spec.Name, "not a valid name"))
|
||||
}
|
||||
//if len(spec.RetentionPolicy) == 0 {
|
||||
// result = multierror.Append(result, MakeValidationErr(ErrorInvalidValue, "RecorderSpec.RetentionPolicy", spec.Name, "not a valid retention policy"))
|
||||
//}
|
||||
//if len(spec.EvictionPolicy) == 0 {
|
||||
// result = multierror.Append(result, MakeValidationErr(ErrorInvalidValue, "RecorderSpec.EvictionPolicy", spec.Name, "not a valid eviction policy"))
|
||||
//}
|
||||
|
||||
//log.Info("This is the RecorderSpec validation result: %v", result)
|
||||
return result.ErrorOrNil()
|
||||
}
|
||||
|
||||
func (spec TimeTriggerSpec) Validate() error {
|
||||
var result *multierror.Error
|
||||
|
||||
|
||||
@@ -705,6 +705,87 @@ func (in *PackageStatus) DeepCopy() *PackageStatus {
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Recorder) DeepCopyInto(out *Recorder) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.Metadata.DeepCopyInto(&out.Metadata)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Recorder.
|
||||
func (in *Recorder) DeepCopy() *Recorder {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(Recorder)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *Recorder) 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 *RecorderList) DeepCopyInto(out *RecorderList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
out.Metadata = in.Metadata
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]Recorder, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RecorderList.
|
||||
func (in *RecorderList) DeepCopy() *RecorderList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(RecorderList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *RecorderList) 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 *RecorderSpec) DeepCopyInto(out *RecorderSpec) {
|
||||
*out = *in
|
||||
if in.Triggers != nil {
|
||||
in, out := &in.Triggers, &out.Triggers
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RecorderSpec.
|
||||
func (in *RecorderSpec) DeepCopy() *RecorderSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(RecorderSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Runtime) DeepCopyInto(out *Runtime) {
|
||||
*out = *in
|
||||
|
||||
Reference in New Issue
Block a user