Skip to content

Commit

Permalink
wip: didnt actually fix anything
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Suraci <alex@dagger.io>
  • Loading branch information
vito committed Jul 18, 2023
1 parent 72e97ea commit f3daaef
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 20 deletions.
24 changes: 4 additions & 20 deletions core/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -1097,27 +1097,11 @@ func (container *Container) WithExec(ctx context.Context, gw bkgw.Client, progSo
}

if len(container.Services) > 0 {
hosts := []string{}
for id := range container.Services {
svc, err := id.ToService()
if err != nil {
return nil, err
}

host, err := svc.Hostname()
if err != nil {
return nil, err
}

hosts = append(hosts, host)
o, err := container.Services.RunOpt()
if err != nil {
return nil, err
}

sort.Strings(hosts)

runOpts = append(runOpts,
llb.AddSecret("_DAGGER_SERVICES",
llb.SecretID(ServicesSecretPrefix+strings.Join(hosts, ",")),
llb.SecretAsEnv(true)))
runOpts = append(runOpts, o)
}

metaSt, metaSourcePath := metaMount(opts.Stdin)
Expand Down
23 changes: 23 additions & 0 deletions core/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,29 @@ func (ss *Services) Detach(ctx context.Context, svc *RunningService) error {

type ServiceBindings map[ServiceID]AliasSet

func (bindings ServiceBindings) RunOpt() (llb.RunOption, error) {
hosts := []string{}
for id := range bindings {
svc, err := id.ToService()
if err != nil {
return nil, err
}

host, err := svc.Hostname()
if err != nil {
return nil, err
}

hosts = append(hosts, host)
}

sort.Strings(hosts)

return llb.AddSecret("_DAGGER_SERVICES",
llb.SecretID(ServicesSecretPrefix+strings.Join(hosts, ",")),
llb.SecretAsEnv(true)), nil
}

type AliasSet []string

func (set AliasSet) String() string {
Expand Down

0 comments on commit f3daaef

Please sign in to comment.