Skip to content

Commit

Permalink
Update dependencies and add CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
rolftimmermans committed Nov 3, 2022
1 parent f9c0180 commit ca52ed2
Show file tree
Hide file tree
Showing 27,269 changed files with 251 additions and 7,491,925 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
76 changes: 76 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Release
on:
push:
tags:
- '*'

jobs:
deploy:
# The type of runner that the job will run on
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup
uses: actions/setup-go@v2
with:
go-version: "1.18"

- name: Get tag
id: tag
uses: dawidd6/action-get-tag@v1
with:
# Optionally strip `v` prefix
strip_v: true

- run: awk 'BEGIN { RS="# "; FS="\n"; OFS=""; ORS="" } NR == 2 { print "# Changes in ", $0 }' < CHANGELOG.md > RELEASE.md

- name: Release
uses: actions/create-release@v1
id: create_release
with:
draft: false
prerelease: false
release_name: ${{ github.ref }}
tag_name: ${{ github.ref }}
body_path: RELEASE.md
env:
GITHUB_TOKEN: ${{ github.token }}

- name: Build artifacts
run: |
go version
go install github.com/mitchellh/gox@latest
export version=${{ steps.tag.outputs.tag }}
make cross
- name: Upload Darwin ARM/M1 artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/darwin_arm64_voormedia-toolkit
asset_name: darwin_arm64_vmt
asset_content_type: application/octet-stream

- name: Upload Darwin x64 artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/darwin_amd64_voormedia-toolkit
asset_name: darwin_amd64_vmt
asset_content_type: application/octet-stream

- name: Upload Linux x64 artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/linux_amd64_voormedia-toolkit
asset_name: linux_amd64_vmt
asset_content_type: application/octet-stream
25 changes: 25 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Test & lint
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup
uses: actions/setup-go@v2
with:
go-version: "1.18"

- name: Install dependencies
run: |
go version
go install golang.org/x/lint/golint@latest
- name: Run vet & lint
run: |
go vet .
golint .
- name: Run tests
run: go test -v ./...
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# v1.1.0

* Fix decryption parameters for database backups.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
all:
go build -i -v -o vmt
go build -v -o vmt

test:
go test -v ./pkg/...

cross:
gox -ldflags "-s -w -X github.com/voormedia/voormedia-toolkit/cmd.version=${version}" -arch arm64 -os darwin -output "dist/{{.OS}}_{{.Arch}}_{{.Dir}}"
gox -ldflags "-s -w -X github.com/voormedia/voormedia-toolkit/cmd.version=${version}" -arch amd64 -os darwin -output "dist/{{.OS}}_{{.Arch}}_{{.Dir}}"
gox -ldflags "-s -w -X github.com/voormedia/voormedia-toolkit/cmd.version=${version}" -arch amd64 -os linux -output "dist/{{.OS}}_{{.Arch}}_{{.Dir}}"

.PHONY: all test
5 changes: 3 additions & 2 deletions cmd/backup.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package cmd

import (
"github.com/emielvanlankveld/voormedia-toolkit/pkg/backup"
"github.com/spf13/cobra"
"os"

"github.com/spf13/cobra"
"github.com/voormedia/voormedia-toolkit/pkg/backup"
)

var cmdBackup = &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/proxy.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package cmd

import (
"github.com/emielvanlankveld/voormedia-toolkit/pkg/proxy"
"github.com/spf13/cobra"
"github.com/voormedia/voormedia-toolkit/pkg/proxy"
)

