Skip to content

Conversation

@tsj-30
Copy link
Contributor

@tsj-30 tsj-30 commented Dec 12, 2025

This change teaches Deck about a configurable base path so it can be served from a sub‑URL without breaking static assets, APIs, or Spyglass. It introduces the --base-path flag, wraps the HTTP mux so requests are stripped/prefixed appropriately, extends template helpers to emit base-aware links, and adds deckURL utilities for the front-end.
This fixes #376.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: tsj-30
Once this PR has been reviewed and has the lgtm label, please assign michelle192837 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the area/deck Issues or PRs related to prow's deck component label Dec 12, 2025
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Dec 12, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @tsj-30. Thanks for your PR.

I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Dec 12, 2025
@netlify
Copy link

netlify bot commented Dec 12, 2025

Deploy Preview for k8s-prow ready!

Name Link
🔨 Latest commit 5204a98
🔍 Latest deploy log https://app.netlify.com/projects/k8s-prow/deploys/69705e151206b3000821127a
😎 Deploy Preview https://deploy-preview-576--k8s-prow.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@tsj-30
Copy link
Contributor Author

tsj-30 commented Dec 12, 2025

CC: @petr-muller , @matthyx
As suggested by Petr, I’ll break this down and raise smaller PRs to fix #376.

@Amulyam24
Copy link

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Dec 12, 2025
@tsj-30
Copy link
Contributor Author

tsj-30 commented Jan 2, 2026

/retest

@tsj-30
Copy link
Contributor Author

tsj-30 commented Jan 2, 2026

Hi @petr-muller ,
Can you PTAL?
Thanks 😄

@tsj-30
Copy link
Contributor Author

tsj-30 commented Jan 9, 2026

cc: @loispostula

@loispostula
Copy link

@tsj-30 I'm not sure how to test this, I'll try to get a local build working and check

@tsj-30
Copy link
Contributor Author

tsj-30 commented Jan 21, 2026

Hi @loispostula,
Did you get a chance to test this, I have completed some additional code changes and looking forward to submit a follow PR if this looks good and merged.
If you need any futher help from my side please let me know.
Thanks!

@petr-muller
Copy link
Contributor

/cc
/hold

I have an in-flight review with some feedback, will post hopefully tomorrow

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 21, 2026
Copy link
Contributor

@petr-muller petr-muller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My main concern is how well this was tested on the current default case (path is "/")? If the new subpath functionality is not 100% then I don't mind because we can fix it as we go, but the one thing we need to prevent is breaking existing deployments.

Some comments inline

/hold cancel


func gatherOptions(fs *flag.FlagSet, args ...string) options {
var o options
o.basePath = "/"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this is redundant with setting a default on L192

}

func (o *options) Validate() error {
o.basePath = normalizeBasePath(o.basePath)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems redundant with doing the same in gatherOptions

// withBasePath ensures that only requests that begin with the configured base path are handled
// and that downstream handlers only see paths relative to that base path.
func withBasePath(basePath string, handler http.Handler) http.Handler {
basePath = normalizeBasePath(basePath)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another normalizeBasePath call

Comment on lines +77 to +78
"deckBasePath": func() string { return o.basePath },
"deckPath": func(p string) string { return o.absolutePath(p) },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are these consumed?

Comment on lines +80 to +106
// absolutePath returns the absolute URL path for a given relative path by prepending the
// configured base path. The input is expected to be either "/" or begin with a slash.
func (o options) absolutePath(rel string) string {
if rel == "" {
return ""
}

pathPart := rel
suffix := ""
if idx := strings.IndexAny(rel, "?#"); idx >= 0 {
pathPart = rel[:idx]
suffix = rel[idx:]
}
if pathPart == "" {
pathPart = "/"
}
if !strings.HasPrefix(pathPart, "/") {
pathPart = "/" + pathPart
}
if o.basePath == "/" {
return pathPart + suffix
}
if pathPart == "/" {
return o.basePath + suffix
}
return o.basePath + pathPart + suffix
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not easy to reason about all path manipulation possibilities, I'd like to have unit tests (also for stripBasePath and normalizeBasePath both to make sure they are correct and to serve as examples of what gets transformed to what.


// absolutePath returns the absolute URL path for a given relative path by prepending the
// configured base path. The input is expected to be either "/" or begin with a slash.
func (o options) absolutePath(rel string) string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This technically only needs to basePath from options, could the field be a custom string type and the methods would be defined on that? It would make the interface more narrow.

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/deck Issues or PRs related to prow's deck component cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot run prow at a subpath

6 participants