Skip to content

Commit 1c6f968

Browse files
authored
Fix identification of 'int-or-string' type attributes to include 3rd party types defined by aggregated APIs (#1640)
1 parent c33cc57 commit 1c6f968

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

manifest/openapi/schema.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@ func resolveSchemaRef(ref *openapi3.SchemaRef, defs map[string]*openapi3.SchemaR
3232

3333
// These are exceptional situations that require non-standard types.
3434
switch sid {
35-
case "io.k8s.apimachinery.pkg.util.intstr.IntOrString":
36-
t := openapi3.Schema{
37-
Type: "string",
38-
Description: "io.k8s.apimachinery.pkg.util.intstr.IntOrString", // this value later carries over as the "type hint"
39-
}
40-
return &t, nil
4135
case "io.k8s.apiextensions-apiserver.pkg.apis.apiextensions.v1.JSONSchemaProps":
4236
t := openapi3.Schema{
4337
Type: "",
@@ -90,8 +84,7 @@ func getTypeFromSchema(elem *openapi3.Schema, stackdepth uint64, typeCache *sync
9084
// }
9185
switch elem.Type {
9286
case "string":
93-
switch elem.Description {
94-
case "io.k8s.apimachinery.pkg.util.intstr.IntOrString":
87+
if elem.Format == "int-or-string" {
9588
th[ap.String()] = "io.k8s.apimachinery.pkg.util.intstr.IntOrString"
9689
}
9790
return tftypes.String, nil

manifest/payload/to_value.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func ToTFValue(in interface{}, st tftypes.Type, th map[string]string, at *tftype
6969
if ok && ht == "io.k8s.apimachinery.pkg.util.intstr.IntOrString" { // We store this in state as "string"
7070
return tftypes.NewValue(tftypes.String, strconv.FormatInt(in.(int64), 10)), nil
7171
}
72-
return tftypes.Value{}, at.NewErrorf(`[%s] cannot convert payload from "in64" to "tftypes.String"`, at.String())
72+
return tftypes.Value{}, at.NewErrorf(`[%s] cannot convert payload from "int64" to "tftypes.String"`, at.String())
7373
default:
7474
return tftypes.Value{}, at.NewErrorf(`[%s] cannot convert payload from "int64" to "%s"`, at.String(), st.String())
7575
}

0 commit comments

Comments
 (0)