generated from kyma-project/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: AzureRwxBackup Clients (#1047)
- Loading branch information
Showing
9 changed files
with
212 additions
and
4 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package client | ||
|
||
import ( | ||
"context" | ||
"github.com/Azure/azure-sdk-for-go/sdk/azidentity" | ||
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/recoveryservices/armrecoveryservicesbackup/v4" | ||
) | ||
|
||
type BackupClient interface { | ||
TriggerBackup(ctx context.Context) | ||
} | ||
|
||
type backupClient struct { | ||
*armrecoveryservicesbackup.BackupsClient | ||
} | ||
|
||
func NewBackupClient(subscriptionId string, cred *azidentity.ClientSecretCredential) (BackupClient, error) { | ||
|
||
bc, err := armrecoveryservicesbackup.NewBackupsClient(subscriptionId, cred, nil) | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return backupClient{bc}, nil | ||
} | ||
|
||
func (c backupClient) TriggerBackup(ctx context.Context) { | ||
// TODO: trigger logic here | ||
} |
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,63 @@ | ||
package client | ||
|
||
import ( | ||
"context" | ||
"github.com/Azure/azure-sdk-for-go/sdk/azidentity" | ||
azureclient "github.com/kyma-project/cloud-manager/pkg/kcp/provider/azure/client" | ||
) | ||
|
||
type Client interface { | ||
VaultClient | ||
BackupClient | ||
ProtectionPoliciesClient | ||
RecoveryPointClient | ||
} | ||
|
||
type client struct { | ||
VaultClient | ||
BackupClient | ||
ProtectionPoliciesClient | ||
RecoveryPointClient | ||
} | ||
|
||
func NewClientProvider() azureclient.ClientProvider[Client] { | ||
|
||
return func(ctx context.Context, clientId, clientSecret, subscriptionId, tenantId string) (Client, error) { | ||
var c Client | ||
cred, err := azidentity.NewClientSecretCredential(tenantId, clientId, clientSecret, &azidentity.ClientSecretCredentialOptions{}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
vc, err := NewVaultClient(subscriptionId, cred) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
bc, err := NewBackupClient(subscriptionId, cred) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
ppc, err := NewProtectionPoliciesClient(subscriptionId, cred) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
rpc, err := NewRecoveryPointClient(subscriptionId, cred) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
c = client{ | ||
vc, | ||
bc, | ||
ppc, | ||
rpc, | ||
} | ||
|
||
return c, nil | ||
|
||
} | ||
|
||
} |
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,35 @@ | ||
package client | ||
|
||
import ( | ||
"context" | ||
"github.com/Azure/azure-sdk-for-go/sdk/azidentity" | ||
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/recoveryservices/armrecoveryservicesbackup/v4" | ||
) | ||
|
||
type ProtectionPoliciesClient interface { | ||
CreateBackupPolicy(ctx context.Context) | ||
DeleteBackupPolicy(ctx context.Context) | ||
} | ||
|
||
type protectionPoliciesClient struct { | ||
*armrecoveryservicesbackup.ProtectionPoliciesClient | ||
} | ||
|
||
func NewProtectionPoliciesClient(subscriptionId string, cred *azidentity.ClientSecretCredential) (ProtectionPoliciesClient, error) { | ||
|
||
ppc, err := armrecoveryservicesbackup.NewProtectionPoliciesClient(subscriptionId, cred, nil) | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return protectionPoliciesClient{ppc}, nil | ||
} | ||
|
||
func (c protectionPoliciesClient) CreateBackupPolicy(ctx context.Context) { | ||
// TODO: implementation details | ||
} | ||
|
||
func (c protectionPoliciesClient) DeleteBackupPolicy(ctx context.Context) { | ||
// TODO: implementation details | ||
} |
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,33 @@ | ||
package client | ||
|
||
import ( | ||
"context" | ||
"github.com/Azure/azure-sdk-for-go/sdk/azidentity" | ||
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/recoveryservices/armrecoveryservicesbackup/v4" | ||
) | ||
|
||
type RecoveryPointClient interface { | ||
GetRecoveryPoint(ctx context.Context) | ||
ListRecoveryPoints(ctx context.Context) | ||
} | ||
|
||
type recoveryPointClient struct { | ||
*armrecoveryservicesbackup.RecoveryPointsClient | ||
} | ||
|
||
func NewRecoveryPointClient(subscriptionId string, cred *azidentity.ClientSecretCredential) (RecoveryPointClient, error) { | ||
|
||
rpc, err := armrecoveryservicesbackup.NewRecoveryPointsClient(subscriptionId, cred, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return recoveryPointClient{rpc}, nil | ||
} | ||
|
||
func (c recoveryPointClient) GetRecoveryPoint(ctx context.Context) { | ||
// TODO: implementation details | ||
} | ||
func (c recoveryPointClient) ListRecoveryPoints(ctx context.Context) { | ||
// TODO: implementation details | ||
} |
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,34 @@ | ||
package client | ||
|
||
import ( | ||
"context" | ||
"github.com/Azure/azure-sdk-for-go/sdk/azidentity" | ||
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/recoveryservices/armrecoveryservices" | ||
) | ||
|
||
type VaultClient interface { | ||
CreateVault(ctx context.Context) | ||
DeleteVault(ctx context.Context) | ||
} | ||
|
||
type vaultClient struct { | ||
*armrecoveryservices.VaultsClient | ||
} | ||
|
||
func NewVaultClient(subscriptionId string, cred *azidentity.ClientSecretCredential) (VaultClient, error) { | ||
|
||
vc, err := armrecoveryservices.NewVaultsClient(subscriptionId, cred, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return vaultClient{vc}, nil | ||
} | ||
|
||
func (c vaultClient) CreateVault(ctx context.Context) { | ||
// TODO: implementation details | ||
} | ||
|
||
func (c vaultClient) DeleteVault(ctx context.Context) { | ||
// TODO: implementation details | ||
} |