-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24688 from hashicorp/f/web-api-swap-apps
`appservice` - update to `go-azure-sdk` and API version `2023-01-01`
- Loading branch information
Showing
90 changed files
with
5,645 additions
and
7,666 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
internal/services/appservice/custompollers/app_service_active_slot_poller.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package custompollers | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"time" | ||
|
||
"github.com/hashicorp/go-azure-helpers/lang/pointer" | ||
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" | ||
"github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/webapps" | ||
"github.com/hashicorp/go-azure-sdk/sdk/client/pollers" | ||
) | ||
|
||
var _ pollers.PollerType = &appServiceActiveSlotPoller{} | ||
|
||
type appServiceActiveSlotPoller struct { | ||
client *webapps.WebAppsClient | ||
id webapps.SlotId | ||
appId commonids.AppServiceId | ||
} | ||
|
||
var ( | ||
pollingSuccess = pollers.PollResult{ | ||
Status: pollers.PollingStatusSucceeded, | ||
PollInterval: 10 * time.Second, | ||
} | ||
pollingInProgress = pollers.PollResult{ | ||
Status: pollers.PollingStatusInProgress, | ||
PollInterval: 10 * time.Second, | ||
} | ||
) | ||
|
||
func NewAppServiceActiveSlotPoller(client *webapps.WebAppsClient, id commonids.AppServiceId, slotId webapps.SlotId) *appServiceActiveSlotPoller { | ||
return &appServiceActiveSlotPoller{ | ||
client: client, | ||
id: slotId, | ||
appId: id, | ||
} | ||
} | ||
|
||
func (p appServiceActiveSlotPoller) Poll(ctx context.Context) (*pollers.PollResult, error) { | ||
resp, err := p.client.Get(ctx, p.appId) | ||
if err == nil { | ||
if resp.Model != nil && resp.Model.Properties != nil { | ||
swapStatus := resp.Model.Properties.SlotSwapStatus | ||
if swapStatus == nil || pointer.From(swapStatus.SourceSlotName) != p.id.SlotName { | ||
return &pollingInProgress, err | ||
} | ||
return &pollingSuccess, nil | ||
} | ||
} | ||
return nil, fmt.Errorf("retrieving %s: %+v", p.appId, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.