github.com/ouraigua/jenkins-library@v0.0.0-20231028010029-fbeaf2f3aa9b/pkg/jenkins/artifact.go (about) 1 package jenkins 2 3 import ( 4 "context" 5 6 "github.com/bndr/gojenkins" 7 ) 8 9 // Artifact is an interface to abstract gojenkins.Artifact. 10 // mock generated with: mockery --name Artifact --dir pkg/jenkins --output pkg/jenkins/mocks 11 type Artifact interface { 12 Save(ctx context.Context, path string) (bool, error) 13 SaveToDir(ctx context.Context, dir string) (bool, error) 14 GetData(ctx context.Context) ([]byte, error) 15 FileName() string 16 } 17 18 // ArtifactImpl is a wrapper struct for gojenkins.Artifact that respects the Artifact interface. 19 type ArtifactImpl struct { 20 artifact gojenkins.Artifact 21 } 22 23 // Save refers to the gojenkins.Artifact.Save function. 24 func (a *ArtifactImpl) Save(ctx context.Context, path string) (bool, error) { 25 return a.artifact.Save(ctx, path) 26 } 27 28 // SaveToDir refers to the gojenkins.Artifact.SaveToDir function. 29 func (a *ArtifactImpl) SaveToDir(ctx context.Context, dir string) (bool, error) { 30 return a.artifact.SaveToDir(ctx, dir) 31 } 32 33 // GetData refers to the gojenkins.Artifact.GetData function. 34 func (a *ArtifactImpl) GetData(ctx context.Context) ([]byte, error) { 35 return a.artifact.GetData(ctx) 36 } 37 38 // FileName refers to the gojenkins.Artifact.FileName field. 39 func (a *ArtifactImpl) FileName() string { 40 return a.artifact.FileName 41 }