Skip to content

Commit

Permalink
Accept and seal stringData into secret
Browse files Browse the repository at this point in the history
Ref #104
  • Loading branch information
jiri-pinkava committed Aug 10, 2019
1 parent 543ce88 commit c591d1c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cmd/kubeseal/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,16 @@ func seal(in io.Reader, out io.Writer, codecs runtimeserializer.CodecFactory, pu
return err
}

if len(secret.StringData) > 0 {
if secret.Data == nil {
secret.Data = map[string][]byte{};
}
for key, values := range secret.StringData {
secret.Data[key] = []byte(values)
delete(secret.StringData, key)
}
}

if len(secret.Data) == 0 {
// No data. This is _theoretically_ just fine, but
// almost certainly indicates a misuse of the tools.
Expand Down
6 changes: 6 additions & 0 deletions cmd/kubeseal/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ func TestSeal(t *testing.T) {
Data: map[string][]byte{
"foo": []byte("sekret"),
},
StringData: map[string]string{
"foos": string("stringsekret"),
},
}

info, ok := runtime.SerializerInfoForMediaType(scheme.Codecs.SupportedMediaTypes(), runtime.ContentTypeJSON)
Expand Down Expand Up @@ -170,5 +173,8 @@ func TestSeal(t *testing.T) {
if len(result.Spec.EncryptedData["foo"]) < 100 {
t.Errorf("Encrypted data is implausibly short: %v", result.Spec.EncryptedData)
}
if len(result.Spec.EncryptedData["foos"]) < 100 {
t.Errorf("Encrypted data is implausibly short: %v", result.Spec.EncryptedData)
}
// NB: See sealedsecret_test.go for e2e crypto test
}

0 comments on commit c591d1c

Please sign in to comment.