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

panic: cannot generate crd for resource #121

Closed
IvanTurgenev1 opened this issue Oct 24, 2022 · 8 comments
Closed

panic: cannot generate crd for resource #121

IvanTurgenev1 opened this issue Oct 24, 2022 · 8 comments
Labels
bug Something isn't working community

Comments

@IvanTurgenev1
Copy link

IvanTurgenev1 commented Oct 24, 2022

What happened?

I'm trying to convert private cloud provider to upjet provider.
but on generation stage i am facing error:
panic: cannot generate crd for resource salt_compute_instance: cannot build types for Instance: cannot build the Types: cannot infer type from schema of field disks: invalid schema type TypeInvalid
there is my config/schema.json file :
https://pastebin.com/kiM1GMq6

How can we reproduce it?

i'll prepare custom repo with Makefile if it's neeeded, cause of private terraform provider this may take some time ( and i'm not sure if it needed)

I will be overly grateful if you tell me how to solve this error, if the problem is in the json that the provider generates, please tell me what exactly is wrong.

@IvanTurgenev1 IvanTurgenev1 added the bug Something isn't working label Oct 24, 2022
@turkenh
Copy link
Member

turkenh commented Oct 24, 2022

@IvanTurgenev1 I cannot open the pastebin link failing with SSL handshake failed Error code 525, would you mind checking it?

@IvanTurgenev1
Copy link
Author

IvanTurgenev1 commented Oct 24, 2022

@turkenh it's working well for me..
also i'm able to post json there in spoler:

json
{
"format_version": "1.0",
"provider_schemas": {
  "registry.terraform.io/hashicorp/salt": {
    "provider": {
      "version": 0,
      "block": {
        "attributes": {
          "auth_host": {
            "type": "string",
            "description_kind": "plain",
            "optional": true,
            "computed": true
          },
          "password": {
            "type": "string",
            "description_kind": "plain",
            "required": true,
            "sensitive": true
          },
          "salt_host": {
            "type": "string",
            "description_kind": "plain",
            "optional": true,
            "computed": true
          },
          "username": {
            "type": "string",
            "description_kind": "plain",
            "required": true
          }
        },
        "description_kind": "plain"
      }
    },
    "resource_schemas": {
      "salt_cluster": {
        "version": 0,
        "block": {
          "attributes": {
            "flavor_name": {
              "type": "string",
              "description": "flavor name",
              "description_kind": "plain",
              "required": true
            },
            "id": {
              "type": "string",
              "description": "cluster id",
              "description_kind": "plain",
              "computed": true
            },
            "is_supportable": {
              "type": "bool",
              "description": "is cluster supported",
              "description_kind": "plain",
              "computed": true
            },
            "name": {
              "type": "string",
              "description": "cluster name",
              "description_kind": "plain",
              "computed": true
            },
            "project_id": {
              "type": "string",
              "description": "salt project id",
              "description_kind": "plain",
              "required": true
            },
            "security_groups": {
              "type": [
                "list",
                "string"
              ],
              "description": "security groups names list",
              "description_kind": "plain",
              "required": true
            },
            "status": {
              "type": "string",
              "description": "cluster status",
              "description_kind": "plain",
              "computed": true
            },
            "worker_nodes": {
              "nested_type": {
                "attributes": {
                  "flavor_name": {
                    "type": "string",
                    "description_kind": "plain",
                    "required": true
                  },
                  "name": {
                    "type": "string",
                    "description_kind": "plain",
                    "computed": true
                  },
                  "status": {
                    "type": "string",
                    "description_kind": "plain",
                    "computed": true
                  }
                },
                "nesting_mode": "map"
              },
              "description": "worker nodes",
              "description_kind": "plain",
              "required": true
            }
          },
          "description_kind": "plain"
        }
      },
      "salt_compute_instance": {
        "version": 0,
        "block": {
          "attributes": {
            "disks": {
              "nested_type": {
                "attributes": {
                  "boot": {
                    "type": "bool",
                    "description_kind": "plain",
                    "required": true
                  },
                  "description": {
                    "type": "string",
                    "description_kind": "plain",
                    "optional": true,
                    "computed": true
                  },
                  "disk_id": {
                    "type": "string",
                    "description": "identity disk for attach (existing disk cannot be configured with size, type anc etc.)",
                    "description_kind": "plain",
                    "optional": true,
                    "computed": true
                  },
                  "name": {
                    "type": "string",
                    "description": "displayed name",
                    "description_kind": "plain",
                    "optional": true
                  },
                  "size": {
                    "type": "number",
                    "description": "between 10 and 1024 gb",
                    "description_kind": "plain",
                    "optional": true
                  },
                  "type": {
                    "type": "string",
                    "description": "\"fast\", \"standard\", \"ceph(only Selectel)\"",
                    "description_kind": "plain",
                    "optional": true
                  }
                },
                "nesting_mode": "list"
              },
              "description_kind": "plain",
              "required": true
            },
            "flavor_name": {
              "type": "string",
              "description_kind": "plain",
              "required": true
            },
            "floating_ip": {
              "nested_type": {
                "attributes": {
                  "allocate_new": {
                    "type": "bool",
                    "description_kind": "plain",
                    "required": true
                  },
                  "description": {
                    "type": "string",
                    "description_kind": "plain",
                    "optional": true
                  }
                },
                "nesting_mode": "single"
              },
              "description_kind": "plain",
              "optional": true
            },
            "id": {
              "type": "string",
              "description_kind": "plain",
              "computed": true
            },
            "image_name": {
              "type": "string",
              "description_kind": "plain",
              "required": true
            },
            "key": {
              "type": "string",
              "description": "keypair identity",
              "description_kind": "plain",
              "optional": true
            },
            "name": {
              "type": "string",
              "description_kind": "plain",
              "required": true
            },
            "networks_name": {
              "type": "string",
              "description": "\"admin\", \"frontend\", \"backend\", \"data\"",
              "description_kind": "plain",
              "required": true
            },
            "project_id": {
              "type": "string",
              "description": "salt project id",
              "description_kind": "plain",
              "required": true
            },
            "security_groups": {
              "type": [
                "list",
                "string"
              ],
              "description": "identities of SG",
              "description_kind": "plain",
              "optional": true
            },
            "status": {
              "type": "string",
              "description": "vm operational status",
              "description_kind": "plain",
              "computed": true
            },
            "tags": {
              "type": [
                "list",
                "string"
              ],
              "description_kind": "plain",
              "optional": true
            },
            "usual_vm": {
              "type": "bool",
              "description": "display vm in the salt ui list",
              "description_kind": "plain",
              "required": true
            }
          },
          "description_kind": "plain"
        }
      },
      "salt_dns_record": {
        "version": 0,
        "block": {
          "attributes": {
            "description": {
              "type": "string",
              "description": "Description for dns record",
              "description_kind": "plain",
              "optional": true
            },
            "id": {
              "type": "string",
              "description_kind": "plain",
              "computed": true
            },
            "name": {
              "type": "string",
              "description_kind": "plain",
              "required": true
            },
            "project_id": {
              "type": "string",
              "description": "salt project id",
              "description_kind": "plain",
              "required": true
            },
            "records": {
              "type": [
                "list",
                "string"
              ],
              "description_kind": "plain",
              "required": true
            },
            "ttl": {
              "type": "string",
              "description": "Description for dns record",
              "description_kind": "plain",
              "required": true
            },
            "type": {
              "type": "string",
              "description": "Description for dns record",
              "description_kind": "plain",
              "required": true
            },
            "zone_id": {
              "type": "string",
              "description": "Zone id",
              "description_kind": "plain",
              "required": true
            }
          },
          "description_kind": "plain"
        }
      },
      "salt_floating_ip": {
        "version": 0,
        "block": {
          "attributes": {
            "description": {
              "type": "string",
              "description_kind": "plain",
              "required": true
            },
            "entity_id": {
              "type": "string",
              "description_kind": "plain",
              "optional": true
            },
            "entity_type": {
              "type": "string",
              "description": "\"vm\", \"lb\"",
              "description_kind": "plain",
              "optional": true
            },
            "id": {
              "type": "string",
              "description_kind": "plain",
              "computed": true
            },
            "ip": {
              "type": "string",
              "description_kind": "plain",
              "computed": true
            },
            "project_id": {
              "type": "string",
              "description": "salt project id",
              "description_kind": "plain",
              "required": true
            },
            "tags": {
              "type": [
                "list",
                "string"
              ],
              "description_kind": "plain",
              "optional": true
            }
          },
          "description_kind": "plain"
        }
      },
      "salt_lb_instance": {
        "version": 0,
        "block": {
          "attributes": {
            "description": {
              "type": "string",
              "description_kind": "plain",
              "optional": true
            },
            "flavor_name": {
              "type": "string",
              "description_kind": "plain",
              "required": true
            },
            "id": {
              "type": "string",
              "description_kind": "plain",
              "computed": true
            },
            "listeners": {
              "nested_type": {
                "attributes": {
                  "connection_limit": {
                    "type": "number",
                    "description_kind": "plain",
                    "required": true
                  },
                  "description": {
                    "type": "string",
                    "description_kind": "plain",
                    "computed": true
                  },
                  "headers": {
                    "nested_type": {
                      "attributes": {
                        "x_forwarded_for": {
                          "type": "bool",
                          "description_kind": "plain",
                          "optional": true
                        },
                        "x_forwarded_port": {
                          "type": "bool",
                          "description_kind": "plain",
                          "optional": true
                        },
                        "x_forwarded_proto": {
                          "type": "bool",
                          "description_kind": "plain",
                          "optional": true
                        }
                      },
                      "nesting_mode": "single"
                    },
                    "description_kind": "plain",
                    "optional": true
                  },
                  "id": {
                    "type": "string",
                    "description_kind": "plain",
                    "computed": true
                  },
                  "name": {
                    "type": "string",
                    "description": "displayed name",
                    "description_kind": "plain",
                    "required": true
                  },
                  "pool": {
                    "nested_type": {
                      "attributes": {
                        "algorithm": {
                          "type": "string",
                          "description": "\"LEAST_CONNECTIONS\", \"ROUND_ROBIN\", \"SOURCE_IP\"",
                          "description_kind": "plain",
                          "required": true
                        },
                        "description": {
                          "type": "string",
                          "description_kind": "plain",
                          "computed": true
                        },
                        "id": {
                          "type": "string",
                          "description_kind": "plain",
                          "computed": true
                        },
                        "members": {
                          "nested_type": {
                            "attributes": {
                              "address": {
                                "type": "string",
                                "description_kind": "plain",
                                "required": true
                              },
                              "backup": {
                                "type": "bool",
                                "description_kind": "plain",
                                "required": true
                              },
                              "monitor_address": {
                                "type": "string",
                                "description_kind": "plain",
                                "optional": true
                              },
                              "monitor_port": {
                                "type": "number",
                                "description_kind": "plain",
                                "optional": true
                              },
                              "name": {
                                "type": "string",
                                "description": "name of the existed instance",
                                "description_kind": "plain",
                                "required": true
                              },
                              "network_name": {
                                "type": "string",
                                "description_kind": "plain",
                                "required": true
                              },
                              "port": {
                                "type": "number",
                                "description_kind": "plain",
                                "required": true
                              },
                              "weight": {
                                "type": "number",
                                "description_kind": "plain",
                                "required": true
                              }
                            },
                            "nesting_mode": "list"
                          },
                          "description_kind": "plain",
                          "required": true
                        },
                        "monitor": {
                          "nested_type": {
                            "attributes": {
                              "delay": {
                                "type": "number",
                                "description_kind": "plain",
                                "required": true
                              },
                              "expected_codes": {
                                "type": "string",
                                "description_kind": "plain",
                                "optional": true
                              },
                              "id": {
                                "type": "string",
                                "description_kind": "plain",
                                "computed": true
                              },
                              "max_retries": {
                                "type": "number",
                                "description_kind": "plain",
                                "required": true
                              },
                              "max_retries_down": {
                                "type": "number",
                                "description_kind": "plain",
                                "required": true
                              },
                              "name": {
                                "type": "string",
                                "description_kind": "plain",
                                "optional": true
                              },
                              "timeout": {
                                "type": "number",
                                "description_kind": "plain",
                                "required": true
                              },
                              "type": {
                                "type": "string",
                                "description_kind": "plain",
                                "required": true
                              },
                              "url_path": {
                                "type": "string",
                                "description_kind": "plain",
                                "optional": true
                              }
                            },
                            "nesting_mode": "single"
                          },
                          "description_kind": "plain",
                          "optional": true
                        },
                        "name": {
                          "type": "string",
                          "description_kind": "plain",
                          "computed": true
                        },
                        "session_persistence": {
                          "nested_type": {
                            "attributes": {
                              "cookie_name": {
                                "type": "string",
                                "description_kind": "plain",
                                "optional": true
                              },
                              "type": {
                                "type": "string",
                                "description": "\"NONE\", \"HTTP_COOKIE\", \"APP_COOKIE\", \"SOURCE_IP\"",
                                "description_kind": "plain",
                                "required": true
                              }
                            },
                            "nesting_mode": "single"
                          },
                          "description_kind": "plain",
                          "required": true
                        }
                      },
                      "nesting_mode": "single"
                    },
                    "description_kind": "plain",
                    "required": true
                  },
                  "port": {
                    "type": "number",
                    "description_kind": "plain",
                    "required": true
                  },
                  "protocol": {
                    "type": "string",
                    "description": "\"HTTP\", \"HTTPS\", \"TCP\", \"UDP\", \"TERMINATED_HTTPS\"",
                    "description_kind": "plain",
                    "required": true
                  },
                  "timeout_client_data": {
                    "type": "number",
                    "description_kind": "plain",
                    "optional": true
                  },
                  "timeout_member_connect": {
                    "type": "number",
                    "description_kind": "plain",
                    "optional": true
                  },
                  "timeout_member_data": {
                    "type": "number",
                    "description_kind": "plain",
                    "optional": true
                  },
                  "timeout_tcp_inspect": {
                    "type": "number",
                    "description_kind": "plain",
                    "optional": true
                  },
                  "tls_container_id": {
                    "type": "string",
                    "description_kind": "plain",
                    "optional": true
                  }
                },
                "nesting_mode": "list"
              },
              "description_kind": "plain",
              "required": true
            },
            "name": {
              "type": "string",
              "description": "displayed name",
              "description_kind": "plain",
              "required": true
            },
            "network_name": {
              "type": "string",
              "description": "\"frontend\", \"backend\"",
              "description_kind": "plain",
              "required": true
            },
            "project_id": {
              "type": "string",
              "description": "salt cloud project id",
              "description_kind": "plain",
              "required": true
            },
            "subnet_id": {
              "type": "string",
              "description_kind": "plain",
              "optional": true,
              "computed": true
            },
            "subnet_ip": {
              "type": "string",
              "description_kind": "plain",
              "optional": true,
              "computed": true
            },
            "tags": {
              "type": [
                "list",
                "string"
              ],
              "description_kind": "plain",
              "optional": true
            }
          },
          "description_kind": "plain"
        }
      }
    },
    "data_source_schemas": {
      "salt_flavors_instance": {
        "version": 0,
        "block": {
          "attributes": {
            "flavors": {
              "nested_type": {
                "attributes": {
                  "description": {
                    "type": "string",
                    "description_kind": "plain",
                    "computed": true
                  },
                  "disk": {
                    "type": "number",
                    "description_kind": "plain",
                    "computed": true
                  },
                  "id": {
                    "type": "string",
                    "description_kind": "plain",
                    "computed": true
                  },
                  "name": {
                    "type": "string",
                    "description_kind": "plain",
                    "computed": true
                  },
                  "ram": {
                    "type": "number",
                    "description_kind": "plain",
                    "computed": true
                  },
                  "vcpus": {
                    "type": "number",
                    "description_kind": "plain",
                    "computed": true
                  }
                },
                "nesting_mode": "list"
              },
              "description_kind": "plain",
              "computed": true
            },
            "group_id": {
              "type": "string",
              "description": "Only \"vm\" value",
              "description_kind": "plain",
              "required": true
            }
          },
          "description_kind": "plain"
        }
      },
      "salt_images_instance": {
        "version": 0,
        "block": {
          "attributes": {
            "images": {
              "nested_type": {
                "attributes": {
                  "created": {
                    "type": "string",
                    "description_kind": "plain",
                    "computed": true
                  },
                  "id": {
                    "type": "string",
                    "description_kind": "plain",
                    "computed": true
                  },
                  "min_disk": {
                    "type": "string",
                    "description_kind": "plain",
                    "computed": true
                  },
                  "min_ram": {
                    "type": "string",
                    "description_kind": "plain",
                    "computed": true
                  },
                  "name": {
                    "type": "string",
                    "description_kind": "plain",
                    "computed": true
                  },
                  "progress": {
                    "type": "string",
                    "description_kind": "plain",
                    "computed": true
                  },
                  "status": {
                    "type": "string",
                    "description_kind": "plain",
                    "computed": true
                  },
                  "updated": {
                    "type": "string",
                    "description_kind": "plain",
                    "computed": true
                  }
                },
                "nesting_mode": "list"
              },
              "description_kind": "plain",
              "computed": true
            },
            "project_id": {
              "type": "string",
              "description_kind": "plain",
              "required": true
            }
          },
          "description_kind": "plain"
        }
      },
      "salt_keys_instance": {
        "version": 0,
        "block": {
          "attributes": {
            "key_pairs": {
              "type": [
                "list",
                "string"
              ],
              "description_kind": "plain",
              "computed": true
            }
          },
          "description_kind": "plain"
        }
      },
      "salt_sg_instance": {
        "version": 0,
        "block": {
          "attributes": {
            "project_id": {
              "type": "string",
              "description_kind": "plain",
              "required": true
            },
            "sg": {
              "nested_type": {
                "attributes": {
                  "description": {
                    "type": "string",
                    "description_kind": "plain",
                    "computed": true
                  },
                  "id": {
                    "type": "string",
                    "description_kind": "plain",
                    "computed": true
                  },
                  "name": {
                    "type": "string",
                    "description_kind": "plain",
                    "computed": true
                  }
                },
                "nesting_mode": "list"
              },
              "description_kind": "plain",
              "computed": true
            }
          },
          "description_kind": "plain"
        }
      },
      "salt_zones_instance": {
        "version": 0,
        "block": {
          "attributes": {
            "project_id": {
              "type": "string",
              "description_kind": "plain",
              "required": true
            },
            "zones": {
              "nested_type": {
                "attributes": {
                  "description": {
                    "type": "string",
                    "description": "Description for dns zone",
                    "description_kind": "plain",
                    "computed": true
                  },
                  "dns_records": {
                    "nested_type": {
                      "attributes": {
                        "description": {
                          "type": "string",
                          "description": "Description for dns record",
                          "description_kind": "plain",
                          "computed": true
                        },
                        "id": {
                          "type": "string",
                          "description_kind": "plain",
                          "computed": true
                        },
                        "name": {
                          "type": "string",
                          "description_kind": "plain",
                          "computed": true
                        },
                        "project_id": {
                          "type": "string",
                          "description": "salt project id",
                          "description_kind": "plain",
                          "computed": true
                        },
                        "records": {
                          "type": [
                            "list",
                            "string"
                          ],
                          "description_kind": "plain",
                          "computed": true
                        },
                        "ttl": {
                          "type": "string",
                          "description": "Description for dns record",
                          "description_kind": "plain",
                          "computed": true
                        },
                        "type": {
                          "type": "string",
                          "description": "Description for dns record",
                          "description_kind": "plain",
                          "computed": true
                        },
                        "zone_id": {
                          "type": "string",
                          "description": "Zone id",
                          "description_kind": "plain",
                          "computed": true
                        }
                      },
                      "nesting_mode": "list"
                    },
                    "description_kind": "plain",
                    "computed": true
                  },
                  "id": {
                    "type": "string",
                    "description_kind": "plain",
                    "computed": true
                  },
                  "name": {
                    "type": "string",
                    "description_kind": "plain",
                    "computed": true
                  },
                  "project_id": {
                    "type": "string",
                    "description": "salt project id",
                    "description_kind": "plain",
                    "computed": true
                  },
                  "status": {
                    "type": "string",
                    "description": "Description for dns zone",
                    "description_kind": "plain",
                    "computed": true
                  },
                  "ttl": {
                    "type": "string",
                    "description": "Description for dns zone",
                    "description_kind": "plain",
                    "computed": true
                  },
                  "type": {
                    "type": "string",
                    "description": "Description for dns zone",
                    "description_kind": "plain",
                    "computed": true
                  }
                },
                "nesting_mode": "list"
              },
              "description_kind": "plain",
              "computed": true
            }
          },
          "description_kind": "plain"
        }
      }
    }
  }
}
}

@turkenh
Copy link
Member

turkenh commented Oct 25, 2022

@IvanTurgenev1 I could just reproduce the issue using the schema you provided above.
Investigating further...

@turkenh
Copy link
Member

turkenh commented Oct 25, 2022

@IvanTurgenev1 opened #125, would you mind giving a try on your side and leave a comment on the PR?

@IvanTurgenev1
Copy link
Author

@IvanTurgenev1 opened #125, would you mind giving a try on your side and leave a comment on the PR?

thanks for the work!
it seems that I do not have enough understanding to implement these changes in the template
would you mind to give me a hint how i can test it before changes are implemented ?

@turkenh
Copy link
Member

turkenh commented Oct 25, 2022

it seems that I do not have enough understanding to implement these changes in the template
would you mind to give me a hint how i can test it before changes are implemented ?

Ah, yes. Please add the following line to your go.mod file and run go mod tidy afterwards.

replace github.com/upbound/upjet => github.com/turkenh/upjet v0.0.0-20221025124717-d5ef4dfe08b8

Then, you can run make generate.

@IvanTurgenev1
Copy link
Author

replace github.com/upbound/upjet => github.com/turkenh/upjet v0.0.0-20221025124717-d5ef4dfe08b8

@turkenh thanks!
looks like it's works:
16:42:53 [ .. ] go generate linux_amd64
Generated 1 resources!
16:43:08 [ OK ] go generate linux_amd64
16:43:08 [ .. ] go mod tidy
go: downloading github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c
16:43:09 [ OK ] go mod tidy

@luebken
Copy link

luebken commented Dec 7, 2022

Closing this in favour of #130

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working community
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants