Skip to content

Commit

Permalink
small fixes (#65)
Browse files Browse the repository at this point in the history
* small fixes

* allow release

* mini typo

* publish releases to quay

* push docker
  • Loading branch information
yuval-k authored May 17, 2020
1 parent 9cffe7f commit 0f6baf3
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 28 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: pull_request

on:
push:
branches:
- 'master'
pull_request: {}
release:
types: [published]
env:
TAGGED_VERSION: ${{github.event.release.tag_name || '' }}

jobs:
build:
name: build-works
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Set up Go 1.14
uses: actions/setup-go@v2
with:
go-version: 1.14
- uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Generate code
run: |
go install github.com/hashicorp/packer/cmd/mapstructure-to-hcl2
go generate ./...
if [[ $(git status --porcelain | wc -l) -ne 0 ]]; then
echo "Generating code produced a non-empty diff"
echo "Try running 'go install github.com/hashicorp/packer/cmd/mapstructure-to-hcl2 && go generate ./...' then re-pushing."
git status --porcelain
git diff | cat
exit 1;
fi
- name: Build
run: |
go build -o packer-builder-arm-image .
go build -o flasher github.com/solo-io/packer-builder-arm-image/cmd/flasher
docker build -t packer-builder-arm-image .
- name: Release packer-builder-arm-image
if: github.event.release.tag_name
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_content_type: application/octet-stream
- name: Release flasher
if: github.event.release.tag_name
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./flasher
asset_name: flasher
asset_content_type: application/octet-stream
- name: Push docker
if: github.event.release.tag_name
env:
QUAY_IO_PASSWORD: ${{ secrets.QUAY_IO_PASSWORD }}
run: |
docker login quay.io --username "solo-io+solobot" --password $QUAY_IO_PASSWORD
docker tag packer-builder-arm-image quay.io/solo-io/packer-builder-arm-image:${TAGGED_VERSION}
docker push quay.io/solo-io/packer-builder-arm-image:${TAGGED_VERSION}
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ docker run \
-v ${PWD}:/build:ro \
-v ${PWD}/packer_cache:/build/packer_cache \
-v ${PWD}/output-arm-image:/build/output-arm-image \
packer-builder-arm build samples/raspbian_golang.json
-e PACKER_CACHE_DIR=/build/packer_cache \
-w /build/samples/hostapd/ \
packer-builder-arm build raspbian_hostapd.json
```

Alternativly, you can use the `docker.pkg.github.com/solo-io/packer-builder-arm-image/packer-builder-arm` that's built off latest master:
Expand Down Expand Up @@ -228,9 +230,9 @@ this example requires you to run the plugin without a VM, as it copies your loca
{
"type": "shell",
"inline": [
"sed '/PasswordAuthentication/d' -i /etc/ssh/ssh_config",
"echo >> /etc/ssh/ssh_config",
"echo 'PasswordAuthentication no' >> /etc/ssh/ssh_config"
"sed '/PasswordAuthentication/d' -i /etc/ssh/sshd_config",
"echo >> /etc/ssh/sshd_config",
"echo 'PasswordAuthentication no' >> /etc/ssh/sshd_config"
]
}
]
Expand Down
22 changes: 0 additions & 22 deletions cloudbuild.yaml

This file was deleted.

1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ github.com/antchfx/xquery v0.0.0-20170730121040-eb8c3c172607/go.mod h1:LzD22aAzD
github.com/antihax/optional v0.0.0-20180407024304-ca021399b1a6 h1:uZuxRZCz65cG1o6K/xUqImNcYKtmk9ylqaH0itMSvzA=
github.com/antihax/optional v0.0.0-20180407024304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3 h1:ZSTrOEhiM5J5RFxEaFvMZVEAM1KvT1YzbEOwB2EAGjA=
github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM=
github.com/apparentlymart/go-textseg v1.0.0 h1:rRmlIsPEEhUTIKQb7T++Nz/A5Q6C9IuX2wFoYVvnCs0=
github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk=
Expand Down
2 changes: 2 additions & 0 deletions pkg/flasher/flash.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ func (f *flasher) Flash(ctx context.Context) error {
}
}

f.ui.Say("Unmounting device " + dev.Device)
err = f.unmount(dev)
if err != nil {
return err
}
f.ui.Say("Flashing device " + dev.Device)
res, err := f.flash(ctx, imageToFlash, dev)
if err != nil {
return err
Expand Down
6 changes: 4 additions & 2 deletions pkg/utils/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,18 @@ func CopyWithProgress(ctx context.Context, ui packer.Ui, dst io.Writer, src io.R
} else {
l = NewProgressWriter()
}
// this will cancel the Copy if still in progress when we leave the function
defer l.Stop()
rdr := io.TeeReader(src, l)

copyCompleteCh := make(chan copyResult, 1)
go func() {
defer close(copyCompleteCh)
n, err := io.Copy(dst, rdr)
copyCompleteCh <- copyResult{n: n, err: err}
}()

progressTicker := time.NewTicker(15 * time.Second)
progressTicker := time.NewTicker(5 * time.Second)
defer progressTicker.Stop()

for {
Expand All @@ -48,7 +51,6 @@ func CopyWithProgress(ctx context.Context, ui packer.Ui, dst io.Writer, src io.R
ui.Message(fmt.Sprintf("Progress: %3.2f%%", progress.PercentDone))
}
case <-ctx.Done():
l.Stop()
return int64(l.TotalData()), errors.New("interrupted")
}
}
Expand Down

0 comments on commit 0f6baf3

Please sign in to comment.