Skip to content
Closed
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,21 @@ func (s *ReleaseTargets) EvaluateReleaseTarget(c *gin.Context, workspaceId strin
return
}

targetDecision, err := policyManager.EvaluateTarget(c.Request.Context(), &req.ReleaseTarget, policies)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{
"error": "Failed to evaluate target policies: " + err.Error(),
})
return
}

c.JSON(http.StatusOK, gin.H{
"policiesEvaulated": len(policies),
"workspaceDecision": workspaceDecision,
"versionDecision": versionDecision,
"envVersionDecision": envVersionDecision,
"envTargetVersionDecision": envTargetVersionDecision,
"targetDecision": targetDecision,
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,15 @@ func (p *Planner) findDeployableVersion(
continue // Environment+version+target-scoped rules blocked deployment
}

targetDecision, err := p.policyManager.EvaluateTarget(ctx, releaseTarget, policies)
if err != nil {
span.RecordError(err)
continue // Skip this version on error
}
if !targetDecision.CanDeploy() {
continue // Target-scoped rules blocked deployment
}

// Both checks passed - this version can be deployed
return version
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package releasetargetconcurrency

import (
"context"
"workspace-engine/pkg/oapi"
"workspace-engine/pkg/workspace/releasemanager/policy/evaluator"
"workspace-engine/pkg/workspace/releasemanager/policy/results"
"workspace-engine/pkg/workspace/store"
)

var _ evaluator.TargetScopedEvaluator = &ReleaseTargetConcurrencyEvaluator{}

type ReleaseTargetConcurrencyEvaluator struct {
store *store.Store
}

func NewReleaseTargetConcurrencyEvaluator(store *store.Store) *ReleaseTargetConcurrencyEvaluator {
return &ReleaseTargetConcurrencyEvaluator{store: store}
}

func (e *ReleaseTargetConcurrencyEvaluator) Evaluate(ctx context.Context, releaseTarget *oapi.ReleaseTarget) (*oapi.RuleEvaluation, error) {
processingJobs := e.store.Jobs.GetJobsInProcessingStateForReleaseTarget(releaseTarget)
if len(processingJobs) > 0 {
return results.NewDeniedResult("Release target is already processing jobs").
WithDetail("release_target_key", releaseTarget.Key()).
WithDetail("jobs", processingJobs), nil
}

return results.NewAllowedResult("Release target is not processing jobs"), nil
}
Loading
Loading