Skip to content

Commit

Permalink
chore: implement DeepCopy methods for PEMEncoded* types
Browse files Browse the repository at this point in the history
These types are used in Talos machine config.

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
  • Loading branch information
smira authored and talos-bot committed Jul 7, 2021
1 parent d3cb772 commit deec8d4
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions x509/x509.go
Expand Up @@ -862,6 +862,24 @@ func (p *PEMEncodedCertificateAndKey) GetECDSAKey() (*ecdsa.PrivateKey, error) {
return ecdsaKey, nil
}

// DeepCopy implements DeepCopy interface.
func (p *PEMEncodedCertificateAndKey) DeepCopy() *PEMEncodedCertificateAndKey {
if p == nil {
return nil
}

out := new(PEMEncodedCertificateAndKey)
p.DeepCopyInto(out)

return out
}

// DeepCopyInto implements DeepCopy interface.
func (p *PEMEncodedCertificateAndKey) DeepCopyInto(out *PEMEncodedCertificateAndKey) {
out.Crt = append([]byte(nil), p.Crt...)
out.Key = append([]byte(nil), p.Key...)
}

// UnmarshalYAML implements the yaml.Unmarshaler interface for
// PEMEncodedKey. It is expected that the Key is a base64
// encoded string in the YAML file. This function decodes the strings into byte
Expand Down Expand Up @@ -1016,6 +1034,23 @@ func (p *PEMEncodedKey) GetECDSAKey() (*ECDSAKey, error) {
}, nil
}

// DeepCopy implements DeepCopy interface.
func (p *PEMEncodedKey) DeepCopy() *PEMEncodedKey {
if p == nil {
return nil
}

out := new(PEMEncodedKey)
p.DeepCopyInto(out)

return out
}

// DeepCopyInto implements DeepCopy interface.
func (p *PEMEncodedKey) DeepCopyInto(out *PEMEncodedKey) {
out.Key = append([]byte(nil), p.Key...)
}

// NewCertficateAndKey is the NewCertificateAndKey with a typo in the name.
//
// Deprecated: use NewCertificateAndKey instead.
Expand Down

0 comments on commit deec8d4

Please sign in to comment.