sops

package module
v0.0.0-...-8d23218 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

README

sops-wrap

sops-wrap is a Go package to ease the use of sops as a library

See tests and go docs for usage.

You can run go doc -all ./ in the root of this repository to get documentation.

Documentation

Overview

package sops provides convinience methods for using https://github.com/mozilla/sops as a library

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SopsData

type SopsData struct {
	// contains filtered or unexported fields
}

SopsData is a wrapper around sops data. It can be embedded in other structs. It has been tested with stldib json and https://github.com/go-yaml/yaml

func (*SopsData) Data

func (d *SopsData) Data() map[string]string

Data returns the data. It may or may not be encrypted. Use IsEncrypted() to check

func (*SopsData) Decrypt

func (s *SopsData) Decrypt() (*SopsData, error)

Decrypt the data. The data must have been encrypted using encrypt. You must have access to the key used to encrypt the data.

func (*SopsData) Encrypt

func (s *SopsData) Encrypt(m keys.MasterKey) (*SopsData, error)

Encrypt the data. If the data was decrypted before using Decrypt, then a key is not needed. However, always use NeedsKey to check. Must have access to the key used to decrypt or the one passed in. If the data was decrypted using Decrypt and a key is passed to this function, then the key passed in is used to encrypt.

func (*SopsData) IsEncrypted

func (d *SopsData) IsEncrypted() bool

IsEncrypted checks if the data is encrypted.

func (SopsData) MarshalJSON

func (d SopsData) MarshalJSON() ([]byte, error)

MarshalJSON encodes the data as JSON

func (SopsData) MarshalYAML

func (d SopsData) MarshalYAML() (interface{}, error)

MarshalYAML encodes the data as YAML

func (*SopsData) NeedsKey

func (d *SopsData) NeedsKey() bool

NeedsKey checks if a key should be provided to encrypt. Generally, a key is only needed the first time data is encrypted. if the data comes from a call to Decrypt, then a key is not needed. However, one should always check.

func (*SopsData) UnmarshalJSON

func (d *SopsData) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes the data from JSON

func (*SopsData) UnmarshalYAML

func (d *SopsData) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML decodes the data from YAML

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL