Skip to content

Commit

Permalink
Import changes.
Browse files Browse the repository at this point in the history
  - 1c601f0afc71b24b2595d04bb5983e5e28a9a17e

GitOrigin-RevId: 1c601f0afc71b24b2595d04bb5983e5e28a9a17e
  • Loading branch information
Aalyria Technologies, Inc committed Oct 19, 2024
1 parent fa5da8f commit c8644f4
Show file tree
Hide file tree
Showing 9 changed files with 291 additions and 239 deletions.
13 changes: 0 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ jobs:
target:
- //agent/cmd/agent
- //tools/nbictl/cmd/nbictl
- //tools/generate_jwt
os: [linux, windows, darwin]
arch: [amd64, arm64]

Expand Down Expand Up @@ -81,18 +80,6 @@ jobs:
with:
name: agent-${{ matrix.os }}-${{ matrix.arch }}
path: bazel-bin/agent/cmd/agent/agent_/agent.exe
- name: Upload generate_jwt binary
uses: actions/upload-artifact@v4
if: ${{ matrix.target == '//tools/generate_jwt' && matrix.os != 'windows' }}
with:
name: generate_jwt-${{ matrix.os }}-${{ matrix.arch }}
path: bazel-bin/tools/generate_jwt/generate_jwt_/generate_jwt
- name: Upload generate_jwt binary - Windows
uses: actions/upload-artifact@v4
if: ${{ matrix.target == '//tools/generate_jwt' && matrix.os == 'windows' }}
with:
name: generate_jwt-${{ matrix.os }}-${{ matrix.arch }}
path: bazel-bin/tools/generate_jwt/generate_jwt_/generate_jwt.exe

build-and-upload-docs:
needs: [build-and-test]
Expand Down
28 changes: 0 additions & 28 deletions tools/generate_jwt/BUILD

This file was deleted.

196 changes: 0 additions & 196 deletions tools/generate_jwt/generate_jwt.go

This file was deleted.

4 changes: 4 additions & 0 deletions tools/nbictl/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ go_library(
srcs = [
"config.go",
"connection.go",
"generate_auth_token.go",
"generate_rsa_key.go",
"grpcurl.go",
"model.go",
Expand All @@ -37,6 +38,7 @@ go_library(
"//auth",
"//tools/nbictl/proto:nbictl_go_proto",
"@com_github_fullstorydev_grpcurl//:grpcurl",
"@com_github_golang_jwt_jwt_v5//:jwt",
"@com_github_jhump_protoreflect//desc",
"@com_github_jhump_protoreflect//grpcreflect",
"@com_github_jonboulle_clockwork//:clockwork",
Expand Down Expand Up @@ -64,6 +66,7 @@ go_test(
"connection_test.go",
"fake_modelapi_server_test.go",
"fake_nbi_server_test.go",
"generate_auth_token_test.go",
"generate_rsa_key_test.go",
"model_test.go",
"nbictl_test.go",
Expand All @@ -76,6 +79,7 @@ go_test(
"//api/nbi/v1alpha/resources:nbi_resources_go_grpc",
"//auth/authtest",
"//tools/nbictl/proto:nbictl_go_proto",
"@com_github_golang_jwt_jwt_v5//:jwt",
"@com_github_google_go_cmp//cmp",
"@com_github_urfave_cli_v2//:cli",
"@org_golang_google_grpc//:grpc",
Expand Down
8 changes: 8 additions & 0 deletions tools/nbictl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,14 @@ Takes a fully-qualified method name in 'service.method' or 'service/method' form

**--request, -r**="": File containing the request to make encoded in the selected --format. Defaults to -, which uses stdin. (default: -)

## generate-auth-token

Generate a self-signed JWT token for API authentication.

**--audience, --aud**="": The audience (aud) to set in the JWT token.

**--expiration, --exp**="": The validity duration of token, from the time of creation. (default: 1h)

## help, h

Shows a list of commands or help for one command
Expand Down
9 changes: 7 additions & 2 deletions tools/nbictl/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"errors"
"fmt"
"io"
"io/fs"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -75,7 +76,7 @@ func readConfigs(confFilePath string) (*nbictlpb.AppConfig, error) {
confBytes, err := os.ReadFile(confFilePath)
if err != nil {
if os.IsNotExist(err) {
return confProto, nil
return nil, fmt.Errorf("unable to read file: %w.\nSee `%s help set-config` to learn how to configure the tool.", err, appName)
}
return nil, fmt.Errorf("unable to read file: %w", err)
}
Expand Down Expand Up @@ -196,7 +197,11 @@ func setConfig(outWriter, errWriter io.Writer, confToCreate *nbictlpb.Config, co

confProto, err := readConfigs(confFile)
if err != nil {
return fmt.Errorf("unable to get configs from file %s: %w", confFile, err)
if errors.Is(err, fs.ErrNotExist) {
confProto = &nbictlpb.AppConfig{}
} else {
return fmt.Errorf("unable to get configs from file %s: %w", confFile, err)
}
}

found := false
Expand Down
Loading

0 comments on commit c8644f4

Please sign in to comment.