Skip to content

Commit

Permalink
Merge pull request #7 from ConductorOne/ggreer/upgrade
Browse files Browse the repository at this point in the history
Upgrade everything
  • Loading branch information
ggreer authored Jan 29, 2025
2 parents d3d85b6 + fbef943 commit 4765b20
Show file tree
Hide file tree
Showing 2,375 changed files with 1,783,304 additions and 434,681 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/capabilities.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,22 @@ jobs:
token: ${{ secrets.RELENG_GITHUB_TOKEN }}

- name: Setup Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'

- name: Build
run: go build -o connector ./cmd/baton-dockerhub

- name: Run and save output
env:
BATON_USERNAME: ${{ secrets.BATON_DOCKERHUB_USERNAME }}
BATON_PASSWORD: ${{ secrets.BATON_DOCKERHUB_PASSWORD }}
run: ./connector capabilities > baton_capabilities.json

- name: Commit changes
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
message: 'Updating baton capabilities.'
add: 'baton_capabilities.json'
add: 'baton_capabilities.json'
41 changes: 36 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: 1.22.x
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Run linters
uses: golangci/golangci-lint-action@v3
with:
Expand All @@ -24,15 +24,46 @@ jobs:
steps:
- name: Install Go
if: success()
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: go tests
run: go test -v -covermode=count -json ./... > test.json
- name: annotate go tests
if: always()
uses: guyarb/[email protected]
with:
test-results: test.json
test-results: test.json

test:
runs-on: ubuntu-latest
env:
BATON_USERNAME: ${{ secrets.BATON_DOCKERHUB_USERNAME }}
BATON_PASSWORD: ${{ secrets.BATON_DOCKERHUB_PASSWORD }}
BATON_LOG_LEVEL: debug
CONNECTOR_GRANT: 'team:698390:member:user:062cd47aa72c441e8c660c7273c780e3'
CONNECTOR_ENTITLEMENT: 'team:698390:member'
CONNECTOR_PRINCIPAL: '062cd47aa72c441e8c660c7273c780e3'
CONNECTOR_PRINCIPAL_TYPE: 'user'
steps:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.22.x
- name: Checkout code
uses: actions/checkout@v4
- name: Build baton-dockerhub
run: go build ./cmd/baton-dockerhub
- name: Run baton-dockerhub
run: ./baton-dockerhub

- name: Install baton
run: ./scripts/get-baton.sh && mv baton /usr/local/bin

