Skip to content

Commit

Permalink
refactor: Updating naming schema (#109)
Browse files Browse the repository at this point in the history
* refactor: Multi-component plugin

Since Packer v1.7.0 multi-component plugins are recomended

* refactor: Updating plugin naming schema

Searched for any packer-builder-arm-image mentions in project and
replaced it with packer-plugin-arm-image.

* fix: Changed naming in github workflows
  • Loading branch information
eaglesemanation committed Oct 17, 2021
1 parent 72c0471 commit 51445a9
Show file tree
Hide file tree
Showing 19 changed files with 57 additions and 57 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ jobs:
fi
- name: Build
run: |
go build -ldflags="-s -w" -o packer-builder-arm-image .
go build -ldflags="-s -w" -o flasher github.com/solo-io/packer-builder-arm-image/cmd/flasher
go build -ldflags="-s -w" -o packer-plugin-arm-image .
go build -ldflags="-s -w" -o flasher github.com/solo-io/packer-plugin-arm-image/cmd/flasher
- name: Test
run: |
go test ./...
- name: Artifact packer-builder-arm-image
- name: Artifact packer-plugin-arm-image
uses: actions/upload-artifact@v1
with:
name: packer-builder-arm-image
path: ./packer-builder-arm-image
name: packer-plugin-arm-image
path: ./packer-plugin-arm-image
- name: Artifact flasher
uses: actions/upload-artifact@v1
with:
Expand All @@ -63,10 +63,10 @@ jobs:
TAGGED_VERSION: ${{github.event.release.tag_name}}
steps:
- uses: actions/checkout@v2
- name: Download packer-builder-arm-image
- name: Download packer-plugin-arm-image
uses: actions/download-artifact@v1
with:
name: packer-builder-arm-image
name: packer-plugin-arm-image
path: ./
- name: Download flasher
uses: actions/download-artifact@v1
Expand All @@ -82,20 +82,20 @@ jobs:
asset_path: ./flasher
asset_name: flasher
asset_content_type: application/octet-stream
- name: Release packer-builder-arm-image
- name: Release packer-plugin-arm-image
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./packer-builder-arm-image
asset_name: packer-builder-arm-image
asset_path: ./packer-plugin-arm-image
asset_name: packer-plugin-arm-image
asset_content_type: application/octet-stream
- name: Push docker
env:
QUAY_IO_PASSWORD: ${{ secrets.QUAY_IO_PASSWORD }}
run: |
docker login quay.io --username "solo-io+solobot" --password $QUAY_IO_PASSWORD
chmod +x packer-builder-arm-image
docker build -t quay.io/solo-io/packer-builder-arm-image:${TAGGED_VERSION} -f Dockerfile.release .
docker push quay.io/solo-io/packer-builder-arm-image:${TAGGED_VERSION}
chmod +x packer-plugin-arm-image
docker build -t quay.io/solo-io/packer-plugin-arm-image:${TAGGED_VERSION} -f Dockerfile.release .
docker push quay.io/solo-io/packer-plugin-arm-image:${TAGGED_VERSION}
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ RUN apt-get update -qq \
WORKDIR /build

# if you wish to build from upstream, un comment this line, and comment lines below
# RUN git clone --depth 1 https://github.com/solo-io/packer-builder-arm-image /build
# RUN git clone --depth 1 https://github.com/solo-io/packer-plugin-arm-image /build

# if you wish to build from upstream, comment from here.
COPY go.mod go.sum ./
RUN go mod download
COPY . .
# if you wish to build from upstream, comment up to here.

RUN go build -o packer-builder-arm-image
RUN go build -o packer-plugin-arm-image

FROM ubuntu:focal

Expand All @@ -36,5 +36,5 @@ RUN wget https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER
WORKDIR /build
COPY entrypoint.sh /entrypoint.sh

COPY --from=builder /build/packer-builder-arm-image /bin/packer-builder-arm-image
COPY --from=builder /build/packer-plugin-arm-image /bin/packer-plugin-arm-image
ENTRYPOINT ["/entrypoint.sh"]
2 changes: 1 addition & 1 deletion Dockerfile.release
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ RUN wget https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER
WORKDIR /build
COPY entrypoint.sh /entrypoint.sh

COPY ./packer-builder-arm-image /bin/packer-builder-arm-image
COPY ./packer-plugin-arm-image /bin/packer-plugin-arm-image
ENTRYPOINT ["/entrypoint.sh"]
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ As this tool performs low-level OS manipulations - consider using a VM to run th
This project uses [go modules](https://github.com/golang/go/wiki/Modules) for dependencies introduced in Go 1.11.
To build:
```bash
git clone https://github.com/solo-io/packer-builder-arm-image
cd packer-builder-arm-image
git clone https://github.com/solo-io/packer-plugin-arm-image
cd packer-plugin-arm-image
go mod download
go build
```
Expand All @@ -82,8 +82,8 @@ custom provisions to build an image in an iterative fashion (thanks to @tommie-l
To use the Vagrant environment, run the following commands:

```
git clone https://github.com/solo-io/packer-builder-arm-image
cd packer-builder-arm-image
git clone https://github.com/solo-io/packer-plugin-arm-image
cd packer-plugin-arm-image
vagrant up
```

Expand Down Expand Up @@ -119,18 +119,18 @@ docker run \
```

### Option 2: Run the published Docker image
Alternatively, you can use the `docker.pkg.github.com/solo-io/packer-builder-arm-image/packer-builder-arm` that's built off latest master without needing to clone this repository.
Alternatively, you can use the `docker.pkg.github.com/solo-io/packer-plugin-arm-image/packer-builder-arm` that's built off latest master without needing to clone this repository.
```shell
docker run \
--rm \
--privileged \
-v ${PWD}:/build:ro \
-v ${PWD}/packer_cache:/build/packer_cache \
-v ${PWD}/output-arm-image:/build/output-arm-image \
docker.pkg.github.com/solo-io/packer-builder-arm-image/packer-builder-arm build samples/raspbian_golang.json
docker.pkg.github.com/solo-io/packer-plugin-arm-image/packer-builder-arm build samples/raspbian_golang.json
```

Note: On every release docker images are published to `quay.io/solo-io/packer-builder-arm-image` as well (for example: `quay.io/solo-io/packer-builder-arm-image:v0.1.5`).
Note: On every release docker images are published to `quay.io/solo-io/packer-plugin-arm-image` as well (for example: `quay.io/solo-io/packer-plugin-arm-image:v0.1.5`).

That's it, flash it and run!

Expand Down
2 changes: 1 addition & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/focal64"
config.vm.synced_folder "./", "/vagrant", disabled: false
config.vm.provision "build-env", type: "shell", :path => "provision-build-env.sh", privileged: false
config.vm.provision "packer-builder-arm-image", type: "shell", :path => "provision-packer-builder-arm-image.sh", privileged: false, env: {"GIT_CLONE_URL" => ENV["GIT_CLONE_URL"]}
config.vm.provision "packer-plugin-arm-image", type: "shell", :path => "provision-packer-plugin-arm-image.sh", privileged: false, env: {"GIT_CLONE_URL" => ENV["GIT_CLONE_URL"]}
config.vm.provision "build-image", type: "shell", :path => "provision-build-image.sh", privileged: false, env: {"PACKERFILE" => ENV["PACKERFILE"]}
end
2 changes: 1 addition & 1 deletion cmd/flasher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"
"github.com/hashicorp/packer-plugin-sdk/packer"
"github.com/mattn/go-tty"
"github.com/solo-io/packer-builder-arm-image/pkg/flasher"
"github.com/solo-io/packer-plugin-arm-image/pkg/flasher"
"io/ioutil"
"log"
"os"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/solo-io/packer-builder-arm-image
module github.com/solo-io/packer-plugin-arm-image

require (
github.com/hashicorp/go-getter/v2 v2.0.0
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package main

import (
"github.com/hashicorp/packer-plugin-sdk/plugin"
"github.com/solo-io/packer-builder-arm-image/pkg/builder"
"github.com/solo-io/packer-builder-arm-image/pkg/postprocessor"
"github.com/solo-io/packer-plugin-arm-image/pkg/builder"
"github.com/solo-io/packer-plugin-arm-image/pkg/postprocessor"
)

func main() {
Expand Down
4 changes: 2 additions & 2 deletions pkg/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (
"github.com/hashicorp/packer-plugin-sdk/packer"
"github.com/hashicorp/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer-plugin-sdk/template/interpolate"
"github.com/solo-io/packer-builder-arm-image/pkg/image"
"github.com/solo-io/packer-builder-arm-image/pkg/image/utils"
"github.com/solo-io/packer-plugin-arm-image/pkg/image"
"github.com/solo-io/packer-plugin-arm-image/pkg/image/utils"

getter "github.com/hashicorp/go-getter/v2"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/builder/builder.hcl2spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/builder/step_copy_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"path/filepath"
"time"

"github.com/solo-io/packer-builder-arm-image/pkg/image"
"github.com/solo-io/packer-builder-arm-image/pkg/utils"
"github.com/solo-io/packer-plugin-arm-image/pkg/image"
"github.com/solo-io/packer-plugin-arm-image/pkg/utils"

"github.com/hashicorp/packer-plugin-sdk/multistep"
"github.com/hashicorp/packer-plugin-sdk/packer"
Expand Down
6 changes: 3 additions & 3 deletions pkg/builder/step_register_bin_fmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ func (s *stepRegisterBinFmt) Run(_ context.Context, state multistep.StateBag) mu
ui := state.Get("ui").(packer.Ui)
qemu := state.Get(s.QemuPathKey).(string)

// registerstring := `:packer-builder-arm-image:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-arm-static:`
// registerstring := `:packer-plugin-arm-image:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-arm-static:`

registerstring_prefix := []byte{':', 'p', 'a', 'c', 'k', 'e', 'r', '-', 'b', 'u', 'i', 'l', 'd', 'e', 'r', '-', 'a', 'r', 'm', '-', 'i', 'm', 'a', 'g', 'e', ':', 'M', ':', ':', '\\', 'x', '7', 'f', 'E', 'L', 'F', '\\', 'x', '0', '1', '\\', 'x', '0', '1', '\\', 'x', '0', '1', '\\', 'x', '0', '0', '\\', 'x', '0', '0', '\\', 'x', '0', '0', '\\', 'x', '0', '0', '\\', 'x', '0', '0', '\\', 'x', '0', '0', '\\', 'x', '0', '0', '\\', 'x', '0', '0', '\\', 'x', '0', '0', '\\', 'x', '0', '2', '\\', 'x', '0', '0', '(', '\\', 'x', '0', '0', ':', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', '0', '0', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'e', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', ':'}
registerstring_prefix := []byte{':', 'p', 'a', 'c', 'k', 'e', 'r', '-', 'p', 'l', 'u', 'g', 'i', 'n', '-', 'a', 'r', 'm', '-', 'i', 'm', 'a', 'g', 'e', ':', 'M', ':', ':', '\\', 'x', '7', 'f', 'E', 'L', 'F', '\\', 'x', '0', '1', '\\', 'x', '0', '1', '\\', 'x', '0', '1', '\\', 'x', '0', '0', '\\', 'x', '0', '0', '\\', 'x', '0', '0', '\\', 'x', '0', '0', '\\', 'x', '0', '0', '\\', 'x', '0', '0', '\\', 'x', '0', '0', '\\', 'x', '0', '0', '\\', 'x', '0', '0', '\\', 'x', '0', '2', '\\', 'x', '0', '0', '(', '\\', 'x', '0', '0', ':', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', '0', '0', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'e', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', ':'}
registerstring := append(registerstring_prefix, ([]byte(qemu))...)
registerstring = append(registerstring, ':')
f, err := os.OpenFile("/proc/sys/fs/binfmt_misc/register", os.O_RDWR, 0)
Expand All @@ -39,7 +39,7 @@ func (s *stepRegisterBinFmt) Run(_ context.Context, state multistep.StateBag) mu
func (s *stepRegisterBinFmt) Cleanup(state multistep.StateBag) {
ui := state.Get("ui").(packer.Ui)

f, err := os.OpenFile("/proc/sys/fs/binfmt_misc/packer-builder-arm-image", os.O_RDWR, 0)
f, err := os.OpenFile("/proc/sys/fs/binfmt_misc/packer-plugin-arm-image", os.O_RDWR, 0)
if err != nil {
ui.Error(err.Error())
return
Expand Down
6 changes: 3 additions & 3 deletions pkg/flasher/flash.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import (
"github.com/hashicorp/packer-plugin-sdk/packer"
"github.com/hashicorp/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer-plugin-sdk/template/interpolate"
"github.com/solo-io/packer-builder-arm-image/pkg/image"
imageutils "github.com/solo-io/packer-builder-arm-image/pkg/image/utils"
"github.com/solo-io/packer-builder-arm-image/pkg/utils"
"github.com/solo-io/packer-plugin-arm-image/pkg/image"
imageutils "github.com/solo-io/packer-plugin-arm-image/pkg/image/utils"
"github.com/solo-io/packer-plugin-arm-image/pkg/utils"
)

const BlockSize = 512
Expand Down
2 changes: 1 addition & 1 deletion pkg/postprocessor/flash.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/hashicorp/packer-plugin-sdk/packer"
"github.com/hashicorp/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer-plugin-sdk/template/interpolate"
"github.com/solo-io/packer-builder-arm-image/pkg/flasher"
"github.com/solo-io/packer-plugin-arm-image/pkg/flasher"
)

type FlashConfig struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/utils/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"time"

"github.com/hashicorp/packer-plugin-sdk/packer"
"github.com/solo-io/packer-builder-arm-image/pkg/image"
"github.com/solo-io/packer-plugin-arm-image/pkg/image"
)

type copyResult struct {
Expand Down
2 changes: 1 addition & 1 deletion provision-build-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# @script provision.sh
# @description provisioning script that builds environment for
# https://github.com/solo-io/packer-builder-arm-image
# https://github.com/solo-io/packer-plugin-arm-image
#
# By default, sets up environment, builds the plugin, and image
##
Expand Down
10 changes: 5 additions & 5 deletions provision-build-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# @script provision.sh
# @description provisioning script that builds environment for
# https://github.com/solo-io/packer-builder-arm-image
# https://github.com/solo-io/packer-plugin-arm-image
#
# By default, sets up environment, builds the plugin, and image
##
Expand All @@ -13,9 +13,9 @@ export PACKERFILE=${PACKERFILE:-samples/raspbian_golang.json}

PLUGIN_DIR=${PLUGIN_DIR:-/root/.packer.d/plugins}
sudo mkdir -p $PLUGIN_DIR
sudo cp /vagrant/packer-builder-arm-image "$PLUGIN_DIR/"
sudo cp /vagrant/packer-plugin-arm-image "$PLUGIN_DIR/"
# Now build the image
if sudo test ! -f "$PLUGIN_DIR/packer-builder-arm-image"; then {
if sudo test ! -f "$PLUGIN_DIR/packer-plugin-arm-image"; then {
echo "Error: Plugin not found. Retry build."
exit
} else {
Expand All @@ -29,8 +29,8 @@ if sudo test ! -f "$PLUGIN_DIR/packer-builder-arm-image"; then {
if [[ -f /vagrant/${PACKERFILE} ]]; then {
sudo -E packer build /vagrant/${PACKERFILE} | tee ${PACKER_LOG}
} else {
if [[ -f $GOPATH/src/github.com/solo-io/packer-builder-arm-image/${PACKERFILE} ]]; then {
sudo -E packer build $GOPATH/src/github.com/solo-io/packer-builder-arm-image/${PACKERFILE} | tee ${PACKER_LOG}
if [[ -f $GOPATH/src/github.com/solo-io/packer-plugin-arm-image/${PACKERFILE} ]]; then {
sudo -E packer build $GOPATH/src/github.com/solo-io/packer-plugin-arm-image/${PACKERFILE} | tee ${PACKER_LOG}
} else {
echo "Error: packer build definition ${PACKERFILE} not found."
exit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# @script provision.sh
# @description provisioning script that builds environment for
# https://github.com/solo-io/packer-builder-arm-image
# https://github.com/solo-io/packer-plugin-arm-image
#
# By default, sets up environment, builds the plugin, and image
##
Expand All @@ -14,19 +14,19 @@ mkdir -p $GOPATH/src/github.com/solo-io/
cd $GOPATH/src/github.com/solo-io/

# clean up potential residual files from previous builds
rm -rf packer-builder-arm-image
rm -rf packer-plugin-arm-image
if [[ -z "${GIT_CLONE_URL}" ]]; then
cp -a /vagrant packer-builder-arm-image
cp -a /vagrant packer-plugin-arm-image
else
git clone ${GIT_CLONE_URL} packer-builder-arm-image
git clone ${GIT_CLONE_URL} packer-plugin-arm-image
fi
cd packer-builder-arm-image
cd packer-plugin-arm-image
go build

# Check if plugin built and copy into place
if [[ ! -f packer-builder-arm-image ]]; then
if [[ ! -f packer-plugin-arm-image ]]; then
echo "Error Plugin failed to build."
exit
else
cp packer-builder-arm-image /vagrant
cp packer-plugin-arm-image /vagrant
fi
4 changes: 2 additions & 2 deletions samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ docker run \
-v ${HOME}/.ssh/id_rsa.pub:/config/id_rsa.pub:ro \
-e PACKER_CACHE_DIR=/build/packer_cache \
-w /build/hostapd \
quay.io/solo-io/packer-builder-arm-image:v0.1.5 build -var wifi_ssid=wifi_extender -var wifi_psk=$PASSWORD -var local_ssh_public_key=/config/id_rsa.pub .
quay.io/solo-io/packer-plugin-arm-image:v0.1.5 build -var wifi_ssid=wifi_extender -var wifi_psk=$PASSWORD -var local_ssh_public_key=/config/id_rsa.pub .
```

The pi will now create a new wifi access point, bridging it to the ethernet network.
Expand All @@ -32,4 +32,4 @@ If you don't see the wifi network, log-in to the pi. and get hostapd logs:
journalctl -u hostapd
```

And if you see `rfkill: WLAN soft blocked`, issue this command `sudo rfkill unblock 0`.
And if you see `rfkill: WLAN soft blocked`, issue this command `sudo rfkill unblock 0`.

0 comments on commit 51445a9

Please sign in to comment.