From b5ccdf7f4b74b64e1c2af5a929e5c4d5ec400d2b Mon Sep 17 00:00:00 2001 From: peefy Date: Thu, 7 Dec 2023 11:08:06 +0800 Subject: [PATCH] feat: impl multiple crd import Signed-off-by: peefy --- examples/import/Makefile | 5 + examples/import/crd/Makefile | 11 + examples/import/crd/crd.yaml | 799 ++++++++++++++++++ examples/import/crd/kcl.mod | 7 + examples/import/crd/kcl.mod.lock | 9 + examples/import/crd/main.k | 1 + .../crd/models/dapr_io_v1alpha1_component.k | 125 +++ .../models/dapr_io_v1alpha1_configuration.k | 689 +++++++++++++++ .../crd/models/dapr_io_v1alpha1_resiliency.k | 269 ++++++ .../models/dapr_io_v2alpha1_subscription.k | 129 +++ go.mod | 6 +- go.sum | 12 +- pkg/options/import.go | 14 +- pkg/options/run.go | 6 +- 14 files changed, 2067 insertions(+), 15 deletions(-) create mode 100644 examples/import/Makefile create mode 100644 examples/import/crd/Makefile create mode 100644 examples/import/crd/crd.yaml create mode 100644 examples/import/crd/kcl.mod create mode 100644 examples/import/crd/kcl.mod.lock create mode 100644 examples/import/crd/main.k create mode 100644 examples/import/crd/models/dapr_io_v1alpha1_component.k create mode 100644 examples/import/crd/models/dapr_io_v1alpha1_configuration.k create mode 100644 examples/import/crd/models/dapr_io_v1alpha1_resiliency.k create mode 100644 examples/import/crd/models/dapr_io_v2alpha1_subscription.k diff --git a/examples/import/Makefile b/examples/import/Makefile new file mode 100644 index 0000000..6de8565 --- /dev/null +++ b/examples/import/Makefile @@ -0,0 +1,5 @@ +run: + make test + +test: + make -C crd diff --git a/examples/import/crd/Makefile b/examples/import/crd/Makefile new file mode 100644 index 0000000..0ad8071 --- /dev/null +++ b/examples/import/crd/Makefile @@ -0,0 +1,11 @@ +run: + kcl import -m crd crd.yaml + cd models && rm -r ./k8s + rm -rf ./models/dapr_io_v1alpha1_subscription.k + kcl mod init + kcl mod add k8s + kcl run ./models + cd .. + +test: + make run diff --git a/examples/import/crd/crd.yaml b/examples/import/crd/crd.yaml new file mode 100644 index 0000000..a809965 --- /dev/null +++ b/examples/import/crd/crd.yaml @@ -0,0 +1,799 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: components.dapr.io + labels: + app.kubernetes.io/part-of: "dapr" +spec: + group: dapr.io + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: Component describes an Dapr component type + 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 + auth: + description: Auth represents authentication details for the component + properties: + secretStore: + type: string + required: + - secretStore + type: object + 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 + scopes: + items: + type: string + type: array + spec: + description: ComponentSpec is the spec for a component + properties: + initTimeout: + type: string + ignoreErrors: + type: boolean + metadata: + items: + description: MetadataItem is a name/value pair for a metadata + properties: + name: + type: string + secretKeyRef: + description: SecretKeyRef is a reference to a secret holding + the value for the metadata item. Name is the secret name, + and key is the field in the secret. + properties: + key: + type: string + name: + type: string + required: + - key + - name + type: object + value: + x-kubernetes-preserve-unknown-fields: true + required: + - name + type: object + type: array + type: + type: string + version: + type: string + required: + - metadata + - type + - version + type: object + type: object + served: true + storage: true + names: + kind: Component + plural: components + singular: component + categories: + - all + - dapr + scope: Namespaced +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.9.2 + creationTimestamp: null + name: configurations.dapr.io + labels: + app.kubernetes.io/part-of: "dapr" +spec: + group: dapr.io + names: + kind: Configuration + listKind: ConfigurationList + plural: configurations + singular: configuration + scope: Namespaced + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: Configuration describes an Dapr configuration setting. + 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: ConfigurationSpec is the spec for an configuration. + properties: + accessControl: + description: AccessControlSpec is the spec object in ConfigurationSpec. + properties: + defaultAction: + type: string + policies: + items: + description: AppPolicySpec defines the policy data structure + for each app. + properties: + appId: + type: string + defaultAction: + type: string + namespace: + type: string + operations: + items: + description: AppOperationAction defines the data structure + for each app operation. + properties: + action: + type: string + httpVerb: + items: + type: string + type: array + name: + type: string + required: + - action + - name + type: object + type: array + trustDomain: + type: string + required: + - appId + type: object + type: array + trustDomain: + type: string + type: object + api: + description: APISpec describes the configuration for Dapr APIs. + properties: + allowed: + description: List of allowed APIs. Can be used in conjunction with denied. + items: + description: APIAccessRule describes an access rule for allowing or denying a Dapr API. + properties: + name: + type: string + protocol: + type: string + version: + type: string + required: + - name + - version + type: object + type: array + denied: + description: List of denied APIs. Can be used in conjunction with allowed. + items: + description: APIAccessRule describes an access rule for allowing or denying a Dapr API. + properties: + name: + type: string + protocol: + type: string + version: + type: string + required: + - name + - version + type: object + type: array + type: object + appHttpPipeline: + description: PipelineSpec defines the middleware pipeline. + properties: + handlers: + items: + description: HandlerSpec defines a request handlers. + properties: + name: + type: string + selector: + description: SelectorSpec selects target services to which + the handler is to be applied. + properties: + fields: + items: + description: SelectorField defines a selector fields. + properties: + field: + type: string + value: + type: string + required: + - field + - value + type: object + type: array + required: + - fields + type: object + type: + type: string + required: + - name + - type + type: object + type: array + required: + - handlers + type: object + components: + description: ComponentsSpec describes the configuration for Dapr components + properties: + deny: + description: Denylist of component types that cannot be instantiated + items: + type: string + type: array + type: object + features: + items: + description: FeatureSpec defines the features that are enabled/disabled. + properties: + enabled: + type: boolean + name: + type: string + required: + - enabled + - name + type: object + type: array + httpPipeline: + description: PipelineSpec defines the middleware pipeline. + properties: + handlers: + items: + description: HandlerSpec defines a request handlers. + properties: + name: + type: string + selector: + description: SelectorSpec selects target services to which + the handler is to be applied. + properties: + fields: + items: + description: SelectorField defines a selector fields. + properties: + field: + type: string + value: + type: string + required: + - field + - value + type: object + type: array + required: + - fields + type: object + type: + type: string + required: + - name + - type + type: object + type: array + required: + - handlers + type: object + logging: + description: LoggingSpec defines the configuration for logging. + properties: + apiLogging: + description: Configure API logging. + properties: + enabled: + description: Default value for enabling API logging. Sidecars can always override this by setting `--enable-api-logging` to true or false explicitly. The default value is false. + type: boolean + obfuscateURLs: + description: 'When enabled, obfuscates the values of URLs in HTTP API logs, logging the route name rather than the full path being invoked, which could contain PII. Default: false. This option has no effect if API logging is disabled.' + type: boolean + omitHealthChecks: + description: 'If true, health checks are not reported in API logs. Default: false. This option has no effect if API logging is disabled.' + type: boolean + type: object + type: object + metric: + default: + enabled: true + description: MetricSpec defines metrics configuration. + properties: + enabled: + type: boolean + rules: + items: + description: MetricsRule defines configuration options for a + metric. + properties: + labels: + items: + description: MetricsLabel defines an object that allows + to set regex expressions for a label. + properties: + name: + type: string + regex: + additionalProperties: + type: string + type: object + required: + - name + - regex + type: object + type: array + name: + type: string + required: + - labels + - name + type: object + type: array + required: + - enabled + type: object + metrics: + default: + enabled: true + description: MetricSpec defines metrics configuration. + properties: + enabled: + type: boolean + rules: + items: + description: MetricsRule defines configuration options for a + metric. + properties: + labels: + items: + description: MetricsLabel defines an object that allows + to set regex expressions for a label. + properties: + name: + type: string + regex: + additionalProperties: + type: string + type: object + required: + - name + - regex + type: object + type: array + name: + type: string + required: + - labels + - name + type: object + type: array + required: + - enabled + type: object + mtls: + description: MTLSSpec defines mTLS configuration. + properties: + allowedClockSkew: + type: string + enabled: + type: boolean + workloadCertTTL: + type: string + required: + - enabled + type: object + nameResolution: + description: NameResolutionSpec is the spec for name resolution configuration. + properties: + component: + type: string + configuration: + description: DynamicValue is a dynamic value struct for the component.metadata + pair value. + type: object + x-kubernetes-preserve-unknown-fields: true + version: + type: string + required: + - component + - configuration + - version + type: object + secrets: + description: SecretsSpec is the spec for secrets configuration. + properties: + scopes: + items: + description: SecretsScope defines the scope for secrets. + properties: + allowedSecrets: + items: + type: string + type: array + defaultAccess: + type: string + deniedSecrets: + items: + type: string + type: array + storeName: + type: string + required: + - storeName + type: object + type: array + required: + - scopes + type: object + tracing: + description: TracingSpec defines distributed tracing configuration. + properties: + otel: + description: OtelSpec defines Otel exporter configurations. + properties: + endpointAddress: + type: string + isSecure: + type: boolean + protocol: + type: string + required: + - endpointAddress + - isSecure + - protocol + type: object + samplingRate: + type: string + stdout: + type: boolean + zipkin: + description: ZipkinSpec defines Zipkin trace configurations. + properties: + endpointAddress: + type: string + required: + - endpointAddress + type: object + required: + - samplingRate + type: object + type: object + type: object + served: true + storage: true +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.5.0 + creationTimestamp: null + name: resiliencies.dapr.io + labels: + app.kubernetes.io/part-of: "dapr" +spec: + group: dapr.io + names: + kind: Resiliency + listKind: ResiliencyList + plural: resiliencies + singular: resiliency + categories: + - dapr + scope: Namespaced + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + 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 + scopes: + items: + type: string + type: array + spec: + properties: + policies: + properties: + circuitBreakers: + additionalProperties: + properties: + interval: + type: string + maxRequests: + type: integer + timeout: + type: string + trip: + type: string + type: object + type: object + retries: + additionalProperties: + properties: + duration: + type: string + maxInterval: + type: string + maxRetries: + type: integer + policy: + type: string + type: object + type: object + timeouts: + additionalProperties: + type: string + type: object + type: object + targets: + properties: + actors: + additionalProperties: + properties: + circuitBreaker: + type: string + circuitBreakerCacheSize: + type: integer + circuitBreakerScope: + type: string + retry: + type: string + timeout: + type: string + type: object + type: object + apps: + additionalProperties: + properties: + circuitBreaker: + type: string + circuitBreakerCacheSize: + type: integer + retry: + type: string + timeout: + type: string + type: object + type: object + components: + additionalProperties: + properties: + inbound: + properties: + circuitBreaker: + type: string + retry: + type: string + timeout: + type: string + type: object + outbound: + properties: + circuitBreaker: + type: string + retry: + type: string + timeout: + type: string + type: object + type: object + type: object + type: object + required: + - policies + - targets + type: object + type: object + served: true + storage: true +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: subscriptions.dapr.io + labels: + app.kubernetes.io/part-of: "dapr" +spec: + group: dapr.io + conversion: + strategy: Webhook + webhook: + clientConfig: + service: + namespace: replaceme # Patched by post-install webhook + name: dapr-webhook + path: /convert + #caBundle: Patched by post-install webhook + conversionReviewVersions: + - v1 + - v2alpha1 + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: Subscription describes an pub/sub event subscription. + 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 + scopes: + items: + type: string + type: array + spec: + description: SubscriptionSpec is the spec for an event subscription. + properties: + pubsubname: + type: string + route: + type: string + topic: + type: string + deadLetterTopic: + type: string + bulkSubscribe: + description: Represents bulk subscribe properies + properties: + enabled: + type: boolean + maxMessagesCount: + type: integer + maxAwaitDurationMs: + type: integer + required: + - enabled + type: object + metadata: + additionalProperties: + type: string + type: object + required: + - pubsubname + - route + - topic + type: object + type: object + served: true + storage: false + - name: v2alpha1 + schema: + openAPIV3Schema: + description: Subscription describes an pub/sub event subscription. + 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 + scopes: + items: + type: string + type: array + spec: + description: SubscriptionSpec is the spec for an event subscription. + properties: + metadata: + additionalProperties: + type: string + description: The optional metadata to provide the subscription. + type: object + pubsubname: + description: The PubSub component name. + type: string + routes: + description: The Routes configuration for this topic. + properties: + default: + type: string + rules: + description: The list of rules for this topic. + items: + description: Rule is used to specify the condition for sending + a message to a specific path. + properties: + match: + description: The optional CEL expression used to match the + event. If the match is not specified, then the route is + considered the default. The rules are tested in the order + specified, so they should be define from most-to-least + specific. The default route should appear last in the + list. + type: string + path: + description: The path for events that match this rule. + type: string + required: + - match + - path + type: object + type: array + type: object + topic: + description: The topic name to subscribe to. + type: string + deadLetterTopic: + description: The optional dead letter queue for this topic to send events to. + type: string + bulkSubscribe: + description: Represents bulk subscribe properies + properties: + enabled: + type: boolean + maxMessagesCount: + type: integer + maxAwaitDurationMs: + type: integer + required: + - enabled + type: object + required: + - pubsubname + - routes + - topic + type: object + type: object + served: true + storage: true + names: + kind: Subscription + listKind: SubscriptionList + plural: subscriptions + singular: subscription + categories: + - all + - dapr + scope: Namespaced diff --git a/examples/import/crd/kcl.mod b/examples/import/crd/kcl.mod new file mode 100644 index 0000000..019d9c9 --- /dev/null +++ b/examples/import/crd/kcl.mod @@ -0,0 +1,7 @@ +[package] +name = "import" +edition = "0.0.1" +version = "0.0.1" + +[dependencies] +k8s = "1.28" diff --git a/examples/import/crd/kcl.mod.lock b/examples/import/crd/kcl.mod.lock new file mode 100644 index 0000000..8c61a23 --- /dev/null +++ b/examples/import/crd/kcl.mod.lock @@ -0,0 +1,9 @@ +[dependencies] + [dependencies.k8s] + name = "k8s" + full_name = "k8s_1.28" + version = "1.28" + sum = "aTxPUVZyr9MdiB3YdiY/8pCh9sC55yURnZdGlJsKG6Q=" + reg = "ghcr.io" + repo = "kcl-lang/k8s" + oci_tag = "1.28" diff --git a/examples/import/crd/main.k b/examples/import/crd/main.k new file mode 100644 index 0000000..fa7048e --- /dev/null +++ b/examples/import/crd/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file diff --git a/examples/import/crd/models/dapr_io_v1alpha1_component.k b/examples/import/crd/models/dapr_io_v1alpha1_component.k new file mode 100644 index 0000000..f8221b7 --- /dev/null +++ b/examples/import/crd/models/dapr_io_v1alpha1_component.k @@ -0,0 +1,125 @@ +""" +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 k8s.apimachinery.pkg.apis.meta.v1 + + +schema Component: + """ + Component describes an Dapr component type + + Attributes + ---------- + apiVersion : str, default is "dapr.io/v1alpha1", required + 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 + auth : DaprIoV1alpha1ComponentAuth, default is Undefined, optional + auth + kind : str, default is "Component", required + 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 + metadata : v1.ObjectMeta, default is Undefined, optional + metadata + scopes : [str], default is Undefined, optional + scopes + spec : DaprIoV1alpha1ComponentSpec, default is Undefined, optional + spec + """ + + + apiVersion: "dapr.io/v1alpha1" = "dapr.io/v1alpha1" + + auth?: DaprIoV1alpha1ComponentAuth + + kind: "Component" = "Component" + + metadata?: v1.ObjectMeta + + scopes?: [str] + + spec?: DaprIoV1alpha1ComponentSpec + + +schema DaprIoV1alpha1ComponentAuth: + """ + Auth represents authentication details for the component + + Attributes + ---------- + secretStore : str, default is Undefined, required + secret store + """ + + + secretStore: str + + +schema DaprIoV1alpha1ComponentSpec: + """ + ComponentSpec is the spec for a component + + Attributes + ---------- + ignoreErrors : bool, default is Undefined, optional + ignore errors + initTimeout : str, default is Undefined, optional + init timeout + metadata : [DaprIoV1alpha1ComponentSpecMetadataItems0], default is Undefined, required + metadata + $type : str, default is Undefined, required + type + version : str, default is Undefined, required + version + """ + + + ignoreErrors?: bool + + initTimeout?: str + + metadata: [DaprIoV1alpha1ComponentSpecMetadataItems0] + + $type: str + + version: str + + +schema DaprIoV1alpha1ComponentSpecMetadataItems0: + """ + MetadataItem is a name/value pair for a metadata + + Attributes + ---------- + name : str, default is Undefined, required + name + secretKeyRef : DaprIoV1alpha1ComponentSpecMetadataItems0SecretKeyRef, default is Undefined, optional + secret key ref + value : any, default is Undefined, optional + value + """ + + + name: str + + secretKeyRef?: DaprIoV1alpha1ComponentSpecMetadataItems0SecretKeyRef + + value?: any + + +schema DaprIoV1alpha1ComponentSpecMetadataItems0SecretKeyRef: + """ + SecretKeyRef is a reference to a secret holding the value for the metadata item. Name is the secret name, and key is the field in the secret. + + Attributes + ---------- + key : str, default is Undefined, required + key + name : str, default is Undefined, required + name + """ + + + key: str + + name: str + + diff --git a/examples/import/crd/models/dapr_io_v1alpha1_configuration.k b/examples/import/crd/models/dapr_io_v1alpha1_configuration.k new file mode 100644 index 0000000..2f09f83 --- /dev/null +++ b/examples/import/crd/models/dapr_io_v1alpha1_configuration.k @@ -0,0 +1,689 @@ +""" +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 k8s.apimachinery.pkg.apis.meta.v1 + + +schema Configuration: + """ + Configuration describes an Dapr configuration setting. + + Attributes + ---------- + apiVersion : str, default is "dapr.io/v1alpha1", required + 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 + kind : str, default is "Configuration", required + 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 + metadata : v1.ObjectMeta, default is Undefined, optional + metadata + spec : DaprIoV1alpha1ConfigurationSpec, default is Undefined, optional + spec + """ + + + apiVersion: "dapr.io/v1alpha1" = "dapr.io/v1alpha1" + + kind: "Configuration" = "Configuration" + + metadata?: v1.ObjectMeta + + spec?: DaprIoV1alpha1ConfigurationSpec + + +schema DaprIoV1alpha1ConfigurationSpec: + """ + ConfigurationSpec is the spec for an configuration. + + Attributes + ---------- + accessControl : DaprIoV1alpha1ConfigurationSpecAccessControl, default is Undefined, optional + access control + api : DaprIoV1alpha1ConfigurationSpecAPI, default is Undefined, optional + api + appHttpPipeline : DaprIoV1alpha1ConfigurationSpecAppHTTPPipeline, default is Undefined, optional + app Http pipeline + components : DaprIoV1alpha1ConfigurationSpecComponents, default is Undefined, optional + components + features : [DaprIoV1alpha1ConfigurationSpecFeaturesItems0], default is Undefined, optional + features + httpPipeline : DaprIoV1alpha1ConfigurationSpecHTTPPipeline, default is Undefined, optional + http pipeline + logging : DaprIoV1alpha1ConfigurationSpecLogging, default is Undefined, optional + logging + metric : DaprIoV1alpha1ConfigurationSpecMetric, default is Undefined, optional + metric + metrics : DaprIoV1alpha1ConfigurationSpecMetrics, default is Undefined, optional + metrics + mtls : DaprIoV1alpha1ConfigurationSpecMtls, default is Undefined, optional + mtls + nameResolution : DaprIoV1alpha1ConfigurationSpecNameResolution, default is Undefined, optional + name resolution + secrets : DaprIoV1alpha1ConfigurationSpecSecrets, default is Undefined, optional + secrets + tracing : DaprIoV1alpha1ConfigurationSpecTracing, default is Undefined, optional + tracing + """ + + + accessControl?: DaprIoV1alpha1ConfigurationSpecAccessControl + + api?: DaprIoV1alpha1ConfigurationSpecAPI + + appHttpPipeline?: DaprIoV1alpha1ConfigurationSpecAppHTTPPipeline + + components?: DaprIoV1alpha1ConfigurationSpecComponents + + features?: [DaprIoV1alpha1ConfigurationSpecFeaturesItems0] + + httpPipeline?: DaprIoV1alpha1ConfigurationSpecHTTPPipeline + + logging?: DaprIoV1alpha1ConfigurationSpecLogging + + metric?: DaprIoV1alpha1ConfigurationSpecMetric + + metrics?: DaprIoV1alpha1ConfigurationSpecMetrics + + mtls?: DaprIoV1alpha1ConfigurationSpecMtls + + nameResolution?: DaprIoV1alpha1ConfigurationSpecNameResolution + + secrets?: DaprIoV1alpha1ConfigurationSpecSecrets + + tracing?: DaprIoV1alpha1ConfigurationSpecTracing + + +schema DaprIoV1alpha1ConfigurationSpecAPI: + """ + APISpec describes the configuration for Dapr APIs. + + Attributes + ---------- + allowed : [DaprIoV1alpha1ConfigurationSpecAPIAllowedItems0], default is Undefined, optional + List of allowed APIs. Can be used in conjunction with denied. + denied : [DaprIoV1alpha1ConfigurationSpecAPIDeniedItems0], default is Undefined, optional + List of denied APIs. Can be used in conjunction with allowed. + """ + + + allowed?: [DaprIoV1alpha1ConfigurationSpecAPIAllowedItems0] + + denied?: [DaprIoV1alpha1ConfigurationSpecAPIDeniedItems0] + + +schema DaprIoV1alpha1ConfigurationSpecAPIAllowedItems0: + """ + APIAccessRule describes an access rule for allowing or denying a Dapr API. + + Attributes + ---------- + name : str, default is Undefined, required + name + $protocol : str, default is Undefined, optional + protocol + version : str, default is Undefined, required + version + """ + + + name: str + + $protocol?: str + + version: str + + +schema DaprIoV1alpha1ConfigurationSpecAPIDeniedItems0: + """ + APIAccessRule describes an access rule for allowing or denying a Dapr API. + + Attributes + ---------- + name : str, default is Undefined, required + name + $protocol : str, default is Undefined, optional + protocol + version : str, default is Undefined, required + version + """ + + + name: str + + $protocol?: str + + version: str + + +schema DaprIoV1alpha1ConfigurationSpecAccessControl: + """ + AccessControlSpec is the spec object in ConfigurationSpec. + + Attributes + ---------- + defaultAction : str, default is Undefined, optional + default action + policies : [DaprIoV1alpha1ConfigurationSpecAccessControlPoliciesItems0], default is Undefined, optional + policies + trustDomain : str, default is Undefined, optional + trust domain + """ + + + defaultAction?: str + + policies?: [DaprIoV1alpha1ConfigurationSpecAccessControlPoliciesItems0] + + trustDomain?: str + + +schema DaprIoV1alpha1ConfigurationSpecAccessControlPoliciesItems0: + """ + AppPolicySpec defines the policy data structure for each app. + + Attributes + ---------- + appId : str, default is Undefined, required + app Id + defaultAction : str, default is Undefined, optional + default action + namespace : str, default is Undefined, optional + namespace + operations : [DaprIoV1alpha1ConfigurationSpecAccessControlPoliciesItems0OperationsItems0], default is Undefined, optional + operations + trustDomain : str, default is Undefined, optional + trust domain + """ + + + appId: str + + defaultAction?: str + + namespace?: str + + operations?: [DaprIoV1alpha1ConfigurationSpecAccessControlPoliciesItems0OperationsItems0] + + trustDomain?: str + + +schema DaprIoV1alpha1ConfigurationSpecAccessControlPoliciesItems0OperationsItems0: + """ + AppOperationAction defines the data structure for each app operation. + + Attributes + ---------- + action : str, default is Undefined, required + action + httpVerb : [str], default is Undefined, optional + http verb + name : str, default is Undefined, required + name + """ + + + action: str + + httpVerb?: [str] + + name: str + + +schema DaprIoV1alpha1ConfigurationSpecAppHTTPPipeline: + """ + PipelineSpec defines the middleware pipeline. + + Attributes + ---------- + handlers : [DaprIoV1alpha1ConfigurationSpecAppHTTPPipelineHandlersItems0], default is Undefined, required + handlers + """ + + + handlers: [DaprIoV1alpha1ConfigurationSpecAppHTTPPipelineHandlersItems0] + + +schema DaprIoV1alpha1ConfigurationSpecAppHTTPPipelineHandlersItems0: + """ + HandlerSpec defines a request handlers. + + Attributes + ---------- + name : str, default is Undefined, required + name + selector : DaprIoV1alpha1ConfigurationSpecAppHTTPPipelineHandlersItems0Selector, default is Undefined, optional + selector + $type : str, default is Undefined, required + type + """ + + + name: str + + selector?: DaprIoV1alpha1ConfigurationSpecAppHTTPPipelineHandlersItems0Selector + + $type: str + + +schema DaprIoV1alpha1ConfigurationSpecAppHTTPPipelineHandlersItems0Selector: + """ + SelectorSpec selects target services to which the handler is to be applied. + + Attributes + ---------- + fields : [DaprIoV1alpha1ConfigurationSpecAppHTTPPipelineHandlersItems0SelectorFieldsItems0], default is Undefined, required + fields + """ + + + fields: [DaprIoV1alpha1ConfigurationSpecAppHTTPPipelineHandlersItems0SelectorFieldsItems0] + + +schema DaprIoV1alpha1ConfigurationSpecAppHTTPPipelineHandlersItems0SelectorFieldsItems0: + """ + SelectorField defines a selector fields. + + Attributes + ---------- + field : str, default is Undefined, required + field + value : str, default is Undefined, required + value + """ + + + field: str + + value: str + + +schema DaprIoV1alpha1ConfigurationSpecComponents: + """ + ComponentsSpec describes the configuration for Dapr components + + Attributes + ---------- + deny : [str], default is Undefined, optional + Denylist of component types that cannot be instantiated + """ + + + deny?: [str] + + +schema DaprIoV1alpha1ConfigurationSpecFeaturesItems0: + """ + FeatureSpec defines the features that are enabled/disabled. + + Attributes + ---------- + enabled : bool, default is Undefined, required + enabled + name : str, default is Undefined, required + name + """ + + + enabled: bool + + name: str + + +schema DaprIoV1alpha1ConfigurationSpecHTTPPipeline: + """ + PipelineSpec defines the middleware pipeline. + + Attributes + ---------- + handlers : [DaprIoV1alpha1ConfigurationSpecHTTPPipelineHandlersItems0], default is Undefined, required + handlers + """ + + + handlers: [DaprIoV1alpha1ConfigurationSpecHTTPPipelineHandlersItems0] + + +schema DaprIoV1alpha1ConfigurationSpecHTTPPipelineHandlersItems0: + """ + HandlerSpec defines a request handlers. + + Attributes + ---------- + name : str, default is Undefined, required + name + selector : DaprIoV1alpha1ConfigurationSpecHTTPPipelineHandlersItems0Selector, default is Undefined, optional + selector + $type : str, default is Undefined, required + type + """ + + + name: str + + selector?: DaprIoV1alpha1ConfigurationSpecHTTPPipelineHandlersItems0Selector + + $type: str + + +schema DaprIoV1alpha1ConfigurationSpecHTTPPipelineHandlersItems0Selector: + """ + SelectorSpec selects target services to which the handler is to be applied. + + Attributes + ---------- + fields : [DaprIoV1alpha1ConfigurationSpecHTTPPipelineHandlersItems0SelectorFieldsItems0], default is Undefined, required + fields + """ + + + fields: [DaprIoV1alpha1ConfigurationSpecHTTPPipelineHandlersItems0SelectorFieldsItems0] + + +schema DaprIoV1alpha1ConfigurationSpecHTTPPipelineHandlersItems0SelectorFieldsItems0: + """ + SelectorField defines a selector fields. + + Attributes + ---------- + field : str, default is Undefined, required + field + value : str, default is Undefined, required + value + """ + + + field: str + + value: str + + +schema DaprIoV1alpha1ConfigurationSpecLogging: + """ + LoggingSpec defines the configuration for logging. + + Attributes + ---------- + apiLogging : DaprIoV1alpha1ConfigurationSpecLoggingAPILogging, default is Undefined, optional + api logging + """ + + + apiLogging?: DaprIoV1alpha1ConfigurationSpecLoggingAPILogging + + +schema DaprIoV1alpha1ConfigurationSpecLoggingAPILogging: + """ + Configure API logging. + + Attributes + ---------- + enabled : bool, default is Undefined, optional + Default value for enabling API logging. Sidecars can always override this by setting `--enable-api-logging` to true or false explicitly. The default value is false. + obfuscateURLs : bool, default is Undefined, optional + When enabled, obfuscates the values of URLs in HTTP API logs, logging the route name rather than the full path being invoked, which could contain PII. Default: false. This option has no effect if API logging is disabled. + omitHealthChecks : bool, default is Undefined, optional + If true, health checks are not reported in API logs. Default: false. This option has no effect if API logging is disabled. + """ + + + enabled?: bool + + obfuscateURLs?: bool + + omitHealthChecks?: bool + + +schema DaprIoV1alpha1ConfigurationSpecMetric: + """ + MetricSpec defines metrics configuration. + + Attributes + ---------- + enabled : bool, default is Undefined, required + enabled + rules : [DaprIoV1alpha1ConfigurationSpecMetricRulesItems0], default is Undefined, optional + rules + """ + + + enabled: bool + + rules?: [DaprIoV1alpha1ConfigurationSpecMetricRulesItems0] + + +schema DaprIoV1alpha1ConfigurationSpecMetricRulesItems0: + """ + MetricsRule defines configuration options for a metric. + + Attributes + ---------- + labels : [DaprIoV1alpha1ConfigurationSpecMetricRulesItems0LabelsItems0], default is Undefined, required + labels + name : str, default is Undefined, required + name + """ + + + labels: [DaprIoV1alpha1ConfigurationSpecMetricRulesItems0LabelsItems0] + + name: str + + +schema DaprIoV1alpha1ConfigurationSpecMetricRulesItems0LabelsItems0: + """ + MetricsLabel defines an object that allows to set regex expressions for a label. + + Attributes + ---------- + name : str, default is Undefined, required + name + regex : {str:str}, default is Undefined, required + regex + """ + + + name: str + + regex: {str:str} + + +schema DaprIoV1alpha1ConfigurationSpecMetrics: + """ + MetricSpec defines metrics configuration. + + Attributes + ---------- + enabled : bool, default is Undefined, required + enabled + rules : [DaprIoV1alpha1ConfigurationSpecMetricsRulesItems0], default is Undefined, optional + rules + """ + + + enabled: bool + + rules?: [DaprIoV1alpha1ConfigurationSpecMetricsRulesItems0] + + +schema DaprIoV1alpha1ConfigurationSpecMetricsRulesItems0: + """ + MetricsRule defines configuration options for a metric. + + Attributes + ---------- + labels : [DaprIoV1alpha1ConfigurationSpecMetricsRulesItems0LabelsItems0], default is Undefined, required + labels + name : str, default is Undefined, required + name + """ + + + labels: [DaprIoV1alpha1ConfigurationSpecMetricsRulesItems0LabelsItems0] + + name: str + + +schema DaprIoV1alpha1ConfigurationSpecMetricsRulesItems0LabelsItems0: + """ + MetricsLabel defines an object that allows to set regex expressions for a label. + + Attributes + ---------- + name : str, default is Undefined, required + name + regex : {str:str}, default is Undefined, required + regex + """ + + + name: str + + regex: {str:str} + + +schema DaprIoV1alpha1ConfigurationSpecMtls: + """ + MTLSSpec defines mTLS configuration. + + Attributes + ---------- + allowedClockSkew : str, default is Undefined, optional + allowed clock skew + enabled : bool, default is Undefined, required + enabled + workloadCertTTL : str, default is Undefined, optional + workload cert TTL + """ + + + allowedClockSkew?: str + + enabled: bool + + workloadCertTTL?: str + + +schema DaprIoV1alpha1ConfigurationSpecNameResolution: + """ + NameResolutionSpec is the spec for name resolution configuration. + + Attributes + ---------- + component : str, default is Undefined, required + component + configuration : any, default is Undefined, required + DynamicValue is a dynamic value struct for the component.metadata pair value. + version : str, default is Undefined, required + version + """ + + + component: str + + configuration: any + + version: str + + +schema DaprIoV1alpha1ConfigurationSpecSecrets: + """ + SecretsSpec is the spec for secrets configuration. + + Attributes + ---------- + scopes : [DaprIoV1alpha1ConfigurationSpecSecretsScopesItems0], default is Undefined, required + scopes + """ + + + scopes: [DaprIoV1alpha1ConfigurationSpecSecretsScopesItems0] + + +schema DaprIoV1alpha1ConfigurationSpecSecretsScopesItems0: + """ + SecretsScope defines the scope for secrets. + + Attributes + ---------- + allowedSecrets : [str], default is Undefined, optional + allowed secrets + defaultAccess : str, default is Undefined, optional + default access + deniedSecrets : [str], default is Undefined, optional + denied secrets + storeName : str, default is Undefined, required + store name + """ + + + allowedSecrets?: [str] + + defaultAccess?: str + + deniedSecrets?: [str] + + storeName: str + + +schema DaprIoV1alpha1ConfigurationSpecTracing: + """ + TracingSpec defines distributed tracing configuration. + + Attributes + ---------- + otel : DaprIoV1alpha1ConfigurationSpecTracingOtel, default is Undefined, optional + otel + samplingRate : str, default is Undefined, required + sampling rate + stdout : bool, default is Undefined, optional + stdout + zipkin : DaprIoV1alpha1ConfigurationSpecTracingZipkin, default is Undefined, optional + zipkin + """ + + + otel?: DaprIoV1alpha1ConfigurationSpecTracingOtel + + samplingRate: str + + stdout?: bool + + zipkin?: DaprIoV1alpha1ConfigurationSpecTracingZipkin + + +schema DaprIoV1alpha1ConfigurationSpecTracingOtel: + """ + OtelSpec defines Otel exporter configurations. + + Attributes + ---------- + endpointAddress : str, default is Undefined, required + endpoint address + isSecure : bool, default is Undefined, required + is secure + $protocol : str, default is Undefined, required + protocol + """ + + + endpointAddress: str + + isSecure: bool + + $protocol: str + + +schema DaprIoV1alpha1ConfigurationSpecTracingZipkin: + """ + ZipkinSpec defines Zipkin trace configurations. + + Attributes + ---------- + endpointAddress : str, default is Undefined, required + endpoint address + """ + + + endpointAddress: str + + diff --git a/examples/import/crd/models/dapr_io_v1alpha1_resiliency.k b/examples/import/crd/models/dapr_io_v1alpha1_resiliency.k new file mode 100644 index 0000000..09eb781 --- /dev/null +++ b/examples/import/crd/models/dapr_io_v1alpha1_resiliency.k @@ -0,0 +1,269 @@ +""" +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 k8s.apimachinery.pkg.apis.meta.v1 + + +schema Resiliency: + """ + dapr io v1alpha1 resiliency + + Attributes + ---------- + apiVersion : str, default is "dapr.io/v1alpha1", required + 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 + kind : str, default is "Resiliency", required + 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 + metadata : v1.ObjectMeta, default is Undefined, optional + metadata + scopes : [str], default is Undefined, optional + scopes + spec : DaprIoV1alpha1ResiliencySpec, default is Undefined, optional + spec + """ + + + apiVersion: "dapr.io/v1alpha1" = "dapr.io/v1alpha1" + + kind: "Resiliency" = "Resiliency" + + metadata?: v1.ObjectMeta + + scopes?: [str] + + spec?: DaprIoV1alpha1ResiliencySpec + + +schema DaprIoV1alpha1ResiliencySpec: + """ + dapr io v1alpha1 resiliency spec + + Attributes + ---------- + policies : DaprIoV1alpha1ResiliencySpecPolicies, default is Undefined, required + policies + targets : DaprIoV1alpha1ResiliencySpecTargets, default is Undefined, required + targets + """ + + + policies: DaprIoV1alpha1ResiliencySpecPolicies + + targets: DaprIoV1alpha1ResiliencySpecTargets + + +schema DaprIoV1alpha1ResiliencySpecPolicies: + """ + dapr io v1alpha1 resiliency spec policies + + Attributes + ---------- + circuitBreakers : {str:DaprIoV1alpha1ResiliencySpecPoliciesCircuitBreakersAnon}, default is Undefined, optional + circuit breakers + retries : {str:DaprIoV1alpha1ResiliencySpecPoliciesRetriesAnon}, default is Undefined, optional + retries + timeouts : {str:str}, default is Undefined, optional + timeouts + """ + + + circuitBreakers?: {str:DaprIoV1alpha1ResiliencySpecPoliciesCircuitBreakersAnon} + + retries?: {str:DaprIoV1alpha1ResiliencySpecPoliciesRetriesAnon} + + timeouts?: {str:str} + + +schema DaprIoV1alpha1ResiliencySpecPoliciesCircuitBreakersAnon: + """ + dapr io v1alpha1 resiliency spec policies circuit breakers anon + + Attributes + ---------- + interval : str, default is Undefined, optional + interval + maxRequests : int, default is Undefined, optional + max requests + timeout : str, default is Undefined, optional + timeout + trip : str, default is Undefined, optional + trip + """ + + + interval?: str + + maxRequests?: int + + timeout?: str + + trip?: str + + +schema DaprIoV1alpha1ResiliencySpecPoliciesRetriesAnon: + """ + dapr io v1alpha1 resiliency spec policies retries anon + + Attributes + ---------- + duration : str, default is Undefined, optional + duration + maxInterval : str, default is Undefined, optional + max interval + maxRetries : int, default is Undefined, optional + max retries + policy : str, default is Undefined, optional + policy + """ + + + duration?: str + + maxInterval?: str + + maxRetries?: int + + policy?: str + + +schema DaprIoV1alpha1ResiliencySpecTargets: + """ + dapr io v1alpha1 resiliency spec targets + + Attributes + ---------- + actors : {str:DaprIoV1alpha1ResiliencySpecTargetsActorsAnon}, default is Undefined, optional + actors + apps : {str:DaprIoV1alpha1ResiliencySpecTargetsAppsAnon}, default is Undefined, optional + apps + components : {str:DaprIoV1alpha1ResiliencySpecTargetsComponentsAnon}, default is Undefined, optional + components + """ + + + actors?: {str:DaprIoV1alpha1ResiliencySpecTargetsActorsAnon} + + apps?: {str:DaprIoV1alpha1ResiliencySpecTargetsAppsAnon} + + components?: {str:DaprIoV1alpha1ResiliencySpecTargetsComponentsAnon} + + +schema DaprIoV1alpha1ResiliencySpecTargetsActorsAnon: + """ + dapr io v1alpha1 resiliency spec targets actors anon + + Attributes + ---------- + circuitBreaker : str, default is Undefined, optional + circuit breaker + circuitBreakerCacheSize : int, default is Undefined, optional + circuit breaker cache size + circuitBreakerScope : str, default is Undefined, optional + circuit breaker scope + retry : str, default is Undefined, optional + retry + timeout : str, default is Undefined, optional + timeout + """ + + + circuitBreaker?: str + + circuitBreakerCacheSize?: int + + circuitBreakerScope?: str + + retry?: str + + timeout?: str + + +schema DaprIoV1alpha1ResiliencySpecTargetsAppsAnon: + """ + dapr io v1alpha1 resiliency spec targets apps anon + + Attributes + ---------- + circuitBreaker : str, default is Undefined, optional + circuit breaker + circuitBreakerCacheSize : int, default is Undefined, optional + circuit breaker cache size + retry : str, default is Undefined, optional + retry + timeout : str, default is Undefined, optional + timeout + """ + + + circuitBreaker?: str + + circuitBreakerCacheSize?: int + + retry?: str + + timeout?: str + + +schema DaprIoV1alpha1ResiliencySpecTargetsComponentsAnon: + """ + dapr io v1alpha1 resiliency spec targets components anon + + Attributes + ---------- + inbound : DaprIoV1alpha1ResiliencySpecTargetsComponentsAnonInbound, default is Undefined, optional + inbound + outbound : DaprIoV1alpha1ResiliencySpecTargetsComponentsAnonOutbound, default is Undefined, optional + outbound + """ + + + inbound?: DaprIoV1alpha1ResiliencySpecTargetsComponentsAnonInbound + + outbound?: DaprIoV1alpha1ResiliencySpecTargetsComponentsAnonOutbound + + +schema DaprIoV1alpha1ResiliencySpecTargetsComponentsAnonInbound: + """ + dapr io v1alpha1 resiliency spec targets components anon inbound + + Attributes + ---------- + circuitBreaker : str, default is Undefined, optional + circuit breaker + retry : str, default is Undefined, optional + retry + timeout : str, default is Undefined, optional + timeout + """ + + + circuitBreaker?: str + + retry?: str + + timeout?: str + + +schema DaprIoV1alpha1ResiliencySpecTargetsComponentsAnonOutbound: + """ + dapr io v1alpha1 resiliency spec targets components anon outbound + + Attributes + ---------- + circuitBreaker : str, default is Undefined, optional + circuit breaker + retry : str, default is Undefined, optional + retry + timeout : str, default is Undefined, optional + timeout + """ + + + circuitBreaker?: str + + retry?: str + + timeout?: str + + diff --git a/examples/import/crd/models/dapr_io_v2alpha1_subscription.k b/examples/import/crd/models/dapr_io_v2alpha1_subscription.k new file mode 100644 index 0000000..698ad4f --- /dev/null +++ b/examples/import/crd/models/dapr_io_v2alpha1_subscription.k @@ -0,0 +1,129 @@ +""" +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 k8s.apimachinery.pkg.apis.meta.v1 + + +schema Subscription: + """ + Subscription describes an pub/sub event subscription. + + Attributes + ---------- + apiVersion : str, default is "dapr.io/v2alpha1", required + 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 + kind : str, default is "Subscription", required + 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 + metadata : v1.ObjectMeta, default is Undefined, optional + metadata + scopes : [str], default is Undefined, optional + scopes + spec : DaprIoV2alpha1SubscriptionSpec, default is Undefined, optional + spec + """ + + + apiVersion: "dapr.io/v2alpha1" = "dapr.io/v2alpha1" + + kind: "Subscription" = "Subscription" + + metadata?: v1.ObjectMeta + + scopes?: [str] + + spec?: DaprIoV2alpha1SubscriptionSpec + + +schema DaprIoV2alpha1SubscriptionSpec: + """ + SubscriptionSpec is the spec for an event subscription. + + Attributes + ---------- + bulkSubscribe : DaprIoV2alpha1SubscriptionSpecBulkSubscribe, default is Undefined, optional + bulk subscribe + deadLetterTopic : str, default is Undefined, optional + The optional dead letter queue for this topic to send events to. + metadata : {str:str}, default is Undefined, optional + The optional metadata to provide the subscription. + pubsubname : str, default is Undefined, required + The PubSub component name. + routes : DaprIoV2alpha1SubscriptionSpecRoutes, default is Undefined, required + routes + topic : str, default is Undefined, required + The topic name to subscribe to. + """ + + + bulkSubscribe?: DaprIoV2alpha1SubscriptionSpecBulkSubscribe + + deadLetterTopic?: str + + metadata?: {str:str} + + pubsubname: str + + routes: DaprIoV2alpha1SubscriptionSpecRoutes + + topic: str + + +schema DaprIoV2alpha1SubscriptionSpecBulkSubscribe: + """ + Represents bulk subscribe properies + + Attributes + ---------- + enabled : bool, default is Undefined, required + enabled + maxAwaitDurationMs : int, default is Undefined, optional + max await duration ms + maxMessagesCount : int, default is Undefined, optional + max messages count + """ + + + enabled: bool + + maxAwaitDurationMs?: int + + maxMessagesCount?: int + + +schema DaprIoV2alpha1SubscriptionSpecRoutes: + """ + The Routes configuration for this topic. + + Attributes + ---------- + default : str, default is Undefined, optional + default + rules : [DaprIoV2alpha1SubscriptionSpecRoutesRulesItems0], default is Undefined, optional + The list of rules for this topic. + """ + + + default?: str + + rules?: [DaprIoV2alpha1SubscriptionSpecRoutesRulesItems0] + + +schema DaprIoV2alpha1SubscriptionSpecRoutesRulesItems0: + """ + Rule is used to specify the condition for sending a message to a specific path. + + Attributes + ---------- + match : str, default is Undefined, required + The optional CEL expression used to match the event. If the match is not specified, then the route is considered the default. The rules are tested in the order specified, so they should be define from most-to-least specific. The default route should appear last in the list. + path : str, default is Undefined, required + The path for events that match this rule. + """ + + + match: str + + path: str + + diff --git a/go.mod b/go.mod index c2fb752..30b3aa6 100644 --- a/go.mod +++ b/go.mod @@ -5,8 +5,8 @@ go 1.19 require ( github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d github.com/spf13/cobra v1.7.0 - kcl-lang.io/kcl-go v0.7.1-0.20231203064943-11c700b3e353 - kcl-lang.io/kcl-openapi v0.5.2-0.20231116071001-d8316c05cd2d + kcl-lang.io/kcl-go v0.7.1-0.20231206101603-8382cbe12f7c + kcl-lang.io/kcl-openapi v0.5.2 kcl-lang.io/kcl-playground v0.5.1-0.20230919072953-347ab8959295 kcl-lang.io/kpm v0.4.2 ) @@ -81,7 +81,6 @@ require ( k8s.io/klog/v2 v2.100.1 // indirect k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 // indirect - kcl-lang.io/kcl-artifact-go v0.7.1 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect sigs.k8s.io/yaml v1.3.0 // indirect @@ -145,6 +144,7 @@ require ( golang.org/x/tools v0.8.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect + kcl-lang.io/lib v0.7.2 // indirect oras.land/oras-go v1.2.3 // indirect oras.land/oras-go/v2 v2.3.0 // indirect ) diff --git a/go.sum b/go.sum index a8e7966..dce178f 100644 --- a/go.sum +++ b/go.sum @@ -1284,16 +1284,16 @@ k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/ k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 h1:qY1Ad8PODbnymg2pRbkyMT/ylpTrCM8P2RJ0yroCyIk= k8s.io/utils v0.0.0-20230406110748-d93618cff8a2/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -kcl-lang.io/kcl-artifact-go v0.7.1 h1:tPSJxVKNm3+QseqtyDwtfx9qTeAioyHNYJIUsz7djqU= -kcl-lang.io/kcl-artifact-go v0.7.1/go.mod h1:c07mqi9Hu2UjPW7lYfHhAAWOlZiB7lo7Vkr4jL5ov/M= -kcl-lang.io/kcl-go v0.7.1-0.20231203064943-11c700b3e353 h1:JRvEZ0h3GE2AnmkWFT16W50SSAAvGLRa41ocAoFoYi0= -kcl-lang.io/kcl-go v0.7.1-0.20231203064943-11c700b3e353/go.mod h1:ZEA8AA/L+vvp68PeBX16aR1Se81hLAWNp+7Qa2cYWdo= -kcl-lang.io/kcl-openapi v0.5.2-0.20231116071001-d8316c05cd2d h1:wbaI/FjzeMbzFGEjzBBA4o5AotRAy376IoHXZh/oNJQ= -kcl-lang.io/kcl-openapi v0.5.2-0.20231116071001-d8316c05cd2d/go.mod h1:Ai9mFztCVKkRSFabczO/r5hCNdqaNtAc2ZIRxTeV0Mk= +kcl-lang.io/kcl-go v0.7.1-0.20231206101603-8382cbe12f7c h1:9sfv54sp4TACYKMh9YAZuVuh+TLjrN4BZJmKLNuMq5o= +kcl-lang.io/kcl-go v0.7.1-0.20231206101603-8382cbe12f7c/go.mod h1:xcGpqeGzHYMv1BQ/9pPhAUSHNIClEoKRUKqeGiq2or8= +kcl-lang.io/kcl-openapi v0.5.2 h1:BY4itrE6XBEepFXadD1yZFu9B+F/+zyRtj8i/KANJvw= +kcl-lang.io/kcl-openapi v0.5.2/go.mod h1:Ai9mFztCVKkRSFabczO/r5hCNdqaNtAc2ZIRxTeV0Mk= kcl-lang.io/kcl-playground v0.5.1-0.20230919072953-347ab8959295 h1:RUY3w6jNAB6GoMo27CO1oS4C4gjyWdMXfOTNpTEnkjs= kcl-lang.io/kcl-playground v0.5.1-0.20230919072953-347ab8959295/go.mod h1:3aMvkPRLMZeORiQ/sHxXQCopwr8L1MMSSXMPC+hxwPA= kcl-lang.io/kpm v0.4.2 h1:rEjfUdX+2kmwwuBaYvsNURQ5D97C3qLNBYAd+XT+DbU= kcl-lang.io/kpm v0.4.2/go.mod h1:9C/Q9RhRDinbhN7HzQxEexw00HVWUYwWbarMuC1E4xM= +kcl-lang.io/lib v0.7.2 h1:ciex5XIsDc/i1Qlu84sOQpSca9WCRQX11nwf1vGyNUY= +kcl-lang.io/lib v0.7.2/go.mod h1:ubsalGXxJaa5II/EsHmsI/tL2EluYHIcW+BwzQPt+uY= oras.land/oras-go v1.2.3 h1:v8PJl+gEAntI1pJ/LCrDgsuk+1PKVavVEPsYIHFE5uY= oras.land/oras-go v1.2.3/go.mod h1:M/uaPdYklze0Vf3AakfarnpoEckvw0ESbRdN8Z1vdJg= oras.land/oras-go/v2 v2.3.0 h1:lqX1aXdN+DAmDTKjiDyvq85cIaI4RkIKp/PghWlAGIU= diff --git a/pkg/options/import.go b/pkg/options/import.go index 3b1f9f5..580c2bd 100644 --- a/pkg/options/import.go +++ b/pkg/options/import.go @@ -68,21 +68,25 @@ func (o *ImportOptions) Run() error { if err := opts.EnsureDefaults(); err != nil { return err } - + var specs []string // when the spec is a crd, get openapi spec file from it if mode == Crd { - spec, err := crdGen.GetSpec(&crdGen.GenOpts{ + specs, err = crdGen.GetSpecs(&crdGen.GenOpts{ Spec: opts.Spec, }) if err != nil { return err } - opts.Spec = spec // do not run validate spec on spec file generated from crd opts.ValidateSpec = false + } else { + specs = []string{opts.Spec} } - if err := generator.Generate(opts); err != nil { - return err + for _, spec := range specs { + opts.Spec = spec + if err := generator.Generate(opts); err != nil { + return err + } } } return nil diff --git a/pkg/options/run.go b/pkg/options/run.go index 03e54a1..fab809c 100644 --- a/pkg/options/run.go +++ b/pkg/options/run.go @@ -123,8 +123,12 @@ func (o *RunOptions) Run() error { entries := pkg.GetPkgProfile().Entries if len(entries) > 0 { opts.SetEntries(entries) + opts.SetPkgPath(transformedEntries[0]) + } else { + // Multiple entries with the kcl.mod file and deps. + opts.SetEntries(transformedEntries) + opts.SetPkgPath(entry.PackageSource()) } - opts.SetPkgPath(transformedEntries[0]) } else { // Multiple entries with the kcl.mod file and deps. opts.SetEntries(transformedEntries)