Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

Commit

Permalink
Minor review comments. Use the serializer-embedded codecs and documen…
Browse files Browse the repository at this point in the history
…t other types of secrets
  • Loading branch information
luxas authored and twelho committed Jul 31, 2020
1 parent 9b6cd27 commit 325ec9e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 1 addition & 5 deletions pkg/apis/baremetal/scheme/scheme.go
Expand Up @@ -3,7 +3,6 @@ package scheme
import (
ssv1alpha1 "github.com/bitnami-labs/sealed-secrets/pkg/apis/sealed-secrets/v1alpha1"
"k8s.io/apimachinery/pkg/runtime"
k8sserializer "k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/apimachinery/pkg/util/errors"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
Expand All @@ -18,11 +17,8 @@ var (
// Scheme contains information about all known types, API versions, and defaulting & conversion methods
Scheme = runtime.NewScheme()

// Codecs provides k8s API machinery low-level codec functionality
Codecs = k8sserializer.NewCodecFactory(Scheme)

// Serializer provides powerful high-level encoding/decoding functionality
Serializer = serializer.NewSerializer(Scheme, &Codecs)
Serializer = serializer.NewSerializer(Scheme, nil)
)

func init() {
Expand Down
8 changes: 7 additions & 1 deletion pkg/apis/wksprovider/machine/os/os.go
Expand Up @@ -826,6 +826,8 @@ func processSecret(b *plan.Builder, key *rsa.PrivateKey, configDir, secretFileNa
// Create the secret to decode into
ss := &ssv1alpha1.SealedSecret{}
// Decode the Sealed Secret into the object
// In the future, if we wish to support other kinds of secrets than SealedSecrets, we
// can just change this to do .Decode(fr), and switch on the type
if err := scheme.Serializer.Decoder().DecodeInto(fr, ss); err != nil {
return nil, nil, "", nil, errors.Wrapf(err, "File %q does not contain a sealed secret, couldn't decode", secretFileName)
}
Expand All @@ -836,7 +838,11 @@ func processSecret(b *plan.Builder, key *rsa.PrivateKey, configDir, secretFileNa
}
keys := map[string]*rsa.PrivateKey{fingerprint: key}

secret, err := ss.Unseal(scheme.Codecs, keys)
codecs := scheme.Serializer.Codecs()
if codecs == nil {
return nil, nil, "", nil, fmt.Errorf("codecs must not be nil")
}
secret, err := ss.Unseal(*codecs, keys)
if err != nil {
return nil, nil, "", nil, errors.Wrap(err, "Could not unseal auth secret")
}
Expand Down

0 comments on commit 325ec9e

Please sign in to comment.