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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release-please.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ env:
PUBLISHABLE_ITEMS: '["flagd","flagd-proxy"]'
REGISTRY: ghcr.io
REPO_OWNER: ${{ github.repository_owner }}
DEFAULT_GO_VERSION: '~1.25'
DEFAULT_GO_VERSION: "~1.27"
PUBLIC_KEY_FILE: publicKey.pub
GOPRIVATE: buf.build/gen/go

Expand Down
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ FLAGD_PROXY_IMG ?= flagd-proxy:latest
FLAGD_PROXY_IMG_ZD ?= flagd-proxy:zd

DOCS_DIR ?= docs
GOBIN := $(or $(shell go env GOBIN),$(shell go env GOPATH | cut -d: -f1)/bin)

workspace-init: workspace-clean
go work init
Expand Down Expand Up @@ -74,13 +75,13 @@ uninstall:
rm /etc/systemd/system/flagd.service
rm -f $(DESTDIR)$(PREFIX)/bin/flagd
lint:
go install -v github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.7.2
$(foreach module, $(ALL_GO_MOD_DIRS), ${GOPATH}/bin/golangci-lint run $(module)/...;)
go install -v github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.13.0
$(foreach module, $(ALL_GO_MOD_DIRS), ${GOBIN}/golangci-lint run $(module)/...;)
lint-fix:
go install -v github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.7.2
$(foreach module, $(ALL_GO_MOD_DIRS), ${GOPATH}/bin/golangci-lint run --fix $(module)/...;)
go install -v github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.13.0
$(foreach module, $(ALL_GO_MOD_DIRS), ${GOBIN}/golangci-lint run --fix $(module)/...;)
install-mockgen:
go install go.uber.org/mock/mockgen@v0.4.0
go install go.uber.org/mock/mockgen@v0.6.0
mockgen: install-mockgen
cd core; mockgen -source=pkg/sync/http/http_sync.go -destination=pkg/sync/http/mock/http.go -package=syncmock
cd core; mockgen -source=pkg/sync/grpc/grpc_sync.go -destination=pkg/sync/grpc/mock/grpc.go -package=grpcmock
Expand Down
9 changes: 5 additions & 4 deletions core/pkg/evaluator/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ import (
"golang.org/x/exp/maps"
)

type contextKey string

const (
SelectorMetadataKey = "scope"
flagdPropertiesKey = "$flagd"
// targetingKeyKey is used to extract the targetingKey to bucket on in fractional
// evaluation if the user did not supply the optional bucketing property.
targetingKeyKey = "targetingKey"
Disabled = "DISABLED"
ProtoVersionKey = "__flagd.protoVersion__" // used to mark if the request is coming from an older proto source, which has different fallback behavior
targetingKeyKey = "targetingKey"
Disabled = "DISABLED"
ProtoVersionKey contextKey = "__flagd.protoVersion__" // used to mark if the request is coming from an older proto source, which has different fallback behavior
)

