Skip to content

Commit

Permalink
feat: add describe collector (#826)
Browse files Browse the repository at this point in the history
* feat: add describe collector

Signed-off-by: Charles-Edouard Brétéché <[email protected]>

* validation

Signed-off-by: Charles-Edouard Brétéché <[email protected]>

---------

Signed-off-by: Charles-Edouard Brétéché <[email protected]>
  • Loading branch information
eddycharly authored Feb 9, 2024
1 parent 043a1e4 commit b01fe35
Show file tree
Hide file tree
Showing 25 changed files with 762 additions and 34 deletions.
48 changes: 48 additions & 0 deletions .crds/chainsaw.kyverno.io_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,30 @@ spec:
required:
- entrypoint
type: object
describe:
description: Describe determines the resource describe
collector to execute.
properties:
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
type: string
namespace:
description: 'Namespace of the referent. More info:
https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/'
type: string
resource:
description: Resource type.
type: string
selector:
description: Selector defines labels selector.
type: string
timeout:
description: Timeout for the operation. Overrides
the global timeout set in the Configuration.
type: string
required:
- resource
type: object
description:
description: Description contains a description of the
operation.
Expand Down Expand Up @@ -227,6 +251,30 @@ spec:
required:
- entrypoint
type: object
describe:
description: Describe determines the resource describe
collector to execute.
properties:
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
type: string
namespace:
description: 'Namespace of the referent. More info:
https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/'
type: string
resource:
description: Resource type.
type: string
selector:
description: Selector defines labels selector.
type: string
timeout:
description: Timeout for the operation. Overrides
the global timeout set in the Configuration.
type: string
required:
- resource
type: object
description:
description: Description contains a description of the
operation.
Expand Down
46 changes: 46 additions & 0 deletions .crds/chainsaw.kyverno.io_teststeps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,29 @@ spec:
required:
- entrypoint
type: object
describe:
description: Describe determines the resource describe collector
to execute.
properties:
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
type: string
namespace:
description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/'
type: string
resource:
description: Resource type.
type: string
selector:
description: Selector defines labels selector.
type: string
timeout:
description: Timeout for the operation. Overrides the global
timeout set in the Configuration.
type: string
required:
- resource
type: object
description:
description: Description contains a description of the operation.
type: string
Expand Down Expand Up @@ -184,6 +207,29 @@ spec:
required:
- entrypoint
type: object
describe:
description: Describe determines the resource describe collector
to execute.
properties:
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
type: string
namespace:
description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/'
type: string
resource:
description: Resource type.
type: string
selector:
description: Selector defines labels selector.
type: string
timeout:
description: Timeout for the operation. Overrides the global
timeout set in the Configuration.
type: string
required:
- resource
type: object
description:
description: Description contains a description of the operation.
type: string
Expand Down
1 change: 1 addition & 0 deletions .release-notes/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Release notes for `TODO`.

- Allowed passing test folders by args (`chainsaw test ./folder` instead of `chainsaw test --test-dir ./folder`)
- Added new binding `$namespace` containing the test namespace name
- Added new `describe` collector to invoke `kubectl describe ...`

## 🔧 Fixes 🔧

Expand Down
88 changes: 88 additions & 0 deletions .schemas/json/test-chainsaw-v1alpha1.json
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,50 @@
}
}
},
"describe": {
"description": "Describe determines the resource describe collector to execute.",
"type": [
"object",
"null"
],
"required": [
"resource"
],
"properties": {
"name": {
"description": "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names",
"type": [
"string",
"null"
]
},
"namespace": {
"description": "Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/",
"type": [
"string",
"null"
]
},
"resource": {
"description": "Resource type.",
"type": "string"
},
"selector": {
"description": "Selector defines labels selector.",
"type": [
"string",
"null"
]
},
"timeout": {
"description": "Timeout for the operation. Overrides the global timeout set in the Configuration.",
"type": [
"string",
"null"
]
}
}
},
"description": {
"description": "Description contains a description of the operation.",
"type": [
Expand Down Expand Up @@ -616,6 +660,50 @@
}
}
},
"describe": {
"description": "Describe determines the resource describe collector to execute.",
"type": [
"object",
"null"
],
"required": [
"resource"
],
"properties": {
"name": {
"description": "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names",
"type": [
"string",
"null"
]
},
"namespace": {
"description": "Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/",
"type": [
"string",
"null"
]
},
"resource": {
"description": "Resource type.",
"type": "string"
},
"selector": {
"description": "Selector defines labels selector.",
"type": [
"string",
"null"
]
},
"timeout": {
"description": "Timeout for the operation. Overrides the global timeout set in the Configuration.",
"type": [
"string",
"null"
]
}
}
},
"description": {
"description": "Description contains a description of the operation.",
"type": [
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/v1alpha1/catch.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ type Catch struct {
// +optional
Events *Events `json:"events,omitempty"`

// Describe determines the resource describe collector to execute.
// +optional
Describe *Describe `json:"describe,omitempty"`

// Command defines a command to run.
// +optional
Command *Command `json:"command,omitempty"`
Expand Down
29 changes: 29 additions & 0 deletions pkg/apis/v1alpha1/describe.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// Describe defines how to describe resources.
type Describe struct {
// Timeout for the operation. Overrides the global timeout set in the Configuration.
// +optional
Timeout *metav1.Duration `json:"timeout,omitempty"`

// Resource type.
Resource string `json:"resource"`

// Namespace of the referent.
// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/
// +optional
Namespace string `json:"namespace,omitempty"`

// Name of the referent.
// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
// +optional
Name string `json:"name,omitempty"`

// Selector defines labels selector.
// +optional
Selector string `json:"selector,omitempty"`
}
4 changes: 4 additions & 0 deletions pkg/apis/v1alpha1/finally.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ type Finally struct {
// +optional
Events *Events `json:"events,omitempty"`

// Describe determines the resource describe collector to execute.
// +optional
Describe *Describe `json:"describe,omitempty"`

// Command defines a command to run.
// +optional
Command *Command `json:"command,omitempty"`
Expand Down
31 changes: 31 additions & 0 deletions pkg/apis/v1alpha1/zz_generated.deepcopy.go

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

4 changes: 4 additions & 0 deletions pkg/commands/build/docs/docs.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ command
events
{{- else if .PodLogs -}}
pod logs
{{- else if .Describe -}}
describe
{{- else if .Script -}}
script
{{- else if .Sleep -}}
Expand All @@ -39,6 +41,8 @@ command
events
{{- else if .PodLogs -}}
pod logs
{{- else if .Describe -}}
describe
{{- else if .Script -}}
script
{{- else if .Sleep -}}
Expand Down
Loading

0 comments on commit b01fe35

Please sign in to comment.