Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More azappconfig cleanup #22209

Merged
merged 2 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions sdk/data/azappconfig/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,11 +473,12 @@ func TestSnapshotListConfigurationSettings(t *testing.T) {

// Cleanup Settings
for _, setting := range Settings {
_, _ = client.DeleteSetting(context.Background(), *setting.Key, nil)
_, err = client.DeleteSetting(context.Background(), *setting.Key, nil)
require.NoError(t, err)
}

// Cleanup Snapshots
_ = CleanupSnapshot(client, snapshotName)
require.NoError(t, CleanupSnapshot(client, snapshotName))
}

func TestGetSnapshots(t *testing.T) {
Expand Down Expand Up @@ -525,7 +526,7 @@ func TestGetSnapshots(t *testing.T) {
// Cleanup Snapshots
for i := 0; i < ssCreateCount; i++ {
cleanSSName := snapshotName + fmt.Sprintf("%d", i)
_ = CleanupSnapshot(client, cleanSSName)
require.NoError(t, CleanupSnapshot(client, cleanSSName))
}
}

Expand All @@ -548,7 +549,7 @@ func TestSnapshotArchive(t *testing.T) {
require.Equal(t, azappconfig.SnapshotStatusArchived, *archiveSnapshot.Snapshot.Status)

//Best effort snapshot cleanup
_ = CleanupSnapshot(client, snapshotName)
require.NoError(t, CleanupSnapshot(client, snapshotName))
}

func TestSnapshotRecover(t *testing.T) {
Expand Down Expand Up @@ -576,7 +577,7 @@ func TestSnapshotRecover(t *testing.T) {
require.Equal(t, azappconfig.SnapshotStatusReady, *readySnapshot.Snapshot.Status)

// Best effort snapshot cleanup
_ = CleanupSnapshot(client, snapshotName)
require.NoError(t, CleanupSnapshot(client, snapshotName))
}

func TestSnapshotCreate(t *testing.T) {
Expand All @@ -591,7 +592,7 @@ func TestSnapshotCreate(t *testing.T) {
require.Equal(t, snapshotName, *snapshot.Name)

// Best effort cleanup snapshot
_ = CleanupSnapshot(client, snapshotName)
require.NoError(t, CleanupSnapshot(client, snapshotName))
}

func CreateSnapshot(c *azappconfig.Client, snapshotName string, sf []azappconfig.SettingFilter) (azappconfig.CreateSnapshotResponse, error) {
Expand All @@ -604,10 +605,8 @@ func CreateSnapshot(c *azappconfig.Client, snapshotName string, sf []azappconfig
}
}

retPer := int64(3600)

opts := &azappconfig.CreateSnapshotOptions{
RetentionPeriod: &retPer,
RetentionPeriod: to.Ptr[int64](3600),
}

//Create a snapshot
Expand All @@ -617,9 +616,6 @@ func CreateSnapshot(c *azappconfig.Client, snapshotName string, sf []azappconfig
return azappconfig.CreateSnapshotResponse{}, err
}

if resp == nil {
return azappconfig.CreateSnapshotResponse{}, fmt.Errorf("resp is nil")
}
snapshot, err := resp.PollUntilDone(context.Background(), &runtime.PollUntilDoneOptions{
Frequency: 1 * time.Second,
})
Expand Down
17 changes: 1 addition & 16 deletions sdk/data/azappconfig/response_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ package azappconfig
import (
"time"

"github.com/Azure/azure-sdk-for-go/sdk/azcore"
"github.com/Azure/azure-sdk-for-go/sdk/data/azappconfig/internal/exported"
)

Expand Down Expand Up @@ -103,7 +102,7 @@ type ListSnapshotsResponse struct {
// CreateSnapshotResponse contains the response from the BeginCreateSnapshot method.
type CreateSnapshotResponse struct {
// Read-Only information about the snapshot retrieved from a Create Snapshot operation.
SnapshotInfo
Snapshot
}

// ListSettingsForSnapshotResponse contains the response from the ListConfigurationSettingsForSnapshot method.
Expand Down Expand Up @@ -148,17 +147,3 @@ type updateSnapshotStatusResponse struct {
// SyncToken contains the information returned from the Sync-Token header response.
SyncToken SyncToken
}

// AzureAppConfigurationClientUpdateSnapshotResponse contains the response from method AzureAppConfigurationClient.UpdateSnapshot.
type AzureAppConfigurationClientUpdateSnapshotResponse struct {
Snapshot

// ETag contains the information returned from the ETag header response.
ETag azcore.ETag

// Link contains the information returned from the Link header response.
Link *string

// SyncToken contains the information returned from the Sync-Token header response.
SyncToken *string
}
29 changes: 0 additions & 29 deletions sdk/data/azappconfig/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,8 @@ import (
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
)

// SnapshotInfo contains the snapshot information returned from a Create Snapshot Request
type SnapshotInfo struct {

// READ-ONLY; The name of the snapshot.
Name *string `json:"name"`

// READ-ONLY; The current status of the snapshot.
Status *SnapshotStatus `json:"status"`

// READ-ONLY; The time that the snapshot was created.
Created *time.Time `json:"created"`

// READ-ONLY; A value representing the current state of the snapshot.
ETag *azcore.ETag `json:"etag"`

// READ-ONLY; The time that the snapshot will expire.
Expires *time.Time `json:"expires"`

// READ-ONLY; The amount of key-values in the snapshot.
ItemsCount *int64 `json:"items_count"`

// READ-ONLY; The size in bytes of the snapshot.
Size *int64 `json:"size"`

// READ-ONLY; The retention period of the snapshot on archive in seconds.
RetentionPeriod *int64 `json:"retention_period"`
}

// Snapshot contains the snapshot information returned from a Get Snapshot Request
type Snapshot struct {

// REQUIRED; A list of filters used to filter the key-values included in the snapshot.
Filters []SettingFilter `json:"filters"`

Expand Down