@@ -38,11 +38,9 @@ func (c *Calcium) BuildImage(ctx context.Context, opts *types.BuildOptions) (ch
38
38
)
39
39
switch opts .BuildMethod {
40
40
case types .BuildFromSCM :
41
- refs = node .Engine .BuildRefs (ctx , toBuildRefOptions (opts ))
42
- resp , err = c .buildFromSCM (ctx , node , refs , opts )
41
+ refs , resp , err = c .buildFromSCM (ctx , node , opts )
43
42
case types .BuildFromRaw :
44
- refs = node .Engine .BuildRefs (ctx , toBuildRefOptions (opts ))
45
- resp , err = c .buildFromContent (ctx , node , refs , opts .Tar )
43
+ refs , resp , err = c .buildFromContent (ctx , node , opts )
46
44
case types .BuildFromExist :
47
45
refs , node , resp , err = c .buildFromExist (ctx , opts )
48
46
default :
@@ -75,7 +73,7 @@ func (c *Calcium) selectBuildNode(ctx context.Context) (*types.Node, error) {
75
73
return node , err
76
74
}
77
75
78
- func (c * Calcium ) buildFromSCM (ctx context.Context , node * types.Node , refs [] string , opts * types.BuildOptions ) (io.ReadCloser , error ) {
76
+ func (c * Calcium ) buildFromSCM (ctx context.Context , node * types.Node , opts * types.BuildOptions ) ([] string , io.ReadCloser , error ) {
79
77
buildContentOpts := & enginetypes.BuildContentOptions {
80
78
User : opts .User ,
81
79
UID : opts .UID ,
@@ -84,14 +82,16 @@ func (c *Calcium) buildFromSCM(ctx context.Context, node *types.Node, refs []str
84
82
path , content , err := node .Engine .BuildContent (ctx , c .source , buildContentOpts )
85
83
defer os .RemoveAll (path )
86
84
if err != nil {
87
- return nil , errors .WithStack (err )
85
+ return nil , nil , errors .WithStack (err )
88
86
}
89
- return c .buildFromContent (ctx , node , refs , content )
87
+ opts .Tar = content
88
+ return c .buildFromContent (ctx , node , opts )
90
89
}
91
90
92
- func (c * Calcium ) buildFromContent (ctx context.Context , node * types.Node , refs []string , content io.Reader ) (io.ReadCloser , error ) {
93
- resp , err := node .Engine .ImageBuild (ctx , content , refs )
94
- return resp , errors .WithStack (err )
91
+ func (c * Calcium ) buildFromContent (ctx context.Context , node * types.Node , opts * types.BuildOptions ) ([]string , io.ReadCloser , error ) {
92
+ refs := node .Engine .BuildRefs (ctx , toBuildRefOptions (opts ))
93
+ resp , err := node .Engine .ImageBuild (ctx , opts .Tar , refs )
94
+ return refs , resp , errors .WithStack (err )
95
95
}
96
96
97
97
func (c * Calcium ) buildFromExist (ctx context.Context , opts * types.BuildOptions ) (refs []string , node * types.Node , resp io.ReadCloser , err error ) {
0 commit comments