Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stack ref for access policy identifier #124

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion apis/cloud/v1alpha1/zz_accesspolicy_types.go

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

20 changes: 20 additions & 0 deletions apis/cloud/v1alpha1/zz_generated.deepcopy.go

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

47 changes: 47 additions & 0 deletions apis/cloud/v1alpha1/zz_generated.resolvers.go

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

7 changes: 7 additions & 0 deletions config/grafana/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ func Configure(p *ujconfig.Provider) {
return conn, nil
}
})
p.AddResourceConfigurator("grafana_cloud_access_policy", func(r *ujconfig.Resource) {
r.References["realm.identifier"] = ujconfig.Reference{
TerraformName: "grafana_cloud_stack",
RefFieldName: "StackRef",
SelectorFieldName: "StackSelector",
}
})
p.AddResourceConfigurator("grafana_cloud_access_policy_token", func(r *ujconfig.Resource) {
r.References["access_policy_id"] = ujconfig.Reference{
TerraformName: "grafana_cloud_access_policy",
Expand Down
6 changes: 4 additions & 2 deletions examples-generated/cloud/v1alpha1/accesspolicy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ spec:
displayName: My Policy
name: my-policy
realm:
- identifier: ${data.grafana_cloud_organization.current.id}
labelPolicy:
- labelPolicy:
- selector: '{namespace="default"}'
stackSelector:
matchLabels:
testing.upbound.io/example-name: grafana_cloud_organization
type: org
region: us
scopes:
Expand Down
6 changes: 4 additions & 2 deletions examples-generated/cloud/v1alpha1/accesspolicytoken.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ spec:
displayName: My Policy
name: my-policy
realm:
- identifier: ${data.grafana_cloud_organization.current.id}
labelPolicy:
- labelPolicy:
- selector: '{namespace="default"}'
stackSelector:
matchLabels:
testing.upbound.io/example-name: grafana_cloud_organization
type: org
region: us
scopes:
Expand Down
4 changes: 3 additions & 1 deletion examples-generated/sm/v1alpha1/installation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ spec:
name: metric-publisher-for-sm
provider: ${grafana.cloud}
realm:
- identifier: ${grafana_cloud_stack.sm_stack.id}
- stackSelector:
matchLabels:
testing.upbound.io/example-name: sm_stack
type: stack
region: ${var.cloud_region}
scopes:
Expand Down
148 changes: 148 additions & 0 deletions package/crds/cloud.grafana.crossplane.io_accesspolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,80 @@ spec:
type: string
type: object
type: array
stackRef:
description: Reference to a Stack in cloud to populate identifier.
properties:
name:
description: Name of the referenced object.
type: string
policy:
description: Policies for referencing.
properties:
resolution:
default: Required
description: |-
Resolution specifies whether resolution of this reference is required.
The default is 'Required', which means the reconcile will fail if the
reference cannot be resolved. 'Optional' means this reference will be
a no-op if it cannot be resolved.
enum:
- Required
- Optional
type: string
resolve:
description: |-
Resolve specifies when this reference should be resolved. The default
is 'IfNotPresent', which will attempt to resolve the reference only when
the corresponding field is not present. Use 'Always' to resolve the
reference on every reconcile.
enum:
- Always
- IfNotPresent
type: string
type: object
required:
- name
type: object
stackSelector:
description: Selector for a Stack in cloud to populate identifier.
properties:
matchControllerRef:
description: |-
MatchControllerRef ensures an object with the same controller reference
as the selecting object is selected.
type: boolean
matchLabels:
additionalProperties:
type: string
description: MatchLabels ensures an object with matching
labels is selected.
type: object
policy:
description: Policies for selection.
properties:
resolution:
default: Required
description: |-
Resolution specifies whether resolution of this reference is required.
The default is 'Required', which means the reconcile will fail if the
reference cannot be resolved. 'Optional' means this reference will be
a no-op if it cannot be resolved.
enum:
- Required
- Optional
type: string
resolve:
description: |-
Resolve specifies when this reference should be resolved. The default
is 'IfNotPresent', which will attempt to resolve the reference only when
the corresponding field is not present. Use 'Always' to resolve the
reference on every reconcile.
enum:
- Always
- IfNotPresent
type: string
type: object
type: object
type:
description: |-
(String) Whether a policy applies to a Cloud org or a specific stack. Should be one of org or stack.
Expand Down Expand Up @@ -169,6 +243,80 @@ spec:
type: string
type: object
type: array
stackRef:
description: Reference to a Stack in cloud to populate identifier.
properties:
name:
description: Name of the referenced object.
type: string
policy:
description: Policies for referencing.
properties:
resolution:
default: Required
description: |-
Resolution specifies whether resolution of this reference is required.
The default is 'Required', which means the reconcile will fail if the
reference cannot be resolved. 'Optional' means this reference will be
a no-op if it cannot be resolved.
enum:
- Required
- Optional
type: string
resolve:
description: |-
Resolve specifies when this reference should be resolved. The default
is 'IfNotPresent', which will attempt to resolve the reference only when
the corresponding field is not present. Use 'Always' to resolve the
reference on every reconcile.
enum:
- Always
- IfNotPresent
type: string
type: object
required:
- name
type: object
stackSelector:
description: Selector for a Stack in cloud to populate identifier.
properties:
matchControllerRef:
description: |-
MatchControllerRef ensures an object with the same controller reference
as the selecting object is selected.
type: boolean
matchLabels:
additionalProperties:
type: string
description: MatchLabels ensures an object with matching
labels is selected.
type: object
policy:
description: Policies for selection.
properties:
resolution:
default: Required
description: |-
Resolution specifies whether resolution of this reference is required.
The default is 'Required', which means the reconcile will fail if the
reference cannot be resolved. 'Optional' means this reference will be
a no-op if it cannot be resolved.
enum:
- Required
- Optional
type: string
resolve:
description: |-
Resolve specifies when this reference should be resolved. The default
is 'IfNotPresent', which will attempt to resolve the reference only when
the corresponding field is not present. Use 'Always' to resolve the
reference on every reconcile.
enum:
- Always
- IfNotPresent
type: string
type: object
type: object
type:
description: |-
(String) Whether a policy applies to a Cloud org or a specific stack. Should be one of org or stack.
Expand Down
Loading