Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e6bfd8b
move go local provider to repo
vahidlazio Oct 31, 2025
51797ee
Remove generated .pb.go files from git tracking
vahidlazio Oct 31, 2025
2e8f5b3
fix: some minor PR fixes
nicklasl Nov 3, 2025
2b666a6
fix: add generated protobuf files
nicklasl Nov 3, 2025
8aaa31a
build(go): add makefile for go provider
nicklasl Nov 3, 2025
05d4306
build(go): add Go provider to docker file
nicklasl Nov 3, 2025
7373c44
fix(go): Make FlagsAdminStateFetcher implement StateProvider interface
nicklasl Nov 3, 2025
bd9e220
fix(go): remove disableable exposure logging
nicklasl Nov 3, 2025
7502378
fix(go): align error message with other providers
nicklasl Nov 3, 2025
d3a4c91
chore(go): remove dead code
nicklasl Nov 3, 2025
dd3efc4
chore(go): add some comments
nicklasl Nov 4, 2025
a2da020
feat(go): embed WASM module in Go provider binary
nicklasl Nov 4, 2025
dcfbae4
chore(go): pin rust version to make builds property deterministic
nicklasl Nov 4, 2025
b6c018e
feat(go): setup release please
nicklasl Nov 4, 2025
520c115
fix: copy Go provider Cargo.toml in Docker build stages
nicklasl Nov 4, 2025
47d3fa7
fix(ci): ensure deterministic WASM builds
nicklasl Nov 4, 2025
bff6931
fix: pin protoc to 29.4-r0 for deterministic builds
nicklasl Nov 4, 2025
0dde2ea
fix: try to define docker platform
nicklasl Nov 4, 2025
d4fc797
Revert "fix: pin protoc to 29.4-r0 for deterministic builds"
nicklasl Nov 4, 2025
c2d46a7
Revert "fix(ci): ensure deterministic WASM builds"
nicklasl Nov 4, 2025
4d6458b
fix: declare arm64 on make sync-wasm-go
nicklasl Nov 4, 2025
168a41f
fix(go): clean up unused poll interval
nicklasl Nov 4, 2025
cffb029
docs(go): add readme
nicklasl Nov 4, 2025
5deb3ab
chore(go): cleanup unused func
nicklasl Nov 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# Ignore generated protobuf Java sources vendored during local build
openfeature-provider/java/src/main/java/com/spotify/confidence/wasm/Messages.java

# Ignore compiled Go binaries
openfeature-provider/go/demo/demo
.DS_Store
*.stamp
.idea/
.java-version

target/
# Ignore WASM in root wasm/ directory (build artifact)
wasm/confidence_resolver.wasm
# But DO track WASM embedded in Go provider (committed for go:embed)
!openfeature-provider/go/wasm/confidence_resolver.wasm


10 changes: 9 additions & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
{"confidence-resolver":"0.6.0","confidence-cloudflare-resolver":"0.3.0","wasm-msg":"0.2.1","wasm/rust-guest":"0.1.9","openfeature-provider/java":"0.7.2","openfeature-provider/js":"0.1.1"}
{
"confidence-resolver": "0.6.0",
"confidence-cloudflare-resolver": "0.3.0",
"wasm-msg": "0.2.1",
"wasm/rust-guest": "0.1.9",
"openfeature-provider/java": "0.7.2",
"openfeature-provider/js": "0.1.1",
"openfeature-provider/go": "0.0.0"
}
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ members = [
"confidence-resolver",
"confidence-cloudflare-resolver",
"openfeature-provider/java",
"openfeature-provider/js"
"openfeature-provider/js",
"openfeature-provider/go"
]

# Exclude the Java provider from default workspace builds (cargo build --workspace)
Expand Down
99 changes: 97 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ COPY wasm-msg/Cargo.toml ./wasm-msg/
COPY wasm/rust-guest/Cargo.toml ./wasm/rust-guest/
COPY openfeature-provider/java/Cargo.toml ./openfeature-provider/java/
COPY openfeature-provider/js/Cargo.toml ./openfeature-provider/js/
COPY openfeature-provider/go/Cargo.toml ./openfeature-provider/go/

