@@ -32,10 +32,11 @@ func WorkflowResource() resource.Resource {
3232
3333// WorkflowResourceModel describes the resource data model.
3434type workflowResourceModel struct {
35- Id types.String `tfsdk:"id"`
36- Name types.String `tfsdk:"name"`
37- Inputs []workflowInputModel `tfsdk:"inputs"`
38- Steps []workflowStepModel `tfsdk:"steps"`
35+ Id types.String `tfsdk:"id"`
36+ Name types.String `tfsdk:"name"`
37+ TriggerLinearLabelName types.String `tfsdk:"trigger_linear_label_name"`
38+ Inputs []workflowInputModel `tfsdk:"inputs"`
39+ Steps []workflowStepModel `tfsdk:"steps"`
3940}
4041
4142type workflowInputModel struct {
@@ -114,6 +115,10 @@ func (r *workflowResource) Schema(_ context.Context, _ resource.SchemaRequest, r
114115 MarkdownDescription : "The name of the workflow." ,
115116 Required : true ,
116117 },
118+ "trigger_linear_label_name" : schema.StringAttribute {
119+ MarkdownDescription : "The name of the Linear label that should trigger the workflow." ,
120+ Optional : true ,
121+ },
117122 "inputs" : schema.ListNestedAttribute {
118123 Optional : true ,
119124 NestedObject : schema.NestedAttributeObject {
@@ -349,9 +354,10 @@ func (r *workflowResource) Create(ctx context.Context, req resource.CreateReques
349354 }
350355
351356 input := devhub.Workflow {
352- Name : plan .Name .ValueString (),
353- Inputs : inputs ,
354- Steps : steps ,
357+ Name : plan .Name .ValueString (),
358+ TriggerLinearLabel : devhub.TriggerLinearLabel {Name : plan .TriggerLinearLabelName .ValueString ()},
359+ Inputs : inputs ,
360+ Steps : steps ,
355361 }
356362
357363 createdWorkflow , err := r .client .CreateWorkflow (input )
@@ -403,6 +409,12 @@ func (r *workflowResource) Read(ctx context.Context, req resource.ReadRequest, r
403409 state .Id = types .StringValue (workflow .Id )
404410 state .Name = types .StringValue (workflow .Name )
405411
412+ if workflow .TriggerLinearLabel .Name == "" {
413+ state .TriggerLinearLabelName = types .StringNull ()
414+ } else {
415+ state .TriggerLinearLabelName = types .StringValue (workflow .TriggerLinearLabel .Name )
416+ }
417+
406418 var stateInputs []workflowInputModel
407419 for _ , input := range workflow .Inputs {
408420 stateInputs = append (stateInputs , workflowInputModel {
@@ -550,10 +562,11 @@ func (r *workflowResource) Update(ctx context.Context, req resource.UpdateReques
550562 }
551563
552564 workflow := devhub.Workflow {
553- Id : plan .Id .ValueString (),
554- Name : plan .Name .ValueString (),
555- Inputs : inputs ,
556- Steps : steps ,
565+ Id : plan .Id .ValueString (),
566+ Name : plan .Name .ValueString (),
567+ TriggerLinearLabel : devhub.TriggerLinearLabel {Name : plan .TriggerLinearLabelName .ValueString ()},
568+ Inputs : inputs ,
569+ Steps : steps ,
557570 }
558571
559572 updatedWorkflow , err := r .client .UpdateWorkflow (plan .Id .ValueString (), workflow )
0 commit comments