func addSchemaResource(compiler *jsonschema.Compiler, url string, schemaData string) error {
Expand Down Expand Up @@ -326,7 +328,6 @@ func resolve[T constraints](ctx context.Context, reqID string, key string, conte
func (je *Resolver) evaluateVariant(ctx context.Context, reqID string, flagKey string, evalCtx map[string]any) (
variant string, variants map[string]interface{}, reason string, metadata map[string]interface{}, err error,
) {

var selector store.Selector
s := ctx.Value(store.SelectorContextKey{})
if s != nil {
Expand Down
114 changes: 58 additions & 56 deletions core/pkg/evaluator/mock/ievaluator.go

Large diffs are not rendered by default.

18 changes: 10 additions & 8 deletions core/pkg/sync/builder/mock/syncbuilder.go

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

1 change: 1 addition & 0 deletions core/pkg/sync/grpc/credentials/mock/builder.go

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

31 changes: 15 additions & 16 deletions core/pkg/sync/grpc/grpc_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/open-feature/flagd/core/pkg/sync"
grpccredential "github.com/open-feature/flagd/core/pkg/sync/grpc/credentials"
_ "github.com/open-feature/flagd/core/pkg/sync/grpc/nameresolvers" // initialize custom resolvers e.g. envoy.Init()
"go.uber.org/zap"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/metadata"
Expand All @@ -39,7 +40,7 @@ type FlagSyncServiceClient interface {
syncv1grpc.FlagSyncServiceClient
}
type FlagSyncServiceClientResponse interface {
syncv1grpc.FlagSyncService_SyncFlagsClient
grpc.ServerStreamingClient[v1.SyncFlagsResponse]
}

type Sync struct {
Expand Down Expand Up @@ -109,7 +110,7 @@ func (g *Sync) contextWithHeaders(ctx context.Context) context.Context {
}

func (g *Sync) ReSync(ctx context.Context, dataSync chan<- sync.DataSync) error {
res, err := g.client.FetchAllFlags(g.contextWithHeaders(ctx), &v1.FetchAllFlagsRequest{ProviderId: g.ProviderID, Selector: g.Selector})
res, err := g.client.FetchAllFlags(g.contextWithHeaders(ctx), &v1.FetchAllFlagsRequest{ProviderId: g.ProviderID, Selector: g.Selector}) //nolint:staticcheck // Deprecated: migrate to Flagd-Selector header
if err != nil {
err = fmt.Errorf("error fetching all flags: %w", err)
g.Logger.Error(err.Error())
Expand All @@ -128,26 +129,24 @@ func (g *Sync) IsReady() bool {
}

func (g *Sync) Sync(ctx context.Context, dataSync chan<- sync.DataSync) error {
g.Logger.Info(fmt.Sprintf("starting sync from %s", g.URI))
g.Logger.Info("starting sync", zap.String("uri", g.URI))

// Initialize SyncFlags client. This fails if server connection establishment fails (ex:- grpc server offline)
g.Logger.Debug(fmt.Sprintf("initial stream connection to %s", g.URI))
syncClient, err := g.client.SyncFlags(g.contextWithHeaders(ctx), &v1.SyncFlagsRequest{ProviderId: g.ProviderID, Selector: g.Selector})
g.Logger.Debug("initial stream connection", zap.String("uri", g.URI))
syncClient, err := g.client.SyncFlags(g.contextWithHeaders(ctx), &v1.SyncFlagsRequest{ProviderId: g.ProviderID, Selector: g.Selector}) //nolint:staticcheck // Deprecated: migrate to Flagd-Selector header
if err != nil {
return fmt.Errorf("unable to sync flags: %w", err)
}

g.Logger.Debug(fmt.Sprintf("watching %s for changes", g.URI))
g.Logger.Debug("watching for changes", zap.String("uri", g.URI))

// Initial stream listening. Error will be logged and continue and retry connection establishment
err = g.handleFlagSync(syncClient, dataSync)
if err == nil {
err = g.handleFlagSync(syncClient, dataSync) //nolint:staticcheck
if err != nil { //nolint:staticcheck
// This should not happen as handleFlagSync expects to return with an error
return nil
g.Logger.Warn("error with stream listener", zap.Error(err))
}

g.Logger.Warn(fmt.Sprintf("error with stream listener: %s", err.Error()))

// retry connection establishment
for {
syncClient, ok := g.connectWithRetry(ctx)
Expand All @@ -156,9 +155,9 @@ func (g *Sync) Sync(ctx context.Context, dataSync chan<- sync.DataSync) error {
return nil
}

err = g.handleFlagSync(syncClient, dataSync)
if err != nil {
g.Logger.Warn(fmt.Sprintf("error with stream listener: %s", err.Error()))
err = g.handleFlagSync(syncClient, dataSync) //nolint:staticcheck
if err != nil { //nolint:staticcheck
g.Logger.Warn("error with stream listener", zap.Error(err))
continue
}
}
Expand Down Expand Up @@ -193,7 +192,7 @@ func (g *Sync) connectWithRetry(

g.Logger.Warn(fmt.Sprintf("connection re-establishment attempt in-progress for grpc target: %s", g.URI))

syncClient, err := g.client.SyncFlags(g.contextWithHeaders(ctx), &v1.SyncFlagsRequest{ProviderId: g.ProviderID, Selector: g.Selector})
syncClient, err := g.client.SyncFlags(g.contextWithHeaders(ctx), &v1.SyncFlagsRequest{ProviderId: g.ProviderID, Selector: g.Selector}) //nolint:staticcheck // Deprecated: migrate to Flagd-Selector header
if err != nil {
g.Logger.Debug(fmt.Sprintf("error opening service client: %s", err.Error()))
continue
Expand All @@ -205,7 +204,7 @@ func (g *Sync) connectWithRetry(
}

// handleFlagSync wraps the stream listening and push updates through dataSync channel
func (g *Sync) handleFlagSync(stream syncv1grpc.FlagSyncService_SyncFlagsClient, dataSync chan<- sync.DataSync) error {
func (g *Sync) handleFlagSync(stream syncv1grpc.FlagSyncService_SyncFlagsClient, dataSync chan<- sync.DataSync) error { //nolint:staticcheck
g.ready.Store(true)

for {
Expand Down
7 changes: 4 additions & 3 deletions core/pkg/sync/grpc/mock/grpc.go

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

1 change: 1 addition & 0 deletions core/pkg/sync/http/mock/http.go

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

2 changes: 1 addition & 1 deletion core/pkg/utils/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

func GenerateSha(body []byte) string {
hasher := sha3.New256()
hasher := sha3.New256() //nolint:govet
hasher.Write(canonicalize(body))
return base64.URLEncoding.EncodeToString(hasher.Sum(nil))
}
Expand Down
2 changes: 1 addition & 1 deletion flagd-proxy/build.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Main Dockerfile for flagd builds
# Build the manager binary
FROM --platform=$BUILDPLATFORM golang:1.25-alpine AS builder
FROM --platform=$BUILDPLATFORM golang:1.27-alpine AS builder

WORKDIR /src

Expand Down
2 changes: 1 addition & 1 deletion flagd-proxy/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/open-feature/flagd/flagd-proxy

go 1.25.5
go 1.27.0

require (
buf.build/gen/go/open-feature/flagd/grpc/go v1.6.1-20260217192757-1388a552fc3c.1
Expand Down
4 changes: 2 additions & 2 deletions flagd-proxy/pkg/service/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (nh *handler) SyncFlags(
defer cancel()
errChan := make(chan error)
dataSync := make(chan sync.DataSync)
nh.syncStore.RegisterSubscription(ctx, request.GetSelector(), request, dataSync, errChan)
nh.syncStore.RegisterSubscription(ctx, request.GetSelector(), request, dataSync, errChan) //nolint:staticcheck // Deprecated: migrate to Flagd-Selector header
for {
select {
case e := <-errChan:
Expand All @@ -52,7 +52,7 @@ func (nh *handler) FetchAllFlags(
ctx context.Context,
request *syncv12.FetchAllFlagsRequest,
) (*syncv12.FetchAllFlagsResponse, error) {
data, err := nh.syncStore.FetchAllFlags(ctx, request, request.GetSelector())
data, err := nh.syncStore.FetchAllFlags(ctx, request, request.GetSelector()) //nolint:staticcheck // Deprecated: migrate to Flagd-Selector header
if err != nil {
return &syncv12.FetchAllFlagsResponse{}, fmt.Errorf("error fetching all flags from sync store: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion flagd/build.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Main Dockerfile for flagd builds
# Build the manager binary
FROM --platform=$BUILDPLATFORM golang:1.25-alpine AS builder
FROM --platform=$BUILDPLATFORM golang:1.27-alpine AS builder

WORKDIR /src

Expand Down
2 changes: 1 addition & 1 deletion flagd/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/open-feature/flagd/flagd

go 1.25.5
go 1.27.0

require (
buf.build/gen/go/open-feature/flagd/connectrpc/go v1.19.1-20260217192757-1388a552fc3c.2
Expand Down
1 change: 1 addition & 0 deletions flagd/pkg/service/flag-evaluation/mock/eventstream.go

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

2 changes: 1 addition & 1 deletion flagd/pkg/service/flag-evaluation/ofrep/ofrep_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func NewOfrepService(
) (*Service, error) {
corsMiddleware := corsmw.New(origins)

var h http.Handler = NewOfrepHandler(
h := NewOfrepHandler(
cfg.Logger,
evaluator,
contextValues,
Expand Down
1 change: 1 addition & 0 deletions flagd/pkg/service/middleware/mock/interface.go

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

2 changes: 1 addition & 1 deletion flagd/profile.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Dockerfile with pprof profiler
# Build the manager binary
FROM --platform=$BUILDPLATFORM golang:1.25-alpine AS builder
FROM --platform=$BUILDPLATFORM golang:1.27-alpine AS builder

WORKDIR /src

Expand Down
Loading