Hello, im writing a native provider without using ...
# package-authoring
s
Hello, im writing a native provider without using the terraform bridge, i was wondering if there is an example on how a Read/Diff/Update function would look like. does it have the same signature as the Create function or is there something different?
a
Hi @silly-match-79024, what language are you writing in? Are you using https://github.com/pulumi/pulumi-go-provider? Are you writing directly against the gRPC interface? Read, Diff and Update all have different signatures.
s
I found the repository you mentioned and started working on implmenting my own Read/Diff/Update functions. However, I have a different problem now. I have a struct called
EnvironmentVariable
that looks like this
Copy code
type EnvironmentVariable struct {
	Name string `pulumi:"name"`
	Value string `pulumi:"value"`
}
I use this struct in a ResourceArgs object as an array
Copy code
type ServerlessFunctionArgs struct {
	Path string `pulumi:"path"` 
	EnvironmentVariables []domain.EnvironmentVariable `pulumi:"environmentVariables,optional"`
}
But when i call pulumi up on my nodejs example i get this error
Copy code
error: Running program '/workspaces/pulumi-genezio/examples/nodejs/' failed with an unhandled exception:
    <ref *1> Error: 13 INTERNAL: Request message serialization failure: b.Va is not a function
        at callErrorFromStatus (/workspaces/pulumi-genezio/examples/nodejs/node_modules/@grpc/grpc-js/src/call.ts:82:17)
        at Object.onReceiveStatus (/workspaces/pulumi-genezio/examples/nodejs/node_modules/@grpc/grpc-js/src/client.ts:360:55)
        at Object.onReceiveStatus (/workspaces/pulumi-genezio/examples/nodejs/node_modules/@grpc/grpc-js/src/client-interceptors.ts:458:34)
        at Object.onReceiveStatus (/workspaces/pulumi-genezio/examples/nodejs/node_modules/@grpc/grpc-js/src/client-interceptors.ts:419:48)
        at /workspaces/pulumi-genezio/examples/nodejs/node_modules/@grpc/grpc-js/src/resolving-call.ts:163:24
        at processTicksAndRejections (node:internal/process/task_queues:77:11)
    for call at
        at ServiceClientImpl.makeUnaryRequest (/workspaces/pulumi-genezio/examples/nodejs/node_modules/@grpc/grpc-js/src/client.ts:325:42)
        at ServiceClientImpl.registerResourceOutputs (/workspaces/pulumi-genezio/examples/nodejs/node_modules/@grpc/grpc-js/src/make-client.ts:189:15)
        at /workspaces/pulumi-genezio/examples/nodejs/node_modules/@pulumi/runtime/resource.ts:1087:33
        at new Promise (<anonymous>)
        at Object.<anonymous> (/workspaces/pulumi-genezio/examples/nodejs/node_modules/@pulumi/runtime/resource.ts:1086:21)
        at Generator.next (<anonymous>)
        at fulfilled (/workspaces/pulumi-genezio/examples/nodejs/node_modules/@pulumi/pulumi/runtime/resource.js:18:58)
        at processTicksAndRejections (node:internal/process/task_queues:95:5) {
      code: 13,
      details: 'Request message serialization failure: b.Va is not a function',
      metadata: Metadata { internalRepr: Map(0) {}, options: {} },
      promise: Promise { <rejected> [Circular *1] }
    }
i did some digging and the problem seems to be that my index.ts file that im testing my library with has the following export
Copy code
const myFunction = new genezio.ServerlessFunction("MyFunction", {
  folderHash: sha256FromFolder("./function"),
  path: "./function",
  projectName: "project-function-pulumi-2",
  region: "us-east-1",
  entry: "app.mjs",
  handler: "handler",
  name: "my-function",
  authToken: process.env.AUTH_TOKEN ?? "",
  environmentVariables: {
    NAME: "Hellos",
    MYENVVAR: "Worlds",
  },
});


export const functionsdasdOutput = {
  projectId: myFunction.projectId,
  projectEnvId: myFunction.projectEnvId,
  functionId: myFunction.functionId,
};
For some reason if i have an array of custom objects in the ResourceArgs when i do any kind of export based on that resource i get the error mentioned above