
The original sprig-library implementation of genCA and genSignedCert may accept only CN parameter which isn't enough for K8s admin certificate. That certification must have O=system:masters, e.g. /CN=admin/O=system:masters This PR introduces the set of functions that insted of cn accept subj argument that may have a form compatible with openssl -subj parameter. If the first symbol isn't '/' subj behaves as cn argument. The set of new functions that accept subj arg is: genCAEx genCAWithKeyEx genSignedCertEx genSignedCertWithKeyEx Since the implementaion required to copy some non-exported helper functions from sprig, the decision was made to separate all go-template extension functions into a separate package: extlib. This package can be reused in other go-applications, it's just necessary to use GenericFuncMap function to get function-map. Change-Id: I0ffddee2e597323803bf5f1b54f315ded424b7be
27 lines
768 B
Go
27 lines
768 B
Go
/*
|
|
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
|
|
|
|
https://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 extlib
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestFileExists(t *testing.T) {
|
|
assert.Equal(t, true, fileExists("fs_test.go"))
|
|
assert.Equal(t, false, fileExists("fs_test_nonexistent.go"))
|
|
}
|