This repository has been archived by the owner on Apr 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable web UI via build tag or runtime flag (#47)
* Optionally disable UI with build tag * Add macOS and Windows to test matrix
- Loading branch information
Showing
7 changed files
with
132 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//go:build !headless | ||
|
||
package main | ||
|
||
import ( | ||
// This file should be the only one to import ui-server packages. | ||
// This is to avoid embedding the UI's static assets in the binary when the `headless` build tag is enabled. | ||
uiserver "github.com/temporalio/ui-server/server" | ||
uiconfig "github.com/temporalio/ui-server/server/config" | ||
uiserveroptions "github.com/temporalio/ui-server/server/server_options" | ||
|
||
"github.com/DataDog/temporalite" | ||
) | ||
|
||
func newUIOption(frontendAddr string, uiIP string, uiPort int) temporalite.ServerOption { | ||
return temporalite.WithUI(uiserver.NewServer(uiserveroptions.WithConfigProvider(newUIConfig( | ||
frontendAddr, | ||
uiIP, | ||
uiPort, | ||
)))) | ||
} | ||
|
||
func newUIConfig(frontendAddr string, uiIP string, uiPort int) *uiconfig.Config { | ||
return &uiconfig.Config{ | ||
TemporalGRPCAddress: frontendAddr, | ||
Host: uiIP, | ||
Port: uiPort, | ||
EnableUI: true, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
//go:build headless | ||
|
||
package main | ||
|
||
import "github.com/DataDog/temporalite" | ||
|
||
func newUIOption(frontendAddr string, uiIP string, uiPort int) temporalite.ServerOption { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//go:build headless | ||
|
||
package main | ||
|
||
import ( | ||
"runtime/debug" | ||
"testing" | ||
) | ||
|
||
// This test ensures that the ui-server module is not a dependency of Temporalite when built | ||
// for headless mode. | ||
func TestNoUIServerDependency(t *testing.T) { | ||
info, _ := debug.ReadBuildInfo() | ||
for _, dep := range info.Deps { | ||
if dep.Path == uiServerModule { | ||
t.Errorf("%s should not be a dependency when headless tag is enabled", uiServerModule) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//go:build !headless | ||
|
||
package main | ||
|
||
import ( | ||
"runtime/debug" | ||
"testing" | ||
) | ||
|
||
// This test ensures that ui-server is a dependency of Temporalite built in non-headless mode. | ||
func TestHasUIServerDependency(t *testing.T) { | ||
info, _ := debug.ReadBuildInfo() | ||
for _, dep := range info.Deps { | ||
if dep.Path == uiServerModule { | ||
return | ||
} | ||
} | ||
t.Errorf("%s should be a dependency when headless tag is not enabled", uiServerModule) | ||
// If the ui-server module name is ever changed, this test should fail and indicate that the | ||
// module name should be updated for this and the equivalent test case in ui_disabled_test.go | ||
// to continue working. | ||
t.Logf("Temporalite's %s dependency is missing. Was this module renamed recently?", uiServerModule) | ||
} | ||
|
||
func TestNewUIConfig(t *testing.T) { | ||
cfg := newUIConfig("localhost:7233", "localhost", 8233) | ||
if err := cfg.Validate(); err != nil { | ||
t.Errorf("config not valid: %s", err) | ||
} | ||
} |