var cmdProxy = &cobra.Command{
Expand Down
9 changes: 5 additions & 4 deletions cmd/restore.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package cmd

import (
"github.com/emielvanlankveld/voormedia-toolkit/pkg/restore"
"github.com/spf13/cobra"
"os"

"github.com/spf13/cobra"
"github.com/voormedia/voormedia-toolkit/pkg/restore"
)

var cmdRestore = &cobra.Command{
Use: "restore",
Short: "Download and restore a Backblaze backup of a Google Cloud SQL database.",
Use: "restore",
Short: "Download and restore a Backblaze backup of a Google Cloud SQL database.",
DisableFlagsInUseLine: true,

Run: func(cmd *cobra.Command, args []string) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package cmd

import (
"github.com/emielvanlankveld/voormedia-toolkit/pkg/util"
"github.com/spf13/cobra"
"github.com/voormedia/voormedia-toolkit/pkg/util"
)

var version = "master"
Expand Down
6 changes: 3 additions & 3 deletions cmd/shell.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package cmd

import (
"github.com/emielvanlankveld/voormedia-toolkit/pkg/shell"
"github.com/spf13/cobra"
"github.com/voormedia/voormedia-toolkit/pkg/shell"
)

var cmdShell = &cobra.Command{
Use: "shell",
Short: "Run a shell of a Google Cloud SQL database.",
Use: "shell",
Short: "Run a shell of a Google Cloud SQL database.",
DisableFlagsInUseLine: true,

Run: func(_ *cobra.Command, args []string) {
Expand Down
24 changes: 24 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package cmd

import (
"text/template"

"github.com/spf13/cobra"
)

var cmdVersion = &cobra.Command{
Use: "version",
Short: "Show version",
DisableFlagsInUseLine: true,

Long: "Show version number and exit",

Run: func(cmd *cobra.Command, args []string) {
tmpl := template.Must(template.New("top").Parse(cmd.VersionTemplate()))
tmpl.Execute(cmd.OutOrStdout(), cmdRoot)
},
}

func init() {
cmdRoot.AddCommand(cmdVersion)
}
28 changes: 28 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module github.com/voormedia/voormedia-toolkit

go 1.18

require (
github.com/AlecAivazis/survey v1.8.1
github.com/fatih/color v1.13.0
github.com/kurin/blazer v0.5.3
github.com/pkg/errors v0.9.1
gopkg.in/yaml.v2 v2.4.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/mattn/go-colorable v0.1.9 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/cobra v1.6.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.8.1 // indirect
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
gopkg.in/AlecAivazis/survey.v1 v1.8.8 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
66 changes: 66 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
github.com/AlecAivazis/survey v1.8.1 h1:ChXdaEIUZpe2KOcXkHoxtKhgy2RNF8lsbSLNBbDnF2k=
github.com/AlecAivazis/survey v1.8.1/go.mod h1:MVECab6WqEH1aXhj8nKIwF7HEAJAj2bhhGiSjNy3wII=
github.com/AlecAivazis/survey/v2 v2.0.5/go.mod h1:WYBhg6f0y/fNYUuesWQc0PKbJcEliGcYHB9sNT3Bg74=
github.com/Netflix/go-expect v0.0.0-20180615182759-c93bf25de8e8/go.mod h1:oX5x61PbNXchhh0oikYAH+4Pcfw5LKv21+Jnpr6r6Pc=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/hinshun/vt10x v0.0.0-20180616224451-1954e6464174/go.mod h1:DqJ97dSdRW1W22yXSB90986pcOyQ7r45iio1KN2ez1A=
github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc=
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/kr/pty v1.1.4/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kurin/blazer v0.5.3 h1:SAgYv0TKU0kN/ETfO5ExjNAPyMt2FocO2s/UlCHfjAk=
github.com/kurin/blazer v0.5.3/go.mod h1:4FCXMUWo9DllR2Do4TtBd377ezyAJ51vB5uTBjt0pGU=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-colorable v0.1.9 h1:sqDoxXbdeALODt0DAeJCVp38ps9ZogZEAXjus69YV3U=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4=
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190530182044-ad28b68e88f1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
gopkg.in/AlecAivazis/survey.v1 v1.8.8 h1:5UtTowJZTz1j7NxVzDGKTz6Lm9IWm8DDF6b7a2wq9VY=
gopkg.in/AlecAivazis/survey.v1 v1.8.8/go.mod h1:CaHjv79TCgAvXMSFJSVgonHXYWxnhzI3eoHtnX5UgUo=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"github.com/emielvanlankveld/voormedia-toolkit/cmd"
"github.com/voormedia/voormedia-toolkit/cmd"
)

func main() {
Expand Down
9 changes: 5 additions & 4 deletions pkg/backup/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package backup

import (
"fmt"
"github.com/AlecAivazis/survey"
"github.com/emielvanlankveld/voormedia-toolkit/pkg/util"
"github.com/pkg/errors"
"os"
"os/exec"
"strings"
"time"

"github.com/AlecAivazis/survey"
"github.com/pkg/errors"
"github.com/voormedia/voormedia-toolkit/pkg/util"
)

// Run backup creation and stores it in Backblaze B2.
Expand Down Expand Up @@ -95,7 +96,7 @@ func Run(log *util.Logger, port string, host string, b2id string, b2key string,
}
}

cmd := exec.Command("openssl", "aes-256-cbc", "-in", "/tmp/"+file, "-out", "/tmp/"+file+".encrypted", "-pass", "pass:"+b2encrypt)
cmd := exec.Command("openssl", "aes-256-cbc", "-md", "md5", "-in", "/tmp/"+file, "-out", "/tmp/"+file+".encrypted", "-pass", "pass:"+b2encrypt)
cmd.Run()

err = util.B2Upload(b2Context, b2Bucket, databaseSelection.Database, file+".encrypted")
Expand Down
2 changes: 1 addition & 1 deletion pkg/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"runtime"

"github.com/AlecAivazis/survey"
"github.com/emielvanlankveld/voormedia-toolkit/pkg/util"
homedir "github.com/mitchellh/go-homedir"
"github.com/pkg/errors"
"github.com/voormedia/voormedia-toolkit/pkg/util"
)

// Run Google Cloud SQL proxy container
Expand Down
2 changes: 1 addition & 1 deletion pkg/restore/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"strings"

"github.com/AlecAivazis/survey"
"github.com/emielvanlankveld/voormedia-toolkit/pkg/util"
"github.com/kurin/blazer/b2"
"github.com/pkg/errors"
"github.com/voormedia/voormedia-toolkit/pkg/util"
)

// Run backup download (from Backblaze) and restore of a Google Cloud SQL database
Expand Down
2 changes: 1 addition & 1 deletion pkg/shell/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os/exec"

"github.com/AlecAivazis/survey"
"github.com/emielvanlankveld/voormedia-toolkit/pkg/util"
"github.com/voormedia/voormedia-toolkit/pkg/util"
)

// Run a shell of a Google Cloud SQL database of choice.
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/b2.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func B2Object(ctx context.Context, bucket *b2.Bucket, fileName string, encryptio
}

f.Close()
cmd := exec.Command("openssl", "aes-256-cbc", "-d", "-in", target, "-out", strings.Replace(target, ".encrypted", "", 1), "-pass", "pass:"+encryptionKey)
cmd := exec.Command("openssl", "aes-256-cbc", "-md", "md5", "-d", "-in", target, "-out", strings.Replace(target, ".encrypted", "", 1), "-pass", "pass:"+encryptionKey)
cmd.Run()

return target, nil
Expand Down
Loading

0 comments on commit ca52ed2

Please sign in to comment.