Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On the way to process directories via grpc #50

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configs/firecracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func NewFcConfigProvider(jailingFcConfig *JailingFirecrackerConfig, machineConfi

func (c *defaultFcConfigProvider) ToSDKConfig() firecracker.Config {

var fifo io.WriteCloser // TODO: do it like firectl does it
var fifo io.WriteCloser // CONSIDER: do it like firectl does it

return firecracker.Config{
SocketPath: "", // given via Jailer
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require (
github.com/firecracker-microvm/firecracker-go-sdk v0.22.0
github.com/go-git/go-git/v5 v5.2.0
github.com/gofrs/uuid v4.0.0+incompatible
github.com/golang/protobuf v1.5.1
github.com/hashicorp/go-hclog v0.15.0
github.com/hashicorp/go-multierror v1.0.0
github.com/mitchellh/mapstructure v1.3.2
Expand Down
2 changes: 1 addition & 1 deletion pkg/build/dependency.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ func (ddb *defaultDependencyBuild) Build(externalCopies []commands.Copy) ([]reso
return emptyResponse, fmt.Errorf("error fetching Docker client: %+v", clientErr)
}

// TODO: verify that this is actually possible with Docker.
// Do not return early, maybe somebody attempts to build a base image
// using the multistage build but without extracting actual resources.
// This is perfectly possible with Docker.

// The cloned sources reside in .../sources directory, let's write our stage Dockerfile in there
randFileName := strings.ToLower(utils.RandStringBytes(32))
Expand Down
29 changes: 19 additions & 10 deletions pkg/build/resources/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,16 +191,11 @@ func (dr *defaultResolver) resolveResources(originalSource, resourcePath, target
return nil, fmt.Errorf("resource failed: resolved '%s', reason: %v", match, statErr)
}
if statResult.IsDir() {
resources = append(resources, &defaultResolvedResource{contentsReader: func() (io.ReadCloser, error) {
return ioutil.NopCloser(bytes.NewReader([]byte{})), nil
},
isDir: true,
resolved: newPath,
sourcePath: resourcePath,
targetMode: statResult.Mode().Perm(),
targetPath: targetPath,
targetWorkdir: targetWorkdir,
targetUser: targetUser})
resources = append(resources,
NewResolvedDirectoryResourceWithPath(statResult.Mode().Perm(),
newPath, resourcePath, targetPath,
targetWorkdir,
targetUser))
} else {
resources = append(resources, &defaultResolvedResource{contentsReader: func() (io.ReadCloser, error) {
file, err := os.Open(newPath)
Expand Down Expand Up @@ -238,3 +233,17 @@ func NewResolvedFileResourceWithPath(contentsReader func() (io.ReadCloser, error
targetWorkdir: workdir,
targetUser: user}
}

// NewResolvedDirectoryResourceWithPath creates a resolved resource from input information containing resource source path.
func NewResolvedDirectoryResourceWithPath(mode fs.FileMode, resolvedPath, sourcePath, targetPath string, workdir commands.Workdir, user commands.User) ResolvedResource {
return &defaultResolvedResource{contentsReader: func() (io.ReadCloser, error) {
return ioutil.NopCloser(bytes.NewReader([]byte{})), nil
},
isDir: true,
resolved: resolvedPath,
targetMode: mode,
sourcePath: sourcePath,
targetPath: targetPath,
targetWorkdir: workdir,
targetUser: user}
}
2 changes: 1 addition & 1 deletion pkg/build/rootfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (b *defaultBuild) CreateContext(dependencies server.Resources) (*server.Wor
ctx.ResourcesResolved[sourcePath] = []resources.ResolvedResource{dependencyResource}

ctx.ExecutableCommands = append(ctx.ExecutableCommands, commands.Copy{
OriginalCommand: "",
OriginalCommand: tcommand.OriginalCommand,
OriginalSource: dependencyResource.ResolvedURIOrPath(),
Source: sourcePath,
Target: dependencyResource.TargetPath(),
Expand Down
Loading