Skip to content

Commit

Permalink
pull in latest
Browse files Browse the repository at this point in the history
  • Loading branch information
suchak1 committed May 30, 2024
2 parents b73a0c4 + c444357 commit 82fd713
Show file tree
Hide file tree
Showing 133 changed files with 5,248 additions and 2,734 deletions.
24 changes: 24 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# dependabot.yml
#
# Documentation:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
commit-message:
prefix: 'chore(dependabot)'
- package-ecosystem: gomod
directory: /
schedule:
interval: daily
commit-message:
prefix: 'chore(dependabot)'
ignore:
# The platform and SDK are not yet following semver, so we do not want a bump for every
# new commit. We will handle these updates manually while breaking change likelihood is high.
- dependency-name: github.com/opentdf/platform/protocol/go
- dependency-name: github.com/opentdf/platform/sdk
26 changes: 2 additions & 24 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,15 @@ jobs:
go-version-file: 'go.mod'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc
uses: golangci/golangci-lint-action@9d1e0624a798bb64f6c3cea93db47765312263dc
with:
version: v1.55
# Optional: golangci-lint command line arguments.
args: --timeout=10m
args: --timeout=10m
unit:
name: unit tests
runs-on: ubuntu-22.04
env:
GOPRIVATE: github.com/opentdf/platform/*
steps:
- name: Generate a token
id: generate_token
uses: actions/[email protected]
with:
app-id: '416599'
private-key: '${{ secrets.GH_APP_PRIVATE_KEY }}'
owner: ${{ github.repository_owner }}
repositories: 'platform'
- run: git config --global url.https://x-access-token:${{ steps.generate_token.outputs.token }}@github.com/.insteadOf https://github.com/
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491
with:
Expand All @@ -46,18 +35,7 @@ jobs:
end-to-end:
name: e2e tests
runs-on: ubuntu-22.04
env:
GOPRIVATE: github.com/opentdf/platform/*
steps:
- name: Generate a token
id: generate_token
uses: actions/[email protected]
with:
app-id: '416599'
private-key: '${{ secrets.GH_APP_PRIVATE_KEY }}'
owner: ${{ github.repository_owner }}
repositories: 'platform'
- run: git config --global url.https://x-access-token:${{ steps.generate_token.outputs.token }}@github.com/.insteadOf https://github.com/
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491
with:
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/dependabot-approve-and-merge.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Dependabot auto approve and merge
on: pull_request

# Docs: https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#common-dependabot-automations

permissions:
pull-requests: write
contents: write

jobs:
dependabot:
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v2
with:
github-token: '${{ secrets.GITHUB_TOKEN }}'
- name: Enable auto-merge
run: |
echo "enabling auto merge for dependency bump PR '$PR_URL'"
gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Approve the PR
id: approval-minor-patch
if: ${{ steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor' }}
run: |
echo "approving minor or patch bump in PR '$PR_URL'"
gh pr review --approve "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Report on skip of PR approval
if: ${{ steps.approval-minor-patch.conclusion == 'skipped' }}
run: echo "Not approving PR '$PR_URL' because dependency bump is not minor or patch (major, unknown non-SEMVER bump, etc)"
env:
PR_URL: ${{github.event.pull_request.html_url}}
3 changes: 2 additions & 1 deletion .github/workflows/pr-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
name: Validate PR title
runs-on: ubuntu-22.04
steps:
- uses: amannn/action-semantic-pull-request@e9fabac35e210fea40ca5b14c0da95a099eff26f
- uses: amannn/action-semantic-pull-request@cfb60706e18bc85e8aec535e3c577abe8f70378e
with:
types: |
fix
Expand All @@ -28,5 +28,6 @@ jobs:
tui
demo
ci
dependabot
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30 changes: 10 additions & 20 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ jobs:
runs-on: ubuntu-22.04
env:
GOPRIVATE: github.com/opentdf/platform/*
BIN_NAME: tructl
BIN_NAME: otdfctl
steps:
<<<<<<< HEAD
- name: Is actor in ${{ env.MAINTAINER_TEAM }}
uses: actions/github-script@v7
with:
Expand Down Expand Up @@ -53,47 +54,36 @@ jobs:
console.log(`Error checking membership: ${error}`);
core.setFailed(`Error checking membership: ${error}`);
}
# - uses: actions/checkout@v3
# - uses: actions/checkout@v4
# - uses: actions/setup-go@v5
# with:
# go-version-file: './go.mod'
# cache: false
# - name: Get next version
# uses: reecetech/version-increment@2023.9.3
# uses: reecetech/version-increment@2024.4.4
# id: version
# with:
# release_branch: main
# scheme: semver
# increment: ${{ github.event.inputs.versionBumpType }}
# pep440: false
# - name: print-version
# run: echo Incrementing Version ${{ steps.version.outputs.current-version }} -> ${{ steps.version.outputs.version }}
# # TODO: remove this step when `opentdf/platform` is public
# # special app the virtru eng team created, to grab a token for accessing other org repos, in a secure way
# - name: Generate a token
# id: generate_token
# uses: actions/[email protected]
# with:
# app-id: '416599'
# private-key: '${{ secrets.GH_APP_PRIVATE_KEY }}'
# owner: ${{ github.repository_owner }}
# repositories: 'platform'
# - run: git config --global url.https://x-access-token:${{ steps.generate_token.outputs.token }}@github.com/.insteadOf https://github.com/
# run: echo Incrementing Version ${{ steps.version.outputs.current-v-version }} -> ${{ steps.version.outputs.v-version }}
# - name: make-targets
# env:
# SEM_VER: ${{ steps.version.outputs.version }}
# SEM_VER: ${{ steps.version.outputs.v-version }}
# run: make build
# - name: smoke-test
# run: go test ./... -short -race -cover
# - name: Compress the builds and generate checksums
# env:
# SEM_VER: ${{ steps.version.outputs.version }}
# SEM_VER: ${{ steps.version.outputs.v-version }}
# run: make zip-builds
# - name: Release
# uses: softprops/action-gh-release@v1
# uses: softprops/action-gh-release@v2
# with:
# files: './output/**/*'
# body: 'This is a test release, and will be removed'
# tag_name: ${{ steps.version.outputs.version }}
# repository: opentdf/tructl
# tag_name: ${{ steps.version.outputs.v-version }}
# repository: opentdf/otdfctl
# generate_release_notes: true
12 changes: 0 additions & 12 deletions .github/workflows/security-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,7 @@ jobs:
govulncheck_job:
runs-on: ubuntu-latest
name: Run govulncheck
env:
GOPRIVATE: github.com/opentdf/platform/*
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Generate a token
id: generate_token
uses: actions/[email protected]
with:
app-id: '416599'
private-key: '${{ secrets.GH_APP_PRIVATE_KEY }}'
owner: ${{ github.repository_owner }}
repositories: 'platform'
- run: git config --global url.https://x-access-token:${{ steps.generate_token.outputs.token }}@github.com/.insteadOf https://github.com/
- id: govulncheck
uses: golang/govulncheck-action@v1
with:
Expand Down
14 changes: 12 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,15 @@ bin/.DS_Store
.DS_Store
target/
.vscode/launch.json
tructl.yaml
output/
otdfctl.yaml

# Ignore the tructl binary
otdfctl

# Hugo
public/
.hugo_build.lock
output/

# Ignore any TDF files created by the CLI
*.tdf
2 changes: 1 addition & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# CODEOWNERS

* @opentdf/developers
* @opentdf/opentdf-cli
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# tructl: cli to manage Virtru Data Security Platform
# otdfctl: cli to manage OpenTDF Platform

This command line interface is used to manage Virtru Data Security Platform.
This command line interface is used to manage OpenTDF Platform.

The main goals are to:

Expand All @@ -15,13 +15,11 @@ The main goals are to:
- [ ] Add support for `--verbose` persistent flag
- [ ] Helper functions to support common tasks like pretty printing and json output

## Installation

## Usage

The CLI is configured via the `tructl.yaml`. There is an example provided in `example-tructl.yaml`.
The CLI is configured via the `otdfctl.yaml`. There is an example provided in `otdfctl-example.yaml`.

Run `cp example-tructl.yaml tructl.yaml` to copy the example config when running the CLI.
Run `cp otdfctl-example.yaml otdfctl.yaml` to copy the example config when running the CLI.

Load up the platform (see its [README](https://github.com/opentdf/platform?tab=readme-ov-file#run) for instructions).

Expand All @@ -33,7 +31,7 @@ The CLI is built using [cobra](https://cobra.dev/).

The primary function is to support CRUD operations using commands as arguments and flags as the values.

The output format (currently `styled` or `json`) is configurable in the `tructl.yaml` or via CLI flag.
The output format (currently `styled` or `json`) is configurable in the `otdfctl.yaml` or via CLI flag.

#### To add a command

Expand All @@ -48,3 +46,8 @@ The output format (currently `styled` or `json`) is configurable in the `tructl.
> This is a work in progress please avoid touching until framework is defined
The TUI will be used to create an interactive experience for the user.

## Documentation

Documentation drives the CLI in this project. This can be found in `/docs/man` and is used in the
CLI via the `man.Docs.GetDoc()` function.
58 changes: 58 additions & 0 deletions cmd/auth-clearCachedCredentials.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package cmd

import (
"errors"
"fmt"

"github.com/opentdf/otdfctl/pkg/cli"
"github.com/opentdf/otdfctl/pkg/handlers"
"github.com/opentdf/otdfctl/pkg/man"
"github.com/spf13/cobra"
"github.com/zalando/go-keyring"
)

var clearCachedCredsCmd = man.Docs.GetCommand("auth/clear-cached-credentials",
man.WithRun(auth_clearCreds),
man.WithHiddenFlags("with-client-creds", "with-client-creds-file"),
)

func auth_clearCreds(cmd *cobra.Command, args []string) {
cachedClientID, err := handlers.GetClientIDFromCache()
if err != nil {
if errors.Is(err, keyring.ErrNotFound) {
fmt.Println("No client-id found in the cache to clear.")
} else {
cli.ExitWithError("Failed to retrieve client id from keyring", err)
}
}

// clear the client ID and secret from the keyring
err = keyring.Delete(handlers.TOKEN_URL, cachedClientID)
if err != nil {
if errors.Is(err, keyring.ErrNotFound) {
fmt.Println("No client secret found in the cache to clear under client-id: ", cachedClientID)
} else {
cli.ExitWithError("Failed to clear client secret from keyring", err)
}
}

err = keyring.Delete(handlers.TOKEN_URL, handlers.OTDFCTL_CLIENT_ID_CACHE_KEY)
if err != nil {
if errors.Is(err, keyring.ErrNotFound) {
fmt.Println("No client id found in the cache to clear.")
} else {
cli.ExitWithError("Failed to clear client id from keyring", err)
}
}

err = keyring.Delete(handlers.TOKEN_URL, handlers.OTDFCTL_OIDC_TOKEN_KEY)
if err != nil {
if errors.Is(err, keyring.ErrNotFound) {
fmt.Println("No token found in the cache to clear.")
} else {
cli.ExitWithError("Failed to clear token from keyring", err)
}
}

fmt.Println(cli.SuccessMessage("Cached client credentials and token are clear."))
}
Loading

0 comments on commit 82fd713

Please sign in to comment.