# Copy proto files (needed by build.rs)
COPY confidence-resolver/protos ./confidence-resolver/protos/
Expand Down Expand Up @@ -99,6 +100,7 @@ COPY wasm/rust-guest/ ./wasm/rust-guest/
COPY wasm/proto/ ./wasm/proto/
COPY openfeature-provider/java/Cargo.toml ./openfeature-provider/java/
COPY openfeature-provider/js/Cargo.toml ./openfeature-provider/js/
COPY openfeature-provider/go/Cargo.toml ./openfeature-provider/go/

# Touch files to ensure rebuild (dependencies are cached)
RUN find . -type f -name "*.rs" -exec touch {} +
Expand Down Expand Up @@ -152,6 +154,7 @@ COPY wasm/rust-guest/ ./wasm/rust-guest/
COPY wasm/proto/ ./wasm/proto/
COPY openfeature-provider/java/Cargo.toml ./openfeature-provider/java/
COPY openfeature-provider/js/Cargo.toml ./openfeature-provider/js/
COPY openfeature-provider/go/Cargo.toml ./openfeature-provider/go/

# Copy data directory (needed by confidence-cloudflare-resolver include_str! macros)
COPY data/ ./data/
Expand Down Expand Up @@ -437,6 +440,92 @@ FROM scratch AS openfeature-provider-js.artifact

COPY --from=openfeature-provider-js.pack /app/package.tgz /package.tgz

# ==============================================================================
# OpenFeature Provider (Go) - Build and test
# ==============================================================================
FROM golang:1.24-alpine AS openfeature-provider-go-base

# Install make (needed for Makefile targets)
RUN apk add --no-cache make

WORKDIR /app

# Copy go.mod for dependency caching
COPY openfeature-provider/go/go.mod openfeature-provider/go/go.sum ./
COPY openfeature-provider/go/Makefile ./

# Download Go dependencies (this layer will be cached)
RUN go mod download

# Copy pre-generated protobuf files
COPY openfeature-provider/go/proto ./proto/

# Copy WASM module to embedded location
COPY --from=wasm-rust-guest.artifact /confidence_resolver.wasm ./wasm/confidence_resolver.wasm

# Set environment variable
ENV IN_DOCKER_BUILD=1

