Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api): skip missing integration error while loading workflow #6526

Merged
merged 2 commits into from
Apr 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions sdk/workflow_node.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package sdk

import (
"context"
"sort"

"github.com/fsamin/go-dump"
"github.com/rockbears/log"
)

const (
Expand Down Expand Up @@ -74,7 +76,7 @@ func (n *Node) FilterHooksConfig(s ...string) {
}
}

//AddTrigger adds a trigger to the destination node from the node found by its name
// AddTrigger adds a trigger to the destination node from the node found by its name
func (n *Node) AddTrigger(name string, dest Node) {
if n.Name == name {
n.Triggers = append(n.Triggers, NodeTrigger{
Expand All @@ -88,14 +90,14 @@ func (n *Node) AddTrigger(name string, dest Node) {
}
}

//Sort sorts the workflow node
// Sort sorts the workflow node
func (n *Node) Sort() {
sort.Slice(n.Triggers, func(i, j int) bool {
return n.Triggers[i].ChildNode.Name < n.Triggers[j].ChildNode.Name
})
}

//VisitNode all the workflow and apply the visitor func on the current node and the children
// VisitNode all the workflow and apply the visitor func on the current node and the children
func (n *Node) VisitNode(w *Workflow, visitor func(node *Node, w *Workflow)) {
visitor(n, w)
for i := range n.Triggers {
Expand Down Expand Up @@ -264,7 +266,7 @@ func (n *Node) IsLinkedToRepo(w *Workflow) bool {
}

// CheckApplicationDeploymentStrategies checks application deployment strategies
func (n Node) CheckApplicationDeploymentStrategies(proj Project, w *Workflow) error {
func (n *Node) CheckApplicationDeploymentStrategies(proj Project, w *Workflow) error {
if n.Context == nil {
return nil
}
Expand All @@ -283,7 +285,8 @@ func (n Node) CheckApplicationDeploymentStrategies(proj Project, w *Workflow) er

app := w.Applications[n.Context.ApplicationID]
if _, has := app.DeploymentStrategies[pf.Name]; !has {
return NewErrorFrom(ErrInvalidData, "integration %s unavailable on application %s", pf.Name, app.Name)
n.Context.ProjectIntegrationID = 0 // remove the integration from the context to still be able to load the workflow
log.Error(context.Background(), "integration %s(%d) unavailable on application %s/%s (%d)", pf.Name, pf.ID, proj.Key, app.Name, app.ID)
}
return nil
}