Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
32 changes: 32 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,35 @@ jobs:
- uses: golangci/golangci-lint-action@v9
with:
working-directory: src/brats/

lint-bosh-nats-sync:
name: lint (bosh-nats-sync)
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v7
Comment thread
aramprice marked this conversation as resolved.
with:
persist-credentials: false
- uses: actions/setup-go@v6
Comment thread
aramprice marked this conversation as resolved.
with:
go-version-file: src/bosh-nats-sync/go.mod
- uses: golangci/golangci-lint-action@v9
with:
working-directory: src/bosh-nats-sync/

test-bosh-nats-sync:
name: test (bosh-nats-sync)
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: actions/setup-go@v6
with:
go-version-file: src/bosh-nats-sync/go.mod
- name: Run tests
run: go test ./...
working-directory: src/bosh-nats-sync/
1 change: 0 additions & 1 deletion .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ jobs:
sub_project:
- common:parallel
- monitor:parallel
- nats_sync:parallel
- release
steps:
- uses: actions/checkout@v7
Expand Down
27 changes: 27 additions & 0 deletions ci/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1414,6 +1414,16 @@ jobs:
output_repo: bosh-out
params:
SOURCE_PATH: src/brats/
- task: bump-bosh-nats-sync-deps
file: golang-release/ci/tasks/shared/bump-deps.yml
input_mapping:
input_repo: bosh-out
output_mapping:
output_repo: bosh-out
params:
SOURCE_PATH: src/bosh-nats-sync/
GO_PACKAGE: golang-1.26-linux
GOOS_LIST: linux
- task: lint-brats
file: bosh-ci/ci/tasks/lint-brats.yml
image: integration-image
Expand Down Expand Up @@ -1455,6 +1465,8 @@ jobs:
trigger: true
params:
globs: [ nats-server-v*-linux-amd64.tar.gz ]
- get: golang-release
trigger: true
- task: bump-nginx-packages
file: nginx-release/ci/shared/bump-nginx-package.yml
image: integration-image
Expand Down Expand Up @@ -1518,6 +1530,21 @@ jobs:
options:
credentials_source: static
json_key: '((gcp_json_key))'
- task: bump-golang-package
file: golang-release/ci/tasks/shared/bump-golang-package.yml
input_mapping:
input_repo: bosh-out
output_mapping:
output_repo: bosh-out
params:
GIT_USER_NAME: *git_user_name
GIT_USER_EMAIL: *git_user_email
PACKAGES: ["golang-1.26-linux"]
PRIVATE_YML: |
blobstore:
options:
credentials_source: static
json_key: '((gcp_json_key))'
- task: bump-ruby-package
file: ruby-release/ci/tasks/shared/bump-ruby-package.yml
input_mapping:
Expand Down
1 change: 0 additions & 1 deletion jobs/nats/spec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ templates:

packages:
- nats
- director-ruby-3.4

properties:
nats.listen_address:
Expand Down
1 change: 0 additions & 1 deletion jobs/nats/templates/bosh_nats_sync
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/bin/bash

