Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
skonto committed Apr 5, 2024
1 parent 7faadbe commit aa2f05b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pkg/reconciler/route/domains/domains.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@ func DomainNameFromTemplate(ctx context.Context, r metav1.ObjectMeta, name strin
}

if err := templ.Execute(&buf, data); err != nil {
return "", DomainNameError{msg: fmt.Errorf("error executing the DomainTemplate: %w", err).Error()}
return "", DomainNameError{msg: fmt.Sprintf("error executing the DomainTemplate: %q", err.Error())}
}

urlErrs := validation.IsFullyQualifiedDomainName(field.NewPath("url"), buf.String())
if urlErrs != nil {
return "", DomainNameError{msg: fmt.Errorf("invalid domain name %q: %w", buf.String(), urlErrs.ToAggregate()).Error()}
return "", DomainNameError{msg: fmt.Sprintf("invalid domain name %q: %q", buf.String(), urlErrs.ToAggregate())}
}

return buf.String(), nil
Expand Down
4 changes: 3 additions & 1 deletion pkg/reconciler/route/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ type Reconciler struct {
enqueueAfter func(interface{}, time.Duration)
}

const errorConfigMsg = "ErrorConfig"

// Check that our Reconciler implements routereconciler.Interface
var _ routereconciler.Interface = (*Reconciler)(nil)

Expand Down Expand Up @@ -119,7 +121,7 @@ func (c *Reconciler) ReconcileKind(ctx context.Context, r *v1.Route) pkgreconcil
if traffic == nil || err != nil {
if err != nil {
if errors.As(err, &domains.DomainNameError{}) {
r.Status.MarkRevisionTargetTrafficError("ErrorConfig", err.Error())
r.Status.MarkRevisionTargetTrafficError(errorConfigMsg, err.Error())
} else {
r.Status.MarkUnknownTrafficError(err.Error())
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/route/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2047,7 +2047,7 @@ func TestReconcile(t *testing.T) {
Object: Route("default", "tooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo-long",
WithConfigTarget("config"), WithRouteObservedGeneration,
WithRouteFinalizer, WithInitRouteConditions,
MarkRevisionTargetTrafficError("ErrorConfig", `invalid domain name "tooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo-long.default.example.com": url: Invalid value: "tooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo-long": must be no more than 63 characters`),
MarkRevisionTargetTrafficError(errorConfigMsg, `invalid domain name "tooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo-long.default.example.com": url: Invalid value: "tooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo-long": must be no more than 63 characters`),
WithHost("tooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo-long.default.svc.cluster.local"),
),
}},
Expand Down

0 comments on commit aa2f05b

Please sign in to comment.