Skip to content

Commit

Permalink
Revert "Make testable examples use different DBs (#54)"
Browse files Browse the repository at this point in the history
This reverts commit ea97e8a.
  • Loading branch information
jeyhun committed Aug 7, 2023
1 parent ea97e8a commit 63463fe
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 36 deletions.
25 changes: 7 additions & 18 deletions docs/DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -493,14 +493,10 @@ func main() {
DevInstanceCtx := instancer.WithInstanceId(ServiceAdminCtx, "Dev")
ProdInstanceCtx := instancer.WithInstanceId(ServiceAdminCtx, "Prod")

// Initializes the Datastore using the metadata authorizer and connection details obtained from the ENV variables, except for DB name.
cfg := datastore.ConfigFromEnv("ExampleDataStore_multiInstance" /* dbName */)
if err := datastore.DBCreate(cfg); err != nil {
log.Fatalf("DB creation failed: %s", err)
}
ds, err := datastore.FromConfig(datastore.GetCompLogger(), mdAuthorizer, instancer, cfg)
// Initializes the Datastore using the metadata authorizer and connection details obtained from the ENV variables.
ds, err := datastore.FromEnv(datastore.GetCompLogger(), mdAuthorizer, instancer)
if err != nil {
log.Fatalf("datastore initialization from config errored: %s", err)
log.Fatalf("datastore initialization from env errored: %s", err)
}

// Registers the necessary structs with their corresponding role mappings.
Expand Down Expand Up @@ -616,14 +612,10 @@ func main() {
CokeOrgCtx := mdAuthorizer.GetAuthContext("Coke", TENANT_ADMIN)
PepsiOrgCtx := mdAuthorizer.GetAuthContext("Pepsi", TENANT_ADMIN)

// Initializes the Datastore using the metadata authorizer and connection details obtained from the ENV variables, except for DB name.
cfg := datastore.ConfigFromEnv("ExampleDataStore_multiTenancy" /* dbName */)
if err := datastore.DBCreate(cfg); err != nil {
log.Fatalf("DB creation failed: %s", err)
}
ds, err := datastore.FromConfig(datastore.GetCompLogger(), mdAuthorizer, nil /* instancer */, cfg)
// Initializes the Datastore using the metadata authorizer and connection details obtained from the ENV variables.
ds, err := datastore.FromEnv(datastore.GetCompLogger(), mdAuthorizer, nil)
if err != nil {
log.Fatalf("datastore initialization from config errored: %s", err)
log.Fatalf("datastore initialization from env errored: %s", err)
}

// Registers the necessary structs with their corresponding tenant role mappings.
Expand Down Expand Up @@ -1138,10 +1130,7 @@ func main() {
// Initialize protostore with proper logger, authorizer and datastore
myLogger := datastore.GetCompLogger()
mdAuthorizer := authorizer.MetadataBasedAuthorizer{}

cfg := datastore.ConfigFromEnv("ExampleProtoStore" /* dbName */)
_ = datastore.DBCreate(cfg)
myDatastore, _ := datastore.FromConfig(myLogger, mdAuthorizer, nil /* instancer */, cfg)
myDatastore, _ := datastore.FromEnv(myLogger, mdAuthorizer, nil)
ctx := mdAuthorizer.GetAuthContext("Coke", "service_admin")
myProtostore := protostore.GetProtoStore(myLogger, myDatastore)

Expand Down
10 changes: 3 additions & 7 deletions pkg/datastore/example_multiinstance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,10 @@ func ExampleDataStore_multiInstance() {
DevInstanceCtx := instancer.WithInstanceId(ServiceAdminCtx, "Dev")
ProdInstanceCtx := instancer.WithInstanceId(ServiceAdminCtx, "Prod")

// Initializes the Datastore using the metadata authorizer and connection details obtained from the ENV variables, except for DB name.
cfg := datastore.ConfigFromEnv("ExampleDataStore_multiInstance" /* dbName */)
if err := datastore.DBCreate(cfg); err != nil {
log.Fatalf("DB creation failed: %s", err)
}
ds, err := datastore.FromConfig(datastore.GetCompLogger(), mdAuthorizer, instancer, cfg)
// Initializes the Datastore using the metadata authorizer and connection details obtained from the ENV variables.
ds, err := datastore.FromEnv(datastore.GetCompLogger(), mdAuthorizer, instancer)
if err != nil {
log.Fatalf("datastore initialization from config errored: %s", err)
log.Fatalf("datastore initialization from env errored: %s", err)
}

// Registers the necessary structs with their corresponding role mappings.
Expand Down
10 changes: 3 additions & 7 deletions pkg/datastore/example_multitenancy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,10 @@ func ExampleDataStore_multiTenancy() {
CokeOrgCtx := mdAuthorizer.GetAuthContext("Coke", TENANT_ADMIN)
PepsiOrgCtx := mdAuthorizer.GetAuthContext("Pepsi", TENANT_ADMIN)

// Initializes the Datastore using the metadata authorizer and connection details obtained from the ENV variables, except for DB name.
cfg := datastore.ConfigFromEnv("ExampleDataStore_multiTenancy" /* dbName */)
if err := datastore.DBCreate(cfg); err != nil {
log.Fatalf("DB creation failed: %s", err)
}
ds, err := datastore.FromConfig(datastore.GetCompLogger(), mdAuthorizer, nil /* instancer */, cfg)
// Initializes the Datastore using the metadata authorizer and connection details obtained from the ENV variables.
ds, err := datastore.FromEnv(datastore.GetCompLogger(), mdAuthorizer, nil)
if err != nil {
log.Fatalf("datastore initialization from config errored: %s", err)
log.Fatalf("datastore initialization from env errored: %s", err)
}

// Registers the necessary structs with their corresponding tenant role mappings.
Expand Down
5 changes: 1 addition & 4 deletions pkg/protostore/example_protostore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ func ExampleProtoStore() {
// Initialize protostore with proper logger, authorizer and datastore
myLogger := datastore.GetCompLogger()
mdAuthorizer := authorizer.MetadataBasedAuthorizer{}

cfg := datastore.ConfigFromEnv("ExampleProtoStore" /* dbName */)
_ = datastore.DBCreate(cfg)
myDatastore, _ := datastore.FromConfig(myLogger, mdAuthorizer, nil /* instancer */, cfg)
myDatastore, _ := datastore.FromEnv(myLogger, mdAuthorizer, nil)
ctx := mdAuthorizer.GetAuthContext("Coke", "service_admin")
myProtostore := protostore.GetProtoStore(myLogger, myDatastore)

Expand Down

0 comments on commit 63463fe

Please sign in to comment.