Skip to content

Commit 0df15ad

Browse files
committed
refactor controller hooks
1 parent d7e75a4 commit 0df15ad

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2177
-2480
lines changed

Makefile

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ SHELL := /bin/bash # Use bash syntax
33
# Set up variables
44
GO111MODULE=on
55

6-
AWS_SDK_GO_VERSION="$(shell echo $(shell go list -m -f '{{.Version}}' github.com/aws/aws-sdk-go))"
7-
AWS_SDK_GO_VERSIONED_PATH="$(shell echo github.com/aws/aws-sdk-go@$(AWS_SDK_GO_VERSION))"
8-
ELASTICACHE_API_PATH="$(shell echo $(shell go env GOPATH))/pkg/mod/$(AWS_SDK_GO_VERSIONED_PATH)/service/elasticache/elasticacheiface"
9-
SERVICE_CONTROLLER_SRC_PATH="$(shell pwd)"
10-
116
# Build ldflags
127
VERSION ?= "v0.0.0"
138
GITCOMMIT=$(shell git rev-parse HEAD)
@@ -16,34 +11,22 @@ GO_LDFLAGS=-ldflags "-X main.version=$(VERSION) \
1611
-X main.buildHash=$(GITCOMMIT) \
1712
-X main.buildDate=$(BUILDDATE)"
1813

19-
.PHONY: all test local-test clean-mocks mocks
14+
.PHONY: all test local-test
2015

2116
all: test
2217

23-
test: | mocks ## Run code tests
24-
go test -v ./...
18+
local-run-controller: ## Run a controller image locally for SERVICE
19+
@go run ./cmd/controller/main.go \
20+
--aws-region=us-west-2 \
21+
--enable-development-logging \
22+
--log-level=debug
2523

26-
test-cover: | mocks ## Run code tests with resources coverage
27-
go test -coverpkg=./pkg/resource/... -covermode=count -coverprofile=coverage.out ./...
28-
go tool cover -func=coverage.out
24+
test: ## Run code tests
25+
go test -v ./...
2926

30-
local-test: | mocks ## Run code tests using go.local.mod file
27+
local-test: ## Run code tests using go.local.mod file
3128
go test -modfile=go.local.mod -v ./...
3229

33-
clean-mocks: ## Remove mocks directory
34-
rm -rf mocks
35-
36-
install-mockery:
37-
@scripts/install-mockery.sh
38-
39-
mocks: install-mockery ## Build mocks
40-
go get -d $(AWS_SDK_GO_VERSIONED_PATH)
41-
@echo "building mocks for $(ELASTICACHE_API_PATH) ... "
42-
@pushd $(ELASTICACHE_API_PATH) 1>/dev/null; \
43-
$(SERVICE_CONTROLLER_SRC_PATH)/bin/mockery --all --dir=. --output=$(SERVICE_CONTROLLER_SRC_PATH)/mocks/aws-sdk-go/elasticache/ ; \
44-
popd 1>/dev/null;
45-
@echo "ok."
46-
4730
help: ## Show this help.
4831
@grep -F -h "##" $(MAKEFILE_LIST) | grep -F -v grep | sed -e 's/\\$$//' \
49-
| awk -F'[:#]' '{print $$1 = sprintf("%-30s", $$1), $$4}'
32+
| awk -F'[:#]' '{print $$1 = sprintf("%-30s", $$1), $$4}'
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
ack_generate_info:
2-
build_date: "2025-02-07T19:16:11Z"
2+
build_date: "2025-02-11T18:55:56Z"
33
build_hash: 3d74f13b9de7134b4c76ab7526a9c578c4857602
44
go_version: go1.23.4
55
version: v0.41.0-18-g3d74f13
6-
api_directory_checksum: eb643965cba3c68f76c1b45f100874d07d39c935
6+
api_directory_checksum: b78c0279ac10fe3af8f70f5ee45857b33e2e0738
77
api_version: v1alpha1
88
aws_sdk_go_version: v1.32.6
99
generator_config_info:
10-
file_checksum: 3c359b3f45716af86c99ab2ea0f2ab50eeae5dc9
10+
file_checksum: 15f526c333ffc0eff7d3bfa7d077a8b35a2667cf
1111
original_file_name: generator.yaml
1212
last_modification:
1313
reason: API generation

