@@ -24,6 +24,7 @@ import (
24
24
"github.com/ovh/cds/engine/api/keys"
25
25
"github.com/ovh/cds/engine/api/observability"
26
26
"github.com/ovh/cds/engine/api/pipeline"
27
+ "github.com/ovh/cds/engine/api/workflowtemplate"
27
28
"github.com/ovh/cds/sdk"
28
29
"github.com/ovh/cds/sdk/log"
29
30
)
@@ -71,6 +72,7 @@ type LoadOptions struct {
71
72
WithIcon bool
72
73
WithAsCodeUpdateEvent bool
73
74
WithIntegrations bool
75
+ WithTemplate bool
74
76
}
75
77
76
78
// UpdateOptions is option to parse a workflow
@@ -587,6 +589,18 @@ func load(ctx context.Context, db gorp.SqlExecutor, proj sdk.Project, opts LoadO
587
589
res .EventIntegrations = integrations
588
590
}
589
591
592
+ if opts .WithTemplate {
593
+ wti , err := workflowtemplate .LoadInstanceByWorkflowID (ctx , db , res .ID , workflowtemplate .LoadInstanceOptions .WithTemplate )
594
+ if err != nil && ! sdk .ErrorIs (err , sdk .ErrNotFound ) {
595
+ return nil , err
596
+ }
597
+ if wti != nil {
598
+ res .TemplateInstance = wti
599
+ res .FromTemplate = fmt .Sprintf ("%s@%d" , wti .Template .Path (), wti .WorkflowTemplateVersion )
600
+ res .TemplateUpToDate = wti .Template .Version == wti .WorkflowTemplateVersion
601
+ }
602
+ }
603
+
590
604
_ , next = observability .Span (ctx , "workflow.load.loadNotifications" )
591
605
notifs , errN := loadNotifications (db , & res )
592
606
next ()
@@ -1256,7 +1270,7 @@ func checkProjectIntegration(proj sdk.Project, w *sdk.Workflow, n *sdk.Node) err
1256
1270
}
1257
1271
}
1258
1272
if ppProj .ID == 0 {
1259
- return sdk .WithStack (sdk .ErrorWithData ( sdk . ErrIntegrationtNotFound , n .Context .ProjectIntegrationName ) )
1273
+ return sdk .WithData (sdk .ErrIntegrationtNotFound , n .Context .ProjectIntegrationName )
1260
1274
}
1261
1275
w .ProjectIntegrations [ppProj .ID ] = ppProj
1262
1276
n .Context .ProjectIntegrationID = ppProj .ID
@@ -1338,7 +1352,7 @@ func checkApplication(store cache.Store, db gorp.SqlExecutor, proj sdk.Project,
1338
1352
appDB , err := application .LoadByName (db , proj .Key , n .Context .ApplicationName , application .LoadOptions .WithDeploymentStrategies , application .LoadOptions .WithVariables )
1339
1353
if err != nil {
1340
1354
if sdk .ErrorIs (err , sdk .ErrNotFound ) {
1341
- return sdk .WithStack (sdk .ErrorWithData ( sdk . ErrNotFound , n .Context .ApplicationName ) )
1355
+ return sdk .WithData (sdk .ErrNotFound , n .Context .ApplicationName )
1342
1356
}
1343
1357
return sdk .WrapError (err , "unable to load application %s" , n .Context .ApplicationName )
1344
1358
}
0 commit comments