Skip to content

feat(web): initial work to setup root handler in the web component #2192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
May 29, 2025

Conversation

JGAntunes
Copy link
Member

@JGAntunes JGAntunes commented May 27, 2025

What this PR does / why we need it:

Story: https://app.shortcut.com/replicated/story/124147/setup-template-enabled-web-handlers

The idea is to setup a root handler that we can template our initial HTML we serve with any needed state we need before rendering the app.

We should follow up with a way we can redirect requests to the vite dev server when running local dev for faster dev feedback loop.

Which issue(s) this PR fixes:

Does this PR require a test?

Does this PR require a release note?


Does this PR require documentation?

@sgalsaleh sgalsaleh force-pushed the salah/sc-123874/steelthread-configure-data-dir-in-the-new branch 2 times, most recently from ec30def to 50ef28e Compare May 27, 2025 14:49
@JGAntunes JGAntunes force-pushed the feat/setup-root-handler branch from d0e9711 to 8ec8727 Compare May 27, 2025 16:36
sgalsaleh
sgalsaleh previously approved these changes May 27, 2025
Base automatically changed from salah/sc-123874/steelthread-configure-data-dir-in-the-new to main May 27, 2025 18:35
@sgalsaleh sgalsaleh dismissed their stale review May 27, 2025 18:35

The base branch was changed.

@JGAntunes JGAntunes self-assigned this May 28, 2025
@JGAntunes JGAntunes requested a review from sgalsaleh May 28, 2025 09:30
@JGAntunes JGAntunes force-pushed the feat/setup-root-handler branch from 8ec8727 to d905503 Compare May 28, 2025 09:31
@JGAntunes JGAntunes marked this pull request as ready for review May 28, 2025 09:32
@@ -124,7 +124,6 @@ func (a *API) RegisterRoutes(router *mux.Router) {
router.PathPrefix("/swagger/").Handler(httpSwagger.WrapHandler)

router.HandleFunc("/auth/login", a.postAuthLogin).Methods("POST")
router.HandleFunc("/branding", a.getBranding).Methods("GET")
Copy link
Member Author

Choose a reason for hiding this comment

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

We no longer need the branding routes.

@JGAntunes
Copy link
Member Author

#2201 should address the CI failures. It's probably better than creating a placeholder index.html file in the dist folder.

@JGAntunes JGAntunes force-pushed the feat/setup-root-handler branch from e931fe4 to bd6de36 Compare May 28, 2025 16:06
Copy link

github-actions bot commented May 28, 2025

This PR has been released (on staging) and is available for download with a embedded-cluster-smoke-test-staging-app license ID.

Online Installer:

curl "https://staging.replicated.app/embedded/embedded-cluster-smoke-test-staging-app/ci/appver-dev-5553e91" -H "Authorization: $EC_SMOKE_TEST_LICENSE_ID" -o embedded-cluster-smoke-test-staging-app-ci.tgz

Airgap Installer (may take a few minutes before the airgap bundle is built):

curl "https://staging.replicated.app/embedded/embedded-cluster-smoke-test-staging-app/ci-airgap/appver-dev-5553e91?airgap=true" -H "Authorization: $EC_SMOKE_TEST_LICENSE_ID" -o embedded-cluster-smoke-test-staging-app-ci.tgz

Happy debugging!

@@ -581,7 +581,7 @@ func Test_runInstallAPI(t *testing.T) {
},
}
resp, err := httpClient.Get(url)
assert.NoError(t, err)
require.NoError(t, err)
Copy link
Member Author

Choose a reason for hiding this comment

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

Later it would panic leading to a red herring because there's no resp.

@@ -224,94 +223,3 @@ func TestAPIError_ErrorOrNil(t *testing.T) {
})
}
}

func TestAPIError_JSON(t *testing.T) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Some mismatch between PRs that have been merged, this fixes some go vet issues:

Comment on lines -277 to 278
go test -tags $(GO_BUILD_TAGS) -v ./pkg/... ./cmd/...
go test -tags $(GO_BUILD_TAGS) -v ./pkg/... ./cmd/... ./api/... ./web/... ./pkg-new/...
$(MAKE) -C operator test
Copy link
Member Author

Choose a reason for hiding this comment

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

We haven't been running the full unit test suite in CI.

Comment on lines +101 to +102
// webAssetsFS is the filesystem to be used by the web component. Defaults to nil allowing the web server to use the default assets embedded in the binary. Useful for testing.
var webAssetsFS fs.FS = nil
Copy link
Member Author

Choose a reason for hiding this comment

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

Not particularly happy about this, unsure if we should keep this somewhere else, open to ideas.

Copy link
Member

Choose a reason for hiding this comment

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

Rather than that README.md hack could you have a stub index.html?

Copy link
Member Author

Choose a reason for hiding this comment

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

The main issue with that is when building the web assets, index.html will change and it's not gitignored so you'll end up with changes that shouldn't be staged for commit.

@JGAntunes JGAntunes requested a review from emosbaugh May 29, 2025 09:42
@JGAntunes JGAntunes changed the title feat(web): initial work to setup root handler feat(web): initial work to setup root handler in the web component May 29, 2025
Comment on lines +101 to +102
// webAssetsFS is the filesystem to be used by the web component. Defaults to nil allowing the web server to use the default assets embedded in the binary. Useful for testing.
var webAssetsFS fs.FS = nil
Copy link
Member

Choose a reason for hiding this comment

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

Rather than that README.md hack could you have a stub index.html?

@@ -560,6 +561,29 @@ func Test_runInstallAPI(t *testing.T) {
certPool := x509.NewCertPool()
certPool.AddCert(cert.Leaf)

// We need a release object to pass over to the Web component.
dataMap := map[string][]byte{
"kots-app.yaml": []byte(`
Copy link
Member

Choose a reason for hiding this comment

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

should probably include an icon and a title

Copy link
Member Author

Choose a reason for hiding this comment

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

we can, albeit it's not really being used right now. Unless we also want to run some requests within this test against the web components?

@sgalsaleh
Copy link
Member

Merging as the changes aren't related to the flaky e2e tests.

@sgalsaleh sgalsaleh merged commit 8967af3 into main May 29, 2025
55 of 65 checks passed
@sgalsaleh sgalsaleh deleted the feat/setup-root-handler branch May 29, 2025 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants