sparse-intern-71089
06/07/2019, 11:20 PMearly-musician-41645
06/07/2019, 11:21 PMconst schedule = new gitlab.ScheduledPipeline("test-pipeline", {
description: "Testy test test schedule2",
ref: "master",
cron: "0 1 * * 5",
cron_timezone: "UTC",
active: true,
variables: [{
key: "testvar",
value: "fooval",
}],
},
);
console.log(`Schedule ID: ${schedule.id}`);
How do I get the schedule object to store the ID returned in the POST response from gitlab?early-musician-41645
06/07/2019, 11:23 PMconst gitlabScheduledPipelineProvider: pulumi.dynamic.ResourceProvider = {
async create(inputs: Schedule) {
let postData: Schedule = <Schedule>{
description: inputs.description,
ref: inputs.ref,
cron: inputs.cron,
cron_timezone: inputs.cron_timezone,
active: inputs.active,
variables: inputs.variables,
};
let rest: rm.RestClient = new rm.RestClient('gitlab-client', baseUrl);
let res: rm.IRestResponse<Schedule> = await rest.create<Schedule>(pipelineSchedulesPath, postData);
return { id: "foo", outs: {}};
},
}early-musician-41645
06/07/2019, 11:23 PMexport class ScheduledPipeline extends pulumi.dynamic.Resource {
public readonly id!: pulumi.Output<number>;
constructor(name: string, props: Schedule, opts?: pulumi.CustomResourceOptions) {
super(gitlabScheduledPipelineProvider, name, props, opts);
}
}early-musician-41645
06/07/2019, 11:23 PMid propertyclever-sunset-76585
06/07/2019, 11:48 PMclever-sunset-76585
06/07/2019, 11:54 PMnot sure how to hook up theAny property returned from thepropertyid
create function in the outs property will be set in the corresponding class member of your dynamic.Resource class.
What you have here: https://pulumi-community.slack.com/archives/C84L4E3N1/p1559949818250800?thread_ts=1559949621.250200&cid=C84L4E3N1, should allow you to access that id already. You shouldn’t need the !. As long as you are setting an id in the result of the create function, it’ll be persisted by the engine. In addition, you can also return other output properties, by adding them to the outs property of the return value of create.early-musician-41645
06/10/2019, 7:53 PMid was already a property. What I really meant was "some arbitrary property that I'd like to store"clever-sunset-76585
06/10/2019, 10:36 PMcreate function of your pulumi.dynamic.ResourceProvider implementation, be sure to set that in the outs property. For example,
...
async create(.....) {
return { id: "....", outs: { someOutput: "simpleValue", anotherOutput2: { key: "value", key2: true, key3: 5 } }
}
...clever-sunset-76585
06/10/2019, 10:39 PMpulumi.dynamic.Resource (assuming this is all in TypeScript rather than plain JS), you can declare these:
export interface SomeOutputType {
key: pulumi.Output<string>;
key2: pulumi.Output<boolean>;
key3: pulumi.Output<number>;
}
export class MyResource extends pulumi.dynamic.Resource{
public readonly someOutput: pulumi.Output<string>;
public readonly anotherOutput2: pulumi.Output<SomeOutputType>;
constructor(.....) {
super(......);
}
}early-musician-41645
06/11/2019, 10:42 PM