-
Notifications
You must be signed in to change notification settings - Fork 42
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
[Docs]: Functions Example in Docs #957
Comments
@vfarcic We have some examples here. we can make a specific directory here |
That would be great. What I'm looking for is an example of |
|
@shubham-cmyk Would that work without a script? I'm trying to add something like that to the assert manifest. |
assert manifest ? |
currently we generate the docs from the code... i will see if i can improve that in the jp lib, i agree this is a bit poor ;) |
i think we can. |
Here's a manifest: apiVersion: devopstoolkitseries.com/v1alpha1
kind: SQL
metadata:
name: xyz
spec:
claimRef:
apiVersion: devopstoolkitseries.com/v1alpha1
kind: SQLClaim
name: my-db
compositionRef:
name: aws-postgresql
compositionSelector:
matchLabels:
db: postgresql
provider: aws
compositionUpdatePolicy: Automatic
id: my-db-aws
parameters:
size: medium
version: "13.4"
resourceRefs:
- apiVersion: ec2.aws.upbound.io/v1beta1
kind: InternetGateway
name: my-db-aws
- apiVersion: ec2.aws.upbound.io/v1beta1
kind: MainRouteTableAssociation
name: my-db-aws
- apiVersion: ec2.aws.upbound.io/v1beta1
kind: RouteTableAssociation
name: my-db-aws-1a
- apiVersion: ec2.aws.upbound.io/v1beta1
kind: RouteTableAssociation
name: my-db-aws-1b
- apiVersion: ec2.aws.upbound.io/v1beta1
kind: RouteTableAssociation
name: my-db-aws-1c
- apiVersion: ec2.aws.upbound.io/v1beta1
kind: RouteTable
name: my-db-aws
- apiVersion: ec2.aws.upbound.io/v1beta1
kind: Route
name: my-db-aws
- apiVersion: ec2.aws.upbound.io/v1beta1
kind: SecurityGroupRule
name: my-db-aws
- apiVersion: ec2.aws.upbound.io/v1beta1
kind: SecurityGroup
name: my-db-aws
- apiVersion: ec2.aws.upbound.io/v1beta1
kind: Subnet
name: my-db-aws-a
- apiVersion: ec2.aws.upbound.io/v1beta1
kind: Subnet
name: my-db-aws-b
- apiVersion: ec2.aws.upbound.io/v1beta1
kind: Subnet
name: my-db-aws-c
- apiVersion: ec2.aws.upbound.io/v1beta1
kind: VPC
name: my-db-aws
- apiVersion: kubernetes.crossplane.io/v1alpha1
kind: ProviderConfig
name: my-db-aws-sql
- apiVersion: kubernetes.crossplane.io/v1alpha2
kind: Object
name: my-db-aws-secret
- apiVersion: postgresql.sql.crossplane.io/v1alpha1
kind: Database
name: my-db-aws-db-01
- apiVersion: postgresql.sql.crossplane.io/v1alpha1
kind: Database
name: my-db-aws-db-02
- apiVersion: postgresql.sql.crossplane.io/v1alpha1
kind: Database
name: my-db-aws-db-03
- apiVersion: postgresql.sql.crossplane.io/v1alpha1
kind: ProviderConfig
name: my-db-aws
- apiVersion: rds.aws.upbound.io/v1beta1
kind: Instance
name: my-db-aws
- apiVersion: rds.aws.upbound.io/v1beta1
kind: SubnetGroup
name: my-db-aws I'd like to check that, among other things, that resource contains |
refer : https://kyverno.github.io/chainsaw/main/operations/assert/#usage-in-test Would this example help |
@vfarcic you can do something like this:
It's called multiselect in jmespath term. (you can do multiselect hash but harder to use because it uses |
Would something like the following be it? apiVersion: devopstoolkitseries.com/v1alpha1
kind: SQL
metadata:
labels:
crossplane.io/claim-name: my-db
spec:
claimRef:
apiVersion: devopstoolkitseries.com/v1alpha1
kind: SQLClaim
name: my-db
compositionRef:
name: aws-postgresql
compositionSelector:
matchLabels:
db: postgresql
provider: aws
compositionUpdatePolicy: Automatic
id: my-db-aws
parameters:
size: medium
version: "13.4"
(contains(resourceRefs[?kind == InternetGateway].[name], ['my-db-aws'])): true
resourceRefs:
- apiVersion: ec2.aws.upbound.io/v1beta1
kind: InternetGateway
name: my-db-aws
- apiVersion: ec2.aws.upbound.io/v1beta1
kind: MainRouteTableAssociation
name: my-db-aws
- apiVersion: ec2.aws.upbound.io/v1beta1
kind: RouteTableAssociation
name: my-db-aws-1a That one is throwing I left the existing |
|
Tried it, with quotes it passes: apiVersion: devopstoolkitseries.com/v1alpha1
kind: SQL
metadata:
labels:
crossplane.io/claim-name: my-db
spec:
claimRef:
apiVersion: devopstoolkitseries.com/v1alpha1
kind: SQLClaim
name: my-db
compositionRef:
name: aws-postgresql
compositionSelector:
matchLabels:
db: postgresql
provider: aws
compositionUpdatePolicy: Automatic
id: my-db-aws
parameters:
size: medium
version: "13.4"
(length(resourceRefs[?kind == 'InternetGateway'])): 1
(contains(resourceRefs[?kind == 'InternetGateway'].[name], ['my-db-aws'])): true chainsaw assert -r ./_resource.yaml -f ./_assert.yaml
Assertion(s) PASSED |
@vfarcic there's a simpler and more elegant solution: apiVersion: devopstoolkitseries.com/v1alpha1
kind: SQL
metadata:
labels:
crossplane.io/claim-name: my-db
spec:
claimRef:
apiVersion: devopstoolkitseries.com/v1alpha1
kind: SQLClaim
name: my-db
compositionRef:
name: aws-postgresql
compositionSelector:
matchLabels:
db: postgresql
provider: aws
compositionUpdatePolicy: Automatic
id: my-db-aws
parameters:
size: medium
version: "13.4"
(resourceRefs[?kind == 'InternetGateway']):
- name: my-db-aws |
That's the one I like the most. @eddycharly. It's easy to read than the previous example. |
For reference grafana/tempo-operator#786 (comment) |
Problem Statement
It's not clear how to use functions based on https://kyverno.github.io/chainsaw/latest/jp/functions/.
Solution Description
Add a few examples to the docs.
Alternatives
No response
Additional Context
No response
Slack discussion
No response
Research
The text was updated successfully, but these errors were encountered: