Giter Club home page Giter Club logo

Comments (4)

lblackstone avatar lblackstone commented on August 29, 2024 1

Sorry, I should have made it clearer that my comment was for whomever works on the fix for this issue. I'm fairly certain this a bug in the schema generated internally by crd2pulumi.

from crd2pulumi.

ringods avatar ringods commented on August 29, 2024

Update: comparing the type definitions of between my generated code and the k8s Service class made me remove the undefined part as well from:

  • apiVersion
  • kind
  • spec
  • status

from crd2pulumi.

lblackstone avatar lblackstone commented on August 29, 2024

I took a look at the schema for the k8s provider, and I think crd2pulumi may not be setting the requiredOutputs language option for nodejs. Here's what the schema should look like for a Service resource:

"kubernetes:core/v1:Service": {
    "description": "Service is a named abstraction of software service (for example, mysql) consisting of local port (for example 3306) that the proxy listens on, and the selector that determines which pods will answer requests sent through the proxy.\n\nThis resource waits until its status is ready before registering success\nfor create/update, and populating output properties from the current state of the resource.\nThe following conditions are used to determine whether the resource creation has\nsucceeded or failed:\n\n1. Service object exists.\n2. Related Endpoint objects are created. Each time we get an update, wait 10 seconds\n   for any stragglers.\n3. The endpoints objects target some number of living objects (unless the Service is\n   an \"empty headless\" Service [1] or a Service with '.spec.type: ExternalName').\n4. External IP address is allocated (if Service has '.spec.type: LoadBalancer').\n\nKnown limitations: \nServices targeting ReplicaSets (and, by extension, Deployments,\nStatefulSets, etc.) with '.spec.replicas' set to 0 are not handled, and will time\nout. To work around this limitation, set 'pulumi.com/skipAwait: \"true\"' on\n'.metadata.annotations' for the Service. Work to handle this case is in progress [2].\n\n[1] https://kubernetes.io/docs/concepts/services-networking/service/#headless-services\n[2] https://github.com/pulumi/pulumi-kubernetes/pull/703\n\nIf the Service has not reached a Ready state after 10 minutes, it will\ntime out and mark the resource update as Failed. You can override the default timeout value\nby setting the 'customTimeouts' option on the resource.",
    "properties": {
        "apiVersion": {
            "type": "string",
            "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
            "const": "v1"
        },
        "kind": {
            "type": "string",
            "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds",
            "const": "Service"
        },
        "metadata": {
            "$ref": "#/types/kubernetes:meta/v1:ObjectMeta",
            "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata"
        },
        "spec": {
            "$ref": "#/types/kubernetes:core/v1:ServiceSpec",
            "description": "Spec defines the behavior of a service. https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status"
        },
        "status": {
            "$ref": "#/types/kubernetes:core/v1:ServiceStatus",
            "description": "Most recently observed status of the service. Populated by the system. Read-only. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status"
        }
    },
    "type": "object",
    "language": {
        "nodejs": {
            "requiredOutputs": [
                "apiVersion",
                "kind",
                "metadata",
                "spec",
                "status"
            ]
        }
    }
},

crd2pulumi/gen/schema.go

Lines 152 to 181 in e646398

func AddType(schema map[string]interface{}, name string, types map[string]pschema.ObjectTypeSpec) {
properties, foundProperties, _ := unstruct.NestedMap(schema, "properties")
description, _, _ := unstruct.NestedString(schema, "description")
schemaType, _, _ := unstruct.NestedString(schema, "type")
required, _, _ := unstruct.NestedStringSlice(schema, "required")
propertySpecs := map[string]pschema.PropertySpec{}
for propertyName := range properties {
propertySchema, _, _ := unstruct.NestedMap(properties, propertyName)
propertyDescription, _, _ := unstruct.NestedString(propertySchema, "description")
defaultValue, _, _ := unstruct.NestedFieldNoCopy(propertySchema, "default")
propertySpecs[propertyName] = pschema.PropertySpec{
TypeSpec: GetTypeSpec(propertySchema, name+strings.Title(propertyName), types),
Description: propertyDescription,
Default: defaultValue,
}
}
// If the type wasn't specified but we found properties, then we can infer that the type is an object
if foundProperties && schemaType == "" {
schemaType = Object
}
types[name] = pschema.ObjectTypeSpec{
Type: schemaType,
Properties: propertySpecs,
Required: required,
Description: description,
}
}

from crd2pulumi.

ringods avatar ringods commented on August 29, 2024

@lblackstone I don't understand what you are trying to explain here. For the record: I don't have problems with the core Kubernetes Service class. I have problems with the properties in the generated BackendConfig class, generated from the Google Cloud specific BackendConfig CRD.

from crd2pulumi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.