Skip to content

Commit

Permalink
Add valid certificate ref condition setting
Browse files Browse the repository at this point in the history
  • Loading branch information
jm96441n committed Apr 24, 2023
1 parent eb3b997 commit d83a09c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions agent/consul/gateways/controller_gateways.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,14 @@ func (r *apiGatewayReconciler) reconcileGateway(_ context.Context, req controlle
updater.SetCondition(invalidCertificate(ref, err))
}

if len(certificateErrors) == 0 {
for _, listener := range gateway.Listeners {
for _, ref := range listener.TLS.Certificates {
updater.SetCondition(validCertificate(ref))
}
}
}

if len(certificateErrors) > 0 {
updater.SetCondition(invalidCertificates())
} else {
Expand Down Expand Up @@ -840,6 +848,19 @@ func gatewayAccepted() structs.Condition {
)
}

// validCertificate returns a condition used when a gateway references a
// certificate that does not exist. It takes a ref used to scope the condition
// to a given APIGateway listener.
func validCertificate(ref structs.ResourceReference) structs.Condition {
return structs.NewGatewayCondition(
api.GatewayConditionResolvedRefs,
api.ConditionStatusTrue,
api.GatewayReasonResolvedRefs,
"resolved refs",
ref,
)
}

// invalidCertificate returns a condition used when a gateway references a
// certificate that does not exist. It takes a ref used to scope the condition
// to a given APIGateway listener.
Expand Down

0 comments on commit d83a09c

Please sign in to comment.