5b7b1cab79
- Refactored to keep every transformation of built-in types (e.g. FS, Secret, etc) to/from CUE in the same place (plancontext) - dagger.#Service and dagger.#Secret are now following the new FS-like format (e.g. `_service: id: string`) - Backward compatibility - dagger.#Stream is now an alias for dagger.#Service Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
36 lines
736 B
Go
36 lines
736 B
Go
package solver
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/moby/buildkit/session"
|
|
"github.com/moby/buildkit/session/secrets"
|
|
"github.com/moby/buildkit/session/secrets/secretsprovider"
|
|
"github.com/rs/zerolog/log"
|
|
"go.dagger.io/dagger/plancontext"
|
|
)
|
|
|
|
func NewSecretsStoreProvider(pctx *plancontext.Context) session.Attachable {
|
|
return secretsprovider.NewSecretProvider(&inputStore{pctx})
|
|
}
|
|
|
|
type inputStore struct {
|
|
pctx *plancontext.Context
|
|
}
|
|
|
|
func (s *inputStore) GetSecret(ctx context.Context, id string) ([]byte, error) {
|
|
lg := log.Ctx(ctx)
|
|
|
|
secret := s.pctx.Secrets.Get(id)
|
|
if secret == nil {
|
|
return nil, secrets.ErrNotFound
|
|
}
|
|
|
|
lg.
|
|
Debug().
|
|
Str("id", id).
|
|
Msg("injecting secret")
|
|
|
|
return []byte(secret.PlainText()), nil
|
|
}
|