Skip to content

Commit

Permalink
fix: fixed default jqQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsinai committed May 16, 2024
1 parent 8f44d8a commit 8b53483
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/crd/crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const (
KindCRD = "CustomResourceDefinition"
K8SIcon = "Cluster"
CrossplaneIcon = "Crossplane"
NestedSchemaSeperator = "__"
NestedSchemaSeparator = "__"
)

func createKindConfigFromCRD(crd v1.CustomResourceDefinition) port.Resource {
Expand Down Expand Up @@ -108,7 +108,7 @@ func buildUpdateAction(crd v1.CustomResourceDefinition, as *port.ActionUserInput
updatedStruct := v

defaultMap := make(map[string]string)
defaultMap["jqQuery"] = ".entity.properties." + strings.Replace(k, ".", NestedSchemaSeperator, -1)
defaultMap["jqQuery"] = ".entity.properties." + strings.Replace(k, NestedSchemaSeparator, ".", -1)
updatedStruct.Default = defaultMap

as.Properties[k] = updatedStruct
Expand Down Expand Up @@ -344,14 +344,14 @@ func handleNestedSchema(schema *v1.JSONSchemaProps, parent string, originalSchem
if parent == "" {
shallowedKey = k
} else {
shallowedKey = parent + NestedSchemaSeperator + k
shallowedKey = parent + NestedSchemaSeparator + k
}

if v.Type != "object" {
originalSchema.Properties[shallowedKey] = v
if shallowedKey != k && slices.Contains(originalSchema.Required, strings.Split(shallowedKey, NestedSchemaSeperator)[0]) {
if shallowedKey != k && slices.Contains(originalSchema.Required, strings.Split(shallowedKey, NestedSchemaSeparator)[0]) {
originalSchema.Required = append(originalSchema.Required, shallowedKey)
originalSchema.Required = goutils.Filter(originalSchema.Required, strings.Split(shallowedKey, NestedSchemaSeperator)[0])
originalSchema.Required = goutils.Filter(originalSchema.Required, strings.Split(shallowedKey, NestedSchemaSeparator)[0])
}
} else {
handleNestedSchema(&v, shallowedKey, originalSchema)
Expand Down

0 comments on commit 8b53483

Please sign in to comment.