Skip to content

Commit

Permalink
refactor: rename 'layer' as 'image' in stacker publish path (#583)
Browse files Browse the repository at this point in the history
Signed-off-by: Ramkumar Chinchani <[email protected]>
  • Loading branch information
rchincha authored Jan 12, 2024
1 parent 583c4f6 commit 554db17
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions cmd/stacker/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ var publishCmd = cli.Command{
Value: cli.NewStringSlice("tar"),
},
&cli.StringSliceFlag{
Name: "layer",
Usage: "layer to be published; can be specified multiple times",
Name: "image",
Usage: "specific image to be published when a stacker file has many images; can be specified multiple times",
},
},
Before: beforePublish,
Expand Down Expand Up @@ -127,7 +127,7 @@ func doPublish(ctx *cli.Context) error {
Progress: shouldShowProgress(ctx),
SkipTLS: ctx.Bool("skip-tls"),
LayerTypes: layerTypes,
Layers: ctx.StringSlice("layer"),
Images: ctx.StringSlice("image"),
}

var stackerFiles []string
Expand Down
6 changes: 3 additions & 3 deletions pkg/stacker/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type PublishArgs struct {
Progress bool
SkipTLS bool
LayerTypes []types.LayerType
Layers []string
Images []string
}

// Publisher is responsible for publishing the layers based on stackerfiles
Expand Down Expand Up @@ -377,9 +377,9 @@ func (p *Publisher) Publish(file string) error {
log.Infof("will not publish: %s build_only %s", file, name)
continue
}
if len(p.opts.Layers) > 0 {
if len(p.opts.Images) > 0 {
found := false
for _, lname := range p.opts.Layers {
for _, lname := range p.opts.Images {
if lname == name {
found = true
break
Expand Down
8 changes: 4 additions & 4 deletions test/convert.bats
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ EOF
if [ -z "${REGISTRY_URL}" ]; then
skip "test because no registry found in REGISTRY_URL env variable"
fi
stacker publish -f stacker.yaml --substitute-file stacker-subs.yaml --substitute IMAGE=app --skip-tls --url docker://${REGISTRY_URL} --layer app --tag latest
stacker publish -f stacker.yaml --substitute-file stacker-subs.yaml --substitute IMAGE=app --skip-tls --url docker://${REGISTRY_URL} --image app --tag latest
rm -f stacker.yaml stacker-subs.yaml
stacker clean
}
Expand All @@ -56,7 +56,7 @@ EOF
stacker convert --docker-file Dockerfile --output-file stacker.yaml --substitute-file stacker-subs.yaml
stacker build -f stacker.yaml --substitute-file stacker-subs.yaml --substitute IMAGE=alpine --substitute STACKER_VOL1="$TEMPDIR"
if [ -nz "${REGISTRY_URL}" ]; then
stacker publish -f stacker.yaml --substitute-file stacker-subs.yaml --substitute IMAGE=alpine --substitute STACKER_VOL1="$TEMPDIR" --skip-tls --url docker://${REGISTRY_URL} --layer alpine --tag latest
stacker publish -f stacker.yaml --substitute-file stacker-subs.yaml --substitute IMAGE=alpine --substitute STACKER_VOL1="$TEMPDIR" --skip-tls --url docker://${REGISTRY_URL} --image alpine --tag latest
fi
rm -f stacker.yaml stacker-subs.yaml
stacker clean
Expand All @@ -70,7 +70,7 @@ EOF
stacker convert --docker-file Dockerfile --output-file stacker.yaml --substitute-file stacker-subs.yaml
stacker build -f stacker.yaml --substitute-file stacker-subs.yaml --substitute IMAGE=elasticsearch
if [ -nz "${REGISTRY_URL}" ]; then
stacker publish -f stacker.yaml --substitute-file stacker-subs.yaml --substitute IMAGE=elasticsearch --skip-tls --url docker://${REGISTRY_URL} --layer elasticsearch --tag latest
stacker publish -f stacker.yaml --substitute-file stacker-subs.yaml --substitute IMAGE=elasticsearch --skip-tls --url docker://${REGISTRY_URL} --image elasticsearch --tag latest
fi
rm -f stacker.yaml stacker-subs.yaml
stacker clean
Expand All @@ -84,7 +84,7 @@ EOF
stacker convert --docker-file Dockerfile --output-file stacker.yaml --substitute-file stacker-subs.yaml
stacker build -f stacker.yaml --substitute-file stacker-subs.yaml --substitute IMAGE=python
if [ -nz "${REGISTRY_URL}" ]; then
stacker publish -f stacker.yaml --substitute-file stacker-subs.yaml --substitute IMAGE=python --skip-tls --url docker://${REGISTRY_URL} --layer python --tag latest
stacker publish -f stacker.yaml --substitute-file stacker-subs.yaml --substitute IMAGE=python --skip-tls --url docker://${REGISTRY_URL} --image python --tag latest
fi
rm -f stacker.yaml stacker-subs.yaml
stacker clean
Expand Down
2 changes: 1 addition & 1 deletion test/publish.bats
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function teardown() {

@test "publish selected multiple layers" {
stacker recursive-build -d ocibuilds
stacker publish -d ocibuilds --url oci:oci_publish --tag test1 --layer layer1 --layer layer6
stacker publish -d ocibuilds --url oci:oci_publish --tag test1 --image layer1 --image layer6

# Unpack published image and check content
umoci unpack --image oci_publish:layer1_test1 dest/layer1_test1
Expand Down

0 comments on commit 554db17

Please sign in to comment.