Skip to content

Commit 6c4c1e0

Browse files
committed
add and check for gateway.exec.secretenv cap
Signed-off-by: Alex Suraci <[email protected]>
1 parent ad9a37a commit 6c4c1e0

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

frontend/gateway/grpcclient/client.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,13 +806,15 @@ func (c *grpcClient) NewContainer(ctx context.Context, req client.NewContainerRe
806806

807807
return &container{
808808
client: c.client,
809+
caps: c.caps,
809810
id: id,
810811
execMsgs: c.execMsgs,
811812
}, nil
812813
}
813814

814815
type container struct {
815816
client pb.LLBBridgeClient
817+
caps apicaps.CapSet
816818
id string
817819
execMsgs *messageForwarder
818820
}
@@ -821,6 +823,12 @@ func (ctr *container) Start(ctx context.Context, req client.StartRequest) (clien
821823
pid := fmt.Sprintf("%s:%s", ctr.id, identity.NewID())
822824
msgs := ctr.execMsgs.Register(pid)
823825

826+
if len(req.SecretEnv) > 0 {
827+
if err := ctr.caps.Supports(pb.CapGatewayExecSecretEnv); err != nil {
828+
return nil, err
829+
}
830+
}
831+
824832
init := &pb.InitMessage{
825833
ContainerID: ctr.id,
826834
Meta: &opspb.Meta{

frontend/gateway/pb/caps.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ const (
4444
// /etc/hosts for containers created via gateway exec.
4545
CapGatewayExecExtraHosts apicaps.CapID = "gateway.exec.extrahosts"
4646

47+
// CapGatewayExecExtraHosts is the capability to set secrets as env vars for
48+
// containers created via gateway exec.
49+
CapGatewayExecSecretEnv apicaps.CapID = "gateway.exec.secretenv"
50+
4751
// CapGatewayExecExtraHosts is the capability to send signals to a process
4852
// created via gateway exec.
4953
CapGatewayExecSignals apicaps.CapID = "gateway.exec.signals"
@@ -179,6 +183,13 @@ func init() {
179183
Status: apicaps.CapStatusExperimental,
180184
})
181185

186+
Caps.Init(apicaps.Cap{
187+
ID: CapGatewayExecSecretEnv,
188+
Name: "gateway exec secret env",
189+
Enabled: true,
190+
Status: apicaps.CapStatusExperimental,
191+
})
192+
182193
Caps.Init(apicaps.Cap{
183194
ID: CapGatewayExecSignals,
184195
Name: "gateway exec signals",

util/stack/stack.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)