-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin' into add_diff_validate
- Loading branch information
Showing
31 changed files
with
1,470 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,36 +15,50 @@ on: | |
- release-* | ||
env: | ||
PRE_RELEASE: ${{ github.ref == 'refs/heads/main' && 'development' || '' }} | ||
GO_VERSION: "1.19" | ||
GO_VERSION: "1.20" | ||
GO_RELEASER_VERSION: "v1.20.0" | ||
GO_LANGCI_LINT_VERSION: "v1.53.3" | ||
GO_TESTSUM_VERSION: "1.10.1" | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup Go | ||
- | ||
name: Setup Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
- name: Setup caching | ||
uses: actions/cache@v3 | ||
- | ||
name: Build | ||
uses: goreleaser/goreleaser-action@v4 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- name: Install Tools | ||
run: | | ||
go run mage.go deps | ||
- name: Lint | ||
run: | | ||
go run mage.go lint | ||
- name: Test | ||
distribution: goreleaser | ||
version: ${{ env.GO_RELEASER_VERSION }} | ||
args: build --clean --snapshot --single-target | ||
- | ||
name: Lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
version: ${{ env.GO_LANGCI_LINT_VERSION }} | ||
- | ||
name: Test Setup | ||
uses: autero1/[email protected] | ||
with: | ||
gotestsum_version: ${{ env.GO_TESTSUM_VERSION }} | ||
- | ||
name: Test | ||
run: | | ||
go run mage.go test | ||
- name: Upload code coverage | ||
gotestsum --format short-verbose -- -count=1 -v -timeout=240s -coverprofile=cover.out -coverpkg=./... ./... | ||
- | ||
name: Upload code coverage | ||
uses: shogo82148/actions-goveralls@v1 | ||
continue-on-error: true | ||
with: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,10 @@ | |
|
||
.dev/ | ||
.ext/ | ||
.vscode/launch.json | ||
|
||
bin/ | ||
dist/ | ||
|
||
cover.out | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
project_name: azm | ||
|
||
env: | ||
- REGISTRY=ghcr.io | ||
- ORG=aserto-dev | ||
- REPO=azm | ||
|
||
before: | ||
# https://goreleaser.com/customization/hooks/ | ||
hooks: | ||
|
||
builds: | ||
# https://goreleaser.com/customization/build/ | ||
- id: azmcmd | ||
main: ./cmd/azmcmd | ||
binary: azmcmd | ||
goos: | ||
- darwin | ||
- linux | ||
- windows | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
env: | ||
- CGO_ENABLED=0 | ||
ignore: | ||
- goos: windows | ||
goarch: arm64 | ||
ldflags: | ||
- -s | ||
- -w | ||
- -X github.com/{{ .Env.ORG }}/{{ .Env.REPO }}/pkg/azmcmd/cmds/ver={{.Version}} | ||
- -X github.com/{{ .Env.ORG }}/{{ .Env.REPO }}/pkg/azmcmd/cmds/commit={{.ShortCommit}} | ||
- -X github.com/{{ .Env.ORG }}/{{ .Env.REPO }}/pkg/azmcmd/cmds/date={{.Date}} | ||
mod_timestamp: "{{ .CommitTimestamp }}" | ||
|
||
archives: | ||
# https://goreleaser.com/customization/archive/ | ||
- format: zip | ||
builds: | ||
- azmcmd | ||
files: | ||
- LICENSE | ||
- README.md | ||
name_template: >- | ||
azmcmd_{{ .Os }}_{{- if eq .Arch "amd64" }}x86_64{{- else }}{{ .Arch }}{{ end }} | ||
checksum: | ||
# https://goreleaser.com/customization/checksum/ | ||
name_template: "checksums.txt" | ||
|
||
snapshot: | ||
# https://goreleaser.com/customization/snapshots/ | ||
name_template: "{{ .Tag }}" | ||
|
||
source: | ||
# https://goreleaser.com/customization/source/ | ||
enabled: false | ||
|
||
changelog: | ||
# https://goreleaser.com/customization/changelog/ | ||
sort: asc | ||
filters: | ||
exclude: | ||
- "^docs:" | ||
- "^test:" | ||
|
||
release: | ||
# https://goreleaser.com/customization/release/ | ||
github: | ||
owner: "{{ .Env.ORG }}" | ||
name: "{{ .Env.REPO }}" | ||
|
||
draft: false | ||
prerelease: false | ||
name_template: "{{.ProjectName}} {{.Tag}}" | ||
|
||
blobs: | ||
# https://goreleaser.com/customization/blob/ | ||
- | ||
provider: gs | ||
bucket: azm-cli | ||
folder: "azmcmd/{{ .Version }}" | ||
extra_files: | ||
- glob: VERSION.txt | ||
- | ||
provider: gs | ||
bucket: azm0-cli | ||
folder: "azmcmd/latest" | ||
extra_files: | ||
- glob: VERSION.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"cSpell.words": [ | ||
"aserto", | ||
"etag", | ||
"golangci", | ||
"goreleaser", | ||
"gotestsum", | ||
"jsondiff", | ||
"protobuf", | ||
"samber", | ||
"stretchr", | ||
"testsum", | ||
"timestamppb" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# azmcmd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package cmds | ||
|
||
type CLI struct { | ||
Common | ||
Migrate MigrateCmd `cmd:"" help:"migrate directory v2 metadata to an annotated v3 manifest"` | ||
Version VersionCmd `cmd:"" help:"version information"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package cmds | ||
|
||
type Common struct { | ||
Host string `name:"host" env:"ASERTO_DIR_SVC" default:"localhost:9292"` | ||
APIKey string `name:"api-key" env:"ASERTO_DIR_KEY" default:""` | ||
TenantID string `name:"tenant-id" env:"ASERTO_TENANT_ID" default:""` | ||
Insecure bool `name:"insecure" env:"ASERTO_SKIP_TLS_VERIFICATION" default:"false"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package cmds | ||
|
||
import ( | ||
"context" | ||
"os" | ||
|
||
"github.com/aserto-dev/azm/migrate" | ||
client "github.com/aserto-dev/go-aserto/client" | ||
) | ||
|
||
type MigrateCmd struct { | ||
} | ||
|
||
func (a *MigrateCmd) Run(c *Common) error { | ||
ctx := context.Background() | ||
|
||
opts := []client.ConnectionOption{ | ||
client.WithAddr(c.Host), | ||
client.WithAPIKeyAuth(c.APIKey), | ||
client.WithTenantID(c.TenantID), | ||
client.WithInsecure(c.Insecure), | ||
} | ||
|
||
clnt, err := client.NewConnection(ctx, opts...) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
m := migrate.NewMigrator() | ||
|
||
if err := m.Load(clnt.Conn); err != nil { | ||
return err | ||
} | ||
|
||
if err := m.Process(); err != nil { | ||
return err | ||
} | ||
|
||
if err := m.Write(os.Stdout); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package cmds | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"runtime" | ||
"time" | ||
) | ||
|
||
var ( | ||
ver string //nolint:gochecknoglobals // set by linker | ||
date string //nolint:gochecknoglobals // set by linker | ||
commit string //nolint:gochecknoglobals // set by linker | ||
) | ||
|
||
// Info - version info. | ||
type Info struct { | ||
Version string | ||
Date string | ||
Commit string | ||
} | ||
|
||
type VersionCmd struct { | ||
} | ||
|
||
func (a *VersionCmd) Run(c *Common) error { | ||
fmt.Fprint(os.Stdout, GetInfo().String()) | ||
return nil | ||
} | ||
|
||
// GetInfo - get version stamp information. | ||
func GetInfo() Info { | ||
if ver == "" { | ||
ver = "0.0.0" | ||
} | ||
|
||
if date == "" { | ||
date = time.Now().Format(time.RFC3339) | ||
} | ||
|
||
if commit == "" { | ||
commit = "undefined" | ||
} | ||
|
||
return Info{ | ||
Version: ver, | ||
Date: date, | ||
Commit: commit, | ||
} | ||
} | ||
|
||
// String() -- return version info string. | ||
func (vi Info) String() string { | ||
return fmt.Sprintf("%s g%s %s-%s [%s]", | ||
vi.Version, | ||
vi.Commit, | ||
runtime.GOOS, | ||
runtime.GOARCH, | ||
vi.Date, | ||
) | ||
} |
Oops, something went wrong.