2019-12-22 04:36:30 +03:00
|
|
|
package frontend
|
|
|
|
|
|
|
|
// Copyright (c) Microsoft Corporation.
|
|
|
|
// Licensed under the Apache License 2.0.
|
|
|
|
|
|
|
|
import (
|
2020-01-06 18:26:31 +03:00
|
|
|
"context"
|
2019-12-22 04:36:30 +03:00
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/Azure/ARO-RP/pkg/api"
|
|
|
|
)
|
|
|
|
|
2023-01-18 13:27:27 +03:00
|
|
|
func (f *frontend) newAsyncOperation(ctx context.Context, subId, resourceProviderNamespace string, doc *api.OpenShiftClusterDocument) (string, error) {
|
2024-07-18 01:25:32 +03:00
|
|
|
dbAsyncOperations, err := f.dbGroup.AsyncOperations()
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
|
|
|
|
id := dbAsyncOperations.NewUUID()
|
|
|
|
_, err = dbAsyncOperations.Create(ctx, &api.AsyncOperationDocument{
|
2019-12-22 04:36:30 +03:00
|
|
|
ID: id,
|
|
|
|
OpenShiftClusterKey: doc.Key,
|
|
|
|
AsyncOperation: &api.AsyncOperation{
|
2023-01-18 13:27:27 +03:00
|
|
|
ID: f.operationsPath(subId, resourceProviderNamespace, id),
|
2019-12-22 04:36:30 +03:00
|
|
|
Name: id,
|
|
|
|
InitialProvisioningState: doc.OpenShiftCluster.Properties.ProvisioningState,
|
|
|
|
ProvisioningState: doc.OpenShiftCluster.Properties.ProvisioningState,
|
|
|
|
StartTime: time.Now().UTC(),
|
|
|
|
},
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
|
|
|
|
return id, nil
|
|
|
|
}
|
|
|
|
|
2023-01-18 13:27:27 +03:00
|
|
|
func (f *frontend) operationsPath(subId, resProviderNamespace, id string) string {
|
|
|
|
return "/subscriptions/" + subId + "/providers/" + resProviderNamespace + "/locations/" + strings.ToLower(f.env.Location()) + "/operationsstatus/" + id
|
2019-12-22 04:36:30 +03:00
|
|
|
}
|
|
|
|
|
2023-01-18 13:27:27 +03:00
|
|
|
func (f *frontend) operationResultsPath(subId, resourceProviderNamespace, id string) string {
|
|
|
|
return "/subscriptions/" + subId + "/providers/" + resourceProviderNamespace + "/locations/" + strings.ToLower(f.env.Location()) + "/operationresults/" + id
|
2019-12-22 04:36:30 +03:00
|
|
|
}
|