Skip to content

Commit

Permalink
rVASP Status Check
Browse files Browse the repository at this point in the history
  • Loading branch information
bbengfort committed Apr 10, 2024
1 parent d7b1863 commit 5d4b972
Show file tree
Hide file tree
Showing 8 changed files with 428 additions and 160 deletions.
99 changes: 20 additions & 79 deletions .github/workflows/containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ jobs:
steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Set Envrionment
id: vars
run: |
echo "::set-output name=tag::${GITHUB_REF#refs/*/}"
echo "::set-output name=revision::$(git rev-parse --short HEAD)"
echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
echo "revision=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Docker Metadata
id: meta
uses: docker/metadata-action@v3
uses: docker/metadata-action@v4
with:
images: |
trisa/rvasp
Expand All @@ -40,32 +40,32 @@ jobs:
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,prefix=,suffix=,format=short
- name: Setup QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v2

- name: Setup Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to GCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
registry: gcr.io
username: _json_key
password: ${{ secrets.GCR_JSON_KEY }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
uses: docker/build-push-action@v3
with:
# context and Dockerfile - should be configured for each image
context: .
Expand All @@ -75,82 +75,23 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
build-args: |
GIT_REVISION=${{ steps.vars.outputs.revision }}
openvasp:
name: openvasp
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Set Envrionment
id: vars
run: |
echo "::set-output name=tag::${GITHUB_REF#refs/*/}"
echo "::set-output name=revision::$(git rev-parse --short HEAD)"
- name: Docker Metadata
id: meta
uses: docker/metadata-action@v3
with:
images: |
trisa/openvasp
gcr.io/trisa-gds/openvasp
tags: |
type=semver,pattern={{raw}}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,prefix=,suffix=,format=short
- name: Setup QEMU
uses: docker/setup-qemu-action@v1

- name: Setup Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
if: github.event_name == 'pull_request'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to GCR
if: github.event_name == 'pull_request'
uses: docker/login-action@v1
with:
registry: gcr.io
username: _json_key
password: ${{ secrets.GCR_JSON_KEY }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
# context and Dockerfile - should be configured for each image
context: .
file: ./containers/openvasp/Dockerfile
push: ${{ github.event_name == 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
GIT_REVISION=${{ steps.vars.outputs.revision }}
migrate:
name: migrate
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Set Envrionment
id: vars
run: |
echo "::set-output name=tag::${GITHUB_REF#refs/*/}"
echo "::set-output name=revision::$(git rev-parse --short HEAD)"
echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
echo "revision=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Docker Metadata
id: meta
uses: docker/metadata-action@v3
uses: docker/metadata-action@v4
with:
images: |
trisa/rvasp-migrate
Expand All @@ -160,32 +101,32 @@ jobs:
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,prefix=,suffix=,format=short
- name: Setup QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v2

- name: Setup Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to GCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
registry: gcr.io
username: _json_key
password: ${{ secrets.GCR_JSON_KEY }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
uses: docker/build-push-action@v3
with:
# context and Dockerfile - should be configured for each image
context: .
Expand Down
31 changes: 31 additions & 0 deletions cmd/rvasp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,20 @@ func main() {
},
},
},
{
Name: "status",
Usage: "get the current rVASP status and certificate info",
Category: "client",
Action: rvaspStatus,
Flags: []cli.Flag{
cli.StringFlag{
Name: "e, endpoint",
Usage: "the address and port to connect to the server on",
Value: "localhost:4434",
EnvVar: "RVASP_ADDR",
},
},
},
}

app.Run(os.Args)
Expand Down Expand Up @@ -459,6 +473,23 @@ func stream(c *cli.Context) (err error) {
}
}

func rvaspStatus(c *cli.Context) (err error) {
client, err := makeClient(c)
if err != nil {
return cli.NewExitError(err, 1)
}

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()

var status *pb.ServerStatus
if status, err = client.Status(ctx, &pb.Empty{}); err != nil {
return cli.NewExitError(err, 1)
}

return printJSON(status)
}

// helper function to create the GRPC client with default options
func makeClient(c *cli.Context) (_ pb.TRISAIntegrationClient, err error) {
var opts []grpc.DialOption
Expand Down
Loading

0 comments on commit 5d4b972

Please sign in to comment.