-
Notifications
You must be signed in to change notification settings - Fork 661
Replace Ruby bosh-nats-sync with Golang implementation #2746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
aramprice
wants to merge
5
commits into
main
Choose a base branch
from
experiment-golang-bosh-nats-sync
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a2337fd
Golang bosh-nats-sync
aramprice 706ba27
Remove ruby-isms now that nats is golang
aramprice 6cc710d
Fix bosh create-release to work for integration tests
aramprice 502b5ab
Add Go tests for AuthProvider with no CA cert configured (system trus…
colins 5980267
Add Go tests for per-error-type connection retry (isConnectionError)
colins File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,6 @@ templates: | |
|
|
||
| packages: | ||
| - nats | ||
| - director-ruby-3.4 | ||
|
|
||
| properties: | ||
| nats.listen_address: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| ) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.