Skip to content

Commit 10d768b

Browse files
Add inherit-labels option to Build API
Add the inherit-labels option to the build API and tweak the go.mod after some unhappiness in my sandbox. Signed-off-by: tomsweeneyredhat <[email protected]>
1 parent 76b07dd commit 10d768b

File tree

6 files changed

+26
-3
lines changed

6 files changed

+26
-3
lines changed

cmd/podman/common/build.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,10 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *Buil
580580
UnsetLabels: flags.UnsetLabels,
581581
}
582582

583+
if c.Flag("inherit-labels").Changed {
584+
opts.InheritLabels = types.NewOptionalBool(flags.InheritLabels)
585+
}
586+
583587
if flags.IgnoreFile != "" {
584588
excludes, err := parseDockerignore(flags.IgnoreFile)
585589
if err != nil {

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ require (
155155
github.com/moby/docker-image-spec v1.3.1 // indirect
156156
github.com/moby/go-archive v0.1.0 // indirect
157157
github.com/moby/patternmatcher v0.6.0 // indirect
158-
github.com/moby/sys/atomicwriter v0.1.0 // indirect
159158
github.com/moby/sys/mountinfo v0.7.2 // indirect
160159
github.com/moby/sys/sequential v0.6.0 // indirect
161160
github.com/moby/sys/userns v0.1.0 // indirect

pkg/api/handlers/compat/images_build.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
130130
IDMappingOptions string `schema:"idmappingoptions"`
131131
IdentityLabel bool `schema:"identitylabel"`
132132
Ignore bool `schema:"ignore"`
133+
InheritLabels bool `schema:"inheritlabels"`
133134
Isolation string `schema:"isolation"`
134135
Jobs int `schema:"jobs"`
135136
LabelOpts string `schema:"labelopts"`
@@ -744,6 +745,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
744745
IDMappingOptions: &idMappingOptions,
745746
IgnoreUnrecognizedInstructions: query.Ignore,
746747
IgnoreFile: ignoreFile,
748+
InheritLabels: types.NewOptionalBool(query.InheritLabels),
747749
Isolation: isolation,
748750
Jobs: &jobs,
749751
Labels: labels,

pkg/api/server/register_images.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,13 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error {
567567
// Contents of base images to be modified on ADD or COPY only
568568
// (As of Podman version v5.2)
569569
// - in: query
570+
// name: inheritlabels
571+
// type: boolean
572+
// default: true
573+
// description: |
574+
// Inherit the labels from the base image or base stages
575+
// (As of Podman version v5.5)
576+
// - in: query
570577
// name: nocache
571578
// type: boolean
572579
// default: false
@@ -1540,6 +1547,13 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error {
15401547
// Contents of base images to be modified on ADD or COPY only
15411548
// (As of Podman version v5.2)
15421549
// - in: query
1550+
// name: inheritlabels
1551+
// type: boolean
1552+
// default: true
1553+
// description: |
1554+
// Inherit the labels from the base image or base stages
1555+
// (As of Podman version v5.5)
1556+
// - in: query
15431557
// name: nocache
15441558
// type: boolean
15451559
// default: false

pkg/bindings/images/build.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,12 @@ func Build(ctx context.Context, containerFiles []string, options types.BuildOpti
237237
if options.IgnoreUnrecognizedInstructions {
238238
params.Set("ignore", "1")
239239
}
240+
if options.InheritLabels == imageTypes.OptionalBoolFalse {
241+
params.Set("inheritlabels", "0")
242+
} else {
243+
params.Set("inheritlabels", "1")
244+
}
245+
240246
params.Set("isolation", strconv.Itoa(int(options.Isolation)))
241247
if options.CommonBuildOpts.HTTPProxy {
242248
params.Set("httpproxy", "1")

vendor/modules.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -723,8 +723,6 @@ github.com/moby/go-archive/tarheader
723723
# github.com/moby/patternmatcher v0.6.0
724724
## explicit; go 1.19
725725
github.com/moby/patternmatcher
726-
# github.com/moby/sys/atomicwriter v0.1.0
727-
## explicit; go 1.18
728726
# github.com/moby/sys/capability v0.4.0
729727
## explicit; go 1.21
730728
github.com/moby/sys/capability

0 commit comments

Comments
 (0)