Skip to content

Commit

Permalink
fix: Add custom error
Browse files Browse the repository at this point in the history
  • Loading branch information
jachym-tousek-keboola committed Dec 17, 2024
1 parent e307174 commit 3676be8
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/keboola/go-cloud-encrypt/pkg/cloudencrypt"

"github.com/keboola/keboola-as-code/internal/pkg/service/stream/definition/key"
"github.com/keboola/keboola-as-code/internal/pkg/utils/errors"
)

// Token is a Storage API Token used to create staging files and import files to the target table.
Expand All @@ -27,6 +28,10 @@ func (token Token) ID() string {

func (token Token) DecryptToken(ctx context.Context, encryptor *cloudencrypt.GenericEncryptor[keboola.Token], metadata cloudencrypt.Metadata) (keboola.Token, error) {
if token.EncryptedToken != nil {
if encryptor == nil {
return keboola.Token{}, errors.New("missing token encryptor")
}

return encryptor.Decrypt(ctx, token.EncryptedToken, metadata)
}

Expand Down

0 comments on commit 3676be8

Please sign in to comment.