change build interface

This commit is contained in:
Asim Aslam
2020-10-18 09:51:11 +01:00
parent 48de9f25a8
commit 04b5fc19c2
4 changed files with 9 additions and 4 deletions

View File

@@ -4,13 +4,15 @@ package build
// Build is an interface for building packages
type Build interface {
// Package builds a package
Package(name string, src *Source) (*Package, error)
Package(*Source) (*Package, error)
// Remove removes the package
Remove(*Package) error
}
// Source is the source of a build
type Source struct {
// Name of the source
Name string
// Path to the source if local
Path string
// Language is the language of code

View File

@@ -18,7 +18,8 @@ type dockerBuild struct {
Client *docker.Client
}
func (d *dockerBuild) Package(name string, s *build.Source) (*build.Package, error) {
func (d *dockerBuild) Package(s *build.Source) (*build.Package, error) {
name := s.Name
image := name
buf := new(bytes.Buffer)

View File

@@ -34,7 +34,8 @@ func whichGo() string {
return "go"
}
func (g *goBuild) Package(name string, src *build.Source) (*build.Package, error) {
func (g *goBuild) Package(src *build.Source) (*build.Package, error) {
name := src.Name
binary := filepath.Join(g.Path, name)
source := src.Path

View File

@@ -10,7 +10,8 @@ import (
type tarBuild struct{}
func (t *tarBuild) Package(name string, src *build.Source) (*build.Package, error) {
func (t *tarBuild) Package(src *build.Source) (*build.Package, error) {
name := src.Name
pkg := name + ".tar.gz"
// path to the tarball
path := filepath.Join(os.TempDir(), src.Path, pkg)