besom icon indicating copy to clipboard operation
besom copied to clipboard

Add missing Aliases support in codegen

Open lbialy opened this issue 2 years ago • 9 comments

The Aliases implementation needs to be written.

lbialy avatar Jun 04 '23 16:06 lbialy

Metaschema:

                 "aliases": {
                    "description": "The list of aliases for the resource.",
                    "type": "array",
                    "items": {
                        "title": "Alias Definition",
                        "type": "object",
                        "properties": {
                            "name": {
                                "description": "The name portion of the alias, if any",
                                "type": "string"
                            },
                            "project": {
                                "description": "The project portion of the alias, if any",
                                "type": "string"
                            },
                            "type": {
                                "description": "The type portion of the alias, if any",
                                "type": "string"
                            }
                        }
                    }
                },

Production schema fragments:

"aliases": [
  {
    "type": "azure-native:machinelearningservices/v20210301preview:BatchDeployment"
  }
]
"aliases": {
  "type": "array",
  "items": {
    "type": "string"
  }
},
"aliases": {
  "type": "array",
  "items": {
    "type": "string"
  },
  "description": "The network aliases of the container in the specific network.\n",
  "willReplaceOnChanges": true
},
"aliases": {
  "type": "object",
  "additionalProperties": {
    "type": "string"
  },
  "description": "A set of key/value aliases pairs to assign to the IoT Core Device\n"
},

pawelprazak avatar Nov 10 '23 13:11 pawelprazak

An interesting consideration for the alias API design: https://github.com/pulumi/pulumi/issues/2754#issuecomment-498677172

pawelprazak avatar Nov 17 '23 12:11 pawelprazak

true, very interesting bit but can we codegen that type field somehow in codegen? @pawelprazak

lbialy avatar Jan 25 '24 11:01 lbialy

Codegen should have enough information, yes.

pawelprazak avatar Jan 25 '24 13:01 pawelprazak

As discussed on Slack, let's add typeToken filed with the Pulumi Type Token value to the ResourceCompanion using codegen

pawelprazak avatar Feb 06 '24 10:02 pawelprazak

looks like we've already added the typeToken :D

e.g.

object Cluster extends besom.ResourceCompanion[Cluster]:
  def apply(using ctx: besom.types.Context)(
    name: besom.util.NonEmptyString,
    args: ClusterArgs = ClusterArgs(),
    opts: besom.ResourceOptsVariant.Custom ?=> besom.CustomResourceOptions = besom.CustomResourceOptions()
  ): besom.types.Output[Cluster] =
    ctx.readOrRegisterResource[Cluster, ClusterArgs]("google-native:container/v1:Cluster", name, args, opts(using besom.ResourceOptsVariant.Custom))

  private[besom] def typeToken: besom.types.ResourceType = "google-native:container/v1:Cluster"
  ...

So when implementing the aliases we can do as suggested here https://github.com/pulumi/pulumi/issues/2754#issuecomment-498677172

pawelprazak avatar Feb 06 '24 13:02 pawelprazak

Relevant upstream integration tests: https://github.com/pulumi/pulumi/tree/master/tests/integration/aliases

pawelprazak avatar Feb 06 '24 15:02 pawelprazak

Relevant use case: https://www.pulumi.com/blog/cumundi-guest-post/

pawelprazak avatar Feb 09 '24 09:02 pawelprazak

Note to self: remember to investigate the difference between aliasURNs and aliases in the request.

pawelprazak avatar Apr 25 '24 10:04 pawelprazak