Skip to content

Commit

Permalink
lxc/config_trust: use errors.New() where appropriate
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Deziel <[email protected]>
  • Loading branch information
simondeziel committed Sep 5, 2024
1 parent 7fe4f50 commit 776c2d4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lxc/config_trust.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func (c *cmdConfigTrustAdd) run(cmd *cobra.Command, args []string) error {
cert.Type = api.CertificateTypeClient
} else if c.flagType == "metrics" {
if cert.Token {
return fmt.Errorf(i18n.G("Cannot use metrics type certificate when using a token"))
return errors.New(i18n.G("Cannot use metrics type certificate when using a token"))
}

cert.Type = api.CertificateTypeMetrics
Expand Down Expand Up @@ -265,7 +265,7 @@ func (c *cmdConfigTrustEdit) run(cmd *cobra.Command, args []string) error {
resource := resources[0]

if resource.name == "" {
return fmt.Errorf(i18n.G("Missing certificate fingerprint"))
return errors.New(i18n.G("Missing certificate fingerprint"))
}

// If stdin isn't a terminal, read text from it
Expand Down Expand Up @@ -388,7 +388,7 @@ func (c *cmdConfigTrustList) run(cmd *cobra.Command, args []string) error {

certBlock, _ := pem.Decode([]byte(cert.Certificate))
if certBlock == nil {
return fmt.Errorf(i18n.G("Invalid certificate"))
return errors.New(i18n.G("Invalid certificate"))
}

tlsCert, err := x509.ParseCertificate(certBlock.Bytes)
Expand Down Expand Up @@ -673,7 +673,7 @@ func (c *cmdConfigTrustShow) run(cmd *cobra.Command, args []string) error {
client := resource.server

if resource.name == "" {
return fmt.Errorf(i18n.G("Missing certificate fingerprint"))
return errors.New(i18n.G("Missing certificate fingerprint"))
}

// Show the certificate configuration
Expand Down

0 comments on commit 776c2d4

Please sign in to comment.