Skip to content

Commit

Permalink
Add tests for cross namespace resource reference (#112)
Browse files Browse the repository at this point in the history
Issue [#1777](aws-controllers-k8s/community#1777)

Description of changes:
* Adding new e2e test suites to validate our recently introduced feature ["cross namespace resource references"](aws-controllers-k8s/code-generator#532). In order to test this feature, we added a new feature to allow new namespace creation, from which resources will be referenced (Policy in this case).

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
  • Loading branch information
michaelhtm authored Jul 30, 2024
1 parent 224e6e9 commit 6b9d0c1
Show file tree
Hide file tree
Showing 23 changed files with 205 additions and 29 deletions.
6 changes: 3 additions & 3 deletions apis/v1alpha1/ack-generate-metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
ack_generate_info:
build_date: "2024-07-19T22:53:13Z"
build_hash: f0a0f42d507c550c2b063a192b3b43e4522bdd9c
build_date: "2024-07-29T23:59:41Z"
build_hash: 49afe38983d285f926b51b6d34e39a4d9aeffb85
go_version: go1.22.5
version: v0.35.0
version: v0.35.0-2-g49afe38
api_directory_checksum: 761a2c708651b0273bf39d98dddaf029de23d337
api_version: v1alpha1
aws_sdk_go_version: v1.49.0
Expand Down
2 changes: 2 additions & 0 deletions config/crd/bases/iam.services.k8s.aws_groups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ spec:
properties:
name:
type: string
namespace:
type: string
type: object
type: object
type: array
Expand Down
2 changes: 2 additions & 0 deletions config/crd/bases/iam.services.k8s.aws_instanceprofiles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ spec:
properties:
name:
type: string
namespace:
type: string
type: object
type: object
tags:
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/iam.services.k8s.aws_roles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ spec:
properties:
name:
type: string
namespace:
type: string
type: object
type: object
policies:
Expand All @@ -182,6 +184,8 @@ spec:
properties:
name:
type: string
namespace:
type: string
type: object
type: object
type: array
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/iam.services.k8s.aws_users.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ spec:
properties:
name:
type: string
namespace:
type: string
type: object
type: object
policies:
Expand All @@ -136,6 +138,8 @@ spec:
properties:
name:
type: string
namespace:
type: string
type: object
type: object
type: array
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.22.0
toolchain go1.22.5

require (
github.com/aws-controllers-k8s/runtime v0.35.0
github.com/aws-controllers-k8s/runtime v0.35.1-0.20240719172343-a132c887e8d4
github.com/aws/aws-sdk-go v1.49.0
github.com/go-logr/logr v1.4.1
github.com/micahhausler/aws-iam-policy v0.4.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
github.com/a-hilaly/aws-iam-policy v0.0.0-20231121054900-2c56e839ca53 h1:2uNM0nR2WUDN88EYFxjEaroH+PZJ6k/h9kl+KO0dWVc=
github.com/a-hilaly/aws-iam-policy v0.0.0-20231121054900-2c56e839ca53/go.mod h1:Ojgst9ZFn+VEEJpqtuw/LxVGqEf2+hwWBlkYWvF/XWM=
github.com/aws-controllers-k8s/runtime v0.35.0 h1:kLRLFOAcaFJRv/aEiWtb0qhlxFpwvmx6shCWNc1Tuas=
github.com/aws-controllers-k8s/runtime v0.35.0/go.mod h1:gI2pWb20UGLP2SnHf1a1VzTd7iVVy+/I9VAzT0Y+Dew=
github.com/aws-controllers-k8s/runtime v0.35.1-0.20240719172343-a132c887e8d4 h1:CW58T4qFJpoF37hCPlV1NHCc6mdxNf6jdvLobVolSY0=
github.com/aws-controllers-k8s/runtime v0.35.1-0.20240719172343-a132c887e8d4/go.mod h1:gI2pWb20UGLP2SnHf1a1VzTd7iVVy+/I9VAzT0Y+Dew=
github.com/aws/aws-sdk-go v1.49.0 h1:g9BkW1fo9GqKfwg2+zCD+TW/D36Ux+vtfJ8guF4AYmY=
github.com/aws/aws-sdk-go v1.49.0/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
Expand Down
2 changes: 2 additions & 0 deletions helm/crds/iam.services.k8s.aws_groups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ spec:
properties:
name:
type: string
namespace:
type: string
type: object
type: object
type: array
Expand Down
2 changes: 2 additions & 0 deletions helm/crds/iam.services.k8s.aws_instanceprofiles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ spec:
properties:
name:
type: string
namespace:
type: string
type: object
type: object
tags:
Expand Down
4 changes: 4 additions & 0 deletions helm/crds/iam.services.k8s.aws_roles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ spec:
properties:
name:
type: string
namespace:
type: string
type: object
type: object
policies:
Expand All @@ -182,6 +184,8 @@ spec:
properties:
name:
type: string
namespace:
type: string
type: object
type: object
type: array
Expand Down
4 changes: 4 additions & 0 deletions helm/crds/iam.services.k8s.aws_users.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ spec:
properties:
name:
type: string
namespace:
type: string
type: object
type: object
policies:
Expand All @@ -136,6 +138,8 @@ spec:
properties:
name:
type: string
namespace:
type: string
type: object
type: object
type: array
Expand Down
11 changes: 10 additions & 1 deletion helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -237,4 +237,13 @@ rules:
- get
- patch
- update
{{- end }}
{{- end }}

{{/* Convert k/v map to string like: "key1=value1,key2=value2,..." */}}
{{- define "ack-iam-controller.feature-gates" -}}
{{- $list := list -}}
{{- range $k, $v := .Values.featureGates -}}
{{- $list = append $list (printf "%s=%s" $k ( $v | toString)) -}}
{{- end -}}
{{ join "," $list }}
{{- end -}}
8 changes: 8 additions & 0 deletions helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ spec:
{{- range $key, $value := .Values.reconcile.resourceMaxConcurrentSyncs }}
- --reconcile-resource-max-concurrent-syncs
- "$(RECONCILE_RESOURCE_MAX_CONCURRENT_SYNCS_{{ $key | upper }})"
{{- end }}
{{- if .Values.featureGates}}
- --feature-gates
- "$(FEATURE_GATES)"
{{- end }}
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
Expand Down Expand Up @@ -122,6 +126,10 @@ spec:
{{- range $key, $value := .Values.reconcile.resourceMaxConcurrentSyncs }}
- name: RECONCILE_RESOURCE_MAX_CONCURRENT_SYNCS_{{ $key | upper }}
value: {{ $key }}={{ $value }}
{{- end }}
{{- if .Values.featureGates}}
- name: FEATURE_GATES
value: {{ include "ack-iam-controller.feature-gates" . }}
{{- end }}
{{- if .Values.aws.credentials.secretName }}
- name: AWS_SHARED_CREDENTIALS_FILE
Expand Down
7 changes: 7 additions & 0 deletions helm/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,13 @@
"type": "object"
}
},
"featureGates": {
"description": "Feature gates settings",
"type": "object",
"additionalProperties": {
"type": "boolean"
}
},
"required": [
"image",
"deployment",
Expand Down
7 changes: 7 additions & 0 deletions helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,10 @@ leaderElection:
# will attempt to use the namespace of the service account mounted to the Controller
# pod.
namespace: ""

# Configuration for feature gates. These are optional controller features that
# can be individually enabled ("true") or disabled ("false") by adding key/value
# pairs below.
featureGates: {}
# featureGate1: true
# featureGate2: false
8 changes: 5 additions & 3 deletions pkg/resource/group/references.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions pkg/resource/instance_profile/references.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 10 additions & 5 deletions pkg/resource/role/references.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 10 additions & 5 deletions pkg/resource/user/references.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions test/e2e/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ def pytest_configure(config):
config.addinivalue_line(
"markers", "slow: mark test as slow to run"
)
config.addinivalue_line(
"markers", "resource_data: mark test with data to use when creating fixture"
)

def pytest_collection_modifyitems(config, items):
if config.getoption("--runslow"):
Expand Down
Loading

0 comments on commit 6b9d0c1

Please sign in to comment.