github.com/pojntfx/hydrapp/hydrapp@v0.0.0-20240516002902-d08759d6ca9f/pkg/secrets/parse.go (about)

     1  package secrets
     2  
     3  import (
     4  	"io"
     5  
     6  	"gopkg.in/yaml.v2"
     7  )
     8  
     9  type Root struct {
    10  	JavaSecrets JavaSecrets `yaml:"java"`
    11  	PGPSecrets  PGPSecrets  `yaml:"pgp"`
    12  }
    13  
    14  type JavaSecrets struct {
    15  	Keystore            []byte `yaml:"keystore"`
    16  	KeystorePassword    string `yaml:"keystorePassword"`
    17  	CertificatePassword string `yaml:"certificatePassword"`
    18  }
    19  
    20  type PGPSecrets struct {
    21  	Key         string `yaml:"key"`
    22  	KeyID       string `yaml:"keyID"`
    23  	KeyPassword string `yaml:"keyPassword"`
    24  }
    25  
    26  func Parse(r io.Reader) (*Root, error) {
    27  	var root Root
    28  	if err := yaml.NewDecoder(r).Decode(&root); err != nil {
    29  		return nil, err
    30  	}
    31  
    32  	return &root, nil
    33  }