Skip to content

Commit 91bc3aa

Browse files
committed
imagebuildah: unexport the Executor and StageExecutor types
Rename the Executor and StageExecutor types to make them private to the package. Exporting them wasn't required for them to supply an interface that they implemented for use by github.com/openshift/imagebuilder, and we're about to change the signature for StageExecutor.Execute(). Signed-off-by: Nalin Dahyabhai <[email protected]>
1 parent 2fc9d58 commit 91bc3aa

File tree

2 files changed

+56
-56
lines changed

2 files changed

+56
-56
lines changed

imagebuildah/executor.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,16 @@ var builtinAllowedBuildArgs = map[string]struct{}{
5959
internal.SourceDateEpochName: {},
6060
}
6161

62-
// Executor is a buildah-based implementation of the imagebuilder.Executor
62+
// executor is a buildah-based implementation of the imagebuilder.Executor
6363
// interface. It coordinates the entire build by using one or more
64-
// StageExecutors to handle each stage of the build.
65-
type Executor struct {
64+
// stageExecutors to handle each stage of the build.
65+
type executor struct {
6666
cacheFrom []reference.Named
6767
cacheTo []reference.Named
6868
cacheTTL time.Duration
6969
containerSuffix string
7070
logger *logrus.Logger
71-
stages map[string]*StageExecutor
71+
stages map[string]*stageExecutor
7272
store storage.Store
7373
contextDir string
7474
pullPolicy define.PullPolicy
@@ -184,7 +184,7 @@ type imageTypeAndHistoryAndDiffIDs struct {
184184
}
185185

186186
// newExecutor creates a new instance of the imagebuilder.Executor interface.
187-
func newExecutor(logger *logrus.Logger, logPrefix string, store storage.Store, options define.BuildOptions, mainNode *parser.Node, containerFiles []string) (*Executor, error) {
187+
func newExecutor(logger *logrus.Logger, logPrefix string, store storage.Store, options define.BuildOptions, mainNode *parser.Node, containerFiles []string) (*executor, error) {
188188
defaultContainerConfig, err := config.Default()
189189
if err != nil {
190190
return nil, fmt.Errorf("failed to get container config: %w", err)
@@ -244,14 +244,14 @@ func newExecutor(logger *logrus.Logger, logPrefix string, store storage.Store, o
244244
buildOutputs = append(buildOutputs, options.BuildOutput) //nolint:staticcheck
245245
}
246246

247-
exec := Executor{
247+
exec := executor{
248248
args: options.Args,
249249
cacheFrom: options.CacheFrom,
250250
cacheTo: options.CacheTo,
251251
cacheTTL: options.CacheTTL,
252252
containerSuffix: options.ContainerSuffix,
253253
logger: logger,
254-
stages: make(map[string]*StageExecutor),
254+
stages: make(map[string]*stageExecutor),
255255
store: store,
256256
contextDir: options.ContextDirectory,
257257
excludes: excludes,
@@ -399,10 +399,10 @@ func newExecutor(logger *logrus.Logger, logPrefix string, store storage.Store, o
399399

400400
// startStage creates a new stage executor that will be referenced whenever a
401401
// COPY or ADD statement uses a --from=NAME flag.
402-
func (b *Executor) startStage(ctx context.Context, stage *imagebuilder.Stage, stages imagebuilder.Stages, output string) *StageExecutor {
402+
func (b *executor) startStage(ctx context.Context, stage *imagebuilder.Stage, stages imagebuilder.Stages, output string) *stageExecutor {
403403
// create a copy of systemContext for each stage executor.
404404
systemContext := *b.systemContext
405-
stageExec := &StageExecutor{
405+
stageExec := &stageExecutor{
406406
ctx: ctx,
407407
executor: b,
408408
systemContext: &systemContext,
@@ -423,7 +423,7 @@ func (b *Executor) startStage(ctx context.Context, stage *imagebuilder.Stage, st
423423
}
424424

425425
// resolveNameToImageRef creates a types.ImageReference for the output name in local storage
426-
func (b *Executor) resolveNameToImageRef(output string) (types.ImageReference, error) {
426+
func (b *executor) resolveNameToImageRef(output string) (types.ImageReference, error) {
427427
if imageRef, err := alltransports.ParseImageName(output); err == nil {
428428
return imageRef, nil
429429
}
@@ -443,7 +443,7 @@ func (b *Executor) resolveNameToImageRef(output string) (types.ImageReference, e
443443
// that the specified stage has finished. If there is no stage defined by that
444444
// name, then it will return (false, nil). If there is a stage defined by that
445445
// name, it will return true along with any error it encounters.
446-
func (b *Executor) waitForStage(ctx context.Context, name string, stages imagebuilder.Stages) (bool, error) {
446+
func (b *executor) waitForStage(ctx context.Context, name string, stages imagebuilder.Stages) (bool, error) {
447447
found := false
448448
for _, otherStage := range stages {
449449
if otherStage.Name == name || strconv.Itoa(otherStage.Position) == name {
@@ -479,7 +479,7 @@ func (b *Executor) waitForStage(ctx context.Context, name string, stages imagebu
479479
}
480480

481481
// getImageTypeAndHistoryAndDiffIDs returns the os, architecture, manifest type, history, and diff IDs list of imageID.
482-
func (b *Executor) getImageTypeAndHistoryAndDiffIDs(ctx context.Context, imageID string) (string, string, string, []v1.History, []digest.Digest, error) {
482+
func (b *executor) getImageTypeAndHistoryAndDiffIDs(ctx context.Context, imageID string) (string, string, string, []v1.History, []digest.Digest, error) {
483483
b.imageInfoLock.Lock()
484484
imageInfo, ok := b.imageInfoCache[imageID]
485485
b.imageInfoLock.Unlock()
@@ -519,7 +519,7 @@ func (b *Executor) getImageTypeAndHistoryAndDiffIDs(ctx context.Context, imageID
519519
return oci.OS, oci.Architecture, manifestFormat, oci.History, oci.RootFS.DiffIDs, nil
520520
}
521521

522-
func (b *Executor) buildStage(ctx context.Context, cleanupStages map[int]*StageExecutor, stages imagebuilder.Stages, stageIndex int) (imageID string, ref reference.Canonical, onlyBaseImage bool, err error) {
522+
func (b *executor) buildStage(ctx context.Context, cleanupStages map[int]*stageExecutor, stages imagebuilder.Stages, stageIndex int) (imageID string, ref reference.Canonical, onlyBaseImage bool, err error) {
523523
stage := stages[stageIndex]
524524
ib := stage.Builder
525525
node := stage.Node
@@ -616,7 +616,7 @@ func (b *Executor) buildStage(ctx context.Context, cleanupStages map[int]*StageE
616616
}
617617

618618
// Build this stage.
619-
if imageID, ref, onlyBaseImage, err = stageExecutor.Execute(ctx, base); err != nil {
619+
if imageID, ref, onlyBaseImage, err = stageExecutor.execute(ctx, base); err != nil {
620620
return "", nil, onlyBaseImage, err
621621
}
622622

@@ -652,7 +652,7 @@ func markDependencyStagesForTarget(dependencyMap map[string]*stageDependencyInfo
652652
}
653653
}
654654

655-
func (b *Executor) warnOnUnsetBuildArgs(stages imagebuilder.Stages, dependencyMap map[string]*stageDependencyInfo, args map[string]string) {
655+
func (b *executor) warnOnUnsetBuildArgs(stages imagebuilder.Stages, dependencyMap map[string]*stageDependencyInfo, args map[string]string) {
656656
argFound := make(map[string]struct{})
657657
for _, stage := range stages {
658658
node := stage.Node // first line
@@ -699,12 +699,12 @@ func (b *Executor) warnOnUnsetBuildArgs(stages imagebuilder.Stages, dependencyMa
699699

700700
// Build takes care of the details of running Prepare/Execute/Commit/Delete
701701
// over each of the one or more parsed Dockerfiles and stages.
702-
func (b *Executor) Build(ctx context.Context, stages imagebuilder.Stages) (imageID string, ref reference.Canonical, err error) {
702+
func (b *executor) Build(ctx context.Context, stages imagebuilder.Stages) (imageID string, ref reference.Canonical, err error) {
703703
if len(stages) == 0 {
704704
return "", nil, errors.New("building: no stages to build")
705705
}
706706
var cleanupImages []string
707-
cleanupStages := make(map[int]*StageExecutor)
707+
cleanupStages := make(map[int]*stageExecutor)
708708

709709
stdout := b.out
710710
if b.quiet {
@@ -1104,7 +1104,7 @@ func (b *Executor) Build(ctx context.Context, stages imagebuilder.Stages) (image
11041104
// deleteSuccessfulIntermediateCtrs goes through the container IDs in each
11051105
// stage's containerIDs list and deletes the containers associated with those
11061106
// IDs.
1107-
func (b *Executor) deleteSuccessfulIntermediateCtrs() error {
1107+
func (b *executor) deleteSuccessfulIntermediateCtrs() error {
11081108
var lastErr error
11091109
for _, s := range b.stages {
11101110
for _, ctr := range s.containerIDs {

0 commit comments

Comments
 (0)