kubesphere.io/s2irun@v3.2.1+incompatible/pkg/build/interfaces.go (about)

     1  package build
     2  
     3  import (
     4  	"github.com/kubesphere/s2irun/pkg/api"
     5  	"github.com/kubesphere/s2irun/pkg/scm/git"
     6  )
     7  
     8  // Builder is the interface that provides basic methods all implementation
     9  // should have.
    10  // Build method executes the build based on Request and returns the Result.
    11  type Builder interface {
    12  	Build(*api.Config) (*api.Result, error)
    13  }
    14  
    15  // Preparer provides the Prepare method for builders that need to prepare source
    16  // code before it gets passed to the build.
    17  type Preparer interface {
    18  	Prepare(*api.Config) error
    19  }
    20  
    21  // Cleaner provides the Cleanup method for builders that need to cleanup
    22  // temporary containers or directories after build execution finish.
    23  type Cleaner interface {
    24  	Cleanup(*api.Config)
    25  }
    26  
    27  // IncrementalBuilder provides methods that is used for builders that implements
    28  // the 'incremental' build workflow.
    29  // The Exists method checks if the artifacts from the previous build exists
    30  // and if they can be used in the current build.
    31  // The Save method stores the artifacts for the next build.
    32  type IncrementalBuilder interface {
    33  	Exists(*api.Config) bool
    34  	Save(*api.Config) error
    35  }
    36  
    37  // ScriptsHandler provides an interface for executing the scripts
    38  type ScriptsHandler interface {
    39  	Execute(string, string, *api.Config) error
    40  }
    41  
    42  // Downloader provides methods for downloading the application source code
    43  type Downloader interface {
    44  	Download(*api.Config) (*git.SourceInfo, error)
    45  }
    46  
    47  // Ignorer provides ignore file processing on source tree
    48  // NOTE: raised to this level for possible future extensions to
    49  // support say both .gitignore and .dockerignore level functionality
    50  // ( currently do .dockerignore)
    51  type Ignorer interface {
    52  	Ignore(*api.Config) error
    53  }
    54  
    55  // SourceHandler is a wrapper for STI strategy Downloader and Preparer which
    56  // allows to use Download and Prepare functions from the STI strategy.
    57  type SourceHandler interface {
    58  	Downloader
    59  	Preparer
    60  	Ignorer
    61  }
    62  
    63  // LayeredDockerBuilder represents a minimal Docker builder interface that is
    64  // used to execute the layered Docker build with the application source.
    65  type LayeredDockerBuilder interface {
    66  	Builder
    67  }
    68  
    69  // Overrides are interfaces that may be passed into build strategies to
    70  // alter the behavior of a strategy.
    71  type Overrides struct {
    72  	Downloader Downloader
    73  }