Migrate dagger.#Secret and dagger.#Stream to new format

- 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>
This commit is contained in:
Andrea Luzzardi
2021-11-30 17:51:28 -08:00
parent 5ab3c47dac
commit 5b7b1cab79
27 changed files with 284 additions and 217 deletions

View File

@@ -21,7 +21,7 @@ type inputStore struct {
func (s *inputStore) GetSecret(ctx context.Context, id string) ([]byte, error) {
lg := log.Ctx(ctx)
secret := s.pctx.Secrets.Get(plancontext.ContextKey(id))
secret := s.pctx.Secrets.Get(id)
if secret == nil {
return nil, secrets.ErrNotFound
}
@@ -31,5 +31,5 @@ func (s *inputStore) GetSecret(ctx context.Context, id string) ([]byte, error) {
Str("id", id).
Msg("injecting secret")
return []byte(secret.PlainText), nil
return []byte(secret.PlainText()), nil
}

View File

@@ -36,7 +36,7 @@ func (sp *SocketProvider) ForwardAgent(stream sshforward.SSH_ForwardAgentServer)
id = v[0]
}
service := sp.pctx.Services.Get(plancontext.ContextKey(id))
service := sp.pctx.Services.Get(id)
if service == nil {
return fmt.Errorf("invalid socket id %q", id)
}

View File

@@ -12,9 +12,9 @@ import (
)
func dialService(service *plancontext.Service) (net.Conn, error) {
if service.Unix == "" {
if service.Unix() == "" {
return nil, errors.New("unsupported socket type")
}
return net.DialTimeout("unix", service.Unix, time.Second)
return net.DialTimeout("unix", service.Unix(), time.Second)
}

View File

@@ -13,10 +13,10 @@ import (
)
func dialService(service *plancontext.Service) (net.Conn, error) {
if service.Npipe == "" {
if service.NPipe() == "" {
return nil, errors.New("unsupported socket type")
}
dur := time.Second
return winio.DialPipe(service.Npipe, &dur)
return winio.DialPipe(service.NPipe(), &dur)
}