Skip to content

Commit

Permalink
artifact: improve String() representation
Browse files Browse the repository at this point in the history
FileArtifact: returns the relative path from the application directory
              to the artifact
DockerArtifact: returns the repository name on String()
  • Loading branch information
fho committed Jun 19, 2018
1 parent 98c96d3 commit a0ab8c0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func (a *App) setS3ArtifactsFromCFG(cfg *cfg.App) error {
url := "s3://" + ar.Bucket + "/" + destFile

a.Artifacts = append(a.Artifacts, &FileArtifact{
RelPath: ar.Path,
Path: path.Join(a.Dir, ar.Path),
DestFile: destFile,
UploadURL: url,
Expand Down
1 change: 1 addition & 0 deletions artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
type Artifact interface {
Exists() bool
UploadJob() (upload.Job, error)
Name() string
String() string
LocalPath() string
UploadDestination() string
Expand Down
9 changes: 7 additions & 2 deletions dockerartifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,21 @@ func (d *DockerArtifact) UploadJob() (upload.Job, error) {
}, nil
}

// String returns the string representation of the artifact
// String returns the absolute path to the ImageID file
func (d *DockerArtifact) String() string {
return d.ImageIDFile
return d.LocalPath()
}

// LocalPath returns the local path to the artifact
func (d *DockerArtifact) LocalPath() string {
return d.ImageIDFile
}

// Name returns the docker repository name
func (d *DockerArtifact) Name() string {
return d.Repository
}

// UploadDestination returns the upload destination
func (d *DockerArtifact) UploadDestination() string {
return fmt.Sprintf("docker: %s:%s", d.Repository, d.Tag)
Expand Down
8 changes: 7 additions & 1 deletion fileartifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

// FileArtifact is a file build artifact
type FileArtifact struct {
RelPath string
Path string
DestFile string
UploadURL string
Expand All @@ -19,7 +20,7 @@ func (f *FileArtifact) Exists() bool {

// String returns the String representation
func (f *FileArtifact) String() string {
return f.Path
return f.Name()
}

// UploadJob returns a upload.DockerJob for the artifact
Expand All @@ -35,6 +36,11 @@ func (f *FileArtifact) LocalPath() string {
return f.Path
}

// Name returns the path to the artifact relatively to application dir
func (f *FileArtifact) Name() string {
return f.RelPath
}

// UploadDestination returns the upload destination
func (f *FileArtifact) UploadDestination() string {
return f.UploadURL
Expand Down

0 comments on commit a0ab8c0

Please sign in to comment.