feat(template): added secret template function (#1221)

* feat(tmpl): added fetchSecretValue template function

This adds a tmpl `fetchSecretValue` and `expandSecretRefs` function by:
- Adding:
    - `expandSecretRefs` function in tmpl package that uses vals
    package to fetch secrets
    - `fetchSecretValue` function in tmpl package like below but for
    single string value
    - gomock for tests purpose
- Changing:
    - move init of vals package to function (so the same instance can be used for template values and rendering the whole template)

* doc(secret): added doc how to use new tmpl methods

Added example usage of `fetchSecretValue` and `expandSecretRefs`
This commit is contained in:
Marcin Kaciuba
2020-04-25 21:10:02 +09:00
committed by GitHub
parent 3a19a394ab
commit b1190508b2
10 changed files with 301 additions and 145 deletions
+45
View File
@@ -0,0 +1,45 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: expand_secret_ref.go
package tmpl
import (
gomock "github.com/golang/mock/gomock"
reflect "reflect"
)
// MockvalClient is a mock of valClient interface
type MockvalClient struct {
ctrl *gomock.Controller
recorder *MockvalClientMockRecorder
}
// MockvalClientMockRecorder is the mock recorder for MockvalClient
type MockvalClientMockRecorder struct {
mock *MockvalClient
}
// NewMockvalClient creates a new mock instance
func NewMockvalClient(ctrl *gomock.Controller) *MockvalClient {
mock := &MockvalClient{ctrl: ctrl}
mock.recorder = &MockvalClientMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use
func (_m *MockvalClient) EXPECT() *MockvalClientMockRecorder {
return _m.recorder
}
// Eval mocks base method
func (_m *MockvalClient) Eval(template map[string]interface{}) (map[string]interface{}, error) {
ret := _m.ctrl.Call(_m, "Eval", template)
ret0, _ := ret[0].(map[string]interface{})
ret1, _ := ret[1].(error)
return ret0, ret1
}
// Eval indicates an expected call of Eval
func (_mr *MockvalClientMockRecorder) Eval(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCallWithMethodType(_mr.mock, "Eval", reflect.TypeOf((*MockvalClient)(nil).Eval), arg0)
}