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

chore(deps): Bump github.com/getkin/kin-openapi from 0.123.0 to 0.124.0 #120

Merged
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
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module github.com/metio/terraform-provider-k8s
go 1.22

require (
github.com/getkin/kin-openapi v0.123.0
github.com/getkin/kin-openapi v0.124.0
github.com/gruntwork-io/terratest v0.46.13
github.com/hashicorp/terraform-plugin-docs v0.19.0
github.com/hashicorp/terraform-plugin-framework v1.7.0
Expand All @@ -22,8 +22,6 @@ require (
sigs.k8s.io/yaml v1.4.0
)

//replace github.com/hashicorp/terraform-plugin-docs => ../../../../github.com/sebhoss/terraform-plugin-docs

require (
cloud.google.com/go v0.112.0 // indirect
cloud.google.com/go/compute v1.23.3 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3
github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps=
github.com/fvbommel/sortorder v1.1.0 h1:fUmoe+HLsBTctBDoaBwpQo5N+nrCp8g/BjKb/6ZQmYw=
github.com/fvbommel/sortorder v1.1.0/go.mod h1:uk88iVf1ovNn1iLfgUVU2F9o5eO30ui720w+kxuqRs0=
github.com/getkin/kin-openapi v0.123.0 h1:zIik0mRwFNLyvtXK274Q6ut+dPh6nlxBp0x7mNrPhs8=
github.com/getkin/kin-openapi v0.123.0/go.mod h1:wb1aSZA/iWmorQP9KTAS/phLj/t17B5jT7+fS8ed9NM=
github.com/getkin/kin-openapi v0.124.0 h1:VSFNMB9C9rTKBnQ/fpyDU8ytMTr4dWI9QovSKj9kz/M=
github.com/getkin/kin-openapi v0.124.0/go.mod h1:wb1aSZA/iWmorQP9KTAS/phLj/t17B5jT7+fS8ed9NM=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-errors/errors v1.5.0 h1:/EuijeGOu7ckFxzhkj4CXJ8JaenxK7bKUxpPYqeLHqQ=
github.com/go-errors/errors v1.5.0/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
Expand Down
4 changes: 2 additions & 2 deletions tools/internal/generator/openapiv3_converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ func openAPIv3Properties(schema *openapi3.Schema, imports *AdditionalImports, pa
}

var nestedProperties []*Property
if prop.Value.Type == "array" && prop.Value.Items != nil && prop.Value.Items.Value != nil && prop.Value.Items.Value.Type == "object" {
if prop.Value.Type.Is(openapi3.TypeArray) && prop.Value.Items != nil && prop.Value.Items.Value != nil && prop.Value.Items.Value.Type.Is(openapi3.TypeObject) {
nestedProperties = openAPIv3Properties(prop.Value.Items.Value, imports, propPath, terraformResourceName)
} else if prop.Value.Type == "object" && prop.Value.AdditionalProperties.Schema != nil && prop.Value.AdditionalProperties.Schema.Value.Type == "object" {
} else if prop.Value.Type.Is(openapi3.TypeObject) && prop.Value.AdditionalProperties.Schema != nil && prop.Value.AdditionalProperties.Schema.Value.Type.Is(openapi3.TypeObject) {
nestedProperties = openAPIv3Properties(prop.Value.AdditionalProperties.Schema.Value, imports, propPath, terraformResourceName)
} else {
nestedProperties = openAPIv3Properties(prop.Value, imports, propPath, terraformResourceName)
Expand Down
46 changes: 23 additions & 23 deletions tools/internal/generator/openapiv3_type_translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,40 +16,40 @@ type openapiv3TypeTranslator struct {
}

func (t *openapiv3TypeTranslator) hasNoType() bool {
return t.property.Type == ""
return t.property.Type == nil || len(t.property.Type.Slice()) == 0
}

func (t *openapiv3TypeTranslator) isIntOrString() bool {
_, ok := t.property.Extensions["x-kubernetes-int-or-string"]
return ok || t.property.Type == "string" && t.property.Format == "int-or-string"
return ok || t.property.Type.Is(openapi3.TypeString) && t.property.Format == "int-or-string"
}

func (t *openapiv3TypeTranslator) isBoolean() bool {
return t.property.Type == "boolean"
return t.property.Type.Is(openapi3.TypeBoolean)
}

func (t *openapiv3TypeTranslator) isString() bool {
return t.property.Type == "string"
return t.property.Type.Is(openapi3.TypeString)
}

func (t *openapiv3TypeTranslator) isInteger() bool {
return t.property.Type == "integer"
return t.property.Type.Is(openapi3.TypeInteger)
}

func (t *openapiv3TypeTranslator) isNumber() bool {
return t.property.Type == "number"
return t.property.Type.Is(openapi3.TypeNumber)
}

func (t *openapiv3TypeTranslator) isFloat() bool {
return t.property.Format == "float" || t.property.Format == "double"
}

func (t *openapiv3TypeTranslator) isArray() bool {
return t.property.Type == "array"
return t.property.Type.Is(openapi3.TypeArray)
}

func (t *openapiv3TypeTranslator) isObject() bool {
return t.property.Type == "object"
return t.property.Type.Is(openapi3.TypeObject)
}

func (t *openapiv3TypeTranslator) hasUnknownFields() bool {
Expand All @@ -67,7 +67,7 @@ func (t *openapiv3TypeTranslator) hasOneOf() bool {

func (t *openapiv3TypeTranslator) isOneOfArray() bool {
for _, oneOf := range t.property.OneOf {
if oneOf.Value.Type == "array" {
if oneOf.Value.Type.Is(openapi3.TypeArray) {
return true
}
}
Expand All @@ -76,41 +76,41 @@ func (t *openapiv3TypeTranslator) isOneOfArray() bool {

func (t *openapiv3TypeTranslator) isOneOfBoolean() bool {
for _, oneOf := range t.property.OneOf {
if oneOf.Value.Type == "boolean" {
if oneOf.Value.Type.Is(openapi3.TypeBoolean) {
return true
}
}
return false
}

func (t *openapiv3TypeTranslator) isObjectWithAdditionalStringProperties() bool {
return t.property.Type == "object" &&
return t.property.Type.Is(openapi3.TypeObject) &&
t.property.AdditionalProperties.Schema != nil &&
t.property.AdditionalProperties.Schema.Value.Type == "string"
t.property.AdditionalProperties.Schema.Value.Type.Is(openapi3.TypeString)
}

func (t *openapiv3TypeTranslator) isObjectWithAdditionalObjectProperties() bool {
return t.property.Type == "object" &&
return t.property.Type.Is(openapi3.TypeObject) &&
t.property.AdditionalProperties.Schema != nil &&
t.property.AdditionalProperties.Schema.Value.Type == "object"
t.property.AdditionalProperties.Schema.Value.Type.Is(openapi3.TypeObject)
}

func (t *openapiv3TypeTranslator) isObjectWithAdditionalArrayProperties() bool {
return t.property.Type == "object" &&
return t.property.Type.Is(openapi3.TypeObject) &&
t.property.AdditionalProperties.Schema != nil &&
t.property.AdditionalProperties.Schema.Value.Type == "array"
t.property.AdditionalProperties.Schema.Value.Type.Is(openapi3.TypeArray)
}

func (t *openapiv3TypeTranslator) isArrayWithObjectItems() bool {
return t.property.Type == "array" &&
return t.property.Type.Is(openapi3.TypeArray) &&
t.property.Items != nil &&
t.property.Items.Value != nil &&
t.property.Items.Value.Type == "object"
t.property.Items.Value.Type.Is(openapi3.TypeObject)
}

func (t *openapiv3TypeTranslator) additionalPropertiesHaveStringItems() bool {
return t.property.AdditionalProperties.Schema.Value.Items != nil &&
t.property.AdditionalProperties.Schema.Value.Items.Value.Type == "string"
t.property.AdditionalProperties.Schema.Value.Items.Value.Type.Is(openapi3.TypeString)
}

func (t *openapiv3TypeTranslator) additionalPropertiesHaveProperties() bool {
Expand All @@ -124,17 +124,17 @@ func (t *openapiv3TypeTranslator) additionalPropertiesHaveUnknownFields() bool {

func (t *openapiv3TypeTranslator) additionalPropertiesHaveAdditionalStringProperties() bool {
return t.property.AdditionalProperties.Schema.Value.AdditionalProperties.Schema != nil &&
t.property.AdditionalProperties.Schema.Value.AdditionalProperties.Schema.Value.Type == "string"
t.property.AdditionalProperties.Schema.Value.AdditionalProperties.Schema.Value.Type.Is(openapi3.TypeString)
}

func (t *openapiv3TypeTranslator) additionalPropertiesHaveAdditionalArrayProperties() bool {
return t.property.AdditionalProperties.Schema.Value.AdditionalProperties.Schema != nil &&
t.property.AdditionalProperties.Schema.Value.AdditionalProperties.Schema.Value.Type == "array"
t.property.AdditionalProperties.Schema.Value.AdditionalProperties.Schema.Value.Type.Is(openapi3.TypeArray)
}

func (t *openapiv3TypeTranslator) additionalPropertiesHaveAdditionalPropertiesWithStringItems() bool {
return t.property.AdditionalProperties.Schema.Value.AdditionalProperties.Schema.Value.Items != nil &&
t.property.AdditionalProperties.Schema.Value.AdditionalProperties.Schema.Value.Items.Value.Type == "string"
t.property.AdditionalProperties.Schema.Value.AdditionalProperties.Schema.Value.Items.Value.Type.Is(openapi3.TypeString)
}

func (t *openapiv3TypeTranslator) itemsHaveUnknownFields() bool {
Expand All @@ -144,5 +144,5 @@ func (t *openapiv3TypeTranslator) itemsHaveUnknownFields() bool {

func (t *openapiv3TypeTranslator) itemsHaveAdditionalStringProperties() bool {
return t.property.Items.Value.AdditionalProperties.Schema != nil &&
t.property.Items.Value.AdditionalProperties.Schema.Value.Type == "string"
t.property.Items.Value.AdditionalProperties.Schema.Value.Type.Is(openapi3.TypeString)
}
24 changes: 12 additions & 12 deletions tools/internal/generator/openapiv3_validator_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type openapiv3ValidatorExtractor struct {
}

func (v *openapiv3ValidatorExtractor) integerWithMinimum() string {
if v.property.Type == "integer" && v.property.Min != nil {
if v.property.Type.Is(openapi3.TypeInteger) && v.property.Min != nil {
v.imports.Int64Validator = true
min := *v.property.Min
if v.property.ExclusiveMin {
Expand All @@ -30,7 +30,7 @@ func (v *openapiv3ValidatorExtractor) integerWithMinimum() string {
}

func (v *openapiv3ValidatorExtractor) integerWithMaximum() string {
if v.property.Type == "integer" && v.property.Max != nil {
if v.property.Type.Is(openapi3.TypeInteger) && v.property.Max != nil {
v.imports.Int64Validator = true
max := *v.property.Max
if v.property.ExclusiveMax {
Expand All @@ -42,7 +42,7 @@ func (v *openapiv3ValidatorExtractor) integerWithMaximum() string {
}

func (v *openapiv3ValidatorExtractor) integerWithEnums() string {
if v.property.Type == "integer" && len(v.property.Enum) > 0 {
if v.property.Type.Is(openapi3.TypeInteger) && len(v.property.Enum) > 0 {
v.imports.Int64Validator = true
enums := openapiIntEnums(v.property.Enum)
return fmt.Sprintf("int64validator.OneOf(%v)", concatEnums(enums))
Expand All @@ -51,7 +51,7 @@ func (v *openapiv3ValidatorExtractor) integerWithEnums() string {
}

func (v *openapiv3ValidatorExtractor) numberWithMinimum() string {
if v.property.Type == "number" && v.property.Min != nil {
if v.property.Type.Is(openapi3.TypeNumber) && v.property.Min != nil {
v.imports.Float64Validator = true
min := *v.property.Min
if v.property.ExclusiveMin {
Expand All @@ -63,7 +63,7 @@ func (v *openapiv3ValidatorExtractor) numberWithMinimum() string {
}

func (v *openapiv3ValidatorExtractor) numberWithMaximum() string {
if v.property.Type == "number" && v.property.Max != nil {
if v.property.Type.Is(openapi3.TypeNumber) && v.property.Max != nil {
v.imports.Float64Validator = true
max := *v.property.Max
if v.property.ExclusiveMax {
Expand All @@ -75,7 +75,7 @@ func (v *openapiv3ValidatorExtractor) numberWithMaximum() string {
}

func (v *openapiv3ValidatorExtractor) numberWithEnums() string {
if v.property.Type == "number" && len(v.property.Enum) > 0 {
if v.property.Type.Is(openapi3.TypeNumber) && len(v.property.Enum) > 0 {
v.imports.Float64Validator = true
enums := openapiFloatEnums(v.property.Enum)
return fmt.Sprintf("float64validator.OneOf(%v)", concatEnums(enums))
Expand All @@ -84,37 +84,37 @@ func (v *openapiv3ValidatorExtractor) numberWithEnums() string {
}

func (v *openapiv3ValidatorExtractor) stringWithByteFormat() string {
if v.property.Type == "string" && v.property.Format == "byte" {
if v.property.Type.Is(openapi3.TypeString) && v.property.Format == "byte" {
return "validators.Base64Validator()"
}
return ""
}

func (v *openapiv3ValidatorExtractor) stringWithDateTimeFormat() string {
if v.property.Type == "string" && v.property.Format == "date-time" {
if v.property.Type.Is(openapi3.TypeString) && v.property.Format == "date-time" {
return "validators.DateTime64Validator()"
}
return ""
}

func (v *openapiv3ValidatorExtractor) stringWithMinimumLength() string {
if v.property.Type == "string" && v.property.MinLength != 0 {
if v.property.Type.Is(openapi3.TypeString) && v.property.MinLength != 0 {
v.imports.StringValidator = true
return fmt.Sprintf("stringvalidator.LengthAtLeast(%v)", v.property.MinLength)
}
return ""
}

func (v *openapiv3ValidatorExtractor) stringWithMaximumLength() string {
if v.property.Type == "string" && v.property.MaxLength != nil {
if v.property.Type.Is(openapi3.TypeString) && v.property.MaxLength != nil {
v.imports.StringValidator = true
return fmt.Sprintf("stringvalidator.LengthAtMost(%v)", *v.property.MaxLength)
}
return ""
}

func (v *openapiv3ValidatorExtractor) stringWithEnums() string {
if v.property.Type == "string" && len(v.property.Enum) > 0 {
if v.property.Type.Is(openapi3.TypeString) && len(v.property.Enum) > 0 {
v.imports.StringValidator = true
enums := openapiStringEnums(v.property.Enum)
return fmt.Sprintf("stringvalidator.OneOf(%s)", concatEnums(enums))
Expand All @@ -123,7 +123,7 @@ func (v *openapiv3ValidatorExtractor) stringWithEnums() string {
}

func (v *openapiv3ValidatorExtractor) stringWithPattern() string {
if v.property.Type == "string" && v.property.Pattern != "" {
if v.property.Type.Is(openapi3.TypeString) && v.property.Pattern != "" {
v.imports.Regexp = true
v.imports.StringValidator = true
return fmt.Sprintf(`stringvalidator.RegexMatches(regexp.MustCompile(%s), "")`, escapeRegexPattern(v.property.Pattern))
Expand Down
Loading