Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: better go module import impl #373

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
325 changes: 228 additions & 97 deletions pkg/tools/gen/genkcl_gostruct.go

Large diffs are not rendered by default.

1,692 changes: 1,288 additions & 404 deletions pkg/tools/gen/genkcl_gostruct_test.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pkg/tools/gen/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ var kclKeywords = map[string]struct{}{
"else": {},
"elif": {},
"for": {},
"type": {},
"schema": {},
"mixin": {},
"protocol": {},
Expand Down
8 changes: 4 additions & 4 deletions pkg/tools/gen/testdata/jsonschema/allof/expect.k
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ schema ShopProductsOneOf0:

Attributes
----------
type : "clothing", required, default is "clothing"
$type : "clothing", required, default is "clothing"
material : str, optional
name : str, required
price : float, optional
"""

type: "clothing" = "clothing"
$type: "clothing" = "clothing"
material?: str
name: str
price?: float
Expand All @@ -41,13 +41,13 @@ schema ShopProductsOneOf1Items0:

Attributes
----------
type : "clothing", required, default is "clothing"
$type : "clothing", required, default is "clothing"
material : str, optional
name : str, required
price : float, optional
"""

type: "clothing" = "clothing"
$type: "clothing" = "clothing"
material?: str
name: str
price?: float
Expand Down
8 changes: 4 additions & 4 deletions pkg/tools/gen/testdata/jsonschema/complex-workflow/expect.k
Original file line number Diff line number Diff line change
Expand Up @@ -1568,7 +1568,7 @@ schema WorkflowOnOneOf2WorkflowCallInputsPatternProperties0:
A string shown to users using the deprecated input.
required : bool, required
A boolean to indicate whether the action requires the input parameter. Set to true when the parameter is required.
type : "boolean" | "number" | "string", required
$type : "boolean" | "number" | "string", required
Required if input is defined for the on.workflow_call keyword. The value of this parameter is a string specifying the data type of the input. This must be one of: boolean, number, or string.
default : bool | float | str, optional
The default value is used when an input parameter isn't specified in a workflow file.
Expand All @@ -1577,7 +1577,7 @@ schema WorkflowOnOneOf2WorkflowCallInputsPatternProperties0:
description?: str
deprecationMessage?: str
required: bool
type: "boolean" | "number" | "string"
$type: "boolean" | "number" | "string"
default?: bool | float | str

schema WorkflowOnOneOf2WorkflowCallSecrets:
Expand Down Expand Up @@ -1641,7 +1641,7 @@ schema WorkflowOnOneOf2WorkflowDispatchInputsPatternProperties0:
A boolean to indicate whether the action requires the input parameter. Set to true when the parameter is required.
default : any, optional
A string representing the default value. The default value is used when an input parameter isn't specified in a workflow file.
type : "string" | "choice" | "boolean" | "environment", optional
$type : "string" | "choice" | "boolean" | "environment", optional
A string representing the type of the input.
options : [str], optional
The options of the dropdown list, if the type is a choice.
Expand All @@ -1651,7 +1651,7 @@ schema WorkflowOnOneOf2WorkflowDispatchInputsPatternProperties0:
deprecationMessage?: str
required: bool
default?: any
type?: "string" | "choice" | "boolean" | "environment"
$type?: "string" | "choice" | "boolean" | "environment"
options?: [str]

check:
Expand Down
8 changes: 4 additions & 4 deletions pkg/tools/gen/testdata/jsonschema/nested-items/expect.k
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ schema MonacoManifestSchemaEnvironmentGroupsItems0EnvironmentsItems0Url:

Attributes
----------
type : str, optional
$type : str, optional
Optional Type of URL definition.
value : str, optional
The value of the URL, based on type either an URL or environment variable name
"""

type?: str
$type?: str
value?: str

schema MonacoManifestSchemaProjectsItems0:
Expand All @@ -74,13 +74,13 @@ schema MonacoManifestSchemaProjectsItems0:
----------
name : str, required
The name of this project
type : str, optional
$type : str, optional
Optional Type of this project. Default: Simple
path : str, optional
Optional filepath of the project relative to the manifest.yaml location. Defaults to name
"""

name: str
type?: str
$type?: str
path?: str

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ schema TopLevelDefinitionConfigsItems0:
The monaco identifier for this config - is used in references and for some generated IDs in Dynatrace environments.
config : TopLevelDefinitionConfigsItems0Config, required
The actual configuration to be applied
type : str | TopLevelDefinitionConfigsItems0TypeOneOf1 | TopLevelDefinitionConfigsItems0Type, required
$type : str | TopLevelDefinitionConfigsItems0TypeOneOf1 | TopLevelDefinitionConfigsItems0Type, required
The type of this configuration
groupOverrides : [TopLevelDefinitionConfigsItems0GroupOverridesItems0], optional
GroupOverrides overwrite specific parts of the Config when deploying it to any environment in a given group.
Expand All @@ -38,7 +38,7 @@ schema TopLevelDefinitionConfigsItems0:

id: str
config: TopLevelDefinitionConfigsItems0Config
type: str | TopLevelDefinitionConfigsItems0TypeOneOf1 | TopLevelDefinitionConfigsItems0Type
$type: str | TopLevelDefinitionConfigsItems0TypeOneOf1 | TopLevelDefinitionConfigsItems0Type
groupOverrides?: [TopLevelDefinitionConfigsItems0GroupOverridesItems0]
environmentOverrides?: [TopLevelDefinitionConfigsItems0EnvironmentOverridesItems0]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ schema Database:

Attributes
----------
type: str, default is Undefined, required.
$type: str, default is Undefined, required.
Type defines the local deployment mode or the specific cloud vendor that
provides the relational database service (rds).
engine: str, default is Undefined, required.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ schema Secret:

Attributes
----------
type: str, default is Undefined, required.
$type: str, default is Undefined, required.
Type of secret, used to facilitate programmatic handling of secret data.
params: {str,str}, default is Undefined, optional.
Collection of parameters used to facilitate programmatic handling of secret data.
Expand Down
4 changes: 2 additions & 2 deletions pkg/tools/gen/testdata/yaml/k8s-deployment/expect.k
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Editing this file might prove futile when you re-run the KCL auto-gen generate c
readOnlyRootFilesystem = True
runAsNonRoot = True
seccompProfile = {
type = "RuntimeDefault"
$type = "RuntimeDefault"
}
}
}
Expand Down Expand Up @@ -95,7 +95,7 @@ Editing this file might prove futile when you re-run the KCL auto-gen generate c
readOnlyRootFilesystem = True
runAsNonRoot = True
seccompProfile = {
type = "RuntimeDefault"
$type = "RuntimeDefault"
}
}
ports = [
Expand Down