Skip to content
This repository was archived by the owner on Dec 2, 2020. It is now read-only.

Commit 36ed5f4

Browse files
committed
Hook up output directory cli option
1 parent 858e5a3 commit 36ed5f4

File tree

5 files changed

+9
-14
lines changed

5 files changed

+9
-14
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313

1414
vendor/
1515

16-
image-output/
16+
output/

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ docker run lambda-php goodbye '{"name": "World"}'
1212
../../bin/img2lambda -i docker-daemon:lambda-php:latest
1313
```
1414

15+
TODO:
16+
* Utility for creating a function deployment package from a Docker image
17+
* Support image types other than local Docker images ('docker-daemon' transport), where the layer format is tar. For example, layers directly from a Docker registry will be .tar.gz-formatted. OCI images can be either tar or tar.gz, based on the layer's media type.
18+
1519
## License Summary
1620

1721
This sample code is made available under a modified MIT license. See the LICENSE file.

main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ func createApp() (*cli.App, *cmdOptions) {
5151
},
5252
cli.BoolFlag{
5353
Name: "dry-run, d",
54-
Usage: "Conduct a dry-run: Repackage the image, but write the Lambda layers to local disk (do not publish to Lambda)",
54+
Usage: "Conduct a dry-run: Repackage the image, but only write the Lambda layers to local disk (do not publish to Lambda)",
5555
Destination: &opts.dryRun,
5656
},
5757
}
5858
return app, &opts
5959
}
6060

6161
func repackImageAction(opts *cmdOptions) error {
62-
return RepackImage(opts.image)
62+
return RepackImage(opts.image, opts.outputDir)
6363
}
6464

6565
func main() {

repack_image.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313
"github.com/pkg/errors"
1414
)
1515

16-
// Converts container image to Lambda layers
17-
func RepackImage(imageName string) (retErr error) {
16+
// Converts container image to Lambda layer archive files
17+
func RepackImage(imageName string, layerOutputDir string) (retErr error) {
1818
// Get image's layer data from image name
1919
ref, err := alltransports.ParseImageName(imageName)
2020
if err != nil {
@@ -49,11 +49,6 @@ func RepackImage(imageName string) (retErr error) {
4949
layerInfos := src.LayerInfos()
5050

5151
// Unpack and inspect each image layer, copy relevant files to new Lambda layer
52-
dir, err := os.Getwd()
53-
if err != nil {
54-
return err
55-
}
56-
layerOutputDir := filepath.Join(dir, "image-output", imageName)
5752
if err := os.MkdirAll(layerOutputDir, 0777); err != nil {
5853
return err
5954
}

repack_layer.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ import (
1717
// Filters files from the source and only writes a new archive if at least
1818
// one file in the source matches the filter (i.e. does not create empty archives).
1919
func RepackLayer(outputFilename string, layerContents io.Reader) (created bool, retError error) {
20-
// TODO: support image types other than local Docker images (docker-daemon transport),
21-
// where the layer format is tar. For example, layers directly from a Docker registry
22-
// will be .tar.gz-formatted. OCI images can be either tar or tar.gz, based on the
23-
// layer's media type.
2420
t := archiver.NewTar()
2521

2622
err := t.Open(layerContents, 0)

0 commit comments

Comments
 (0)