- name: Sync and check resource/grant
env:
BATON_CONNECTOR: ./baton-dockerhub
BATON: baton
run: ./scripts/grant-revoke.sh
8 changes: 4 additions & 4 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: 1.22.x
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Run linters
uses: golangci/golangci-lint-action@v3
with:
Expand All @@ -27,11 +27,11 @@ jobs:
steps:
- name: Install Go
if: success()
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: go tests
run: go test -v -covermode=count -json ./... > test.json
- name: annotate go tests
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: 1.22.x
- name: Set up Gon
Expand All @@ -41,7 +41,7 @@ jobs:
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: 1.22.x
- name: Docker Login
Expand Down
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ linters:
- bodyclose # checks whether HTTP response body is closed successfully
- durationcheck # check for two durations multiplied together
- errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13.
- execinquery # execinquery is a linter about query string checker in Query function which reads your Go src files and warning it finds
- exhaustive # check exhaustiveness of enum switch statements
- exportloopref # checks for pointers to enclosing loop variables
- forbidigo # Forbids identifiers
Expand Down
2 changes: 1 addition & 1 deletion .gon-arm64.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"source": ["./dist/macos-arm64_darwin_arm64/baton-dockerhub"],
"source": ["./dist/macos-arm64_darwin_arm64_v8.0/baton-dockerhub"],
"bundle_id": "com.conductorone.baton-dockerhub",
"apple_id": {
"username" : "[email protected]"
Expand Down
2 changes: 1 addition & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ builds:
hooks:
post:
- gon .gon-arm64.json
- mv dist/baton-dockerhub-darwin-arm64.signed.zip dist/macos-arm64_darwin_arm64/baton-dockerhub
- mv dist/baton-dockerhub-darwin-arm64.signed.zip dist/macos-arm64_darwin_arm64_v8.0/baton-dockerhub
archives:
- id: linux-archive
builds:
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Check out [Baton](https://github.com/conductorone/baton) to learn more about the

# Prerequisites

Among the prerequisities for running `baton-dockerhub` are prerequisities for running [hub-tool](https://github.com/docker/hub-tool#prerequisites) which is installed Docker on your machine and DockerHub account. You can use account username and password to authenticate in connector.
Among the prerequisities for running `baton-dockerhub` are prerequisities for running [hub-tool](https://github.com/docker/hub-tool#prerequisites) which is installed Docker on your machine and DockerHub account. You can use account username and access token to authenticate in connector.

# Getting Started

Expand All @@ -19,14 +19,14 @@ Among the prerequisities for running `baton-dockerhub` are prerequisities for ru
```
brew install conductorone/baton/baton conductorone/baton/baton-dockerhub
BATON_USERNAME=username BATON_PASSWORD=password baton-dockerhub
BATON_USERNAME=username BATON_ACCESS_TOKEN=access-token baton-dockerhub
baton resources
```

## docker

```
docker run --rm -v $(pwd):/out -e BATON_USERNAME=username BATON_PASSWORD=password ghcr.io/conductorone/baton-dockerhub:latest -f "/out/sync.c1z"
docker run --rm -v $(pwd):/out -e BATON_USERNAME=username BATON_ACCESS_TOKEN=access-token ghcr.io/conductorone/baton-dockerhub:latest -f "/out/sync.c1z"
docker run --rm -v $(pwd):/out ghcr.io/conductorone/baton:latest -f "/out/sync.c1z" resources
```

Expand All @@ -36,7 +36,7 @@ docker run --rm -v $(pwd):/out ghcr.io/conductorone/baton:latest -f "/out/sync.c
go install github.com/conductorone/baton/cmd/baton@main
go install github.com/conductorone/baton-dockerhub/cmd/baton-dockerhub@main
BATON_USERNAME=username BATON_PASSWORD=password baton-dockerhub
BATON_USERNAME=username BATON_ACCESS_TOKEN=access-token baton-dockerhub
baton resources
```

Expand Down Expand Up @@ -79,7 +79,7 @@ Flags:
--log-format string The output format for logs: json, console ($BATON_LOG_FORMAT) (default "json")
--log-level string The log level: debug, info, warn, error ($BATON_LOG_LEVEL) (default "info")
--orgs strings Limit syncing to specific organizations by providing organization slugs. ($BATON_ORGS)
--password string The DockerHub password used to connect to the DockerHub API. ($BATON_PASSWORD)
--access-token string The DockerHub access token used to connect to the DockerHub API. ($BATON_ACCESS_TOKEN)
-p, --provisioning This must be set in order for provisioning actions to be enabled. ($BATON_PROVISIONING)
--username string The DockerHub username used to connect to the DockerHub API. ($BATON_USERNAME)
-v, --version version for baton-dockerhub
Expand Down
34 changes: 0 additions & 34 deletions cmd/baton-dockerhub/config.go

This file was deleted.

17 changes: 10 additions & 7 deletions cmd/baton-dockerhub/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import (
"fmt"
"os"

"github.com/conductorone/baton-sdk/pkg/cli"
configschema "github.com/conductorone/baton-sdk/pkg/config"
"github.com/conductorone/baton-sdk/pkg/connectorbuilder"
"github.com/conductorone/baton-sdk/pkg/types"
"github.com/grpc-ecosystem/go-grpc-middleware/logging/zap/ctxzap"
"github.com/spf13/viper"
"go.uber.org/zap"

"github.com/conductorone/baton-dockerhub/pkg/config"
"github.com/conductorone/baton-dockerhub/pkg/connector"
)

Expand All @@ -19,27 +21,28 @@ var version = "dev"
func main() {
ctx := context.Background()

cfg := &config{}
cmd, err := cli.NewCmd(ctx, "baton-dockerhub", cfg, validateConfig, getConnector)
_, cmd, err := configschema.DefineConfiguration(ctx, "baton-dockerhub", getConnector, config.Configuration)
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}

cmd.Version = version
cmdFlags(cmd)

err = cmd.Execute()
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
}

func getConnector(ctx context.Context, cfg *config) (types.ConnectorServer, error) {
func getConnector(ctx context.Context, v *viper.Viper) (types.ConnectorServer, error) {
l := ctxzap.Extract(ctx)

cb, err := connector.New(ctx, cfg.Username, cfg.Password, cfg.Orgs)
username := v.GetString(config.Username.FieldName)
accessToken := v.GetString(config.AccessToken.FieldName)
orgs := v.GetStringSlice(config.Orgs.FieldName)
password := v.GetString(config.Password.FieldName)
cb, err := connector.New(ctx, username, accessToken, password, orgs)
if err != nil {
l.Error("error creating connector", zap.Error(err))
return nil, err
Expand Down
Loading

0 comments on commit 4765b20

Please sign in to comment.