Skip to content

Commit

Permalink
new syntax for internal configs. will require re-generating existing …
Browse files Browse the repository at this point in the history
…configs. (#30)
  • Loading branch information
AnalogJ authored Dec 9, 2020
1 parent bbb8f08 commit 58e7204
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 72 deletions.
59 changes: 0 additions & 59 deletions .circleci/config.yml

This file was deleted.

24 changes: 24 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: CI
# This workflow is triggered on pushes & pull requests
on: [push, pull_request]

jobs:
build:
name: Build
runs-on: ubuntu-latest
container: packagrio/packagr:latest-golang
env:
PROJECT_PATH: /go/src/github.com/analogj/drawbridge
CGO_ENABLED: 1
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Test
run: |
mkdir -p $(dirname "$PROJECT_PATH")
cp -a $GITHUB_WORKSPACE $PROJECT_PATH
cd $PROJECT_PATH
go mod vendor
go test -race -coverprofile=coverage.txt -covermode=atomic -v -tags "static" $(go list ./... | grep -v /vendor/)
105 changes: 105 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Release
# This workflow is triggered manually
on:
workflow_dispatch:
inputs:
version_bump_type:
description: 'Version Bump Type (major, minor, patch)'
required: true
default: 'patch'
version_metadata_path:
description: 'Path to file containing Version string'
required: true
default: 'pkg/version/version.go'

jobs:
build:
name: Build
runs-on: ubuntu-latest
container: packagrio/packagr:latest-golang
env:
PROJECT_PATH: /go/src/github.com/analogj/drawbridge
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Bump version
id: bump_version
uses: packagrio/action-bumpr-go@master
with:
version_bump_type: ${{ github.event.inputs.version_bump_type }}
version_metadata_path: ${{ github.event.inputs.version_metadata_path }}
github_token: ${{ secrets.DRAWBRIDGE_GITHUB_TOKEN }}
- name: Test
run: |
mkdir -p $(dirname "$PROJECT_PATH")
cp -a $GITHUB_WORKSPACE $PROJECT_PATH
cd $PROJECT_PATH
go mod vendor
go test -v -tags "static" $(go list ./... | grep -v /vendor/)
- name: Build Binaries
run: |
cd $PROJECT_PATH
GOOS=darwin GOARCH=amd64 go build -ldflags "-X main.goos=darwin -X main.goarch=amd64" -o drawbridge-darwin-amd64 -tags "static" $(go list ./cmd/...)
chmod +x drawbridge-darwin-amd64
GOOS=linux GOARCH=amd64 go build -ldflags "-X main.goos=linux -X main.goarch=amd64" -o drawbridge-linux-amd64 -tags "static" $(go list ./cmd/...)
chmod +x drawbridge-linux-amd64
GOOS=windows GOARCH=amd64 go build -ldflags "-X main.goos=windows -X main.goarch=amd64" -o drawbridge-windows-amd64.exe -tags "static" $(go list ./cmd/...)
- name: Commit
uses: EndBug/add-and-commit@v4 # You can change this to use a specific version
with:

author_name: Jason Kulatunga
author_email: [email protected]
cwd: ${{ env.PROJECT_PATH }}
force: false
signoff: true
message: '(${{steps.bump_version.outputs.release_version}}) Automated packaging of release by Packagr'
tag: ${{steps.bump_version.outputs.release_version}}
env:
GITHUB_TOKEN: ${{ secrets.DRAWBRIDGE_GITHUB_TOKEN }} # Leave this line unchanged

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.DRAWBRIDGE_GITHUB_TOKEN }}
with:
tag_name: ${{ steps.bump_version.outputs.release_version }}
release_name: Release ${{ steps.bump_version.outputs.release_version }}
draft: false
prerelease: false

- name: Release Asset - darwin-amd64
id: upload-release-asset1
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.DRAWBRIDGE_GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ${{ env.PROJECT_PATH }}/drawbridge-darwin-amd64
asset_name: drawbridge-darwin-amd64
asset_content_type: application/octet-stream
- name: Release Asset - linux-amd64
id: upload-release-asset2
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.DRAWBRIDGE_GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ${{ env.PROJECT_PATH }}/drawbridge-linux-amd64
asset_name: drawbridge-linux-amd64
asset_content_type: application/octet-stream
- name: Release Asset - windows-amd64
id: upload-release-asset3
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.DRAWBRIDGE_GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ${{ env.PROJECT_PATH }}/drawbridge-windows-amd64.exe
asset_name: drawbridge-windows-amd64.exe
asset_content_type: application/octet-stream
14 changes: 14 additions & 0 deletions .github/workflows/sponsors.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Label sponsors
on:
pull_request:
types: [opened]
issues:
types: [opened]
jobs:
build:
name: is-sponsor-label
runs-on: ubuntu-latest
steps:
- uses: JasonEtco/is-sponsor-label-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions example.drawbridge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ config_templates:
UserKnownHostsFile=/dev/null
StrictHostKeyChecking=no
Host bastion+*
ProxyCommand ssh -F {{.template.filepath}} -W $(echo %h |cut -d+ -f2):%p bastion
Host *.in
ProxyCommand ssh -F {{.template.filepath}} -W $(echo %h |cut -d. -f1):%p bastion
User {{if eq .username "aws"}}cloud-user{{else}}{{.username}}{{end}}
IdentityFile {{.template.pem_filepath}}
LogLevel INFO
Expand Down
2 changes: 1 addition & 1 deletion pkg/actions/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (e *ConnectAction) Start(answerData map[string]interface{}, destHostname st

configHost := "bastion"
if len(destHostname) > 0 {
configHost = fmt.Sprintf("%v+%v", configHost, destHostname)
configHost = fmt.Sprintf("%v.in", destHostname)
}
args := []string{"ssh", configHost, "-F", tmplConfigFilepath}

Expand Down
22 changes: 12 additions & 10 deletions pkg/actions/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,20 @@ func (e *DownloadAction) Start(answerData map[string]interface{}, destHostname s
return nil
}

tmplPemFilepath, err := utils.PopulatePathTemplate(filepath.Join(e.Config.GetString("options.pem_dir"), tmplData.PemFilePath), answerData)
if err != nil {
return nil
}
if tmplData.PemFilePath != "" {
tmplPemFilepath, err := utils.PopulatePathTemplate(filepath.Join(e.Config.GetString("options.pem_dir"), tmplData.PemFilePath), answerData)
if err != nil {
return nil
}

//TODO: Print the lines we're running.
//TODO: Print the lines we're running.

//TODO: Check that the bastion host is accessible.
//TODO: Check that the bastion host is accessible.

err = e.SshAgentAddPemKey(tmplPemFilepath)
if err != nil {
return err
err = e.SshAgentAddPemKey(tmplPemFilepath)
if err != nil {
return err
}
}

fmt.Println("Begin downloading file through bastion")
Expand All @@ -50,7 +52,7 @@ func (e *DownloadAction) Start(answerData map[string]interface{}, destHostname s
return errors.DependencyMissingError("scp is missing")
}

args := []string{"scp", "-F", tmplConfigFilepath, fmt.Sprintf("bastion+%v:%v", destHostname, remoteFilePath), localFilePath}
args := []string{"scp", "-F", tmplConfigFilepath, fmt.Sprintf("%v.in:%v", destHostname, remoteFilePath), localFilePath}

return syscall.Exec(scpBin, args, os.Environ())
}

0 comments on commit 58e7204

Please sign in to comment.