github.com/GoogleContainerTools/skaffold@v1.39.18/pkg/skaffold/build/ko/ko.go (about)

     1  /*
     2  Copyright 2021 The Skaffold Authors
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package ko
    18  
    19  import (
    20  	"context"
    21  
    22  	"github.com/google/go-containerregistry/pkg/name"
    23  	"github.com/google/ko/pkg/build"
    24  	"github.com/google/ko/pkg/commands"
    25  	"github.com/google/ko/pkg/publish"
    26  
    27  	"github.com/GoogleContainerTools/skaffold/pkg/skaffold/config"
    28  	"github.com/GoogleContainerTools/skaffold/pkg/skaffold/docker"
    29  )
    30  
    31  // Builder is an artifact builder that uses ko
    32  type Builder struct {
    33  	localDocker        docker.LocalDaemon
    34  	pushImages         bool
    35  	runMode            config.RunMode
    36  	insecureRegistries map[string]bool
    37  
    38  	// publishImages can be overridden for unit testing purposes.
    39  	publishImages func(context.Context, []string, publish.Interface, build.Interface) (map[string]name.Reference, error)
    40  }
    41  
    42  // NewArtifactBuilder returns a new ko artifact builder
    43  func NewArtifactBuilder(localDocker docker.LocalDaemon, pushImages bool, runMode config.RunMode, insecureRegistries map[string]bool) *Builder {
    44  	return &Builder{
    45  		localDocker:        localDocker,
    46  		pushImages:         pushImages,
    47  		runMode:            runMode,
    48  		insecureRegistries: insecureRegistries,
    49  		publishImages:      commands.PublishImages,
    50  	}
    51  }