From 2bf2b22fbe3b62c772adf05e9b9fbb848447d9cc Mon Sep 17 00:00:00 2001 From: Brian Goff Date: Mon, 8 Jan 2024 22:13:26 +0000 Subject: [PATCH] Add source policies for build Build{x,kit} support passing in source policies via an (expirimental) env var. This change adds those policies to the build request. Signed-off-by: Brian Goff --- pkg/compose/build.go | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/pkg/compose/build.go b/pkg/compose/build.go index 78ff6220e..67f58d621 100644 --- a/pkg/compose/build.go +++ b/pkg/compose/build.go @@ -410,6 +410,11 @@ func (s *composeService) toBuildOptions(project *types.Project, service types.Se }} } + sp, err := build.ReadSourcePolicy() + if err != nil { + return build.Options{}, err + } + return build.Options{ Inputs: build.Inputs{ ContextPath: service.Build.Context, @@ -417,21 +422,22 @@ func (s *composeService) toBuildOptions(project *types.Project, service types.Se DockerfilePath: dockerFilePath(service.Build.Context, service.Build.Dockerfile), NamedContexts: toBuildContexts(service.Build.AdditionalContexts), }, - CacheFrom: pb.CreateCaches(cacheFrom), - CacheTo: pb.CreateCaches(cacheTo), - NoCache: service.Build.NoCache, - Pull: service.Build.Pull, - BuildArgs: flatten(resolveAndMergeBuildArgs(s.dockerCli, project, service, options)), - Tags: tags, - Target: service.Build.Target, - Exports: exports, - Platforms: plats, - Labels: imageLabels, - NetworkMode: service.Build.Network, - ExtraHosts: service.Build.ExtraHosts.AsList(":"), - Ulimits: toUlimitOpt(service.Build.Ulimits), - Session: sessionConfig, - Allow: allow, + CacheFrom: pb.CreateCaches(cacheFrom), + CacheTo: pb.CreateCaches(cacheTo), + NoCache: service.Build.NoCache, + Pull: service.Build.Pull, + BuildArgs: flatten(resolveAndMergeBuildArgs(s.dockerCli, project, service, options)), + Tags: tags, + Target: service.Build.Target, + Exports: exports, + Platforms: plats, + Labels: imageLabels, + NetworkMode: service.Build.Network, + ExtraHosts: service.Build.ExtraHosts.AsList(":"), + Ulimits: toUlimitOpt(service.Build.Ulimits), + Session: sessionConfig, + Allow: allow, + SourcePolicy: sp, }, nil }