зеркало из https://github.com/Azure/ARO-RP.git
remove unused contexts in database layer
This commit is contained in:
Родитель
63dc6f8120
Коммит
224a09da61
|
@ -27,7 +27,7 @@ func rp(ctx context.Context, log *logrus.Entry) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
db, err := database.NewDatabase(ctx, env, uuid, "ARO")
|
db, err := database.NewDatabase(env, uuid, "ARO")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ func run(ctx context.Context, log *logrus.Entry) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
db, err := database.NewDatabase(ctx, env, "", "ARO")
|
db, err := database.NewDatabase(env, "", "ARO")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ package database
|
||||||
// Licensed under the Apache License 2.0.
|
// Licensed under the Apache License 2.0.
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -26,7 +25,7 @@ type AsyncOperations interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewAsyncOperations returns a new AsyncOperations
|
// NewAsyncOperations returns a new AsyncOperations
|
||||||
func NewAsyncOperations(ctx context.Context, uuid string, dbc cosmosdb.DatabaseClient, dbid, collid string) (AsyncOperations, error) {
|
func NewAsyncOperations(uuid string, dbc cosmosdb.DatabaseClient, dbid, collid string) (AsyncOperations, error) {
|
||||||
collc := cosmosdb.NewCollectionClient(dbc, dbid)
|
collc := cosmosdb.NewCollectionClient(dbc, dbid)
|
||||||
|
|
||||||
return &asyncOperations{
|
return &asyncOperations{
|
||||||
|
|
|
@ -4,7 +4,6 @@ package database
|
||||||
// Licensed under the Apache License 2.0.
|
// Licensed under the Apache License 2.0.
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
@ -24,8 +23,8 @@ type Database struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDatabase returns a new Database
|
// NewDatabase returns a new Database
|
||||||
func NewDatabase(ctx context.Context, env env.Interface, uuid, dbid string) (db *Database, err error) {
|
func NewDatabase(env env.Interface, uuid, dbid string) (db *Database, err error) {
|
||||||
databaseAccount, masterKey := env.CosmosDB(ctx)
|
databaseAccount, masterKey := env.CosmosDB()
|
||||||
|
|
||||||
h := &codec.JsonHandle{
|
h := &codec.JsonHandle{
|
||||||
BasicHandle: codec.BasicHandle{
|
BasicHandle: codec.BasicHandle{
|
||||||
|
@ -55,17 +54,17 @@ func NewDatabase(ctx context.Context, env env.Interface, uuid, dbid string) (db
|
||||||
|
|
||||||
db = &Database{}
|
db = &Database{}
|
||||||
|
|
||||||
db.AsyncOperations, err = NewAsyncOperations(ctx, uuid, dbc, dbid, "AsyncOperations")
|
db.AsyncOperations, err = NewAsyncOperations(uuid, dbc, dbid, "AsyncOperations")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
db.OpenShiftClusters, err = NewOpenShiftClusters(ctx, uuid, dbc, dbid, "OpenShiftClusters")
|
db.OpenShiftClusters, err = NewOpenShiftClusters(uuid, dbc, dbid, "OpenShiftClusters")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
db.Subscriptions, err = NewSubscriptions(ctx, uuid, dbc, dbid, "Subscriptions")
|
db.Subscriptions, err = NewSubscriptions(uuid, dbc, dbid, "Subscriptions")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ package database
|
||||||
// Licensed under the Apache License 2.0.
|
// Licensed under the Apache License 2.0.
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -34,7 +33,7 @@ type OpenShiftClusters interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewOpenShiftClusters returns a new OpenShiftClusters
|
// NewOpenShiftClusters returns a new OpenShiftClusters
|
||||||
func NewOpenShiftClusters(ctx context.Context, uuid string, dbc cosmosdb.DatabaseClient, dbid, collid string) (OpenShiftClusters, error) {
|
func NewOpenShiftClusters(uuid string, dbc cosmosdb.DatabaseClient, dbid, collid string) (OpenShiftClusters, error) {
|
||||||
collc := cosmosdb.NewCollectionClient(dbc, dbid)
|
collc := cosmosdb.NewCollectionClient(dbc, dbid)
|
||||||
|
|
||||||
triggers := []*cosmosdb.Trigger{
|
triggers := []*cosmosdb.Trigger{
|
||||||
|
|
|
@ -4,7 +4,6 @@ package database
|
||||||
// Licensed under the Apache License 2.0.
|
// Licensed under the Apache License 2.0.
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -29,7 +28,7 @@ type Subscriptions interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewSubscriptions returns a new Subscriptions
|
// NewSubscriptions returns a new Subscriptions
|
||||||
func NewSubscriptions(ctx context.Context, uuid string, dbc cosmosdb.DatabaseClient, dbid, collid string) (Subscriptions, error) {
|
func NewSubscriptions(uuid string, dbc cosmosdb.DatabaseClient, dbid, collid string) (Subscriptions, error) {
|
||||||
collc := cosmosdb.NewCollectionClient(dbc, dbid)
|
collc := cosmosdb.NewCollectionClient(dbc, dbid)
|
||||||
|
|
||||||
triggers := []*cosmosdb.Trigger{
|
triggers := []*cosmosdb.Trigger{
|
||||||
|
|
|
@ -23,7 +23,7 @@ type Interface interface {
|
||||||
clientauthorizer.ClientAuthorizer
|
clientauthorizer.ClientAuthorizer
|
||||||
instancemetadata.InstanceMetadata
|
instancemetadata.InstanceMetadata
|
||||||
|
|
||||||
CosmosDB(context.Context) (string, string)
|
CosmosDB() (string, string)
|
||||||
DNS() dns.Manager
|
DNS() dns.Manager
|
||||||
FPAuthorizer(string, string) (autorest.Authorizer, error)
|
FPAuthorizer(string, string) (autorest.Authorizer, error)
|
||||||
GetSecret(context.Context, string) (*rsa.PrivateKey, []*x509.Certificate, error)
|
GetSecret(context.Context, string) (*rsa.PrivateKey, []*x509.Certificate, error)
|
||||||
|
|
|
@ -138,7 +138,7 @@ func (p *prod) populateCosmosDB(ctx context.Context, rpAuthorizer autorest.Autho
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *prod) CosmosDB(context.Context) (string, string) {
|
func (p *prod) CosmosDB() (string, string) {
|
||||||
return p.cosmosDBAccountName, p.cosmosDBPrimaryMasterKey
|
return p.cosmosDBAccountName, p.cosmosDBPrimaryMasterKey
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче