GithubHelp home page GithubHelp logo

kcl-lang / kcl-openapi Goto Github PK

View Code? Open in Web Editor NEW
8.0 4.0 6.0 1.31 MB

KCL OpenAPI Integration

Home Page: https://kcl-lang.io/docs/tools/cli/openapi/

License: Apache License 2.0

Go 92.78% Shell 0.06% Makefile 0.88% Dockerfile 0.18% Python 6.10%
kcl openapi swagger

kcl-openapi's Introduction

KCL OpenAPI

GoDoc license Coverage Status FOSSA Status

The work on this project is mainly based on go-swagger, and this project just adds some KCL-specific templates and language features to it. We are grateful and sincerely respectful for the outstanding work in go-swagger. Meanwhile, we are working on making the customized features separated from the basic OpenAPI logic in go-swagger.

Main use cases:

  • Swagger Openapi
    • Translate Swagger OpenAPI spec to KCL code
  • Kubernetes CRD
    • Translate Kubernetes CRD to KCL code

Quick Start

Install

The kcl-openapi tool can be installed in both ways:

1 go install

go install kcl-lang.io/kcl-openapi@latest

2 Curl|sh install (MacOS & Linux)

If you don't have to go, you can install the CLI with this one-liner:

curl -fsSL https://kcl-lang.io/script/install-kcl-openapi.sh | /bin/bash

3 Download from release

# 1. download the released binary from:
# https://github.com/kcl-lang/kcl-openapi/releases

# 2. Unzip the package and add the binary location to PATH
export PATH="<Your directory to store KCLOpenAPI binary>:$PATH"

Features

The tool translates Swagger OpenAPI spec and Kubernetes CRD to KCL models.

Translate Swagger OpenAPI Spec to KCL

The tool now supports OpenAPI 2.0. By parsing the "Definitions" section of the spec, the KCL OpenAPI tool will extract the defined models from it and generate the corresponding KCL representation.

The command is as follows:

kcl-openapi generate model -f ${your_open_api_spec} -t ${the_kcl_files_output_dir}

Note: The Kubernetes KCL models among all versions are pre-generated, you get it by executing kpm add k8s:<version> under your project. For detailed information about kpm usage, please refer to kpm quick start guide. Alternatively, if you may want to generate them yourself, please refer Generate KCL Packages from Kubernetes OpenAPI Specs.

Translate Kubernetes CRD to KCL

The tool can also translate the Kubernetes CRD to KCL models. By parsing the spec.versions[n].schema.openAPIV3Schema (n means the latest version of the spec will be used) section of the CRD, the KCL OpenAPI tool will extract the structural schema and generate the corresponding KCL representation.

The command is as follows:

kcl-openapi generate model --crd -f ${your_CRD.yaml} -t ${the_kcl_files_output_dir} --skip-validation

KCL OpenAPI Spec

The KCL OpenAPI Spec defines a complete specification of how OpenAPI objects are mapped to KCL language elements.

Ask for help

If the tool isn't working as you expect, please reach out to us by filing an issue.

License

Apache License Version 2.0

FOSSA Status

kcl-openapi's People

Contributors

amyxia1994 avatar chai2010 avatar fossabot avatar ldxdl avatar michaelchristopher-ui avatar peefy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

kcl-openapi's Issues

Where is the release kcl package for k8s v1.28

General Question

kubernetes v1.28 is release and kcl have not package for k8s 1.28 : https://github.com/orgs/kcl-lang/packages/container/package/k8s

I have got the nothing after checked the doc https://kcl-lang.io/docs/user_docs/guides/working-with-k8s/adopt-from-kubernetes , i have not find the github action for release it, If not I'd like to work on this and would love some guidance, thanks.

I'm not sure is it the right place for this question, if not true and give some guide please,Thanks.

Support specify a directory instead of a single file which the argument is `-f` when generate models

Feature Request

Is your feature request related to a problem? Please describe:

Describe the feature you'd like:
When generate KCL models, we expect to use a directory argument that all source OpenAPI files in it.
And the command of kcl-openapi generate model should scan all files in the directory.

Describe alternatives you've considered:

Teachability, Documentation, Adoption, Migration Strategy:

generating from CRD supports kubernetes 1.23 feature: validation rules

Enhancement

Since k8s v1.23, the validation rules are introduced to use CEL for expressing validation rules. This feature is to enhance the structrual schema validation in CRD via the vendor extension x-kubernetes-validations

kcl openapi needs to support this feature:

  1. augment the KCL OpenAPI spec
  2. support generate corresponding code

ref: https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#validation-rules

[Bug] the version information may be missed if the crd uses Spec.Versions instead of Spec.Version to set the version

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

the crd:

# Deprecated in v1.16 in favor of apiextensions.k8s.io/v1
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  # name must match the spec fields below, and be in the form: <plural>.<group>
  name: crontabs.stable.example.com
spec:
  # group name to use for REST API: /apis/<group>/<version>
  group: stable.example.com
  # list of versions supported by this CustomResourceDefinition
  versions:
    - name: v1
      # Each version can be enabled/disabled by Served flag.
      served: true
      # One and only one version must be marked as the storage version.
      storage: true
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              properties:
                cronSpec:
                  type: string
                image:
                  type: string
                replicas:
                  type: integer
  # either Namespaced or Cluster
  scope: Namespaced
  names:
    # plural name to be used in the URL: /apis/<group>/<version>/<plural>
    plural: crontabs
    # singular name to be used as an alias on the CLI and for display
    singular: crontab
    # kind is normally the CamelCased singular type. Your resource manifests use this.
    kind: CronTab
    # shortNames allow shorter string to match your resource on the CLI
    shortNames:
      - ct
  preserveUnknownFields: false

2. What did you expect to see? (Required)

the generated file: stable_example_com_v1_cron_tab.k and the contents will contain "apiVersion : str, default is "stable.example.com/v1", required"

3. What did you see instead (Required)

the generated file: stable_example_com_cron_tab.k, and the apiVersion line is "apiVersion : str, default is "stable.example.com/", required"

4. What is your KCL components version? (Required)

wrong indenting when generate from schema/attribute description to docstring

Bug Report

when translating k8s openapi to KCL models, the attribute description may contain line break

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

  1. save following code as oai.json
{
   "definitions": {
      "io.k8s.api.admissionregistration.v1.MutatingWebhook": {
         "description": "MutatingWebhook describes an admission webhook and the resources and operations it applies to.",
         "properties": {
            "matchPolicy": {
               "description": "matchPolicy defines how the \"rules\" list is used to match incoming requests. Allowed values are \"Exact\" or \"Equivalent\".\n\n- Exact: match a request only if it exactly matches a specified rule. For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1, but \"rules\" only included `apiGroups:[\"apps\"], apiVersions:[\"v1\"], resources: [\"deployments\"]`, a request to apps/v1beta1 or extensions/v1beta1 would not be sent to the webhook.\n\n- Equivalent: match a request if modifies a resource listed in rules, even via another API group or version. For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1, and \"rules\" only included `apiGroups:[\"apps\"], apiVersions:[\"v1\"], resources: [\"deployments\"]`, a request to apps/v1beta1 or extensions/v1beta1 would be converted to apps/v1 and sent to the webhook.\n\nDefaults to \"Equivalent\"",
               "type": "string"
            }
         }
      }
   },
   "info": {
      "title": "Kubernetes",
      "version": "unversioned"
   },
   "paths": {},
   "swagger": "2.0"
}
  1. run kcl-openapi generate model -f oai.json -t output
  2. run cat output/models/io_k8s_api_admissionregistration_v1_mutating_webhook.k

2. What did you expect to see? (Required)

"""
This file was generated by the KCL auto-gen tool. DO NOT EDIT.
Editing this file might prove futile when you re-run the KCL auto-gen generate command.
"""


schema MutatingWebhook:
    """ MutatingWebhook describes an admission webhook and the resources and operations it applies to.

    Attributes
    ----------
    matchPolicy : str, default is Undefined, optional
        matchPolicy defines how the "rules" list is used to match incoming requests. Allowed values are "Exact" or "Equivalent".
 
        - Exact: match a request only if it exactly matches a specified rule. For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1, but "rules" only included `apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"]`, a request to apps/v1beta1 or extensions/v1beta1 would not be sent to the webhook.
 
        - Equivalent: match a request if modifies a resource listed in rules, even via another API group or version. For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1, and "rules" only included `apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"]`, a request to apps/v1beta1 or extensions/v1beta1 would be converted to apps/v1 and sent to the webhook.
        Defaults to "Equivalent"
    """


    matchPolicy?: str



3. What did you see instead (Required)

"""
This file was generated by the KCL auto-gen tool. DO NOT EDIT.
Editing this file might prove futile when you re-run the KCL auto-gen generate command.
"""


schema MutatingWebhook:
    """ MutatingWebhook describes an admission webhook and the resources and operations it applies to.

    Attributes
    ----------
    matchPolicy : str, default is Undefined, optional
         matchPolicy defines how the "rules" list is used to match incoming requests. Allowed values are "Exact" or "Equivalent".
 
 - Exact: match a request only if it exactly matches a specified rule. For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1, but "rules" only included `apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"]`, a request to apps/v1beta1 or extensions/v1beta1 would not be sent to the webhook.
 
 - Equivalent: match a request if modifies a resource listed in rules, even via another API group or version. For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1, and "rules" only included `apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"]`, a request to apps/v1beta1 or extensions/v1beta1 would be converted to apps/v1 and sent to the webhook.
 Defaults to "Equivalent"
    """


    matchPolicy?: str



4. What is your KusionStack components version? (Required)

--

Generate OpenAPI model failed

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

definitions:
  v1.TestInt:
    type: object
    properties:
      name:
        type: string
        format: int-or-string
    required:
      - name
    x-kcl-type:
      import:
        package: v1.test_int
        alias: test_int
      type: TestInt
swagger: "2.0"
info:
  title: Kusion
  version: v0.0.2
paths: {}

Run:

kcl-openapi generate model -f test_open_api_spec.yaml -t .

2. What did you expect to see? (Required)

test_int.k was generated.

3. What did you see instead (Required)

2023/04/10 22:12:56 validating spec /var/folders/g1/jg19cnb52bbcz2539wk4xfj40000gp/T/test_open_api_spec.yaml39137477
The swagger spec at "/var/folders/g1/jg19cnb52bbcz2539wk4xfj40000gp/T/test_open_api_spec.yaml39137477" is invalid against swagger specification . see errors :
- .swagger in body is required
- .info in body is required
- .paths in body is required

4. What is your KusionStack components version? (Required)

The latest kcl-openapi version:

go install kusionstack.io/kcl-openapi@latest

Go test ./... failed

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

Go test ./...

2. What did you expect to see? (Required)

all test pass

3. What did you see instead (Required)

Run go test ./...
go: downloading github.com/jessevdk/go-flags v1.5.0
go: downloading github.com/go-openapi/loads v0.21.1
go: downloading k8s.io/apiextensions-apiserver v0.24.1
go: downloading k8s.io/apimachinery v0.24.1
go: downloading k8s.io/client-go v0.24.1
go: downloading k8s.io/kube-openapi v0.0.0-20220413171[6](https://github.com/KusionStack/kcl-openapi/runs/6667123044?check_suite_focus=true#step:6:7)46-5e[7](https://github.com/KusionStack/kcl-openapi/runs/6667123044?check_suite_focus=true#step:6:8)f5fdc6da6
go: downloading github.com/go-openapi/analysis v0.21.3
go: downloading github.com/go-openapi/errors v0.20.2
go: downloading github.com/go-openapi/inflect v0.19.0
verifying github.com/go-openapi/[email protected]: checksum mismatch
	downloaded: h1:CPEa+B2oYCkb+lIKB4xP6Ork[8](https://github.com/KusionStack/kcl-openapi/runs/6667123044?check_suite_focus=true#step:6:9)Gvh0GNg[9](https://github.com/KusionStack/kcl-openapi/runs/6667123044?check_suite_focus=true#step:6:10)dm/twI3+QA=
	go.sum:     h1:vR88pR69D/jGh02vPbT4qoxiG+p9e5uT75JJG3O1JIU=

SECURITY ERROR
This download does NOT match an earlier download recorded in go.sum.
The bits may have been replaced on the origin server, or an attacker may
have intercepted the download attempt.

For more information, see 'go help module-auth'.

4. What is your KusionStack components version? (Required)

support setting package root from cli

Feature Request

Is your feature request related to a problem? Please describe:

If the generated kcl files will be placed in a monorepo like konfig, the import stmts in the generated files will be broken. And users need to manually replace all the import paths after generation.

Describe the feature you'd like:

support a --package-root option to allow users to specify the custom package root path to directly generate the right import stmts.

Describe alternatives you've considered:

None

Teachability, Documentation, Adoption, Migration Strategy:

None

Support reusing existing models

Feature Request

Users can specify a directory path containing existing models so to reuse pre-generated models. For example:

kcl-openapi generate model -f <spec_file> -t <target_dir> --existing-models foo/bar

some scenarios of how users might use this:

  • Users might want to add some custom KCL models converted from custom crds while reusing the existing k8s builtin models

kcl-openapi generate from kubernetes swagger.json failed

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

kcl-openapi generate model -f swagger.json

2. What did you expect to see? (Required)

kcl file generated

3. What did you see instead (Required)

command failed when validating the spec. The $ref s under the paths field is not resolved properly by go swagger validator.

  • By replacing the content of the paths field to {}, the generator works.
  • By setting option --skip-validation to the command, the generator works, too.
2023/06/19 20:14:42 validating spec /var/folders/bz/9gzt5_xn37ng7km3wmtqbfzh0000gp/T/swagger-1.24.json4138140450
The swagger spec at "/var/folders/bz/9gzt5_xn37ng7km3wmtqbfzh0000gp/T/swagger-1.24.json4138140450" is invalid against swagger specification 2.0. see errors :
- some references could not be resolved in spec. First found: invalid character 'd' looking for beginning of value

4. What is your KusionStack components version? (Required)

Generate kubernetes packages for all versions

Feature Request

Is your feature request related to a problem? Please describe:

Describe the feature you'd like:

We could generate all versions of KCL Kubernetes packages in advance so that users could directly reuse them, instead of generating repeatedly.

The generated packages could be located at kusionstack/konfig or be managed by kpm.

Describe alternatives you've considered:

Teachability, Documentation, Adoption, Migration Strategy:

go struct to kcl schema

Feature Request

Is your feature request related to a problem? Please describe:

I am trying to convert Prometheus API to KCL, use --crd flag, but I go obscure schema definition like below:

schema MonitoringCoreosComV1PodMonitorSpecPodMetricsEndpointsItems0Authorization:
    """ Authorization section for this endpoint

    Attributes
    ----------
    credentials : MonitoringCoreosComV1PodMonitorSpecPodMetricsEndpointsItems0AuthorizationCredentials, default is Undefined, optional
        credentials
    $type : str, default is Undefined, optional
         Set the authentication type. Defaults to Bearer, Basic will cause an error
    """


    credentials?: MonitoringCoreosComV1PodMonitorSpecPodMetricsEndpointsItems0AuthorizationCredentials

    $type?: str

schema name is longer than my screen....

Detail: https://github.com/KusionStack/konfig/pull/43/files#diff-113bb68b56de1693d4d7a822059831a84cae205e47f0be2c4aeaeab93e01248cL152

Describe the feature you'd like:

Maybe like kubebuilder, we can use go struct, directly generate kcl schemas.

Describe alternatives you've considered:

None

Teachability, Documentation, Adoption, Migration Strategy:

None

the intOrString types in k8s crd is treated as the first type in generation

Bug Report

the intOrString types in k8s crd is treated as the first type in generation

1. Minimal reproduce step (Required)

for intOrString type declaration, see: https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#intorstring

2. What did you expect to see? (Required)

generated code: attribute: int | str

3. What did you see instead (Required)

generated code: attribute: int

log: warning: JSON-Schema type definition as array with several types is not supported in spec.StringOrArray{"integer", "string"}. Taking the first type: integer

more code-gen features: From TF/GPL

Feature Request

More code-gen features are required for the "Adopting From X" series.

  • adopting from Terraform(TF provider/HCL)
  • adopting from Go/Java/...
  • from the perspective of adopting from multiple cloud providers: adopting from k8s/AWS/aliyun

ref:

bug report for `kcl-openapi generate model --crd`: regex.match()

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

kcl-openapi generate model --crd -f crd/alertmanagerconfigs.yaml  -t . --skip-validation

2. What did you expect to see? (Required)

  1. for keyword check, use regex.match() instead of matchPattern()
  2. import statement is not match with konfig base models
import kusion_kubernetes.apimachinery.apis

...

check:
    regex.match(enforcedBodySizeLimit, r"(^0|([0-9]*[.])?[0-9]+((K|M|G|T|E|P)i?)?B)$") if enforcedBodySizeLimit

3. What did you see instead (Required)

import base.pkg.kusion_kubernetes.apimachinery.apis

...

check:
    matchPattern(enforcedBodySizeLimit, (^0|([0-9]*[.])?[0-9]+((K|M|G|T|E|P)i?)?B)$)

4. What is your KusionStack components version? (Required)

gitInfo:
    latestTag: v0.7.0
    commit: 414a12b275f4a7a6849b19266f91f7a3ebdbc3e5
    treeState: clean
buildInfo:
    goVersion: go1.17.13
    GOOS: linux
    GOARCH: amd64
    numCPU: 2
    compiler: gc
    buildTime: "2022-10-17 03:29:32"
dependency:
    kclvmgoVersion: v0.4.3-alpha.4
    kclPluginVersion: v0.4.1-alpha2

provide preprocess script to generate from k8s swagger.json

Feature Request

Is your feature request related to a problem? Please describe:
related to #42

Describe the feature you'd like:

Before generate, there are some pre-process needed:
such as marking the group-version-kind to constants on k8s top models, add x-kcl-type information to provide the package/module info.

We should provide open sourced and tooled pre-process script, so that users can generate kcl packages on their own as needed and keep it consistent.

Describe alternatives you've considered:

Teachability, Documentation, Adoption, Migration Strategy:

Crossplane Composition CRD generates errors

Bug Report

1. Minimal reproduce step (Required)

  1. Install latest kcl-openapi
  2. Download crossplane composition crd from here, or clone repo whichever is preferred to obtain this file.
  3. Type kcl-openapi generate model --crd -f <location of yaml from step 1> -t . --skip-validation
  4. Observe error in output related to a map value MatchCondition.

2. What did you expect to see? (Required)

No error and a generated schema.

3. What did you see instead (Required)

2024/03/12 18:51:47 preprocessing spec with option:  minimal flattening
2024/03/12 18:51:47 building a plan for generation
2024/03/12 18:51:47 generation target .
2024/03/12 18:51:47 planning definitions
2024/03/12 18:51:47 unexpected ordered map value: MatchCondition

I also ran the schema import using kcl import and that outputs a file albeit with an error on line 1171 of the generated file. See this issue for details.

4. What is your KCL components version? (Required)

KCL: 0.8.0-windows-amd64
KCL vscode extension: v0.1.5
OS: Windows11

the -m option does not work, generated models are always placed in default models pkg

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

kcl-openapi generate model --crd -f <crd_path> -m apps -t <target dir> --skip-validation

2. What did you expect to see and what did you see instead (Required)

the generated models should be placed in the apps pkg specified by the -m option, but was actually located in models pkg(the default pkg).

Regularly pull k8s & CRD updates and upload the generated kcl schemas

Feature Request

Regularly pull k8s & CRD updates and upload the generated kcl schemas to artifacthub.

Regular tasks

  • check if there are new Kubernetes openapi releases (and other CRD releases)
  • download the oai/crd spec updates
  • generate the kcl schemas from the spec
  • generate the docs
  • package them
  • upload: uploading requires authentication, this step could be done manually.

remove unnecessary __settings__ in generated models

Enhancement

KCL language is now removing the "settings" feature from schemas, so it's not necessary to include the attribute code __settings__: {str:str} = {"output_type": "STANDALONE"} in generated models.

[Bug] Empty kcl schema check block errors for empty CRD condition fields

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

Use the following CRD file (crd.yaml)

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  labels:
    component: velero
  annotations:
    controller-gen.kubebuilder.io/version: v0.7.0
  name: restores.velero.io
spec:
  group: velero.io
  names:
    kind: Restore
    listKind: RestoreList
    plural: restores
    singular: restore
  scope: Namespaced
  versions:
  - name: v1
    schema:
      openAPIV3Schema:
        description: Restore is a Velero resource that represents the application
          of resources from a Velero backup to a target Kubernetes cluster.
        properties:
          apiVersion:
            description: 'APIVersion defines the versioned schema of this representation
              of an object. Servers should convert recognized schemas to the latest
              internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
            type: string
          kind:
            description: 'Kind is a string value representing the REST resource this
              object represents. Servers may infer this from the endpoint the client
              submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
            type: string
          metadata:
            type: object
          spec:
            description: RestoreSpec defines the specification for a Velero restore.
            properties:
              backupName:
                description: BackupName is the unique name of the Velero backup to
                  restore from.
                type: string
              excludedNamespaces:
                description: ExcludedNamespaces contains a list of namespaces that
                  are not included in the restore.
                items:
                  type: string
                nullable: true
                type: array
              excludedResources:
                description: ExcludedResources is a slice of resource names that are
                  not included in the restore.
                items:
                  type: string
                nullable: true
                type: array
              existingResourcePolicy:
                description: ExistingResourcePolicy specifies the restore behavior
                  for the kubernetes resource to be restored
                nullable: true
                type: string
              hooks:
                description: Hooks represent custom behaviors that should be executed
                  during or post restore.
                properties:
                  resources:
                    items:
                      description: RestoreResourceHookSpec defines one or more RestoreResrouceHooks
                        that should be executed based on the rules defined for namespaces,
                        resources, and label selector.
                      properties:
                        excludedNamespaces:
                          description: ExcludedNamespaces specifies the namespaces
                            to which this hook spec does not apply.
                          items:
                            type: string
                          nullable: true
                          type: array
                        excludedResources:
                          description: ExcludedResources specifies the resources to
                            which this hook spec does not apply.
                          items:
                            type: string
                          nullable: true
                          type: array
                        includedNamespaces:
                          description: IncludedNamespaces specifies the namespaces
                            to which this hook spec applies. If empty, it applies
                            to all namespaces.
                          items:
                            type: string
                          nullable: true
                          type: array
                        includedResources:
                          description: IncludedResources specifies the resources to
                            which this hook spec applies. If empty, it applies to
                            all resources.
                          items:
                            type: string
                          nullable: true
                          type: array
                        labelSelector:
                          description: LabelSelector, if specified, filters the resources
                            to which this hook spec applies.
                          nullable: true
                          properties:
                            matchExpressions:
                              description: matchExpressions is a list of label selector
                                requirements. The requirements are ANDed.
                              items:
                                description: A label selector requirement is a selector
                                  that contains values, a key, and an operator that
                                  relates the key and values.
                                properties:
                                  key:
                                    description: key is the label key that the selector
                                      applies to.
                                    type: string
                                  operator:
                                    description: operator represents a key's relationship
                                      to a set of values. Valid operators are In,
                                      NotIn, Exists and DoesNotExist.
                                    type: string
                                  values:
                                    description: values is an array of string values.
                                      If the operator is In or NotIn, the values array
                                      must be non-empty. If the operator is Exists
                                      or DoesNotExist, the values array must be empty.
                                      This array is replaced during a strategic merge
                                      patch.
                                    items:
                                      type: string
                                    type: array
                                required:
                                - key
                                - operator
                                type: object
                              type: array
                            matchLabels:
                              additionalProperties:
                                type: string
                              description: matchLabels is a map of {key,value} pairs.
                                A single {key,value} in the matchLabels map is equivalent
                                to an element of matchExpressions, whose key field
                                is "key", the operator is "In", and the values array
                                contains only "value". The requirements are ANDed.
                              type: object
                          type: object
                        name:
                          description: Name is the name of this hook.
                          type: string
                        postHooks:
                          description: PostHooks is a list of RestoreResourceHooks
                            to execute during and after restoring a resource.
                          items:
                            description: RestoreResourceHook defines a restore hook
                              for a resource.
                            properties:
                              exec:
                                description: Exec defines an exec restore hook.
                                properties:
                                  command:
                                    description: Command is the command and arguments
                                      to execute from within a container after a pod
                                      has been restored.
                                    items:
                                      type: string
                                    minItems: 1
                                    type: array
                                  container:
                                    description: Container is the container in the
                                      pod where the command should be executed. If
                                      not specified, the pod's first container is
                                      used.
                                    type: string
                                  execTimeout:
                                    description: ExecTimeout defines the maximum amount
                                      of time Velero should wait for the hook to complete
                                      before considering the execution a failure.
                                    type: string
                                  onError:
                                    description: OnError specifies how Velero should
                                      behave if it encounters an error executing this
                                      hook.
                                    enum:
                                    - Continue
                                    - Fail
                                    type: string
                                  waitTimeout:
                                    description: WaitTimeout defines the maximum amount
                                      of time Velero should wait for the container
                                      to be Ready before attempting to run the command.
                                    type: string
                                required:
                                - command
                                type: object
                              init:
                                description: Init defines an init restore hook.
                                properties:
                                  initContainers:
                                    description: InitContainers is list of init containers
                                      to be added to a pod during its restore.
                                    items:
                                      type: object
                                    type: array
                                    x-kubernetes-preserve-unknown-fields: true
                                  timeout:
                                    description: Timeout defines the maximum amount
                                      of time Velero should wait for the initContainers
                                      to complete.
                                    type: string
                                type: object
                            type: object
                          type: array
                      required:
                      - name
                      type: object
                    type: array
                type: object
              includeClusterResources:
                description: IncludeClusterResources specifies whether cluster-scoped
                  resources should be included for consideration in the restore. If
                  null, defaults to true.
                nullable: true
                type: boolean
              includedNamespaces:
                description: IncludedNamespaces is a slice of namespace names to include
                  objects from. If empty, all namespaces are included.
                items:
                  type: string
                nullable: true
                type: array
              includedResources:
                description: IncludedResources is a slice of resource names to include
                  in the restore. If empty, all resources in the backup are included.
                items:
                  type: string
                nullable: true
                type: array
              itemOperationTimeout:
                description: ItemOperationTimeout specifies the time used to wait
                  for RestoreItemAction operations The default value is 1 hour.
                type: string
              labelSelector:
                description: LabelSelector is a metav1.LabelSelector to filter with
                  when restoring individual objects from the backup. If empty or nil,
                  all objects are included. Optional.
                nullable: true
                properties:
                  matchExpressions:
                    description: matchExpressions is a list of label selector requirements.
                      The requirements are ANDed.
                    items:
                      description: A label selector requirement is a selector that
                        contains values, a key, and an operator that relates the key
                        and values.
                      properties:
                        key:
                          description: key is the label key that the selector applies
                            to.
                          type: string
                        operator:
                          description: operator represents a key's relationship to
                            a set of values. Valid operators are In, NotIn, Exists
                            and DoesNotExist.
                          type: string
                        values:
                          description: values is an array of string values. If the
                            operator is In or NotIn, the values array must be non-empty.
                            If the operator is Exists or DoesNotExist, the values
                            array must be empty. This array is replaced during a strategic
                            merge patch.
                          items:
                            type: string
                          type: array
                      required:
                      - key
                      - operator
                      type: object
                    type: array
                  matchLabels:
                    additionalProperties:
                      type: string
                    description: matchLabels is a map of {key,value} pairs. A single
                      {key,value} in the matchLabels map is equivalent to an element
                      of matchExpressions, whose key field is "key", the operator
                      is "In", and the values array contains only "value". The requirements
                      are ANDed.
                    type: object
                type: object
              namespaceMapping:
                additionalProperties:
                  type: string
                description: NamespaceMapping is a map of source namespace names to
                  target namespace names to restore into. Any source namespaces not
                  included in the map will be restored into namespaces of the same
                  name.
                type: object
              orLabelSelectors:
                description: OrLabelSelectors is list of metav1.LabelSelector to filter
                  with when restoring individual objects from the backup. If multiple
                  provided they will be joined by the OR operator. LabelSelector as
                  well as OrLabelSelectors cannot co-exist in restore request, only
                  one of them can be used
                items:
                  description: A label selector is a label query over a set of resources.
                    The result of matchLabels and matchExpressions are ANDed. An empty
                    label selector matches all objects. A null label selector matches
                    no objects.
                  properties:
                    matchExpressions:
                      description: matchExpressions is a list of label selector requirements.
                        The requirements are ANDed.
                      items:
                        description: A label selector requirement is a selector that
                          contains values, a key, and an operator that relates the
                          key and values.
                        properties:
                          key:
                            description: key is the label key that the selector applies
                              to.
                            type: string
                          operator:
                            description: operator represents a key's relationship
                              to a set of values. Valid operators are In, NotIn, Exists
                              and DoesNotExist.
                            type: string
                          values:
                            description: values is an array of string values. If the
                              operator is In or NotIn, the values array must be non-empty.
                              If the operator is Exists or DoesNotExist, the values
                              array must be empty. This array is replaced during a
                              strategic merge patch.
                            items:
                              type: string
                            type: array
                        required:
                        - key
                        - operator
                        type: object
                      type: array
                    matchLabels:
                      additionalProperties:
                        type: string
                      description: matchLabels is a map of {key,value} pairs. A single
                        {key,value} in the matchLabels map is equivalent to an element
                        of matchExpressions, whose key field is "key", the operator
                        is "In", and the values array contains only "value". The requirements
                        are ANDed.
                      type: object
                  type: object
                nullable: true
                type: array
              preserveNodePorts:
                description: PreserveNodePorts specifies whether to restore old nodePorts
                  from backup.
                nullable: true
                type: boolean
              restorePVs:
                description: RestorePVs specifies whether to restore all included
                  PVs from snapshot
                nullable: true
                type: boolean
              restoreStatus:
                description: RestoreStatus specifies which resources we should restore
                  the status field. If nil, no objects are included. Optional.
                nullable: true
                properties:
                  excludedResources:
                    description: ExcludedResources specifies the resources to which
                      will not restore the status.
                    items:
                      type: string
                    nullable: true
                    type: array
                  includedResources:
                    description: IncludedResources specifies the resources to which
                      will restore the status. If empty, it applies to all resources.
                    items:
                      type: string
                    nullable: true
                    type: array
                type: object
              scheduleName:
                description: ScheduleName is the unique name of the Velero schedule
                  to restore from. If specified, and BackupName is empty, Velero will
                  restore from the most recent successful backup created from this
                  schedule.
                type: string
            required:
            - backupName
            type: object
          status:
            description: RestoreStatus captures the current status of a Velero restore
            properties:
              completionTimestamp:
                description: CompletionTimestamp records the time the restore operation
                  was completed. Completion time is recorded even on failed restore.
                  The server's time is used for StartTimestamps
                format: date-time
                nullable: true
                type: string
              errors:
                description: Errors is a count of all error messages that were generated
                  during execution of the restore. The actual errors are stored in
                  object storage.
                type: integer
              failureReason:
                description: FailureReason is an error that caused the entire restore
                  to fail.
                type: string
              phase:
                description: Phase is the current state of the Restore
                enum:
                - New
                - FailedValidation
                - InProgress
                - WaitingForPluginOperations
                - WaitingForPluginOperationsPartiallyFailed
                - Completed
                - PartiallyFailed
                - Failed
                type: string
              progress:
                description: Progress contains information about the restore's execution
                  progress. Note that this information is best-effort only -- if Velero
                  fails to update it during a restore for any reason, it may be inaccurate/stale.
                nullable: true
                properties:
                  itemsRestored:
                    description: ItemsRestored is the number of items that have actually
                      been restored so far
                    type: integer
                  totalItems:
                    description: TotalItems is the total number of items to be restored.
                      This number may change throughout the execution of the restore
                      due to plugins that return additional related items to restore
                    type: integer
                type: object
              restoreItemOperationsAttempted:
                description: RestoreItemOperationsAttempted is the total number of
                  attempted async RestoreItemAction operations for this restore.
                type: integer
              restoreItemOperationsCompleted:
                description: RestoreItemOperationsCompleted is the total number of
                  successfully completed async RestoreItemAction operations for this
                  restore.
                type: integer
              restoreItemOperationsFailed:
                description: RestoreItemOperationsFailed is the total number of async
                  RestoreItemAction operations for this restore which ended with an
                  error.
                type: integer
              startTimestamp:
                description: StartTimestamp records the time the restore operation
                  was started. The server's time is used for StartTimestamps
                format: date-time
                nullable: true
                type: string
              validationErrors:
                description: ValidationErrors is a slice of all validation errors
                  (if applicable)
                items:
                  type: string
                nullable: true
                type: array
              warnings:
                description: Warnings is a count of all warning messages that were
                  generated during execution of the restore. The actual warnings are
                  stored in object storage.
                type: integer
            type: object
        type: object
    served: true
    storage: true
status:
  acceptedNames:
    kind: ""
    plural: ""
  conditions: []
  storedVersions: []
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  labels:
    component: velero
  annotations:
    controller-gen.kubebuilder.io/version: v0.7.0
  name: schedules.velero.io
spec:
  group: velero.io
  names:
    kind: Schedule
    listKind: ScheduleList
    plural: schedules
    singular: schedule
  scope: Namespaced
  versions:
  - additionalPrinterColumns:
    - description: Status of the schedule
      jsonPath: .status.phase
      name: Status
      type: string
    - description: A Cron expression defining when to run the Backup
      jsonPath: .spec.schedule
      name: Schedule
      type: string
    - description: The last time a Backup was run for this schedule
      jsonPath: .status.lastBackup
      name: LastBackup
      type: date
    - jsonPath: .metadata.creationTimestamp
      name: Age
      type: date
    - jsonPath: .spec.paused
      name: Paused
      type: boolean
    name: v1
    schema:
      openAPIV3Schema:
        description: Schedule is a Velero resource that represents a pre-scheduled
          or periodic Backup that should be run.
        properties:
          apiVersion:
            description: 'APIVersion defines the versioned schema of this representation
              of an object. Servers should convert recognized schemas to the latest
              internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
            type: string
          kind:
            description: 'Kind is a string value representing the REST resource this
              object represents. Servers may infer this from the endpoint the client
              submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
            type: string
          metadata:
            type: object
          spec:
            description: ScheduleSpec defines the specification for a Velero schedule
            properties:
              paused:
                description: Paused specifies whether the schedule is paused or not
                type: boolean
              schedule:
                description: Schedule is a Cron expression defining when to run the
                  Backup.
                type: string
              template:
                description: Template is the definition of the Backup to be run on
                  the provided schedule
                properties:
                  csiSnapshotTimeout:
                    description: CSISnapshotTimeout specifies the time used to wait
                      for CSI VolumeSnapshot status turns to ReadyToUse during creation,
                      before returning error as timeout. The default value is 10 minute.
                    type: string
                  defaultVolumesToFsBackup:
                    description: DefaultVolumesToFsBackup specifies whether pod volume
                      file system backup should be used for all volumes by default.
                    nullable: true
                    type: boolean
                  defaultVolumesToRestic:
                    description: "DefaultVolumesToRestic specifies whether restic
                      should be used to take a backup of all pod volumes by default.
                      \n Deprecated: this field is no longer used and will be removed
                      entirely in future. Use DefaultVolumesToFsBackup instead."
                    nullable: true
                    type: boolean
                  excludedClusterScopedResources:
                    description: ExcludedClusterScopedResources is a slice of cluster-scoped
                      resource type names to exclude from the backup. If set to "*",
                      all cluster-scoped resource types are excluded. The default
                      value is empty.
                    items:
                      type: string
                    nullable: true
                    type: array
                  excludedNamespaceScopedResources:
                    description: ExcludedNamespaceScopedResources is a slice of namespace-scoped
                      resource type names to exclude from the backup. If set to "*",
                      all namespace-scoped resource types are excluded. The default
                      value is empty.
                    items:
                      type: string
                    nullable: true
                    type: array
                  excludedNamespaces:
                    description: ExcludedNamespaces contains a list of namespaces
                      that are not included in the backup.
                    items:
                      type: string
                    nullable: true
                    type: array
                  excludedResources:
                    description: ExcludedResources is a slice of resource names that
                      are not included in the backup.
                    items:
                      type: string
                    nullable: true
                    type: array
                  hooks:
                    description: Hooks represent custom behaviors that should be executed
                      at different phases of the backup.
                    properties:
                      resources:
                        description: Resources are hooks that should be executed when
                          backing up individual instances of a resource.
                        items:
                          description: BackupResourceHookSpec defines one or more
                            BackupResourceHooks that should be executed based on the
                            rules defined for namespaces, resources, and label selector.
                          properties:
                            excludedNamespaces:
                              description: ExcludedNamespaces specifies the namespaces
                                to which this hook spec does not apply.
                              items:
                                type: string
                              nullable: true
                              type: array
                            excludedResources:
                              description: ExcludedResources specifies the resources
                                to which this hook spec does not apply.
                              items:
                                type: string
                              nullable: true
                              type: array
                            includedNamespaces:
                              description: IncludedNamespaces specifies the namespaces
                                to which this hook spec applies. If empty, it applies
                                to all namespaces.
                              items:
                                type: string
                              nullable: true
                              type: array
                            includedResources:
                              description: IncludedResources specifies the resources
                                to which this hook spec applies. If empty, it applies
                                to all resources.
                              items:
                                type: string
                              nullable: true
                              type: array
                            labelSelector:
                              description: LabelSelector, if specified, filters the
                                resources to which this hook spec applies.
                              nullable: true
                              properties:
                                matchExpressions:
                                  description: matchExpressions is a list of label
                                    selector requirements. The requirements are ANDed.
                                  items:
                                    description: A label selector requirement is a
                                      selector that contains values, a key, and an
                                      operator that relates the key and values.
                                    properties:
                                      key:
                                        description: key is the label key that the
                                          selector applies to.
                                        type: string
                                      operator:
                                        description: operator represents a key's relationship
                                          to a set of values. Valid operators are
                                          In, NotIn, Exists and DoesNotExist.
                                        type: string
                                      values:
                                        description: values is an array of string
                                          values. If the operator is In or NotIn,
                                          the values array must be non-empty. If the
                                          operator is Exists or DoesNotExist, the
                                          values array must be empty. This array is
                                          replaced during a strategic merge patch.
                                        items:
                                          type: string
                                        type: array
                                    required:
                                    - key
                                    - operator
                                    type: object
                                  type: array
                                matchLabels:
                                  additionalProperties:
                                    type: string
                                  description: matchLabels is a map of {key,value}
                                    pairs. A single {key,value} in the matchLabels
                                    map is equivalent to an element of matchExpressions,
                                    whose key field is "key", the operator is "In",
                                    and the values array contains only "value". The
                                    requirements are ANDed.
                                  type: object
                              type: object
                            name:
                              description: Name is the name of this hook.
                              type: string
                            post:
                              description: PostHooks is a list of BackupResourceHooks
                                to execute after storing the item in the backup. These
                                are executed after all "additional items" from item
                                actions are processed.
                              items:
                                description: BackupResourceHook defines a hook for
                                  a resource.
                                properties:
                                  exec:
                                    description: Exec defines an exec hook.
                                    properties:
                                      command:
                                        description: Command is the command and arguments
                                          to execute.
                                        items:
                                          type: string
                                        minItems: 1
                                        type: array
                                      container:
                                        description: Container is the container in
                                          the pod where the command should be executed.
                                          If not specified, the pod's first container
                                          is used.
                                        type: string
                                      onError:
                                        description: OnError specifies how Velero
                                          should behave if it encounters an error
                                          executing this hook.
                                        enum:
                                        - Continue
                                        - Fail
                                        type: string
                                      timeout:
                                        description: Timeout defines the maximum amount
                                          of time Velero should wait for the hook
                                          to complete before considering the execution
                                          a failure.
                                        type: string
                                    required:
                                    - command
                                    type: object
                                required:
                                - exec
                                type: object
                              type: array
                            pre:
                              description: PreHooks is a list of BackupResourceHooks
                                to execute prior to storing the item in the backup.
                                These are executed before any "additional items" from
                                item actions are processed.
                              items:
                                description: BackupResourceHook defines a hook for
                                  a resource.
                                properties:
                                  exec:
                                    description: Exec defines an exec hook.
                                    properties:
                                      command:
                                        description: Command is the command and arguments
                                          to execute.
                                        items:
                                          type: string
                                        minItems: 1
                                        type: array
                                      container:
                                        description: Container is the container in
                                          the pod where the command should be executed.
                                          If not specified, the pod's first container
                                          is used.
                                        type: string
                                      onError:
                                        description: OnError specifies how Velero
                                          should behave if it encounters an error
                                          executing this hook.
                                        enum:
                                        - Continue
                                        - Fail
                                        type: string
                                      timeout:
                                        description: Timeout defines the maximum amount
                                          of time Velero should wait for the hook
                                          to complete before considering the execution
                                          a failure.
                                        type: string
                                    required:
                                    - command
                                    type: object
                                required:
                                - exec
                                type: object
                              type: array
                          required:
                          - name
                          type: object
                        nullable: true
                        type: array
                    type: object
                  includeClusterResources:
                    description: IncludeClusterResources specifies whether cluster-scoped
                      resources should be included for consideration in the backup.
                    nullable: true
                    type: boolean
                  includedClusterScopedResources:
                    description: IncludedClusterScopedResources is a slice of cluster-scoped
                      resource type names to include in the backup. If set to "*",
                      all cluster-scoped resource types are included. The default
                      value is empty, which means only related cluster-scoped resources
                      are included.
                    items:
                      type: string
                    nullable: true
                    type: array
                  includedNamespaceScopedResources:
                    description: IncludedNamespaceScopedResources is a slice of namespace-scoped
                      resource type names to include in the backup. The default value
                      is "*".
                    items:
                      type: string
                    nullable: true
                    type: array
                  includedNamespaces:
                    description: IncludedNamespaces is a slice of namespace names
                      to include objects from. If empty, all namespaces are included.
                    items:
                      type: string
                    nullable: true
                    type: array
                  includedResources:
                    description: IncludedResources is a slice of resource names to
                      include in the backup. If empty, all resources are included.
                    items:
                      type: string
                    nullable: true
                    type: array
                  itemOperationTimeout:
                    description: ItemOperationTimeout specifies the time used to wait
                      for asynchronous BackupItemAction operations The default value
                      is 1 hour.
                    type: string
                  labelSelector:
                    description: LabelSelector is a metav1.LabelSelector to filter
                      with when adding individual objects to the backup. If empty
                      or nil, all objects are included. Optional.
                    nullable: true
                    properties:
                      matchExpressions:
                        description: matchExpressions is a list of label selector
                          requirements. The requirements are ANDed.
                        items:
                          description: A label selector requirement is a selector
                            that contains values, a key, and an operator that relates
                            the key and values.
                          properties:
                            key:
                              description: key is the label key that the selector
                                applies to.
                              type: string
                            operator:
                              description: operator represents a key's relationship
                                to a set of values. Valid operators are In, NotIn,
                                Exists and DoesNotExist.
                              type: string
                            values:
                              description: values is an array of string values. If
                                the operator is In or NotIn, the values array must
                                be non-empty. If the operator is Exists or DoesNotExist,
                                the values array must be empty. This array is replaced
                                during a strategic merge patch.
                              items:
                                type: string
                              type: array
                          required:
                          - key
                          - operator
                          type: object
                        type: array
                      matchLabels:
                        additionalProperties:
                          type: string
                        description: matchLabels is a map of {key,value} pairs. A
                          single {key,value} in the matchLabels map is equivalent
                          to an element of matchExpressions, whose key field is "key",
                          the operator is "In", and the values array contains only
                          "value". The requirements are ANDed.
                        type: object
                    type: object
                  metadata:
                    properties:
                      labels:
                        additionalProperties:
                          type: string
                        type: object
                    type: object
                  orLabelSelectors:
                    description: OrLabelSelectors is list of metav1.LabelSelector
                      to filter with when adding individual objects to the backup.
                      If multiple provided they will be joined by the OR operator.
                      LabelSelector as well as OrLabelSelectors cannot co-exist in
                      backup request, only one of them can be used.
                    items:
                      description: A label selector is a label query over a set of
                        resources. The result of matchLabels and matchExpressions
                        are ANDed. An empty label selector matches all objects. A
                        null label selector matches no objects.
                      properties:
                        matchExpressions:
                          description: matchExpressions is a list of label selector
                            requirements. The requirements are ANDed.
                          items:
                            description: A label selector requirement is a selector
                              that contains values, a key, and an operator that relates
                              the key and values.
                            properties:
                              key:
                                description: key is the label key that the selector
                                  applies to.
                                type: string
                              operator:
                                description: operator represents a key's relationship
                                  to a set of values. Valid operators are In, NotIn,
                                  Exists and DoesNotExist.
                                type: string
                              values:
                                description: values is an array of string values.
                                  If the operator is In or NotIn, the values array
                                  must be non-empty. If the operator is Exists or
                                  DoesNotExist, the values array must be empty. This
                                  array is replaced during a strategic merge patch.
                                items:
                                  type: string
                                type: array
                            required:
                            - key
                            - operator
                            type: object
                          type: array
                        matchLabels:
                          additionalProperties:
                            type: string
                          description: matchLabels is a map of {key,value} pairs.
                            A single {key,value} in the matchLabels map is equivalent
                            to an element of matchExpressions, whose key field is
                            "key", the operator is "In", and the values array contains
                            only "value". The requirements are ANDed.
                          type: object
                      type: object
                    nullable: true
                    type: array
                  orderedResources:
                    additionalProperties:
                      type: string
                    description: OrderedResources specifies the backup order of resources
                      of specific Kind. The map key is the resource name and value
                      is a list of object names separated by commas. Each resource
                      name has format "namespace/objectname".  For cluster resources,
                      simply use "objectname".
                    nullable: true
                    type: object
                  resourcePolicy:
                    description: ResourcePolicy specifies the referenced resource
                      policies that backup should follow
                    properties:
                      apiGroup:
                        description: APIGroup is the group for the resource being
                          referenced. If APIGroup is not specified, the specified
                          Kind must be in the core API group. For any other third-party
                          types, APIGroup is required.
                        type: string
                      kind:
                        description: Kind is the type of resource being referenced
                        type: string
                      name:
                        description: Name is the name of resource being referenced
                        type: string
                    required:
                    - kind
                    - name
                    type: object
                  snapshotVolumes:
                    description: SnapshotVolumes specifies whether to take snapshots
                      of any PV's referenced in the set of objects included in the
                      Backup.
                    nullable: true
                    type: boolean
                  storageLocation:
                    description: StorageLocation is a string containing the name of
                      a BackupStorageLocation where the backup should be stored.
                    type: string
                  ttl:
                    description: TTL is a time.Duration-parseable string describing
                      how long the Backup should be retained for.
                    type: string
                  volumeSnapshotLocations:
                    description: VolumeSnapshotLocations is a list containing names
                      of VolumeSnapshotLocations associated with this backup.
                    items:
                      type: string
                    type: array
                type: object
              useOwnerReferencesInBackup:
                description: UseOwnerReferencesBackup specifies whether to use OwnerReferences
                  on backups created by this Schedule.
                nullable: true
                type: boolean
            required:
            - schedule
            - template
            type: object
          status:
            description: ScheduleStatus captures the current state of a Velero schedule
            properties:
              lastBackup:
                description: LastBackup is the last time a Backup was run for this
                  Schedule schedule
                format: date-time
                nullable: true
                type: string
              phase:
                description: Phase is the current phase of the Schedule
                enum:
                - New
                - Enabled
                - FailedValidation
                type: string
              validationErrors:
                description: ValidationErrors is a slice of all validation errors
                  (if applicable)
                items:
                  type: string
                type: array
            type: object
        type: object
    served: true
    storage: true
    subresources: {}
status:
  acceptedNames:
    kind: ""
    plural: ""
  conditions: []
  storedVersions: []

2. What did you expect to see? (Required)

The right generated KCL schema

schema VeleroIoV1RestoreSpecHooksResourcesItems0PostHooksItems0:
    """
    RestoreResourceHook defines a restore hook for a resource.

    Attributes
    ----------
    exec : VeleroIoV1RestoreSpecHooksResourcesItems0PostHooksItems0Exec, default is Undefined, optional
        exec
    init : VeleroIoV1RestoreSpecHooksResourcesItems0PostHooksItems0Init, default is Undefined, optional
        init
    """


    exec?: VeleroIoV1RestoreSpecHooksResourcesItems0PostHooksItems0Exec

    init?: VeleroIoV1RestoreSpecHooksResourcesItems0PostHooksItems0Init

3. What did you see instead (Required)

schema VeleroIoV1RestoreSpecHooksResourcesItems0PostHooksItems0:
    """
    RestoreResourceHook defines a restore hook for a resource.

    Attributes
    ----------
    exec : VeleroIoV1RestoreSpecHooksResourcesItems0PostHooksItems0Exec, default is Undefined, optional
        exec
    init : VeleroIoV1RestoreSpecHooksResourcesItems0PostHooksItems0Init, default is Undefined, optional
        init
    """


    exec?: VeleroIoV1RestoreSpecHooksResourcesItems0PostHooksItems0Exec

    init?: VeleroIoV1RestoreSpecHooksResourcesItems0PostHooksItems0Init


    check:  # Unexpected empty check blocks

4. What is your KCL components version? (Required)

The latest kcl-openapi version

CRD convert error: no openapi schema found

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

  1. unzip the following file and put it in /oam.yaml

oam.yaml.zip

  1. run kcl-openapi generate model --crd --skip-validation -f Desktop/oam.yaml

2. What did you expect to see? (Required)

KCL files generated

3. What did you see instead (Required)

error:

could not generate swagger spec: Desktop/oam.yaml, err: no openapi schema found in the crd file. Please check following fields: spec.Validation.OpenAPIV3Schema, spec.Versions.0.Schema

4. What is your KusionStack components version? (Required)

kcl import issues

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

I tried to import crd from json file and there are several issues.

https://github.com/prometheus-operator/prometheus-operator/blob/main/jsonnet/prometheus-operator/servicemonitors-crd.json

first, if I use -m jsonschema, it will crash.

second, if I use jq and yq command to convert json to yaml and use -m crd to import, It will be successful. However, when i import this generated schema. It is giving error. I think the reason is because pkg regex is imported but there are some fields in the file which are called regex.

2. What did you expect to see? (Required)

I expect there should be no error

3. What did you see instead (Required)

error[E2G22]: TypeError
   --> /Users/me/myproject/models/monitoring_coreos_com_v1_service_monitor.k:598:43
    |
598 |         all sourceLabels in sourceLabels {regex.match(str(sourceLabels), r"^[a-zA-Z_][a-zA-Z0-9_]*$") if sourceLabels } if sourceLabels
    |                                           ^ attribute 'match' not found in 'str'
    |


4. What is your KCL components version? (Required)

0.8.1

bug report: conflict import path when multiple imports exist with the same pkg name

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

kcl-openapi generate model -f swagger.json

2. What did you expect to see? (Required)

For example, the generated io/k8s/api/apps/v1/deployment_spec.k file:

The generated code should add import as name when there are multiple import packages(io.k8s.api.core.v1 and io.k8s.apimachinery.pkg.apis.meta.v1) with the same package name(v1)

"""
This is the deployment_spec module in io.k8s.api.apps.v1 package.
This file was generated by the KCL auto-gen tool. DO NOT EDIT.
Editing this file might prove futile when you re-run the KCL auto-gen generate command.
"""
import io.k8s.api.core.v1 as coreV1
import io.k8s.apimachinery.pkg.apis.meta.v1


schema DeploymentSpec:
    """ DeploymentSpec is the specification of the desired behavior of the Deployment.

    Attributes
    ----------
    minReadySeconds : int, default is Undefined, optional
         Minimum number of seconds for which a newly created pod should be ready without any of its container crashing, for it to be considered available. Defaults to 0 (pod will be considered available as soon as it is ready)
    paused : bool, default is Undefined, optional
         Indicates that the deployment is paused.
    progressDeadlineSeconds : int, default is Undefined, optional
         The maximum time in seconds for a deployment to make progress before it is considered to be failed. The deployment controller will continue to process failed deployments and a condition with a ProgressDeadlineExceeded reason will be surfaced in the deployment status. Note that progress will not be estimated during the time a deployment is paused. Defaults to 600s.
    replicas : int, default is Undefined, optional
         Number of desired pods. This is a pointer to distinguish between explicit zero and not specified. Defaults to 1.
    revisionHistoryLimit : int, default is Undefined, optional
         The number of old ReplicaSets to retain to allow rollback. This is a pointer to distinguish between explicit zero and not specified. Defaults to 10.
    selector : v1.LabelSelector, default is Undefined, required
         Label selector for pods. Existing ReplicaSets whose pods are selected by this will be the ones affected by this deployment. It must match the pod template's labels.
    strategy : DeploymentStrategy, default is Undefined, optional
         The deployment strategy to use to replace existing pods with new ones.
    template : coreV1.PodTemplateSpec, default is Undefined, required
         Template describes the pods that will be created.
    """


    minReadySeconds?: int

    paused?: bool

    progressDeadlineSeconds?: int

    replicas?: int

    revisionHistoryLimit?: int

    selector: v1.LabelSelector

    strategy?: DeploymentStrategy

    template: coreV1.PodTemplateSpec


3. What did you see instead (Required)

# no import as:
import io.k8s.api.core.v1
import io.k8s.apimachinery.pkg.apis.meta.v1

schema DeploymentSpec:
    # ...
    # both use the same import as name "v1"
    selector: v1.LabelSelector
    template: v1.PodTemplateSpec

4. What is your KusionStack components version? (Required)

Go install failed, require a version

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

As readme said: "Or we can only install the tool with go install: Go install ..."

$ go install kusionstack.io/kcl-openapi

2. What did you expect to see? (Required)

Go install succeed

3. What did you see instead (Required)

go: 'go install' requires a version when current directory is not in a module
	Try 'go install kusionstack.io/kcl-openapi@latest' to install the latest version

4. What is your KusionStack components version? (Required)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.