github.com/GoogleContainerTools/skaffold@v1.39.18/pkg/skaffold/test/types.go (about)

     1  /*
     2  Copyright 2019 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 test
    18  
    19  import (
    20  	"context"
    21  	"io"
    22  
    23  	"github.com/GoogleContainerTools/skaffold/pkg/skaffold/graph"
    24  	"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
    25  )
    26  
    27  // Tester is the top level test executor in Skaffold.
    28  // A tester is really a collection of artifact-specific testers,
    29  // each of which contains one or more Tester which implements
    30  // a single test run.
    31  type Tester interface {
    32  	Test(context.Context, io.Writer, []graph.Artifact) error
    33  	TestDependencies(ctx context.Context, artifact *latest.Artifact) ([]string, error)
    34  }
    35  
    36  type Muted interface {
    37  	MuteTest() bool
    38  }
    39  
    40  // FullTester serves as a holder for the individual artifact-specific
    41  // testers. It exists so that the Tester interface can mimic the Builder/Deployer
    42  // interface, so it can be called in a similar fashion from the runner, while
    43  // the FullTester actually handles the work.
    44  
    45  // FullTester should always be the ONLY implementation of the Tester interface;
    46  // newly added testing implementations should implement the imageTester interface.
    47  type FullTester struct {
    48  	Testers ImageTesters
    49  	muted   Muted
    50  	// imagesAreLocal func(imageName string) (bool, error)
    51  }
    52  
    53  // ImageTester is the lowest-level test executor in Skaffold, responsible for
    54  // running a single test on a single artifact image and returning its result.
    55  // Any new test type should implement this interface.
    56  type ImageTester interface {
    57  	Test(ctx context.Context, out io.Writer, tag string) error
    58  
    59  	TestDependencies(ctx context.Context) ([]string, error)
    60  }
    61  
    62  // ImageTesters is a collection of imageTester interfaces grouped by the target image name
    63  type ImageTesters map[string][]ImageTester