Skip to content

Commit

Permalink
moving actions into sub-package
Browse files Browse the repository at this point in the history
  • Loading branch information
jpflueger committed May 29, 2020
1 parent c5cf5df commit 746b099
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion config/samples/azure_v1alpha1_rediscacheaction.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: RedisCacheAction
metadata:
name: rediscacheaction-sample-1
spec:
resourceGroup: resourcegroup-azure-operators
resourceGroup: jupflueg-aso-rg
cacheName: rediscache-sample-1

# possible values are 'rollallkeys', 'rollprimarykey', 'rollsecondarykey'
Expand Down
4 changes: 2 additions & 2 deletions config/samples/azure_v1alpha1_resourcegroup.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: azure.microsoft.com/v1alpha1
kind: ResourceGroup
metadata:
name: resourcegroup-azure-operators
name: jupflueg-aso-rg
spec:
location: "westus"
location: eastus
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
psqlserver "github.com/Azure/azure-service-operator/pkg/resourcemanager/psql/server"
psqlvnetrule "github.com/Azure/azure-service-operator/pkg/resourcemanager/psql/vnetrule"
rediscache "github.com/Azure/azure-service-operator/pkg/resourcemanager/rediscaches"
rediscacheactions "github.com/Azure/azure-service-operator/pkg/resourcemanager/rediscaches/actions"
resourcemanagerresourcegroup "github.com/Azure/azure-service-operator/pkg/resourcemanager/resourcegroups"
blobContainerManager "github.com/Azure/azure-service-operator/pkg/resourcemanager/storages/blobcontainer"
storageaccountManager "github.com/Azure/azure-service-operator/pkg/resourcemanager/storages/storageaccount"
Expand Down Expand Up @@ -142,7 +143,7 @@ func main() {
secretClient,
scheme,
)
redisCacheActionManager := rediscache.NewAzureRedisCacheActionManager(
redisCacheActionManager := rediscacheactions.NewAzureRedisCacheActionManager(
secretClient,
scheme,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

package rediscaches
package actions

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

package rediscaches
package actions

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

package rediscaches
package actions

import (
"context"

"github.com/Azure/azure-service-operator/pkg/resourcemanager/rediscaches"
"github.com/Azure/azure-service-operator/pkg/secrets"

model "github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2018-03-01/redis"
Expand All @@ -15,13 +16,13 @@ import (

// AzureRedisCacheActionManager creates a new RedisCacheManager
type AzureRedisCacheActionManager struct {
AzureRedisManager
rediscaches.AzureRedisManager
}

// NewAzureRedisCacheActionManager creates a new RedisCacheManager
func NewAzureRedisCacheActionManager(secretClient secrets.SecretClient, scheme *runtime.Scheme) *AzureRedisCacheActionManager {
return &AzureRedisCacheActionManager{
AzureRedisManager{
rediscaches.AzureRedisManager{
SecretClient: secretClient,
Scheme: scheme,
},
Expand All @@ -30,7 +31,7 @@ func NewAzureRedisCacheActionManager(secretClient secrets.SecretClient, scheme *

// RegeneratePrimaryAccessKey regenerates either the primary or secondary access keys
func (r *AzureRedisCacheActionManager) RegeneratePrimaryAccessKey(ctx context.Context, resourceGroup string, cacheName string) error {
client, err := getRedisCacheClient()
client, err := r.GetRedisCacheClient()
if err != nil {
return err
}
Expand All @@ -47,7 +48,7 @@ func (r *AzureRedisCacheActionManager) RegeneratePrimaryAccessKey(ctx context.Co

// RegenerateSecondaryAccessKey regenerates either the primary or secondary access keys
func (r *AzureRedisCacheActionManager) RegenerateSecondaryAccessKey(ctx context.Context, resourceGroup string, cacheName string) error {
client, err := getRedisCacheClient()
client, err := r.GetRedisCacheClient()
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/resourcemanager/rediscaches/rediscaches.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (r *AzureRedisCacheManager) CreateRedisCache(
// convert kube labels to expected tag format
tags := helpers.LabelsToTags(instance.GetLabels())

redisClient, err := getRedisCacheClient()
redisClient, err := r.GetRedisCacheClient()
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -110,7 +110,7 @@ func (r *AzureRedisCacheManager) CreateRedisCache(

// GetRedisCache returns a redis cache object if it exists
func (r *AzureRedisCacheManager) GetRedisCache(ctx context.Context, groupName string, redisCacheName string) (result redis.ResourceType, err error) {
redisClient, err := getRedisCacheClient()
redisClient, err := r.GetRedisCacheClient()
if err != nil {
return result, err
}
Expand All @@ -119,7 +119,7 @@ func (r *AzureRedisCacheManager) GetRedisCache(ctx context.Context, groupName st

// DeleteRedisCache removes the resource group named by env var
func (r *AzureRedisCacheManager) DeleteRedisCache(ctx context.Context, groupName string, redisCacheName string) (result redis.DeleteFuture, err error) {
redisClient, err := getRedisCacheClient()
redisClient, err := r.GetRedisCacheClient()
if err != nil {
return result, err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/resourcemanager/rediscaches/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type AzureRedisManager struct {
Scheme *runtime.Scheme
}

func getRedisCacheClient() (redis.Client, error) {
func (r *AzureRedisManager) GetRedisCacheClient() (redis.Client, error) {
redisClient := redis.NewClientWithBaseURI(config.BaseURI(), config.SubscriptionID())
a, err := iam.GetResourceManagementAuthorizer()
if err != nil {
Expand All @@ -38,7 +38,7 @@ func getRedisCacheClient() (redis.Client, error) {

//ListKeys lists the keys for redis cache
func (r *AzureRedisManager) ListKeys(ctx context.Context, resourceGroupName string, redisCacheName string) (result redis.AccessKeys, err error) {
redisClient, err := getRedisCacheClient()
redisClient, err := r.GetRedisCacheClient()
if err != nil {
return result, err
}
Expand Down

0 comments on commit 746b099

Please sign in to comment.