apis/v1alpha1/generator.yaml

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,19 @@ resources:
3737
add_synced_column: true
3838
order_by: index
3939
additional_columns:
40-
- name: VERSION
41-
json_path: .spec.engineVersion
42-
type: string
43-
index: 10
44-
- name: STATUS
45-
json_path: .status.cacheClusterStatus
46-
type: string
47-
index: 20
48-
- name: ENDPOINT
49-
json_path: .status.configurationEndpoint.address
50-
type: string
51-
index: 30
52-
priority: 1
40+
- name: VERSION
41+
json_path: .spec.engineVersion
42+
type: string
43+
index: 10
44+
- name: STATUS
45+
json_path: .status.cacheClusterStatus
46+
type: string
47+
index: 20
48+
- name: ENDPOINT
49+
json_path: .status.configurationEndpoint.address
50+
type: string
51+
index: 30
52+
priority: 1
5353
exceptions:
5454
errors:
5555
404:
@@ -173,6 +173,7 @@ resources:
173173
PrimaryClusterId: # note: "PrimaryClusterID" will not function properly
174174
compare:
175175
is_ignored: true
176+
176177
hooks:
177178
sdk_read_many_post_set_output:
178179
template_path: hooks/replication_group/sdk_read_many_post_set_output.go.tpl
@@ -189,7 +190,7 @@ resources:
189190
sdk_file_end:
190191
template_path: hooks/replication_group/sdk_file_end.go.tpl
191192
sdk_file_end_set_output_post_populate:
192-
code: "rm.customSetOutput(obj, ko) // custom set output from obj"
193+
template_path: hooks/replication_group/sdk_file_end_set_output_post_populate.go.tpl
193194
renames:
194195
operations:
195196
CreateReplicationGroup:
@@ -303,7 +304,7 @@ operations:
303304
custom_implementation: CustomModifyReplicationGroup
304305
set_output_custom_method_name: CustomModifyReplicationGroupSetOutput
305306
override_values:
306-
ApplyImmediately: true
307+
ApplyImmediately: aws.Bool(true)
307308
CreateSnapshot:
308309
custom_implementation: CustomCreateSnapshot
309310
set_output_custom_method_name: CustomCreateSnapshotSetOutput
@@ -327,7 +328,7 @@ operations:
327328
ModifyCacheCluster:
328329
set_output_custom_method_name: customModifyCacheClusterSetOutput
329330
override_values:
330-
ApplyImmediately: true
331+
ApplyImmediately: aws.Bool(true)
331332
ignore:
332333
resource_names:
333334
- ServerlessCache
@@ -348,4 +349,6 @@ ignore:
348349
- CreateReplicationGroupInput.AutoMinorVersionUpgrade
349350
- CreateReplicationGroupInput.NumCacheClusters
350351
- CacheCluster.LogDeliveryConfigurations
351-
- PendingModifiedValues.LogDeliveryConfigurations
352+
- PendingModifiedValues.LogDeliveryConfigurations
353+
- CreateUserInput.AuthenticationMode
354+
- ModifyUserInput.AuthenticationMode

apis/v1alpha1/types.go

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/v1alpha1/user.go

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/v1alpha1/zz_generated.deepcopy.go

Lines changed: 0 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/elasticache.services.k8s.aws_cacheclusters.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ spec:
195195
properties:
196196
name:
197197
type: string
198+
namespace:
199+
type: string
198200
type: object
199201
type: object
200202
cacheSecurityGroupNames:
@@ -230,6 +232,8 @@ spec:
230232
properties:
231233
name:
232234
type: string
235+
namespace:
236+
type: string
233237
type: object
234238
type: object
235239
engine:
@@ -319,6 +323,8 @@ spec:
319323
properties:
320324
name:
321325
type: string
326+
namespace:
327+
type: string
322328
type: object
323329
type: object
324330
numCacheNodes:
@@ -413,6 +419,8 @@ spec:
413419
properties:
414420
name:
415421
type: string
422+
namespace:
423+
type: string
416424
type: object
417425
type: object
418426
securityGroupIDs:
@@ -458,6 +466,8 @@ spec:
458466
properties:
459467
name:
460468
type: string
469+
namespace:
470+
type: string
461471
type: object
462472
type: object
463473
snapshotRetentionLimit:

config/crd/bases/elasticache.services.k8s.aws_cachesubnetgroups.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ spec:
7676
properties:
7777
name:
7878
type: string
79+
namespace:
80+
type: string
7981
type: object
8082
type: object
8183
type: array

config/crd/bases/elasticache.services.k8s.aws_replicationgroups.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ spec:
188188
properties:
189189
name:
190190
type: string
191+
namespace:
192+
type: string
191193
type: object
192194
type: object
193195
cacheSecurityGroupNames:
@@ -217,6 +219,8 @@ spec:
217219
properties:
218220
name:
219221
type: string
222+
namespace:
223+
type: string
220224
type: object
221225
type: object
222226
clusterMode:
@@ -468,6 +472,8 @@ spec:
468472
properties:
469473
name:
470474
type: string
475+
namespace:
476+
type: string
471477
type: object
472478
type: object
473479
type: array

config/crd/bases/elasticache.services.k8s.aws_users.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,6 @@ spec:
4141
accessString:
4242
description: Access permissions string used for this user.
4343
type: string
44-
authenticationMode:
45-
description: Specifies how to authenticate the user.
46-
properties:
47-
passwords:
48-
items:
49-
type: string
50-
type: array
51-
type_:
52-
type: string
53-
type: object
5444
engine:
5545
description: The current supported value is Redis.
5646
type: string

0 commit comments

Comments
 (0)