github.com/tilt-dev/tilt@v0.33.15-0.20240515162809-0a22ed45d8a0/internal/tiltfile/fake.go (about)

     1  package tiltfile
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/tilt-dev/tilt/pkg/apis/core/v1alpha1"
     7  )
     8  
     9  type FakeTiltfileLoader struct {
    10  	Result   TiltfileLoadResult
    11  	Args     []string
    12  	Delegate TiltfileLoader
    13  }
    14  
    15  var _ TiltfileLoader = &FakeTiltfileLoader{}
    16  
    17  func NewFakeTiltfileLoader() *FakeTiltfileLoader {
    18  	return &FakeTiltfileLoader{}
    19  }
    20  
    21  func (tfl *FakeTiltfileLoader) Load(ctx context.Context, tf *v1alpha1.Tiltfile, prevResult *TiltfileLoadResult) TiltfileLoadResult {
    22  	tfl.Args = tf.Spec.Args
    23  	if tfl.Delegate != nil {
    24  		return tfl.Delegate.Load(ctx, tf, prevResult)
    25  	}
    26  	return tfl.Result
    27  }
    28  
    29  // the Args that was passed to the last invocation of Load
    30  func (tfl *FakeTiltfileLoader) PassedArgs() []string {
    31  	return tfl.Args
    32  }