github.com/tilt-dev/tilt@v0.33.15-0.20240515162809-0a22ed45d8a0/internal/tiltfile/tiltextension/types.go (about) 1 package tiltextension 2 3 import ( 4 "context" 5 "path/filepath" 6 7 "github.com/tilt-dev/tilt/pkg/apis/core/v1alpha1" 8 ) 9 10 // Interfaces with just the reconciler methods we need. 11 type ExtRepoReconciler interface { 12 ForceApply(ctx context.Context, repo *v1alpha1.ExtensionRepo) v1alpha1.ExtensionRepoStatus 13 } 14 15 type ExtReconciler interface { 16 ForceApply(ext *v1alpha1.Extension, repo *v1alpha1.ExtensionRepo) v1alpha1.ExtensionStatus 17 } 18 19 // Fake versions of these interfaces. 20 type FakeExtRepoReconciler struct { 21 path string 22 Error string 23 } 24 25 func NewFakeExtRepoReconciler(path string) *FakeExtRepoReconciler { 26 return &FakeExtRepoReconciler{path: path} 27 } 28 29 func (r *FakeExtRepoReconciler) ForceApply(ctx context.Context, repo *v1alpha1.ExtensionRepo) v1alpha1.ExtensionRepoStatus { 30 if r.Error != "" { 31 return v1alpha1.ExtensionRepoStatus{Error: r.Error} 32 } 33 return v1alpha1.ExtensionRepoStatus{ 34 Path: filepath.Join(r.path, filepath.Base(repo.Spec.URL)), 35 } 36 } 37 38 type FakeExtReconciler struct { 39 path string 40 Error string 41 } 42 43 func NewFakeExtReconciler(path string) *FakeExtReconciler { 44 return &FakeExtReconciler{path: path} 45 } 46 47 func (r *FakeExtReconciler) ForceApply(ext *v1alpha1.Extension, repo *v1alpha1.ExtensionRepo) v1alpha1.ExtensionStatus { 48 if r.Error != "" { 49 return v1alpha1.ExtensionStatus{Error: r.Error} 50 } 51 return v1alpha1.ExtensionStatus{ 52 Path: filepath.Join(repo.Status.Path, ext.Spec.RepoPath, "Tiltfile"), 53 } 54 }