Skip to content

Commit

Permalink
StaticRoute: add upstream and remove paths from top-level (#980)
Browse files Browse the repository at this point in the history
Update `cmd/kusk/manifests/dashboard_staticroute.yaml` to new structure of `StaticRoute`.

Signed-off-by: Mohamed Bana <[email protected]>
  • Loading branch information
mbana authored Nov 21, 2022
1 parent 841b792 commit f3401c9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 17 deletions.
2 changes: 1 addition & 1 deletion api/v1alpha1/staticroute_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (spec *StaticRouteSpec) GetOptionsFromSpec() (*options.StaticOptions, error
Paths: paths,
Auth: spec.Auth,
Hosts: spec.Hosts,
Upstream: spec.Upstream,
Upstream: *spec.Upstream,
}
if err := opts.Validate(); err != nil {
return nil, fmt.Errorf("failed to validate options: %w", err)
Expand Down
4 changes: 2 additions & 2 deletions cmd/kusk/cmd/manifest_data.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 5 additions & 12 deletions cmd/kusk/manifests/dashboard_staticroute.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,14 @@ metadata:
labels:
kusk-managed: "true"
spec:
upstream:
service:
name: kusk-gateway-dashboard
namespace: kusk-system
port: 80
fleet:
name: kusk-gateway-private-envoy-fleet
namespace: kusk-system
hosts:
- localhost
- "*"
paths:
/:
get:
route:
upstream:
rewrite:
pattern: ""
substitution: ""
service:
name: kusk-gateway-dashboard
namespace: kusk-system
port: 80
2 changes: 1 addition & 1 deletion internal/controllers/staticroute_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func staticRouteAppendRootPath(logger logr.Logger, opts *options.StaticOptions)

// `upstream` should be defined at the `spec` level.
opts.Paths[pathRoute][method] = &options.SubOptions{
Upstream: opts.Upstream,
Upstream: &opts.Upstream,
}

logger.Info(
Expand Down
2 changes: 1 addition & 1 deletion pkg/options/static_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type StaticOptions struct {
// It should just contain the route path, "/".
Paths map[string]StaticOperationSubOptions `yaml:"paths,omitempty" json:"paths,omitempty"`
// Upstream is a set of options of a target service to receive traffic.
Upstream *UpstreamOptions `json:"upstream,omitempty" yaml:"upstream,omitempty"`
Upstream UpstreamOptions `json:"upstream" yaml:"upstream"`
}

func (o *StaticOptions) fillDefaults() {
Expand Down

0 comments on commit f3401c9

Please sign in to comment.