зеркало из https://github.com/Azure/ARO-RP.git
stop passing request around
This commit is contained in:
Родитель
d17c42fd4a
Коммит
f263d0785b
|
@ -14,13 +14,13 @@ import (
|
||||||
"github.com/Azure/ARO-RP/pkg/api"
|
"github.com/Azure/ARO-RP/pkg/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (f *frontend) newAsyncOperation(ctx context.Context, r *http.Request, doc *api.OpenShiftClusterDocument) (string, error) {
|
func (f *frontend) newAsyncOperation(ctx context.Context, vars map[string]string, doc *api.OpenShiftClusterDocument) (string, error) {
|
||||||
id := f.dbAsyncOperations.NewUUID()
|
id := f.dbAsyncOperations.NewUUID()
|
||||||
_, err := f.dbAsyncOperations.Create(ctx, &api.AsyncOperationDocument{
|
_, err := f.dbAsyncOperations.Create(ctx, &api.AsyncOperationDocument{
|
||||||
ID: id,
|
ID: id,
|
||||||
OpenShiftClusterKey: doc.Key,
|
OpenShiftClusterKey: doc.Key,
|
||||||
AsyncOperation: &api.AsyncOperation{
|
AsyncOperation: &api.AsyncOperation{
|
||||||
ID: f.operationsPath(r, id),
|
ID: f.operationsPath(vars, id),
|
||||||
Name: id,
|
Name: id,
|
||||||
InitialProvisioningState: doc.OpenShiftCluster.Properties.ProvisioningState,
|
InitialProvisioningState: doc.OpenShiftCluster.Properties.ProvisioningState,
|
||||||
ProvisioningState: doc.OpenShiftCluster.Properties.ProvisioningState,
|
ProvisioningState: doc.OpenShiftCluster.Properties.ProvisioningState,
|
||||||
|
@ -34,9 +34,7 @@ func (f *frontend) newAsyncOperation(ctx context.Context, r *http.Request, doc *
|
||||||
return id, nil
|
return id, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *frontend) operationsPath(r *http.Request, id string) string {
|
func (f *frontend) operationsPath(vars map[string]string, id string) string {
|
||||||
vars := mux.Vars(r)
|
|
||||||
|
|
||||||
return "/subscriptions/" + vars["subscriptionId"] + "/providers/" + vars["resourceProviderNamespace"] + "/locations/" + strings.ToLower(f.env.Location()) + "/operationsstatus/" + id
|
return "/subscriptions/" + vars["subscriptionId"] + "/providers/" + vars["resourceProviderNamespace"] + "/locations/" + strings.ToLower(f.env.Location()) + "/operationsstatus/" + id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
|
"github.com/gorilla/mux"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/Azure/ARO-RP/pkg/api"
|
"github.com/Azure/ARO-RP/pkg/api"
|
||||||
|
@ -51,7 +52,7 @@ func (f *frontend) _deleteOpenShiftCluster(ctx context.Context, r *http.Request,
|
||||||
doc.CorrelationData = correlationData
|
doc.CorrelationData = correlationData
|
||||||
doc.Dequeues = 0
|
doc.Dequeues = 0
|
||||||
|
|
||||||
doc.AsyncOperationID, err = f.newAsyncOperation(ctx, r, doc)
|
doc.AsyncOperationID, err = f.newAsyncOperation(ctx, mux.Vars(r), doc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -66,7 +67,7 @@ func (f *frontend) _deleteOpenShiftCluster(ctx context.Context, r *http.Request,
|
||||||
u.Path = f.operationResultsPath(r, doc.AsyncOperationID)
|
u.Path = f.operationResultsPath(r, doc.AsyncOperationID)
|
||||||
(*header)["Location"] = []string{u.String()}
|
(*header)["Location"] = []string{u.String()}
|
||||||
|
|
||||||
u.Path = f.operationsPath(r, doc.AsyncOperationID)
|
u.Path = f.operationsPath(mux.Vars(r), doc.AsyncOperationID)
|
||||||
(*header)["Azure-AsyncOperation"] = []string{u.String()}
|
(*header)["Azure-AsyncOperation"] = []string{u.String()}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -48,7 +48,6 @@ func (f *frontend) putOrPatchOpenShiftCluster(w http.ResponseWriter, r *http.Req
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *frontend) _putOrPatchOpenShiftCluster(ctx context.Context, log *logrus.Entry, body []byte, correlationData *api.CorrelationData, systemData *api.SystemData, path, originalPath, method, referer string, header *http.Header, converter api.OpenShiftClusterConverter, staticValidator api.OpenShiftClusterStaticValidator, vars map[string]string) ([]byte, error) {
|
func (f *frontend) _putOrPatchOpenShiftCluster(ctx context.Context, log *logrus.Entry, body []byte, correlationData *api.CorrelationData, systemData *api.SystemData, path, originalPath, method, referer string, header *http.Header, converter api.OpenShiftClusterConverter, staticValidator api.OpenShiftClusterStaticValidator, vars map[string]string) ([]byte, error) {
|
||||||
|
|
||||||
_, err := f.validateSubscriptionState(ctx, path, api.SubscriptionStateRegistered)
|
_, err := f.validateSubscriptionState(ctx, path, api.SubscriptionStateRegistered)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Загрузка…
Ссылка в новой задаче