-
Notifications
You must be signed in to change notification settings - Fork 465
/
component_types.go
88 lines (73 loc) · 2.28 KB
/
component_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
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation and Dapr Contributors.
// Licensed under the MIT License.
// ------------------------------------------------------------
package conformance
import (
"strconv"
v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// +genclient
// +genclient:noStatus
// +kubebuilder:object:root=true
// Component describes an Dapr component type
type Component struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`
// +optional
Spec ComponentSpec `json:"spec,omitempty"`
// +optional
Auth `json:"auth,omitempty"`
// +optional
Scopes []string `json:"scopes,omitempty"`
}
// ComponentSpec is the spec for a component
type ComponentSpec struct {
Type string `json:"type"`
Version string `json:"version"`
// +optional
IgnoreErrors bool `json:"ignoreErrors"`
Metadata []MetadataItem `json:"metadata"`
// +optional
InitTimeout string `json:"initTimeout"`
}
// MetadataItem is a name/value pair for a metadata
type MetadataItem struct {
Name string `json:"name"`
// +optional
Value DynamicValue `json:"value,omitempty"`
// +optional
SecretKeyRef SecretKeyRef `json:"secretKeyRef,omitempty"`
}
// SecretKeyRef is a reference to a secret holding the value for the metadata item. Name is the secret name, and key is the field in the secret.
type SecretKeyRef struct {
Name string `json:"name"`
Key string `json:"key"`
}
// Auth represents authentication details for the component
type Auth struct {
SecretStore string `json:"secretStore"`
}
// +kubebuilder:object:root=true
// ComponentList is a list of Dapr components
type ComponentList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []Component `json:"items"`
}
// DynamicValue is a dynamic value struct for the component.metadata pair value
type DynamicValue struct {
v1.JSON `json:",inline"`
}
// String returns the string representation of the raw value.
// If the value is a string, it will be unquoted as the string is guaranteed to be a JSON serialized string.
func (d *DynamicValue) String() string {
s := string(d.Raw)
c, err := strconv.Unquote(s)
if err == nil {
s = c
}
return s
}