source /var/vcap/packages/director-ruby-3.4/bosh/runtime.env
exec /var/vcap/packages/nats/bin/bosh-nats-sync -c /var/vcap/jobs/nats/config/bosh_nats_sync_config.yml
4 changes: 0 additions & 4 deletions jobs/nats/templates/bpm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ bosh_nats_sync_config = {
"name" => "bosh_nats_sync",
"executable" => "/var/vcap/jobs/nats/bin/bosh_nats_sync",
"ephemeral_disk" => true,
"env" => {
"BUNDLE_GEMFILE" => "/var/vcap/packages/nats/Gemfile",
"GEM_HOME" => "/var/vcap/packages/nats/gem_home/ruby/3.4.0",
},
"unsafe" => {
"privileged" => true,
"host_pid_namespace" => true,
Expand Down
7 changes: 7 additions & 0 deletions packages/golang-1.26-linux/packaging
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
set -e -x -u

mkdir "${BOSH_INSTALL_TARGET}/bosh"

PACKAGE_NAME="$(basename "${BOSH_INSTALL_TARGET}")"
sed "s#\${PACKAGE_NAME}#${PACKAGE_NAME}#" golang-1.26-linux/compile.env.unix > "${BOSH_INSTALL_TARGET}/bosh/compile.env"
sed "s#\${PACKAGE_NAME}#${PACKAGE_NAME}#" golang-1.26-linux/runtime.env.unix > "${BOSH_INSTALL_TARGET}/bosh/runtime.env"
8 changes: 8 additions & 0 deletions packages/golang-1.26-linux/spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
name: golang-1.26-linux

dependencies: []

files:
- golang-1.26-linux/compile.env.unix
- golang-1.26-linux/runtime.env.unix
35 changes: 8 additions & 27 deletions packages/nats/packaging
Original file line number Diff line number Diff line change
@@ -1,33 +1,14 @@
set -e

mkdir -p ${BOSH_INSTALL_TARGET}/bin
mkdir -p "${BOSH_INSTALL_TARGET}/bin"

tar xzf nats/nats-server-v*-linux-amd64.tar.gz
cp nats-server-v*-linux-amd64/nats-server ${BOSH_INSTALL_TARGET}/bin/nats-server
chmod +x ${BOSH_INSTALL_TARGET}/bin/nats-server
cp nats-server-v*-linux-amd64/nats-server "${BOSH_INSTALL_TARGET}/bin/nats-server"
chmod +x "${BOSH_INSTALL_TARGET}/bin/nats-server"

source /var/vcap/packages/golang-1.26-linux/bosh/compile.env
unset GOPATH
export GO111MODULE=on

mkdir -p ${BOSH_INSTALL_TARGET}/{bin,gem_home}

source /var/vcap/packages/director-ruby-3.4/bosh/compile.env

cat > Gemfile <<EOF
# Explicitly require vendored version to avoid requiring builtin json gem
gem 'json', '~>2'
gem 'bosh-nats-sync'
EOF

for gemspec in $( find . -maxdepth 2 -name *.gemspec ); do
gem_name="$( basename "$( dirname "$gemspec" )" )"
gem_spec="$( basename "$gemspec" )"

pushd "$gem_name"
gem build "$gem_spec"
mv *.gem ../vendor/cache
popd > /dev/null
done

bosh_bundle_local

cp Gemfile ${BOSH_INSTALL_TARGET}
cp Gemfile.lock ${BOSH_INSTALL_TARGET}
cd bosh-nats-sync
CGO_ENABLED=0 go build -mod=vendor -o "${BOSH_INSTALL_TARGET}/bin/bosh-nats-sync" ./cmd/bosh-nats-sync
5 changes: 1 addition & 4 deletions packages/nats/spec
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@
name: nats

dependencies:
- director-ruby-3.4
- golang-1.26-linux

files:
- nats/nats-server-v*-linux-amd64.tar.gz
- bosh-nats-sync/**/*
- bosh-common/**/*
- vendor/cache/*.gem
- vendor/cache/extensions/**
1 change: 0 additions & 1 deletion src/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ source 'https://rubygems.org'

gem 'bosh-director', path: 'bosh-director'
gem 'bosh-monitor', path: 'bosh-monitor'
gem 'bosh-nats-sync', path: 'bosh-nats-sync'
gem 'bosh-common', path: 'bosh-common'

gem 'mysql2'
Expand Down
12 changes: 0 additions & 12 deletions src/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,6 @@ PATH
securerandom
sinatra

PATH
remote: bosh-nats-sync
specs:
bosh-nats-sync (0.0.0)
bosh-common
cf-uaa-lib
json
logging
openssl
rufus-scheduler

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -349,7 +338,6 @@ DEPENDENCIES
bosh-common!
bosh-director!
bosh-monitor!
bosh-nats-sync!
bundle-audit
factory_bot
fakefs
Expand Down
1 change: 0 additions & 1 deletion src/bosh-nats-sync/.gitignore

This file was deleted.

14 changes: 14 additions & 0 deletions src/bosh-nats-sync/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: "2"

linters:
default: standard

exclusions:
rules:
- path: "_test\\.go"
linters:
- errcheck

formatters:
enable:
- goimports
27 changes: 0 additions & 27 deletions src/bosh-nats-sync/bin/bosh-nats-sync

This file was deleted.

35 changes: 0 additions & 35 deletions src/bosh-nats-sync/bosh-nats-sync.gemspec

This file was deleted.

47 changes: 47 additions & 0 deletions src/bosh-nats-sync/cmd/bosh-nats-sync/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package main

import (
"flag"
"fmt"
"os"
"os/signal"
"syscall"

"bosh-nats-sync/pkg/config"
"bosh-nats-sync/pkg/runner"
)

func main() {
configFile := flag.String("c", "", "configuration file")
flag.StringVar(configFile, "config", "", "configuration file")
flag.Parse()

if *configFile == "" {
fmt.Fprintf(os.Stderr, "Usage: bosh-nats-sync -c <config_file>\n")
flag.PrintDefaults()
os.Exit(1)
}

cfg, err := config.Load(*configFile)
if err != nil {
fmt.Fprintf(os.Stderr, "Error loading config: %s\n", err)
os.Exit(1)
}

logger := config.NewLogger(cfg)

r := runner.New(cfg, logger)

sigCh := make(chan os.Signal, 1)
signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM)

go func() {
<-sigCh
r.Stop()
}()

if err := r.Run(); err != nil {
logger.Error("Fatal error, shutting down", "error", err)
os.Exit(1)
}
}
25 changes: 25 additions & 0 deletions src/bosh-nats-sync/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module bosh-nats-sync

go 1.26.3

require (
github.com/onsi/ginkgo/v2 v2.28.1
github.com/onsi/gomega v1.39.1
golang.org/x/oauth2 v0.36.0
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/Masterminds/semver/v3 v3.4.0 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/pprof v0.0.0-20260115054156-294ebfa9ad83 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/mod v0.34.0 // indirect
golang.org/x/net v0.53.0 // indirect
golang.org/x/sync v0.20.0 // indirect
golang.org/x/sys v0.44.0 // indirect
golang.org/x/text v0.36.0 // indirect
golang.org/x/tools v0.43.0 // indirect
)
Loading
Loading