Skip to content

Commit

Permalink
add docs, fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
elsesiy committed Jan 3, 2025
1 parent 75c2d8a commit 6521ebd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions pkg/cmd/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import (
"strings"
)

// SecretDecoder is an interface for decoding various kubernetes secret resources
type SecretDecoder interface {
Decode(input string) (string, error)
}

// Decode decodes a secret based on its type, currently supporting only Opaque and Helm secrets
func (s Secret) Decode(input string) (string, error) {
switch s.Type {
// TODO handle all secret types
Expand Down
4 changes: 4 additions & 0 deletions pkg/cmd/types.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
package cmd

// SecretList represents a list of secrets
type SecretList struct {
Items []Secret `json:"items"`
}

// Secret represents a kubernetes secret
type Secret struct {
Data SecretData `json:"data"`
Metadata Metadata `json:"metadata"`
Type SecretType `json:"type"`
}

// SecretData represents the data of a secret
type SecretData map[string]string

// Metadata represents the metadata of a secret
type Metadata struct {
Name string `json:"name"`
Namespace string `json:"namespace"`
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func TestSerialize(t *testing.T) {
want Secret
wantErr error
}{
"empty opqague secret": {
"empty opaque secret": {
input: invalidSecretJson,
want: Secret{
Metadata: Metadata{
Expand All @@ -69,7 +69,7 @@ func TestSerialize(t *testing.T) {
},
wantErr: errors.New("invalid character '}' looking for beginning of object key string"),
},
"valid opague secret": {
"valid opaque secret": {
input: validSecretJson,
want: Secret{
Data: SecretData{
Expand Down

0 comments on commit 6521ebd

Please sign in to comment.