icy-london-58403
02/17/2020, 6:59 PMprefix.ts(130,21): error TS2564: Property 'endpoint' has no initializer and is not definitely assigned in the constructor.
prefix.ts(131,21): error TS2564: Property 'token' has no initializer and is not definitely assigned in the constructor.
prefix.ts(132,21): error TS2564: Property 'description' has no initializer and is not definitely assigned in the constructor.
I followed the directions on: https://www.pulumi.com/docs/intro/concepts/programming-model/#dynamicproviders
I made my create return the same names as the public readonly
members of my Resource
. What am I doing wrong?
Partial of my code:
class PrefixProvider implements pulumi.dynamic.ResourceProvider {
public async create(inputs: PrefixInputs): Promise<pulumi.dynamic.CreateResult> {
pulumi.log.debug("prefix create...")
let netboxClient = new Client({
host: inputs.endpoint,
token: inputs.token,
})
let description = `${inputs.platform} | ${inputs.region} | ${inputs.type} | ${inputs.name}`
var async_function = async function(): Promise<AxiosResponse<createPrefixResponse>> {
return await netboxClient.createPrefix({
prefix: inputs.prefix,
description: description,
vrf: inputs.vrfID,
})
}
const response = await async_function()
return {
id: response.data.id.toString(),
outs: {
endpoint: inputs.endpoint,
token: inputs.token,
description: description,
},
}
}
public async delete(id: pulumi.ID, props: PrefixInputs): Promise<void> {
pulumi.log.debug("prefix delete...")
let netboxClient = new Client({
host: props.endpoint,
token: props.token,
})
var async_function = async function() {
return await netboxClient.deletePrefix({
id: Number(id),
})
}
const response = await async_function()
}
}
export class Prefix extends pulumi.dynamic.Resource {
public readonly endpoint: pulumi.Output<string>
public readonly token: pulumi.Output<string>
public readonly description: pulumi.Output<string>
constructor(name: string, props: PrefixResourceInputs, opts?: pulumi.CustomResourceOptions) {
super(new PrefixProvider(), name, {...props, endpoint: undefined, token: undefined, description: undefined}, opts)
}
}
microscopic-pilot-97530
public readonly endpoint!: pulumi.Output<string>
public readonly token!: pulumi.Output<string>
public readonly description!: pulumi.Output<string>
strictPropertyInitialization
to false
in tsconfig.json
.icy-london-58403
02/19/2020, 9:11 PM