Skip to content

Commit b2b2182

Browse files
authored
support access key override in options (#12)
1 parent 0e8c21b commit b2b2182

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ spec:
4848
options:
4949
container: bigdata # data container name
5050
cluster: default # which cluster to connect to (optional, default to "default")
51+
accessKey: some-some # data access key (optional)
5152
---
5253
apiVersion: v1
5354
kind: Secret

pkg/flex/mounter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func (m *Mounter) Unmount() *Response {
134134
}
135135

136136
func (m *Mounter) validate() error {
137-
if m.Spec.AccessKey == "" {
137+
if m.Spec.AccessKey == "" && m.Spec.OverrideAccessKey == "" {
138138
return errors.New("required access key is missing")
139139
}
140140
if m.Spec.SubPath != "" && m.Spec.Container == "" {

pkg/flex/types.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,14 @@ func (r *Response) ToJSON() {
8181
}
8282

8383
type VolumeSpec struct {
84-
SubPath string `json:"subPath"`
85-
Container string `json:"container"`
86-
Cluster string `json:"cluster"`
87-
AccessKey string `json:"kubernetes.io/secret/accessKey"`
88-
PodName string `json:"kubernetes.io/pod.name"`
89-
Namespace string `json:"kubernetes.io/pod.namespace"`
90-
Name string `json:"kubernetes.io/pvOrVolumeName"`
84+
SubPath string `json:"subPath"`
85+
Container string `json:"container"`
86+
Cluster string `json:"cluster"`
87+
OverrideAccessKey string `json:"accessKey"`
88+
AccessKey string `json:"kubernetes.io/secret/accessKey"`
89+
PodName string `json:"kubernetes.io/pod.name"`
90+
Namespace string `json:"kubernetes.io/pod.namespace"`
91+
Name string `json:"kubernetes.io/pvOrVolumeName"`
9192
}
9293

9394
func (VolumeSpec) decodeOrDefault(value string) string {
@@ -99,7 +100,10 @@ func (VolumeSpec) decodeOrDefault(value string) string {
99100
}
100101

101102
func (vs *VolumeSpec) GetAccessKey() string {
102-
return vs.decodeOrDefault(vs.AccessKey)
103+
if vs.OverrideAccessKey == "" {
104+
return vs.decodeOrDefault(vs.AccessKey)
105+
}
106+
return vs.OverrideAccessKey
103107
}
104108

105109
func (vs *VolumeSpec) GetClusterName() string {

0 commit comments

Comments
 (0)