This commit is contained in:
Jeremy Facchetti 2022-09-08 12:09:32 +02:00
Родитель d17c42fd4a
Коммит f263d0785b
3 изменённых файлов: 6 добавлений и 8 удалений

Просмотреть файл

@ -14,13 +14,13 @@ import (
"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()
_, err := f.dbAsyncOperations.Create(ctx, &api.AsyncOperationDocument{
ID: id,
OpenShiftClusterKey: doc.Key,
AsyncOperation: &api.AsyncOperation{
ID: f.operationsPath(r, id),
ID: f.operationsPath(vars, id),
Name: id,
InitialProvisioningState: 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
}
func (f *frontend) operationsPath(r *http.Request, id string) string {
vars := mux.Vars(r)
func (f *frontend) operationsPath(vars map[string]string, id string) string {
return "/subscriptions/" + vars["subscriptionId"] + "/providers/" + vars["resourceProviderNamespace"] + "/locations/" + strings.ToLower(f.env.Location()) + "/operationsstatus/" + id
}

Просмотреть файл

@ -8,6 +8,7 @@ import (
"net/http"
"net/url"
"github.com/gorilla/mux"
"github.com/sirupsen/logrus"
"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.Dequeues = 0
doc.AsyncOperationID, err = f.newAsyncOperation(ctx, r, doc)
doc.AsyncOperationID, err = f.newAsyncOperation(ctx, mux.Vars(r), doc)
if err != nil {
return err
}
@ -66,7 +67,7 @@ func (f *frontend) _deleteOpenShiftCluster(ctx context.Context, r *http.Request,
u.Path = f.operationResultsPath(r, doc.AsyncOperationID)
(*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()}
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) {
_, err := f.validateSubscriptionState(ctx, path, api.SubscriptionStateRegistered)
if err != nil {
return nil, err