# Copy source code
COPY openfeature-provider/go/*.go ./

# ==============================================================================
# Validate WASM sync for Go Provider
# ==============================================================================
FROM alpine:3.22 AS openfeature-provider-go.validate-wasm

# Install diffutils for cmp command
RUN apk add --no-cache diffutils

# Copy built WASM from artifact
COPY --from=wasm-rust-guest.artifact /confidence_resolver.wasm /built/confidence_resolver.wasm

# Copy committed WASM from source
COPY openfeature-provider/go/wasm/confidence_resolver.wasm /committed/confidence_resolver.wasm

# Compare files
RUN set -e; \
echo "Validating WASM sync for Go provider..."; \
if ! cmp -s /built/confidence_resolver.wasm /committed/confidence_resolver.wasm; then \
echo ""; \
echo "❌ ERROR: WASM files are out of sync!"; \
echo ""; \
echo "The WASM file in openfeature-provider/go/wasm/ doesn't match the built version."; \
echo ""; \
echo "To fix (using Docker to ensure correct dependencies):"; \
echo " docker build --target wasm-rust-guest.artifact --output type=local,dest=. ."; \
echo " cp confidence_resolver.wasm openfeature-provider/go/wasm/"; \
echo " git add openfeature-provider/go/wasm/confidence_resolver.wasm"; \
echo " git commit -m 'chore: sync WASM module for Go provider'"; \
echo ""; \
echo "Or use the Makefile target:"; \
echo " make sync-wasm-go"; \
echo ""; \
exit 1; \
fi; \
echo "✅ WASM files are in sync"

# ==============================================================================
# Test OpenFeature Provider (Go)
# ==============================================================================
FROM openfeature-provider-go-base AS openfeature-provider-go.test

RUN make test

# ==============================================================================
# Lint OpenFeature Provider (Go)
# ==============================================================================
FROM openfeature-provider-go-base AS openfeature-provider-go.lint

RUN make lint

# ==============================================================================
# Build OpenFeature Provider (Go)
# ==============================================================================
FROM openfeature-provider-go-base AS openfeature-provider-go.build

RUN make build

# ==============================================================================
# OpenFeature Provider (Java) - Build and test
# ==============================================================================
Expand Down Expand Up @@ -511,19 +600,25 @@ COPY --from=wasm-msg.test /workspace/Cargo.toml /markers/test-wasm-msg
COPY --from=openfeature-provider-js.test /app/package.json /markers/test-openfeature-js
COPY --from=openfeature-provider-js.test_e2e /app/package.json /markers/test-openfeature-js-e2e
COPY --from=openfeature-provider-java.test /app/pom.xml /markers/test-openfeature-java
COPY --from=openfeature-provider-go.test /app/go.mod /markers/test-openfeature-go

# Force validation stages to run
COPY --from=openfeature-provider-go.validate-wasm /built/confidence_resolver.wasm /markers/validate-wasm-go

# Force integration test stages to run (host examples)
COPY --from=node-host.test /app/package.json /markers/integration-node
COPY --from=java-host.test /app/pom.xml /markers/integration-java
COPY --from=go-host.test /app/go.mod /markers/integration-go
COPY --from=python-host.test /app/Makefile /markers/integration-python

# Force lint stages to run by copying marker files
# Force lint stages to run by copying marker files
COPY --from=confidence-resolver.lint /workspace/Cargo.toml /markers/lint-resolver
COPY --from=wasm-msg.lint /workspace/Cargo.toml /markers/lint-wasm-msg
COPY --from=wasm-rust-guest.lint /workspace/Cargo.toml /markers/lint-guest
COPY --from=openfeature-provider-go.lint /app/go.mod /markers/lint-openfeature-go
COPY --from=confidence-cloudflare-resolver.lint /workspace/Cargo.toml /markers/lint-cloudflare

# Force build stages to run
COPY --from=openfeature-provider-js.build /app/dist/index.node.js /artifacts/openfeature-js/
COPY --from=openfeature-provider-java.build /app/target/*.jar /artifacts/openfeature-java/
COPY --from=confidence-cloudflare-resolver.lint /workspace/Cargo.toml /markers/lint-cloudflare
COPY --from=openfeature-provider-go.build /app/.build.stamp /artifacts/openfeature-go/
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,27 @@ wasm/confidence_resolver.wasm: $(TARGET_WASM)
@cp -p $(TARGET_WASM) $@
@echo "WASM size: $$(ls -lh $@ | awk '{print $$5}')"

# Sync WASM to Go provider using Docker to ensure correct toolchain
.PHONY: sync-wasm-go
sync-wasm-go:
@echo "Building WASM with Docker to ensure correct dependencies..."
@docker build --target wasm-rust-guest.artifact --output type=local,dest=. .
@echo "Copying to Go provider embedded location..."
@mkdir -p openfeature-provider/go/wasm
@cp confidence_resolver.wasm openfeature-provider/go/wasm/
@rm confidence_resolver.wasm
@echo "✅ WASM synced to openfeature-provider/go/wasm/"
@echo ""
@echo "Don't forget to commit the change:"
@echo " git add openfeature-provider/go/wasm/confidence_resolver.wasm"
@echo " git commit -m 'chore: sync WASM module for Go provider'"

test:
$(MAKE) -C confidence-resolver test
$(MAKE) -C wasm-msg test
$(MAKE) -C openfeature-provider/js test
$(MAKE) -C openfeature-provider/java test
$(MAKE) -C openfeature-provider/go test

integration-test:
$(MAKE) -C wasm/node-host run
Expand All @@ -32,11 +48,13 @@ lint:
$(MAKE) -C wasm-msg lint
$(MAKE) -C wasm/rust-guest lint
$(MAKE) -C confidence-cloudflare-resolver lint
$(MAKE) -C openfeature-provider/go lint
cargo fmt --check -p wasm-msg -p rust-guest -p confidence_resolver -p confidence-cloudflare-resolver

build: wasm/confidence_resolver.wasm
$(MAKE) -C openfeature-provider/js build
$(MAKE) -C openfeature-provider/java build
$(MAKE) -C openfeature-provider/go build

all: lint test build
@echo "✅ All checks passed!"
Expand All @@ -49,5 +67,6 @@ clean:
$(MAKE) -C wasm/python-host clean
$(MAKE) -C openfeature-provider/js clean
$(MAKE) -C openfeature-provider/java clean
$(MAKE) -C openfeature-provider/go clean

.DEFAULT_GOAL := all
2 changes: 2 additions & 0 deletions openfeature-provider/go/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Changelog

20 changes: 20 additions & 0 deletions openfeature-provider/go/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "openfeature-provider-go"
version = "0.0.0"
edition = "2021"
publish = false

# This is a dummy Cargo.toml to enable cargo-workspace plugin tracking
# in release-please. The actual package is built with Go (go.mod).
# This package depends on rust-guest's WASM output.
#
# Note: This dummy package is never actually built - it exists solely for
# release-please dependency tracking via the cargo-workspace plugin.

[lib]
# Dummy library with no source - cargo won't try to build it
path = "Cargo.toml"
crate-type = []

[dependencies]
rust-guest = { path = "../../wasm/rust-guest", version = "0.1.9" }
59 changes: 59 additions & 0 deletions openfeature-provider/go/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# openfeature-provider/go Makefile
# Go OpenFeature local provider

ROOT := $(realpath $(CURDIR)/../..)

# Stamps and directories
BUILD_STAMP := .build.stamp
PROTO_DIR := proto
WASM_ARTIFACT := $(ROOT)/wasm/confidence_resolver.wasm

# Source files
GO_SRC := $(shell find . -name '*.go' -not -path './proto/*' -not -path './demo/*')
PROTO_GEN := $(shell find $(PROTO_DIR) -name '*.pb.go' 2>/dev/null)

.PHONY: install build test lint clean proto

# Always build wasm if not in docker
ifneq ($(IN_DOCKER_BUILD),1)
.PHONY: build-wasm
build-wasm:
@$(MAKE) -C $(ROOT) wasm/confidence_resolver.wasm
$(BUILD_STAMP): | build-wasm
endif

# Install Go dependencies
install:
go mod download
go mod verify

# Generate protobuf files
proto:
./scripts/generate_proto.sh

# Build (compile check)
$(BUILD_STAMP): go.mod go.sum $(GO_SRC) $(PROTO_GEN)
go build ./...
@touch $@

build: $(BUILD_STAMP)

# Run tests
test: $(BUILD_STAMP)
go test -v ./...

# Lint using gofmt and go vet
lint:
@echo "Checking gofmt..."
@test -z "$$(gofmt -l . | grep -v '^proto/' | tee /dev/stderr)" || (echo "Files need formatting. Run: gofmt -w ." && exit 1)
@echo "Running go vet..."
@go vet ./...
@echo "✅ Lint passed"

# Clean build artifacts
clean:
rm -rf $(PROTO_DIR)
rm -f $(BUILD_STAMP)
go clean -cache -testcache -modcache

.DEFAULT_GOAL := build
1 change: 1 addition & 0 deletions openfeature-provider/go/confidence/proto
Loading
Loading