-
Notifications
You must be signed in to change notification settings - Fork 41
/
provider_blobstorage.go
65 lines (55 loc) · 2.27 KB
/
provider_blobstorage.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package gcp
import (
"context"
"fmt"
"github.com/integr8ly/cloud-resource-operator/apis/integreatly/v1alpha1"
"github.com/integr8ly/cloud-resource-operator/apis/integreatly/v1alpha1/types"
"github.com/integr8ly/cloud-resource-operator/pkg/providers"
"github.com/integr8ly/cloud-resource-operator/pkg/resources"
"sigs.k8s.io/controller-runtime/pkg/client"
"time"
)
const blobstorageProviderName = "gcp-storage"
type BlobStorageProvider struct {
Client client.Client
CredentialManager CredentialManager
ConfigManager ConfigManager
}
func NewGCPBlobStorageProvider(client client.Client) *BlobStorageProvider {
return &BlobStorageProvider{
Client: client,
CredentialManager: NewCredentialMinterCredentialManager(client),
ConfigManager: NewDefaultConfigManager(client),
}
}
func (bsp BlobStorageProvider) GetName() string {
return blobstorageProviderName
}
func (bsp BlobStorageProvider) SupportsStrategy(deploymentStrategy string) bool {
return deploymentStrategy == providers.GCPDeploymentStrategy
}
func (bsp BlobStorageProvider) GetReconcileTime(bs *v1alpha1.BlobStorage) time.Duration {
if bs.Status.Phase != types.PhaseComplete {
return time.Second * 60
}
return resources.GetForcedReconcileTimeOrDefault(defaultReconcileTime)
}
func (bsp BlobStorageProvider) CreateStorage(ctx context.Context, bs *v1alpha1.BlobStorage) (*providers.BlobStorageInstance, types.StatusMessage, error) {
_, err := bsp.CredentialManager.ReconcileProviderCredentials(ctx, bs.Namespace)
if err != nil {
errMsg := fmt.Sprintf("failed to reconcile gcp blob storage provider credentials for blob storage instance %s", bs.Name)
return nil, types.StatusMessage(errMsg), fmt.Errorf("%s: %w", errMsg, err)
}
// TODO implement me
return nil, "", nil
}
func (bsp BlobStorageProvider) DeleteStorage(ctx context.Context, bs *v1alpha1.BlobStorage) (types.StatusMessage, error) {
_, err := bsp.CredentialManager.ReconcileProviderCredentials(ctx, bs.Namespace)
if err != nil {
errMsg := fmt.Sprintf("failed to reconcile gcp blob storage provider credentials for blob storage instance %s", bs.Name)
return types.StatusMessage(errMsg), fmt.Errorf("%s: %w", errMsg, err)
}
// TODO implement me
return "", nil
}
var _ providers.BlobStorageProvider = (*BlobStorageProvider)(nil)