diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..5b5bf56a --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "API", + "type": "go", + "request": "launch", + "mode": "auto", + "program": "${workspaceFolder}", + "args": [ + "serve" + ] + } + ] +} \ No newline at end of file diff --git a/Makefile b/Makefile index 8ac42610..40422159 100644 --- a/Makefile +++ b/Makefile @@ -171,7 +171,6 @@ codegen-mkdocs: codegen-docs ## Generate mkdocs website @rm -rf ./website/docs/jp && mkdir -p ./website/docs/jp && cp docs/user/jp/* ./website/docs/jp @mkdocs build -f ./website/mkdocs.yaml - .PHONY: codegen-schema-openapi codegen-schema-openapi: $(KIND) $(HELM) ## Generate openapi schemas (v2 and v3) @echo Generate openapi schema... >&2 @@ -194,15 +193,15 @@ codegen-schema-json: codegen-schema-openapi ## Generate json schemas .PHONY: codegen-schema-all codegen-schema-all: codegen-schema-openapi codegen-schema-json ## Generate openapi and json schemas -.PHONY: codegen-all -codegen-all: codegen-crds codegen-deepcopy codegen-register codegen-docs codegen-mkdocs codegen-schema-all ## Rebuild all generated code and docs +.PHONY: codegen +codegen: codegen-crds codegen-deepcopy codegen-register codegen-docs codegen-mkdocs codegen-schema-all ## Rebuild all generated code and docs .PHONY: verify-codegen -verify-codegen: codegen-all ## Verify all generated code and docs are up to date +verify-codegen: codegen ## Verify all generated code and docs are up to date @echo Checking codegen is up to date... >&2 @git --no-pager diff -- . - @echo 'If this test fails, it is because the git diff is non-empty after running "make codegen-all".' >&2 - @echo 'To correct this, locally run "make codegen-all", commit the changes, and re-run tests.' >&2 + @echo 'If this test fails, it is because the git diff is non-empty after running "make codegen".' >&2 + @echo 'To correct this, locally run "make codegen", commit the changes, and re-run tests.' >&2 @git diff --quiet --exit-code -- . ######## diff --git a/docs/user/apis/_config/config.yaml b/docs/user/apis/_config/config.yaml index 4d81e7c1..127cb501 100644 --- a/docs/user/apis/_config/config.yaml +++ b/docs/user/apis/_config/config.yaml @@ -1,3 +1,37 @@ +hiddenMemberFields: + - "TypeMeta" + +externalPackages: + - match: ^k8s\.io/apimachinery/pkg/apis/meta/v1\.Duration$ + target: https://pkg.go.dev/k8s.io/apimachinery/pkg/apis/meta/v1#Duration + - match: ^k8s\.io/apimachinery/pkg/apis/meta/v1\.GroupVersionKind$ + target: https://pkg.go.dev/k8s.io/apimachinery/pkg/apis/meta/v1#GroupVersionKind + - match: ^k8s\.io/apimachinery/pkg/apis/meta/v1\.GroupVersionResource$ + target: https://pkg.go.dev/k8s.io/apimachinery/pkg/apis/meta/v1#GroupVersionResource + - match: ^k8s\.io/apimachinery/pkg/types\.UID$ + target: https://pkg.go.dev/k8s.io/apimachinery/pkg/types#UID + - match: ^k8s\.io/apimachinery/pkg/runtime\.RawExtension$ + target: https://pkg.go.dev/k8s.io/apimachinery/pkg/runtime/#RawExtension + - match: ^k8s\.io/apimachinery/pkg/api/resource\.QuantityValue$ + target: https://pkg.go.dev/k8s.io/apimachinery/pkg/api/resource#QuantityValue + - match: ^k8s\.io/apimachinery/pkg/api/resource\.Quantity$ + target: https://pkg.go.dev/k8s.io/apimachinery/pkg/api/resource#Quantity + - match: ^k8s\.io/apimachinery/pkg/runtime\.Unknown$ + target: https://pkg.go.dev/k8s.io/apimachinery/pkg/runtime#Unknown + - match: ^time\.Duration$ + target: https://pkg.go.dev/time#Duration + - match: ^io.Writer$ + target: https://pkg.go.dev/io#Writer + - match: ^k8s\.io/(api|apimachinery/pkg/apis)/ + target: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.28/#{{- lower .TypeIdentifier -}}-{{- arrIndex .PackageSegments -1 -}}-{{- arrIndex .PackageSegments -2 -}} + +stripPrefix: + - k8s.io/api/ + - k8s.io/apimachinery/pkg/apis/ + - github.com/tengqm/kubeconfig/config/kubeadm/v1beta2. + - github.com/tengqm/kubeconfig/config/kubeadm/v1beta3. + - github.com/tengqm/kubeconfig/config/bootstraptoken/v1. + markdownDisabled: false apis: diff --git a/docs/user/apis/_config/markdown/members.tpl b/docs/user/apis/_config/markdown/members.tpl index b9702186..6a6972de 100644 --- a/docs/user/apis/_config/markdown/members.tpl +++ b/docs/user/apis/_config/markdown/members.tpl @@ -1,34 +1,40 @@ -{{ define "members" }} - {{/* . is a apiType */}} - {{- range .GetMembers -}} - {{/* . is a apiMember */}} - {{- if not .Hidden }} -
{{ .FieldName }}
- {{- if not .IsOptional }} [Required]{{- end -}}
-{{ .DisplayName }}
+{{- define "comment" -}}
+ {{- $comment := "" -}}
+ {{- range . -}}
+ {{- if . -}}
+ {{- if not (eq (index . 0) '+') -}}
+ {{- if $comment -}}
+ {{- $comment = print $comment " " . -}}
{{- else -}}
-{{ .DisplayName }}
+ {{- $comment = . -}}
{{- end -}}
- {{- end }}
-{{ .FieldName }}
are embedded into this type.)
- {{- end }}
- {{ if .GetComment -}}
- {{ .GetComment }}
- {{- else -}}
- No description provided.
- {{- end }}
- {{- if and (eq (.GetType.Name.Name) "ObjectMeta") -}}
-Refer to the Kubernetes API documentation for the fields of the metadata
field.
- {{- end -}}
-{{ $comment }}
+ {{- else -}} + *No description provided.* + {{- end -}} +{{- end -}} + +{{- define "typ" -}} + {{- if .Link -}} + [`{{ .DisplayName }}`]({{ .Link }}) + {{- else -}} + `{{ .DisplayName }}` + {{- end -}} +{{- end -}} + +{{- define "members" }} + {{- range .GetMembers }} + {{- if not .Hidden }} + {{- $name := .FieldName }} + {{- $optional := .IsOptional }} + {{- $type := .GetType }} + {{- $inline := .IsInline }} + {{- $comment := .GetComment }} +| `{{ $name }}` | {{ template "typ" $type }} | {{ if not $optional }}:white_check_mark:{{ end }} | {{ template "comment" .CommentLines }} | {{- end }} {{- end }} -{{ end }} +{{- end }} diff --git a/docs/user/apis/_config/markdown/type.tpl b/docs/user/apis/_config/markdown/type.tpl index e8e72358..2a255fc0 100644 --- a/docs/user/apis/_config/markdown/type.tpl +++ b/docs/user/apis/_config/markdown/type.tpl @@ -1,37 +1,33 @@ -{{ define "type" }} - +{{- define "type" }} ## `{{ .Name.Name }}` {#{{ .Anchor }}} - -{{ if eq .Kind "Alias" -}} -(Alias of `{{ .Underlying }}`) -{{ end }} +{{- if eq .Kind "Alias" }} +(Alias of `{{ .Underlying }}`) +{{- end }} {{- with .References }} + **Appears in:** -{{ range . }} -{{ if or .Referenced .IsExported -}} + {{ range . }} + {{- if or .Referenced .IsExported }} - [{{ .DisplayName }}]({{ .Link }}) -{{ end -}} -{{- end -}} + {{- end }} + {{- end }} {{- end }} +{{- if .GetComment }} -{{ if .GetComment -}} {{ .GetComment }} -{{ end }} -{{ if .GetMembers -}} -Field | Description |
---|---|
apiVersion string | {{- .APIGroup -}} |
kind string | {{- .Name.Name -}} |
Field | Description |
---|---|
apiVersion string | json.kyverno.io/v1alpha1 |
kind string | Policy |
TypeMeta [Required]- k8s.io/apimachinery/pkg/apis/meta/v1.TypeMeta
- |
-(Members of TypeMeta are embedded into this type.)
- No description provided. |
-
metadata [Required]- k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta
- |
-
- No description provided.Refer to the Kubernetes API documentation for the fields of the metadata field. |
-
spec [Required]- PolicySpec
- |
-- No description provided. | -
Field | Description |
---|---|
Value [Required]- interface{}
- |
-(Members of Value are embedded into this type.)
- No description provided. |
-
Field | Description |
---|---|
any [Required]- []Assertion
- |
-
- Any allows specifying resources which will be ORed. - |
-
all [Required]- []Assertion
- |
-
- All allows specifying resources which will be ANDed. - |
-
Any allows specifying resources which will be ORed.
| +| `all` | [`[]Assertion`](#json-kyverno-io-v1alpha1-Assertion) | :white_check_mark: |All allows specifying resources which will be ANDed.
| ## `Assertion` {#json-kyverno-io-v1alpha1-Assertion} - **Appears in:** - + - [Assert](#json-kyverno-io-v1alpha1-Assert) - - -Field | Description |
---|---|
message [Required]- string
- |
-
- Message is the variable associated message. - |
-
check [Required]- Any
- |
-
- Check is the assertion check definition. - |
-
Message is the variable associated message.
| +| `check` | [`Any`](#json-kyverno-io-v1alpha1-Any) | :white_check_mark: |Check is the assertion check definition.
| ## `ContextEntry` {#json-kyverno-io-v1alpha1-ContextEntry} - **Appears in:** - + - [Rule](#json-kyverno-io-v1alpha1-Rule) -ContextEntry adds variables and data sources to a rule Context.
-Field | Description |
---|---|
name [Required]- string
- |
-
- Name is the variable name. - |
-
variable [Required]- Any
- |
-
- Variable defines an arbitrary JMESPath context variable that can be defined inline. - |
-
Name is the variable name.
| +| `variable` | [`Any`](#json-kyverno-io-v1alpha1-Any) | :white_check_mark: |Variable defines an arbitrary JMESPath context variable that can be defined inline.
| ## `Match` {#json-kyverno-io-v1alpha1-Match} - **Appears in:** - + - [Rule](#json-kyverno-io-v1alpha1-Rule) - - -Field | Description |
---|---|
any [Required]- []Any
- |
-
- Any allows specifying resources which will be ORed. - |
-
all [Required]- []Any
- |
-
- All allows specifying resources which will be ANDed. - |
-
Any allows specifying resources which will be ORed.
| +| `all` | [`[]Any`](#json-kyverno-io-v1alpha1-Any) | :white_check_mark: |All allows specifying resources which will be ANDed.
| ## `PolicySpec` {#json-kyverno-io-v1alpha1-PolicySpec} - **Appears in:** - + - [Policy](#json-kyverno-io-v1alpha1-Policy) - - -Field | Description |
---|---|
rules [Required]- []Rule
- |
-
- Rules is a list of Rule instances. A Policy contains multiple rules and each rule can validate, mutate, or generate resources. - |
-
Rules is a list of Rule instances. A Policy contains multiple rules and each rule can validate, mutate, or generate resources.
| ## `Rule` {#json-kyverno-io-v1alpha1-Rule} - **Appears in:** - + - [PolicySpec](#json-kyverno-io-v1alpha1-PolicySpec) - - -Field | Description |
---|---|
name [Required]- string
- |
-
- Name is a label to identify the rule, It must be unique within the policy. - |
-
context [Required]- []ContextEntry
- |
-
- Context defines variables and data sources that can be used during rule execution. - |
-
match [Required]- Match
- |
-
- Match defines when this policy rule should be applied. The match -criteria can include resource information (e.g. kind, name, namespace, labels) -and admission review request information like the user name or role. -At least one kind is required. - |
-
exclude [Required]- Match
- |
-
- Exclude defines when this policy rule should not be applied. The exclude -criteria can include resource information (e.g. kind, name, namespace, labels) -and admission review request information like the name or role. - |
-
validate [Required]- Validation
- |
-
- Validation is used to validate matching resources. - |
-
Name is a label to identify the rule, It must be unique within the policy.
| +| `context` | [`[]ContextEntry`](#json-kyverno-io-v1alpha1-ContextEntry) | :white_check_mark: |Context defines variables and data sources that can be used during rule execution.
| +| `match` | [`Match`](#json-kyverno-io-v1alpha1-Match) | :white_check_mark: |Match defines when this policy rule should be applied. The match criteria can include resource information (e.g. kind, name, namespace, labels) and admission review request information like the user name or role. At least one kind is required.
| +| `exclude` | [`Match`](#json-kyverno-io-v1alpha1-Match) | :white_check_mark: |Exclude defines when this policy rule should not be applied. The exclude criteria can include resource information (e.g. kind, name, namespace, labels) and admission review request information like the name or role.
| +| `validate` | [`Validation`](#json-kyverno-io-v1alpha1-Validation) | :white_check_mark: |Validation is used to validate matching resources.
| ## `Validation` {#json-kyverno-io-v1alpha1-Validation} - **Appears in:** - + - [Rule](#json-kyverno-io-v1alpha1-Rule) -Validation defines checks to be performed on matching resources.
-Field | Description |
---|---|
assert [Required]- Assert
- |
-
- Assert specifies an overlay-style pattern used to check resources. - |
-
Assert specifies an overlay-style pattern used to check resources.
| + \ No newline at end of file diff --git a/pkg/commands/serve/options.go b/pkg/commands/serve/options.go index 61087585..a215c38b 100644 --- a/pkg/commands/serve/options.go +++ b/pkg/commands/serve/options.go @@ -49,21 +49,6 @@ func (c *options) Run(_ *cobra.Command, _ []string) error { // initialise gin framework gin.SetMode(c.ginFlags.mode) tonic.SetBindHook(tonic.DefaultBindingHookMaxBodyBytes(int64(c.ginFlags.maxBodySize))) - // tonic.SetErrorHook(func(c *gin.Context, err error) (int, interface{}) { - // switch e := err.(type) { - // case engine.PolicyViolationError: - // return http.StatusBadRequest, gin.H{ - // "violations": e.Violations, - // "error": e.Error(), - // "reason": "POLICY_VALIDATION", - // } - // default: - // return http.StatusBadRequest, gin.H{ - // "error": e.Error(), - // "reason": "ERROR", - // } - // } - // }) // create server server, err := server.New(c.ginFlags.log, c.ginFlags.cors) if err != nil { @@ -75,28 +60,10 @@ func (c *options) Run(_ *cobra.Command, _ []string) error { // LocalCrds: c.engineFlags.localCrds, }, } - // register API routes (with/without cluster support) - // if c.clusterFlags.cluster { - // // create rest config - // restConfig, err := utils.RestConfig(c.clusterFlags.kubeConfigOverrides) - // if err != nil { - // return err - // } - // // create cluster - // cluster, err := cluster.New(restConfig) - // if err != nil { - // return err - // } - // // register API routes - // if err := server.AddAPIRoutes(cluster, apiConfig); err != nil { - // return err - // } - // } else { // register API routes if err := server.AddAPIRoutes(apiConfig); err != nil { return err } - // } // run server ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) defer stop() diff --git a/pkg/server/api/scan/handler.go b/pkg/server/api/scan/handler.go index 7e390a37..279e65c0 100644 --- a/pkg/server/api/scan/handler.go +++ b/pkg/server/api/scan/handler.go @@ -7,71 +7,12 @@ import ( "github.com/loopfz/gadgeto/tonic" ) -// import ( -// "context" -// "fmt" -// "net/http" - -// "github.com/Masterminds/semver/v3" -// "github.com/gin-gonic/gin" -// kyvernov1 "github.com/kyverno/kyverno/api/kyverno/v1" -// "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/resource/loader" -// engineapi "github.com/kyverno/kyverno/pkg/engine/api" -// "github.com/loopfz/gadgeto/tonic" -// "sigs.k8s.io/kubectl-validate/pkg/openapiclient" - -// "github.com/kyverno/playground/backend/data" -// "github.com/kyverno/playground/backend/pkg/cluster" -// "github.com/kyverno/playground/backend/pkg/engine" -// "github.com/kyverno/playground/backend/pkg/engine/models" -// ) - func newHandler(config APIConfiguration) (gin.HandlerFunc, error) { - return tonic.Handler(func(ctx *gin.Context, in *Request) (*EngineResponse, error) { - return &EngineResponse{ + return tonic.Handler(func(ctx *gin.Context, in *Request) (*Response, error) { + return &Response{ // Policies: policies, // Resources: resources, // Results: results, }, nil }, http.StatusOK), nil } - -// func parseKubeVersion(kubeVersion string) (string, error) { -// if kubeVersion == "" { -// return "1.28", nil -// } -// version, err := semver.NewVersion(kubeVersion) -// if err != nil { -// return "", err -// } -// return fmt.Sprint(version.Major(), ".", version.Minor()), nil -// } - -// func validateParams(params *models.Parameters, cmResolver engineapi.ConfigmapResolver, policies []kyvernov1.PolicyInterface) error { -// if params == nil { -// return nil -// } - -// for _, policy := range policies { -// for _, rule := range policy.GetSpec().Rules { -// for _, variable := range rule.Context { -// if variable.APICall == nil && variable.ConfigMap == nil { -// continue -// } -// if _, ok := params.Variables[variable.Name]; ok { -// continue -// } -// if variable.ConfigMap != nil { -// _, err := cmResolver.Get(context.Background(), variable.ConfigMap.Namespace, variable.ConfigMap.Name) -// if err == nil { -// continue -// } -// } - -// return fmt.Errorf("Variable %s is not defined in the context", variable.Name) -// } -// } -// } - -// return nil -// } diff --git a/pkg/server/api/scan/handler_test.go b/pkg/server/api/scan/handler_test.go deleted file mode 100644 index 79dd554c..00000000 --- a/pkg/server/api/scan/handler_test.go +++ /dev/null @@ -1,43 +0,0 @@ -package scan - -// import ( -// "bytes" -// "encoding/json" -// "net/http" -// "net/http/httptest" -// "os" -// "testing" - -// "github.com/gin-gonic/gin" -// "github.com/stretchr/testify/require" - -// "github.com/kyverno/playground/backend/pkg/cluster" -// ) - -// func Test_Serve(t *testing.T) { -// singleResource, err := os.ReadFile("../../../../testdata/namespace.yaml") -// require.NoError(t, err) -// singlePolicy, err := os.ReadFile("../../../../testdata/single-policy.yaml") -// require.NoError(t, err) - -// body := new(bytes.Buffer) -// require.NoError(t, json.NewEncoder(body).Encode(EngineRequest{ -// Resources: string(singleResource), -// Policies: string(singlePolicy), -// })) - -// w := httptest.NewRecorder() -// c, _ := gin.CreateTestContext(w) -// c.Request = httptest.NewRequest(http.MethodPost, "/", body) -// c.Request.Header.Add("Content-Type", "application/json") - -// handler, err := newEngineHandler(cluster.NewFake(), APIConfiguration{}) -// require.NoError(t, err) -// handler(c) - -// if w.Result().StatusCode != http.StatusOK { -// buf := new(bytes.Buffer) -// buf.ReadFrom(w.Result().Body) //nolint: errcheck -// t.Errorf("unexpected error: %s", buf.String()) -// } -// } diff --git a/pkg/server/api/scan/request.go b/pkg/server/api/scan/request.go index d30ebd83..cb2d8483 100644 --- a/pkg/server/api/scan/request.go +++ b/pkg/server/api/scan/request.go @@ -1,95 +1,5 @@ package scan -// import ( -// "testing/fstest" - -// kyvernov1 "github.com/kyverno/kyverno/api/kyverno/v1" -// kyvernov2alpha1 "github.com/kyverno/kyverno/api/kyverno/v2alpha1" -// "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/exception" -// "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/resource/loader" -// "k8s.io/api/admissionregistration/v1alpha1" -// corev1 "k8s.io/api/core/v1" -// "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" -// "k8s.io/client-go/openapi" -// "sigs.k8s.io/kubectl-validate/pkg/openapiclient" -// "sigs.k8s.io/yaml" - -// "github.com/kyverno/playground/backend/data" -// "github.com/kyverno/playground/backend/pkg/cluster" -// "github.com/kyverno/playground/backend/pkg/engine/models" -// "github.com/kyverno/playground/backend/pkg/policy" -// "github.com/kyverno/playground/backend/pkg/resource" -// ) - type Request struct { - Payload string `json:"payload"` + Resources []interface{} `json:"resources"` } - -// func (r *EngineRequest) LoadParameters() (*models.Parameters, error) { -// var params models.Parameters -// if err := yaml.Unmarshal([]byte(r.Context), ¶ms); err != nil { -// return nil, err -// } -// return ¶ms, nil -// } - -// func (r *EngineRequest) LoadPolicies(policyLoader loader.Loader) ([]kyvernov1.PolicyInterface, []v1alpha1.ValidatingAdmissionPolicy, error) { -// return policy.Load(policyLoader, []byte(r.Policies)) -// } - -// func (r *EngineRequest) LoadResources(resourceLoader loader.Loader) ([]unstructured.Unstructured, error) { -// return resource.LoadResources(resourceLoader, []byte(r.Resources)) -// } - -// func (r *EngineRequest) LoadClusterResources(resourceLoader loader.Loader) ([]unstructured.Unstructured, error) { -// return resource.LoadResources(resourceLoader, []byte(r.ClusterResources)) -// } - -// func (r *EngineRequest) LoadOldResources(resourceLoader loader.Loader) ([]unstructured.Unstructured, error) { -// return resource.LoadResources(resourceLoader, []byte(r.OldResources)) -// } - -// func (r *EngineRequest) LoadPolicyExceptions(resourceLoader loader.Loader) ([]*kyvernov2alpha1.PolicyException, error) { -// return exception.Load([]byte(r.PolicyExceptions)) -// } - -// func (r *EngineRequest) LoadConfig(resourceLoader loader.Loader) (*corev1.ConfigMap, error) { -// if len(r.Config) == 0 { -// return nil, nil -// } -// return resource.Load[corev1.ConfigMap](resourceLoader, []byte(r.Config)) -// } - -// func (r *EngineRequest) ResourceLoader(cluster cluster.Cluster, kubeVersion string, config APIConfiguration) (loader.Loader, error) { -// var clients []openapi.Client -// if cluster != nil && !cluster.IsFake() { -// dclient, err := cluster.DClient() -// if err != nil { -// return nil, err -// } -// clients = append(clients, dclient.GetKubeClient().Discovery().OpenAPIV3()) -// } else { -// kubeVersion, err := parseKubeVersion(kubeVersion) -// if err != nil { -// return nil, err -// } -// clients = append(clients, openapiclient.NewHardcodedBuiltins(kubeVersion)) -// } -// clients = append(clients, openapiclient.NewLocalSchemaFiles(data.Schemas(), "schemas")) -// if len(r.CustomResourceDefinitions) != 0 { -// mapFs := fstest.MapFS{ -// "crds.yaml": &fstest.MapFile{ -// Data: []byte(r.CustomResourceDefinitions), -// }, -// } -// clients = append(clients, openapiclient.NewLocalCRDFiles(mapFs, ".")) -// } -// for _, crd := range config.LocalCrds { -// clients = append(clients, openapiclient.NewLocalCRDFiles(nil, crd)) -// } -// for _, crd := range config.BuiltInCrds { -// fs, path := data.BuiltInCrds(crd) -// clients = append(clients, openapiclient.NewLocalCRDFiles(fs, path)) -// } -// return loader.New(openapiclient.NewComposite(clients...)) -// } diff --git a/pkg/server/api/scan/response.go b/pkg/server/api/scan/response.go index 1d6f5a99..cae74b4b 100644 --- a/pkg/server/api/scan/response.go +++ b/pkg/server/api/scan/response.go @@ -1,13 +1,6 @@ package scan -// import ( -// kyvernov1 "github.com/kyverno/kyverno/api/kyverno/v1" -// "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - -// "github.com/kyverno/playground/backend/pkg/engine/models" -// ) - -type EngineResponse struct { +type Response struct { // Policies []kyvernov1.PolicyInterface `json:"policies"` // Resources []unstructured.Unstructured `json:"resources"` // *models.Results diff --git a/website/docs/apis/kyverno-json.v1alpha1.md b/website/docs/apis/kyverno-json.v1alpha1.md index 427e6a58..a0621189 100644 --- a/website/docs/apis/kyverno-json.v1alpha1.md +++ b/website/docs/apis/kyverno-json.v1alpha1.md @@ -12,298 +12,109 @@ auto_generated: true - [Policy](#json-kyverno-io-v1alpha1-Policy) - ## `Policy` {#json-kyverno-io-v1alpha1-Policy} - - - -Field | Description |
---|---|
apiVersion string | json.kyverno.io/v1alpha1 |
kind string | Policy |
TypeMeta [Required]- k8s.io/apimachinery/pkg/apis/meta/v1.TypeMeta
- |
-(Members of TypeMeta are embedded into this type.)
- No description provided. |
-
metadata [Required]- k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta
- |
-
- No description provided.Refer to the Kubernetes API documentation for the fields of the metadata field. |
-
spec [Required]- PolicySpec
- |
-- No description provided. | -
Field | Description |
---|---|
Value [Required]- interface{}
- |
-(Members of Value are embedded into this type.)
- No description provided. |
-
Field | Description |
---|---|
any [Required]- []Assertion
- |
-
- Any allows specifying resources which will be ORed. - |
-
all [Required]- []Assertion
- |
-
- All allows specifying resources which will be ANDed. - |
-
Any allows specifying resources which will be ORed.
| +| `all` | [`[]Assertion`](#json-kyverno-io-v1alpha1-Assertion) | :white_check_mark: |All allows specifying resources which will be ANDed.
| ## `Assertion` {#json-kyverno-io-v1alpha1-Assertion} - **Appears in:** - + - [Assert](#json-kyverno-io-v1alpha1-Assert) - - -Field | Description |
---|---|
message [Required]- string
- |
-
- Message is the variable associated message. - |
-
check [Required]- Any
- |
-
- Check is the assertion check definition. - |
-
Message is the variable associated message.
| +| `check` | [`Any`](#json-kyverno-io-v1alpha1-Any) | :white_check_mark: |Check is the assertion check definition.
| ## `ContextEntry` {#json-kyverno-io-v1alpha1-ContextEntry} - **Appears in:** - + - [Rule](#json-kyverno-io-v1alpha1-Rule) -ContextEntry adds variables and data sources to a rule Context.
-Field | Description |
---|---|
name [Required]- string
- |
-
- Name is the variable name. - |
-
variable [Required]- Any
- |
-
- Variable defines an arbitrary JMESPath context variable that can be defined inline. - |
-
Name is the variable name.
| +| `variable` | [`Any`](#json-kyverno-io-v1alpha1-Any) | :white_check_mark: |Variable defines an arbitrary JMESPath context variable that can be defined inline.
| ## `Match` {#json-kyverno-io-v1alpha1-Match} - **Appears in:** - + - [Rule](#json-kyverno-io-v1alpha1-Rule) - - -Field | Description |
---|---|
any [Required]- []Any
- |
-
- Any allows specifying resources which will be ORed. - |
-
all [Required]- []Any
- |
-
- All allows specifying resources which will be ANDed. - |
-
Any allows specifying resources which will be ORed.
| +| `all` | [`[]Any`](#json-kyverno-io-v1alpha1-Any) | :white_check_mark: |All allows specifying resources which will be ANDed.
| ## `PolicySpec` {#json-kyverno-io-v1alpha1-PolicySpec} - **Appears in:** - + - [Policy](#json-kyverno-io-v1alpha1-Policy) - - -Field | Description |
---|---|
rules [Required]- []Rule
- |
-
- Rules is a list of Rule instances. A Policy contains multiple rules and each rule can validate, mutate, or generate resources. - |
-
Rules is a list of Rule instances. A Policy contains multiple rules and each rule can validate, mutate, or generate resources.
| ## `Rule` {#json-kyverno-io-v1alpha1-Rule} - **Appears in:** - + - [PolicySpec](#json-kyverno-io-v1alpha1-PolicySpec) - - -Field | Description |
---|---|
name [Required]- string
- |
-
- Name is a label to identify the rule, It must be unique within the policy. - |
-
context [Required]- []ContextEntry
- |
-
- Context defines variables and data sources that can be used during rule execution. - |
-
match [Required]- Match
- |
-
- Match defines when this policy rule should be applied. The match -criteria can include resource information (e.g. kind, name, namespace, labels) -and admission review request information like the user name or role. -At least one kind is required. - |
-
exclude [Required]- Match
- |
-
- Exclude defines when this policy rule should not be applied. The exclude -criteria can include resource information (e.g. kind, name, namespace, labels) -and admission review request information like the name or role. - |
-
validate [Required]- Validation
- |
-
- Validation is used to validate matching resources. - |
-
Name is a label to identify the rule, It must be unique within the policy.
| +| `context` | [`[]ContextEntry`](#json-kyverno-io-v1alpha1-ContextEntry) | :white_check_mark: |Context defines variables and data sources that can be used during rule execution.
| +| `match` | [`Match`](#json-kyverno-io-v1alpha1-Match) | :white_check_mark: |Match defines when this policy rule should be applied. The match criteria can include resource information (e.g. kind, name, namespace, labels) and admission review request information like the user name or role. At least one kind is required.
| +| `exclude` | [`Match`](#json-kyverno-io-v1alpha1-Match) | :white_check_mark: |Exclude defines when this policy rule should not be applied. The exclude criteria can include resource information (e.g. kind, name, namespace, labels) and admission review request information like the name or role.
| +| `validate` | [`Validation`](#json-kyverno-io-v1alpha1-Validation) | :white_check_mark: |Validation is used to validate matching resources.
| ## `Validation` {#json-kyverno-io-v1alpha1-Validation} - **Appears in:** - + - [Rule](#json-kyverno-io-v1alpha1-Rule) -Validation defines checks to be performed on matching resources.
-Field | Description |
---|---|
assert [Required]- Assert
- |
-
- Assert specifies an overlay-style pattern used to check resources. - |
-
Assert specifies an overlay-style pattern used to check resources.
| + \ No newline at end of file diff --git a/website/docs/overrides/home.html b/website/docs/overrides/home.html index 121e9b18..9f7270c8 100644 --- a/website/docs/overrides/home.html +++ b/website/docs/overrides/home.html @@ -8,19 +8,20 @@ .md-header { position: initial } - .md-main__inner { - margin: 0 + .md-main .md-main__inner { + display: none } .md-content { display: none } [data-md-color-scheme=slate] .tx-container { padding-top: 1rem; - background: url("data:image/svg+xml;utf8,") no-repeat bottom, linear-gradient(to bottom, var(--md-primary-fg-color), var(--kyverno-primary-color) 99%, #fff 99%) + background: url("data:image/svg+xml;utf8,") no-repeat bottom, linear-gradient(to bottom, var(--md-primary-fg-color), var(--kyverno-primary-color) 99%, #fff 99%); } .tx-container { padding-top: 1rem; - background: url("data:image/svg+xml;utf8,") no-repeat bottom, linear-gradient(to bottom, var(--md-primary-fg-color), var(--kyverno-primary-color) 99%, #fff 99%) + background: url("data:image/svg+xml;utf8,") no-repeat bottom, linear-gradient(to bottom, var(--md-primary-fg-color), var(--kyverno-primary-color) 99%, #fff 99%); + height: calc(100vh - 4.8rem); } .tx-hero { margin: 0 .8rem; @@ -35,23 +36,23 @@ color: currentColor; } .tx-hero__content { - padding-bottom: 6rem + padding-bottom: 0; } .tx-hero .md-button { margin-top: .5rem; margin-right: .5rem; - color: var(--md-primary-bg-color) + color: var(--md-primary-bg-color); } .tx-hero .md-button--primary { background-color: var(--md-primary-bg-color); color: var(--kyverno-primary-color); - border-color: var(--md-primary-bg-color) + border-color: var(--md-primary-bg-color); } .tx-hero .md-button:focus, .tx-hero .md-button:hover { background-color: var(--md-accent-fg-color); color: var(--md-default-bg-color); - border-color: var(--md-accent-fg-color) + border-color: var(--md-accent-fg-color); } @media screen and (max-width:70em) { .tx-hero h1 { @@ -66,16 +67,16 @@ } @media screen and (min-width:70em) { .md-sidebar--secondary { - display: none + display: none; } .tx-hero { display: flex; - align-items: stretch + align-items: stretch; } .tx-hero__content { max-width: 30rem; margin-top: 3.5rem; - padding-bottom: 14vw + padding-bottom: 0; } .tx-hero__image { order: 1; @@ -102,7 +103,7 @@