Skip to content

Commit

Permalink
fix api gw dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Singer committed Nov 21, 2023
1 parent 8e8ad14 commit 9840d34
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 4 deletions.
5 changes: 3 additions & 2 deletions pkg/engine2/operational_rule/operational_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type (
)

func (action *operationalResourceAction) handleOperationalResourceAction(resource *construct.Resource) error {
if action.numNeeded <= 0 {
if action.numNeeded == 0 {
return nil
}

Expand All @@ -34,7 +34,8 @@ func (action *operationalResourceAction) handleOperationalResourceAction(resourc
return nil
}

if action.numNeeded > 0 {
// we want the negative and positive case to trigger this so you can specify -1 as all available
if action.numNeeded != 0 {
err := action.useAvailableResources(resource)
if err != nil {
return fmt.Errorf("error during operational resource action while using available resources: %w", err)
Expand Down
3 changes: 3 additions & 0 deletions pkg/engine2/operational_rule/operational_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ type (

func (ctx OperationalRuleContext) HandleOperationalRule(rule knowledgebase.OperationalRule) error {

if ctx.Data.Edge != nil && ctx.Data.Edge.Source.String() == "aws:api_deployment:rest_api_0:api_deployment-0" {
fmt.Println("here")
}
shouldRun, err := EvaluateIfCondition(rule, ctx.Solution, ctx.Data)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion pkg/engine2/operational_rule/operational_step.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (ctx OperationalRuleContext) HandleOperationalStep(step knowledgebase.Opera
}
}

if len(ids) >= step.NumNeeded {
if len(ids) >= step.NumNeeded && step.NumNeeded > 0 {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/engine2/operational_rule/resource_placer.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func (p ClosestPlacer) PlaceResources(
return resourceDepths[availableResources[i].ID] < resourceDepths[availableResources[j].ID]
})
num := *numNeeded
if num > len(availableResources) {
if num > len(availableResources) || num < 0 {
num = len(availableResources)
}
for _, availableResource := range availableResources[:num] {
Expand Down
2 changes: 2 additions & 0 deletions pkg/templates/aws/edges/api_deployment-rest_api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ operational_rules:
direction: downstream
resources:
- '{{ allDownstream "aws:api_integration" .Target}}'
num_needed: -1
- if: '{{ hasDownstream "aws:api_method" .Target }}'
steps:
- resource: '{{ .Source }}'
direction: downstream
resources:
- '{{ allDownstream "aws:api_method" .Target}}'
num_needed: -1
2 changes: 2 additions & 0 deletions pkg/templates/aws/resources/api_integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ properties:
Resource:
type: resource(aws:api_resource)
operational_rule:
if: |
{{ ne (fieldValue "Route" .Self) "/" }}
steps:
- direction: upstream
resources:
Expand Down
2 changes: 2 additions & 0 deletions pkg/templates/aws/resources/api_method.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ properties:
Resource:
type: resource(aws:api_resource)
operational_rule:
if: |
{{ ne (fieldValue "Route" (downstream "aws:api_integration" .Self)) "/" }}
steps:
- direction: upstream
resources:
Expand Down

0 comments on commit 9840d34

Please sign in to comment.