Skip to content

Commit

Permalink
Merge pull request #13 from synackd/postgres-one-db
Browse files Browse the repository at this point in the history
Add bss-init to initialize Postgres DB
  • Loading branch information
alexlovelltroy authored Jan 24, 2024
2 parents 5002b06 + c39fb13 commit 7bb85c8
Show file tree
Hide file tree
Showing 18 changed files with 714 additions and 187 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,17 @@ jobs:
echo "fs.writeFileSync('digest.txt', firstNonNullDigest);" >> process.js
node process.js
echo "digest=$(cat digest.txt)" >> $GITHUB_OUTPUT
- name: Attest Binaries
- name: Attest boot-script-service binary
uses: github-early-access/generate-build-provenance@main
with:
subject-path: dist/boot-script-service
- name: Attest bss-init binary
uses: github-early-access/generate-build-provenance@main
with:
subject-path: dist/bss-init
- name: generate build provenance
uses: github-early-access/generate-build-provenance@main
with:
subject-name: ghcr.io/openchami/bss
subject-digest: ${{ steps.process_goreleaser_output.outputs.digest }}
push-to-registry: true
push-to-registry: true
7 changes: 3 additions & 4 deletions .github/workflows/unit_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
build:
defaults:
run:
working-directory: ./cmd/boot-script-service
working-directory: ./cmd
runs-on: ubuntu-latest

steps:
Expand All @@ -15,7 +15,6 @@
with:
go-version: '1.21.x'
- name: Install dependencies
run: go get .
run: go get ./boot-script-service ./bss-init
- name: Test with the Go CLI
run: go test

run: go test ./boot-script-service ./bss-init
11 changes: 11 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ builds:
no_unique_dist_dir: true
tags:
- dynamic
- id: bss-init
main: ./cmd/bss-init
binary: bss-init
goos:
- linux
goarch:
- amd64
no_unique_dist_dir: true
tags:
- dynamic

dockers:
-
Expand All @@ -37,6 +47,7 @@ dockers:
- CHANGELOG.md
- README.md
- .version
- migrations/

archives:
- format: tar.gz
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.28.0] - 2024-01-24

- Added bss-init and postgres migrations
- Moved postgres init code from boot-script-service to bss-init
- Updated docker-compose postgres and bss-debugger files to use one postgres container
- Updated go.mod:
* Fixed grpc version at v1.29.1 to fix dependency conflict
* Added github.com/golang-migrate/migrate v4.16.2

## [1.27.2] - 2024-01-19

- Added postgres backend
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ RUN set -ex \
&& apk -U upgrade \
&& apk add --no-cache curl

# Get the boot-script-service from the builder stage.
# Get the boot-script-service and bss-init from the builder stage.
COPY boot-script-service /usr/local/bin/
COPY bss-init /usr/local/bin/
COPY migrations/* /migrations/
COPY .version /

# nobody 65534:65534
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# Service
NAME ?= bss
VERSION ?= $(shell cat .version)
BINARIES = boot-script-service
BINARIES = boot-script-service bss-init


all : image unittest ct snyk ct_image
Expand Down
6 changes: 0 additions & 6 deletions cmd/boot-script-service/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,12 +473,6 @@ func main() {
log.Fatalf("Access to Postgres database at %s:%d failed: %v\n", sqlHost, sqlPort, err)
}
defer sqlClose()

// Create database and tables (if they do not exist).
err = bssdb.CreateDB(bssdbName)
if err != nil {
log.Fatalf("Creating Postgres database %q and tables failed: %v\n", bssdbName, err)
}
} else {
err = kvOpen(datastoreBase, svcOpts, kvRetryCount, kvRetryWait)
if err != nil {
Expand Down
Loading

0 comments on commit 7bb85c8

Please sign in to comment.