Skip to content
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

chore: change environment_namespace variable name to environment_id #1457

Merged
merged 2 commits into from
Jan 20, 2025
Merged
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
6 changes: 3 additions & 3 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ SERVICE_TOKEN_PATH=/workspaces/bucketeer/tools/dev/cert/service-token \
API_KEY_NAME="e2e-test-$(date +%s)-client" \
API_KEY_PATH=/workspaces/bucketeer/tools/dev/cert/api_key_client \
API_KEY_ROLE=SDK_CLIENT \
ENVIRONMENT_NAMESPACE=e2e \
ENVIRONMENT_ID=e2e \
make create-api-key
```

Expand All @@ -91,7 +91,7 @@ SERVICE_TOKEN_PATH=/workspaces/bucketeer/tools/dev/cert/service-token \
API_KEY_NAME="e2e-test-$(date +%s)-server" \
API_KEY_PATH=/workspaces/bucketeer/tools/dev/cert/api_key_server \
API_KEY_ROLE=SDK_SERVER \
ENVIRONMENT_NAMESPACE=e2e \
ENVIRONMENT_ID=e2e \
make create-api-key
```

Expand All @@ -105,7 +105,7 @@ GATEWAY_CERT_PATH=/workspaces/bucketeer/tools/dev/cert/tls.crt \
SERVICE_TOKEN_PATH=/workspaces/bucketeer/tools/dev/cert/service-token \
API_KEY_PATH=/workspaces/bucketeer/tools/dev/cert/api_key_client \
API_KEY_SERVER_PATH=/workspaces/bucketeer/tools/dev/cert/api_key_server \
ENVIRONMENT_NAMESPACE=e2e \
ENVIRONMENT_ID=e2e \
ORGANIZATION_ID=default \
make e2e
```
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ create-api-key:
--name=${API_KEY_NAME} \
--role=${API_KEY_ROLE} \
--output=${API_KEY_PATH} \
--environment-namespace=${ENVIRONMENT_NAMESPACE} \
--environment-id=${ENVIRONMENT_ID} \
--no-profile \
--no-gcp-trace-enabled

Expand All @@ -250,7 +250,7 @@ e2e-l4:
-gateway-port=9000 \
-gateway-cert=${GATEWAY_CERT_PATH} \
-service-token=${SERVICE_TOKEN_PATH} \
-environment-namespace=${ENVIRONMENT_NAMESPACE} \
-environment-id=${ENVIRONMENT_ID} \
-test-id=${TEST_ID}

.PHONY: e2e
Expand All @@ -265,7 +265,7 @@ e2e:
-gateway-port=443 \
-gateway-cert=${GATEWAY_CERT_PATH} \
-service-token=${SERVICE_TOKEN_PATH} \
-environment-namespace=${ENVIRONMENT_NAMESPACE} \
-environment-id=${ENVIRONMENT_ID} \
-organization-id=${ORGANIZATION_ID} \
-test-id=${TEST_ID}

Expand Down
2 changes: 1 addition & 1 deletion hack/create-account/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ go run ./hack/create-account create \
--service-token=full-path-to-service-token-file \
--email=email \
--role=role \
--environment-namespace=environment-namespace \
--environment-id=environment-id \
--is-admin(optional) \
--no-profile \
--no-gcp-trace-enabled
Expand Down
24 changes: 12 additions & 12 deletions hack/create-account/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ import (

type command struct {
*kingpin.CmdClause
certPath *string
serviceTokenPath *string
webGatewayAddress *string
email *string
role *string
environmentNamespace *string
organizationID *string
certPath *string
serviceTokenPath *string
webGatewayAddress *string
email *string
role *string
environmentID *string
organizationID *string
}

func registerCommand(r cli.CommandRegistry, p cli.ParentCommand) *command {
Expand All @@ -50,9 +50,9 @@ func registerCommand(r cli.CommandRegistry, p cli.ParentCommand) *command {
webGatewayAddress: cmd.Flag("web-gateway", "Address of web-gateway.").Required().String(),
email: cmd.Flag("email", "The email of an account.").Required().String(),
role: cmd.Flag("role", "The role of an environment.").Required().Enum("VIEWER", "EDITOR"),
environmentNamespace: cmd.Flag(
"environment-namespace",
"The environment namespace for Datestore namespace",
environmentID: cmd.Flag(
"environment-id",
"The environment id for Datestore namespace",
).Required().String(),
organizationID: cmd.Flag("organization-id", "The organization id").Required().String(),
}
Expand All @@ -74,7 +74,7 @@ func (c *command) Run(ctx context.Context, metrics metrics.Metrics, logger *zap.
err = c.createAccount(ctx, client, accountproto.AccountV2_Role_Environment(role))
if err != nil {
logger.Error("Failed to create account", zap.Error(err),
zap.String("environmentNamespace", *c.environmentNamespace))
zap.String("environmentId", *c.environmentID))
return err
}
logger.Info("Account created")
Expand All @@ -88,7 +88,7 @@ func (c *command) createAccount(
) error {
envRoles := []*accountproto.AccountV2_EnvironmentRole{
{
EnvironmentId: *c.environmentNamespace,
EnvironmentId: *c.environmentID,
Role: role,
},
}
Expand Down
2 changes: 1 addition & 1 deletion hack/create-api-key/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ go run ./hack/create-api-key create \
--name=key-name \
--role=key-role \
--output=full-path-to-output-file \
--environment-namespace=environment-namespace \
--environment-id=environment-id \
--no-profile \
--no-gcp-trace-enabled
```
22 changes: 11 additions & 11 deletions hack/create-api-key/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ import (

type command struct {
*kingpin.CmdClause
certPath *string
serviceTokenPath *string
webGatewayAddress *string
name *string
role *string
output *string
environmentNamespace *string
certPath *string
serviceTokenPath *string
webGatewayAddress *string
name *string
role *string
output *string
environmentID *string
}

func registerCommand(r cli.CommandRegistry, p cli.ParentCommand) *command {
Expand All @@ -52,9 +52,9 @@ func registerCommand(r cli.CommandRegistry, p cli.ParentCommand) *command {
role: cmd.Flag(
"role", "The role of key.").Default("SDK_CLIENT").Enum("UNKNOWN", "SDK_CLIENT", "SDK_SERVER"),
output: cmd.Flag("output", "Path of file to write api key.").Required().String(),
environmentNamespace: cmd.Flag(
"environment-namespace",
"The environment namespace to store api key",
environmentID: cmd.Flag(
"environment-id",
"The environment id to store api key",
).Required().String(),
}
r.RegisterCommand(command)
Expand All @@ -77,7 +77,7 @@ func (c *command) Run(ctx context.Context, metrics metrics.Metrics, logger *zap.
Name: *c.name,
Role: accountproto.APIKey_Role(role),
},
EnvironmentId: *c.environmentNamespace,
EnvironmentId: *c.environmentID,
})
if err != nil {
logger.Error("Failed to create api key", zap.Error(err))
Expand Down
4 changes: 2 additions & 2 deletions pkg/account/api/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func (s *AccountService) createAccountV2NoCommand(
CreatedAt: account.CreatedAt,
UpdatedAt: account.UpdatedAt,
},
storage.AdminEnvironmentNamespace,
storage.AdminEnvironmentID,
account,
nil,
)
Expand Down Expand Up @@ -310,7 +310,7 @@ func (s *AccountService) changeExistedAccountV2EnvironmentRoles(
Email: updated.Email,
EnvironmentRoles: updated.EnvironmentRoles,
},
storage.AdminEnvironmentNamespace,
storage.AdminEnvironmentID,
updated,
account,
)
Expand Down
20 changes: 10 additions & 10 deletions pkg/api/api/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ var (
// TODO: Remove project_id.
}, []string{
"project_id", "project_url_code",
"environment_namespace", "environment_url_code", "tag", "evaluation_type",
"environment_id", "environment_url_code", "tag", "evaluation_type",
})
getFeatureFlagsCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Expand All @@ -103,7 +103,7 @@ var (
// TODO: Remove project_id.
}, []string{
"project_id", "project_url_code",
"environment_namespace", "environment_url_code", "tag", "response_type",
"environment_id", "environment_url_code", "tag", "response_type",
})
getSegmentUsersCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Expand All @@ -113,7 +113,7 @@ var (
Help: "Total number of get segment users api requests",
// TODO: Remove project_id.
}, []string{
"project_id", "project_url_code", "environment_namespace", "environment_url_code",
"project_id", "project_url_code", "environment_id", "environment_url_code",
"source_id", "sdk_version", "response_type",
})
requestTotal = prometheus.NewCounterVec(
Expand Down Expand Up @@ -151,7 +151,7 @@ var (
Name: "sdk_get_evaluations_handling_seconds",
Help: "Histogram of get evaluations response latency (seconds).",
Buckets: prometheus.DefBuckets,
}, []string{"environment_namespace", "tag", "state"})
}, []string{"environment_id", "tag", "state"})
// TODO: Remove after deleting api-gateway REST server
sdkGetEvaluationsSizeHistogram = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Expand All @@ -160,46 +160,46 @@ var (
Name: "sdk_get_evaluations_size",
Help: "Histogram of get evaluations response size (byte).",
Buckets: prometheus.DefBuckets,
}, []string{"environment_namespace", "tag", "state"})
}, []string{"environment_id", "tag", "state"})
// TODO: Remove after deleting api-gateway REST server
sdkTimeoutErrorCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: "bucketeer",
Subsystem: "metrics_event",
Name: "sdk_timeout_error_total",
Help: "Total number of sdk timeout errors",
}, []string{"environment_namespace", "tag"})
}, []string{"environment_id", "tag"})
// TODO: Remove after deleting api-gateway REST server
sdkInternalErrorCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: "bucketeer",
Subsystem: "metrics_event",
Name: "sdk_internal_error_total",
Help: "Total number of sdk internal errors",
}, []string{"environment_namespace", "tag"})
}, []string{"environment_id", "tag"})
sdkLatencyHistogram = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: "bucketeer",
Subsystem: "metrics_event",
Name: "sdk_api_handling_seconds",
Help: "Histogram of get evaluations response latency (seconds).",
Buckets: prometheus.DefBuckets,
}, []string{"project_id", "environment_namespace", "tag", "api", "sdk_version", "source_id"})
}, []string{"project_id", "environment_id", "tag", "api", "sdk_version", "source_id"})
sdkSizeHistogram = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: "bucketeer",
Subsystem: "metrics_event",
Name: "sdk_api_response_size",
Help: "Histogram of get evaluations response size (byte).",
Buckets: prometheus.DefBuckets,
}, []string{"project_id", "environment_namespace", "tag", "api", "sdk_version", "source_id"})
}, []string{"project_id", "environment_id", "tag", "api", "sdk_version", "source_id"})
sdkErrorCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: "bucketeer",
Subsystem: "metrics_event",
Name: "sdk_api_error_total",
Help: "Total number of sdk errors",
}, []string{"project_id", "environment_namespace", "tag", "error_type", "api", "sdk_version", "source_id"})
}, []string{"project_id", "environment_id", "tag", "error_type", "api", "sdk_version", "source_id"})
)

