Skip to content

Commit f49c44e

Browse files
committed
Fix import paths after CMAB revert
When reverting CMAB, Git incorrectly changed some import paths: - Fix plugins/odpcache/registry.go: use pkg/cache instead of pkg/odp/cache - Fix pkg/optimizely/cache.go: use odpCachePkg from pkg/cache - Fix pkg/optimizely/client.go: use pkg/cache import - Add missing GetAttributeKeyByID method to TestProjectConfig These changes align with go-sdk PR #420 which reorganized cache packages.
1 parent 9897427 commit f49c44e

File tree

6 files changed

+30
-5
lines changed

6 files changed

+30
-5
lines changed

pkg/optimizely/cache.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ import (
3333
"github.com/optimizely/agent/pkg/syncer"
3434
"github.com/optimizely/agent/plugins/odpcache"
3535
"github.com/optimizely/agent/plugins/userprofileservice"
36+
odpCachePkg "github.com/optimizely/go-sdk/v2/pkg/cache"
3637
"github.com/optimizely/go-sdk/v2/pkg/client"
3738
sdkconfig "github.com/optimizely/go-sdk/v2/pkg/config"
3839
"github.com/optimizely/go-sdk/v2/pkg/decision"
3940
"github.com/optimizely/go-sdk/v2/pkg/event"
4041
"github.com/optimizely/go-sdk/v2/pkg/logging"
4142
"github.com/optimizely/go-sdk/v2/pkg/odp"
42-
odpCachePkg "github.com/optimizely/go-sdk/v2/pkg/odp/cache"
4343
odpEventPkg "github.com/optimizely/go-sdk/v2/pkg/odp/event"
4444
odpSegmentPkg "github.com/optimizely/go-sdk/v2/pkg/odp/segment"
4545
"github.com/optimizely/go-sdk/v2/pkg/tracing"

pkg/optimizely/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ import (
2424
"go.opentelemetry.io/otel"
2525
"go.opentelemetry.io/otel/attribute"
2626

27+
"github.com/optimizely/go-sdk/v2/pkg/cache"
2728
optimizelyclient "github.com/optimizely/go-sdk/v2/pkg/client"
2829
"github.com/optimizely/go-sdk/v2/pkg/decision"
2930
"github.com/optimizely/go-sdk/v2/pkg/entities"
30-
"github.com/optimizely/go-sdk/v2/pkg/odp/cache"
3131
)
3232

3333
// ErrEntityNotFound is returned when no entity exists with a given key

pkg/optimizely/optimizelytest/config.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ func (c *TestProjectConfig) GetEnvironmentKey() string {
117117
return c.environmentKey
118118
}
119119

120+
// GetRegion returns the region for the project
121+
func (c *TestProjectConfig) GetRegion() string {
122+
return "us-east-1" // default test region
123+
}
124+
120125
// GetEvents returns all events
121126
func (c *TestProjectConfig) GetEvents() (eventList []entities.Event) {
122127
for _, event := range c.EventMap {
@@ -518,6 +523,26 @@ func (c *TestProjectConfig) GetFlagVariationsMap() map[string][]entities.Variati
518523
return c.flagVariationsMap
519524
}
520525

526+
// GetAttributeKeyByID returns the attribute key for the given ID
527+
func (c *TestProjectConfig) GetAttributeKeyByID(id string) (string, error) {
528+
for _, attr := range c.AttributeMap {
529+
if attr.ID == id {
530+
return attr.Key, nil
531+
}
532+
}
533+
return "", fmt.Errorf(`attribute with ID "%s" not found`, id)
534+
}
535+
536+
// GetExperimentByID returns the experiment with the given ID
537+
func (c *TestProjectConfig) GetExperimentByID(experimentID string) (entities.Experiment, error) {
538+
for _, experiment := range c.ExperimentMap {
539+
if experiment.ID == experimentID {
540+
return experiment, nil
541+
}
542+
}
543+
return entities.Experiment{}, fmt.Errorf(`experiment with ID "%s" not found`, experimentID)
544+
}
545+
521546
// NewConfig initializes a new datafile from a json byte array using the default JSON datafile parser
522547
func NewConfig() *TestProjectConfig {
523548
config := &TestProjectConfig{

plugins/odpcache/registry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ package odpcache
2020
import (
2121
"fmt"
2222

23-
"github.com/optimizely/go-sdk/v2/pkg/odp/cache"
23+
"github.com/optimizely/go-sdk/v2/pkg/cache"
2424
)
2525

2626
// Creator type defines a function for creating an instance of a Cache

plugins/odpcache/registry_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ package odpcache
2020
import (
2121
"testing"
2222

23-
"github.com/optimizely/go-sdk/v2/pkg/odp/cache"
23+
"github.com/optimizely/go-sdk/v2/pkg/cache"
2424
"github.com/stretchr/testify/assert"
2525
)
2626

plugins/odpcache/services/in_memory_cache.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ package services
2020
import (
2121
"github.com/optimizely/agent/plugins/odpcache"
2222
"github.com/optimizely/agent/plugins/utils"
23-
"github.com/optimizely/go-sdk/v2/pkg/odp/cache"
23+
"github.com/optimizely/go-sdk/v2/pkg/cache"
2424
)
2525

2626
// InMemoryCache represents the in-memory implementation of Cache interface

0 commit comments

Comments
 (0)