func registerMetrics(r metrics.Registerer) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/api/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (s *grpcGatewayService) ListPushes(
if res == nil {
s.logger.Error("Failed to list pushes: nil response",
log.FieldsFromImcomingContext(ctx).AddFields(
zap.String("environment_namespace", envAPIKey.Environment.Id),
zap.String("environment_id", envAPIKey.Environment.Id),
zap.String("search_keyword", req.SearchKeyword),
)...,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ func TestFilterKeysOlderThanThirtyOneDays(t *testing.T) {
expectedError: errSubmatchStringNotFound,
},
{
desc: "success: using empty environment namespace",
desc: "success: using empty environment id",
inputEnvNamespace: "",
inputKind: "uc",
inputKeys: []string{
Expand Down
2 changes: 1 addition & 1 deletion pkg/cache/v3/environment_api_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@ func (c *environmentAPIKeyCache) Put(environmentAPIKey *accountproto.Environment
}

func (c *environmentAPIKeyCache) key(id string) string {
// always use AdminEnvironmentNamespace because we'd like to get APIKey and environment_id only by id
// always use AdminEnvironmentId because we'd like to get APIKey and environment_id only by id
return cache.MakeKey(environmentAPIKeyKind, id, storage.AdminEnvironmentID)
}
2 changes: 1 addition & 1 deletion pkg/role/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func CheckEnvironmentRole(
if token.IsSystemAdmin {
return checkRole(token.Email, token.Name, accountproto.AccountV2_Role_Environment_EDITOR, requiredRole, true)
}
// get account for the environment namespace
// get account for the environment id
account, err := getAccountFunc(token.Email)
if err != nil {
if code := status.Code(err); code == codes.NotFound {
Expand Down
3 changes: 1 addition & 2 deletions pkg/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ import (
)

const (
AdminEnvironmentNamespace = ""
AdminEnvironmentID = ""
AdminEnvironmentID = ""

OrderDirectionAsc OrderDirection = 0
OrderDirectionDesc OrderDirection = 1
Expand Down
24 changes: 12 additions & 12 deletions test/e2e/account/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@ const (
)

var (
webGatewayAddr = flag.String("web-gateway-addr", "", "Web gateway endpoint address")
webGatewayPort = flag.Int("web-gateway-port", 443, "Web gateway endpoint port")
webGatewayCert = flag.String("web-gateway-cert", "", "Web gateway crt file")
apiKeyPath = flag.String("api-key", "", "Client SDK API key for api-gateway")
apiKeyServerPath = flag.String("api-key-server", "", "Server SDK API key for api-gateway")
gatewayAddr = flag.String("gateway-addr", "", "Gateway endpoint address")
gatewayPort = flag.Int("gateway-port", 443, "Gateway endpoint port")
gatewayCert = flag.String("gateway-cert", "", "Gateway crt file")
serviceTokenPath = flag.String("service-token", "", "Service token path")
environmentNamespace = flag.String("environment-namespace", "", "Environment namespace")
organizationID = flag.String("organization-id", "", "Organization ID")
testID = flag.String("test-id", "", "test ID")
webGatewayAddr = flag.String("web-gateway-addr", "", "Web gateway endpoint address")
webGatewayPort = flag.Int("web-gateway-port", 443, "Web gateway endpoint port")
webGatewayCert = flag.String("web-gateway-cert", "", "Web gateway crt file")
apiKeyPath = flag.String("api-key", "", "Client SDK API key for api-gateway")
apiKeyServerPath = flag.String("api-key-server", "", "Server SDK API key for api-gateway")
gatewayAddr = flag.String("gateway-addr", "", "Gateway endpoint address")
gatewayPort = flag.Int("gateway-port", 443, "Gateway endpoint port")
gatewayCert = flag.String("gateway-cert", "", "Gateway crt file")
serviceTokenPath = flag.String("service-token", "", "Service token path")
environmentID = flag.String("environment-id", "", "Environment id")
organizationID = flag.String("organization-id", "", "Organization ID")
testID = flag.String("test-id", "", "test ID")
)

func TestGetAccount(t *testing.T) {
Expand Down
Loading
Loading