Skip to content

Add subpath/route-prefix support #3671

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 41 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
ec76cae
Use core utils to retrieve static assets and add route prefix to the …
AlinaGoaga Nov 23, 2023
1fcec30
Merge branch 'main' into subpath-support
AlinaGoaga Nov 23, 2023
d8452ff
Remove unused functions
AlinaGoaga Nov 23, 2023
d417636
Update chart values to accept additional params since we need to pass…
AlinaGoaga Nov 23, 2023
29dbbad
Merge branch 'subpath-support' of github.com:weaveworks/weave-gitops-…
AlinaGoaga Nov 23, 2023
c8f6124
Bring over changes from ui-on-subpath on APIProvider
AlinaGoaga Nov 24, 2023
5a20df0
Fix ling warnings
AlinaGoaga Nov 24, 2023
b4d646f
Fix ling warnings - updated
AlinaGoaga Nov 24, 2023
590b2be
Remove unused getAssets
AlinaGoaga Nov 24, 2023
a67e5ec
Adds additionalArgs to the deployment.yaml
foot Nov 24, 2023
faaf762
Add route prefix to tiltfile
AlinaGoaga Nov 24, 2023
f027e1f
Do the param pass through dance
foot Nov 24, 2023
0b3f51f
Remove logs
AlinaGoaga Nov 27, 2023
0e8e01c
Make the publicUrl relative so it respects the injected base tag
foot Nov 28, 2023
7ccaf01
Remove EnterpriseClientContext and use solely APIContext to make API …
AlinaGoaga Nov 28, 2023
5f1e6ab
Fix linter warnings
AlinaGoaga Nov 28, 2023
e22b6d2
Remove EnterpriseClientContext and use solely APIContext to make API …
AlinaGoaga Nov 28, 2023
cee9a6c
Small cleanup
AlinaGoaga Nov 28, 2023
fef4569
Merge branch 'main' into subpath-support
AlinaGoaga Nov 29, 2023
4556685
Fix linter warnings - 2
AlinaGoaga Nov 29, 2023
75298cf
Merge branch 'subpath-support' of github.com:weaveworks/weave-gitops-…
AlinaGoaga Nov 29, 2023
fec5900
Update snapshot
AlinaGoaga Nov 29, 2023
3df044c
Fix up tooling around ingress a bit
foot Nov 30, 2023
4a13617
Switch from using enterprise to clustersService in EnterpriseClientCo…
AlinaGoaga Dec 1, 2023
11f1ce4
Switch from using useAPI to useEnterpriseClient in EnterpriseClientCo…
AlinaGoaga Dec 1, 2023
699baa4
Add GitAuth API to Enterprise Client
AlinaGoaga Dec 1, 2023
9eeeffe
Add GitAuth API to Enterprise Client - updatd
AlinaGoaga Dec 1, 2023
968310e
Fix linter warning
AlinaGoaga Dec 1, 2023
60de3c4
Update tests to reflect latest changes to EnterpriseContext
AlinaGoaga Dec 1, 2023
e3f2ce4
Fix linter warnings
AlinaGoaga Dec 1, 2023
1c38b74
Fixes gitlab auth, hopefully the others too
foot Dec 4, 2023
8c4b487
`yarn lint --fix`
foot Dec 4, 2023
786cf53
Merge branch 'main' into subpath-support
foot Dec 4, 2023
cd749e5
Comment out route prefix in dev values
AlinaGoaga Dec 4, 2023
b12f0f6
Merge branch 'main' into subpath-support
AlinaGoaga Dec 4, 2023
73ca463
Update verify subpath with ingress cls instructions
AlinaGoaga Dec 4, 2023
7f6b62e
Merge branch 'subpath-support' of github.com:weaveworks/weave-gitops-…
AlinaGoaga Dec 4, 2023
ed4e39d
Update with core main
AlinaGoaga Dec 4, 2023
04c8fa0
check.Cmd -> check.GetCommand
foot Dec 4, 2023
6fa1285
Pass in options to GetCommand too
foot Dec 4, 2023
5d4bc43
Merge branch 'main' into subpath-support
AlinaGoaga Dec 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -180,5 +180,5 @@ else:
ignore=["ui", "build", ".parcel-cache"],
dockerfile='cmd/clusters-service/Dockerfile',
build_args={'GITHUB_BUILD_TOKEN': os.getenv('GITHUB_TOKEN'),'image_tag': 'tilt'},
entrypoint= ["/clusters-service", "--log-level=debug"]
entrypoint= ["/clusters-service", "--log-level=debug"],
)
5 changes: 5 additions & 0 deletions charts/mccp/templates/clusters-service/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ spec:
{{- range .Values.clustersService.args }}
- {{ . }}
{{- end }}
{{- with .Values.additionalArgs }}
{{- range . }}
- {{ . | quote }}
{{- end }}
{{- end }}
{{ if .Values.explorer.cleaner.disabled }}
- --explorer-cleaner-disabled=true
{{- end }}
Expand Down
3 changes: 3 additions & 0 deletions charts/mccp/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ ingress:
# hosts:
# - chart-example.local

# -- Additional arguments to pass in to the gitops-server
additionalArgs: []

envVars:
- name: WEAVE_GITOPS_FEATURE_TENANCY
value: "true"
Expand Down
7 changes: 7 additions & 0 deletions cmd/clusters-service/app/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type Options struct {
CAPIClustersNamespace string
CAPIEnabled bool
EntitlementSecretKey client.ObjectKey
RoutePrefix string
HtmlRootPath string
ClientGetter kube.ClientGetter
AuthMethods map[auth.AuthMethod]bool
Expand Down Expand Up @@ -298,3 +299,9 @@ func WithExplorerEnabledFor(enabledFor []string) Option {
o.ExplorerEnabledFor = append(o.ExplorerEnabledFor, enabledFor...)
}
}

func WithRoutePrefix(routePrefix string) Option {
return func(o *Options) {
o.RoutePrefix = routePrefix
}
}
27 changes: 13 additions & 14 deletions cmd/clusters-service/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ type Params struct {
HelmRepoName string `mapstructure:"helm-repo-name"`
ProfileCacheLocation string `mapstructure:"profile-cache-location"`
HtmlRootPath string `mapstructure:"html-root-path"`
RoutePrefix string `mapstructure:"route-prefix"`
OIDC OIDCAuthenticationOptions `mapstructure:",squash"`
GitProviderType string `mapstructure:"git-provider-type"`
GitProviderHostname string `mapstructure:"git-provider-hostname"`
Expand Down Expand Up @@ -218,6 +219,7 @@ func NewAPIServerCommand() *cobra.Command {
cmdFlags.String("helm-repo-namespace", os.Getenv("RUNTIME_NAMESPACE"), "the namespace of the Helm Repository resource to scan for profiles")
cmdFlags.String("helm-repo-name", "weaveworks-charts", "the name of the Helm Repository resource to scan for profiles")
cmdFlags.String("profile-cache-location", "/tmp/helm-cache", "the location where the cache Profile data lives")
cmdFlags.String("route-prefix", "", "Mount the UI and API endpoint under a path prefix, e.g. /weave-gitops-enterprise")
cmdFlags.String("html-root-path", "/html", "Where to serve static assets from")
cmdFlags.String("git-provider-type", "", "")
cmdFlags.String("git-provider-hostname", "", "")
Expand Down Expand Up @@ -588,6 +590,7 @@ func StartServer(ctx context.Context, p Params, logOptions flux_logger.Options)
WithMonitoring(p.MonitoringEnabled, p.MonitoringBindAddress, p.MetricsEnabled, p.ProfilingEnabled, log),
WithExplorerCleanerDisabled(p.ExplorerCleanerDisabled),
WithExplorerEnabledFor(p.ExplorerEnabledFor),
WithRoutePrefix(p.RoutePrefix),
)
}

Expand Down Expand Up @@ -747,7 +750,11 @@ func RunInProcessGateway(ctx context.Context, addr string, setters ...Option) er

// UI
args.Log.Info("Attaching FileServer", "HtmlRootPath", args.HtmlRootPath)
staticAssets := http.StripPrefix("/", http.FileServer(&spaFileSystem{http.Dir(args.HtmlRootPath)}))

assetFS := os.DirFS(args.HtmlRootPath)
assertFSHandler := http.FileServer(http.FS(assetFS))
redirectHandler := core.IndexHTMLHandler(assetFS, args.Log, args.RoutePrefix)
assetHandler := core.AssetHandler(assertFSHandler, redirectHandler)

mux := http.NewServeMux()

Expand Down Expand Up @@ -859,10 +866,14 @@ func RunInProcessGateway(ctx context.Context, addr string, setters ...Option) er

mux.Handle("/v1/", commonMiddleware(grpcHttpHandler))

staticAssetsWithGz := gziphandler.GzipHandler(staticAssets)
staticAssetsWithGz := gziphandler.GzipHandler(assetHandler)

mux.Handle("/", staticAssetsWithGz)

if args.RoutePrefix != "" {
mux = core.WithRoutePrefix(mux, args.RoutePrefix)
}

handler := http.Handler(mux)
handler = args.SessionManager.LoadAndSave(handler)

Expand Down Expand Up @@ -1028,18 +1039,6 @@ func defaultOptions() *Options {
}
}

type spaFileSystem struct {
root http.FileSystem
}

func (fs *spaFileSystem) Open(name string) (http.File, error) {
f, err := fs.root.Open(name)
if os.IsNotExist(err) {
return fs.root.Open("index.html")
}
return f, err
}

func makeCostEstimator(ctx context.Context, log logr.Logger, p Params) (estimation.Estimator, error) {
var pricer estimation.Pricer
if p.CostEstimationFilename != "" {
Expand Down
2 changes: 1 addition & 1 deletion cmd/gitops/app/root/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func Command(client *adapters.HTTPClient) *cobra.Command {
rootCmd.AddCommand(delete.Command(options, client))
rootCmd.AddCommand(upgrade.Cmd)
rootCmd.AddCommand(docs.Cmd)
rootCmd.AddCommand(check.Cmd)
rootCmd.AddCommand(check.GetCommand(options))
rootCmd.AddCommand(set.SetCommand(options))
rootCmd.AddCommand(generate.Command())
rootCmd.AddCommand(bootstrap.Command(options))
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.7.0
github.com/stretchr/testify v1.8.4
github.com/weaveworks/weave-gitops v0.37.0
github.com/weaveworks/weave-gitops v0.37.1-0.20231204151309-6cbe63a273ff
github.com/weaveworks/weave-gitops-enterprise-credentials v0.0.2
github.com/weaveworks/weave-gitops-enterprise/common v0.0.0
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down Expand Up @@ -73,7 +73,7 @@ require (
go.mozilla.org/sops/v3 v3.7.3
golang.org/x/crypto v0.14.0
golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb
golang.org/x/oauth2 v0.11.0
golang.org/x/oauth2 v0.13.0
google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d
google.golang.org/grpc v1.59.0
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0
Expand Down Expand Up @@ -249,7 +249,7 @@ require (
github.com/cheshir/ttlcache v1.0.1-0.20220504185148-8ceeff21b789
github.com/clbanning/mxj/v2 v2.7.0 // indirect
github.com/containerd/containerd v1.7.0 // indirect
github.com/coreos/go-oidc/v3 v3.1.0 // indirect
github.com/coreos/go-oidc/v3 v3.4.0 // indirect
github.com/cyphar/filepath-securejoin v0.2.4
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
Expand Down Expand Up @@ -366,7 +366,7 @@ require (
golang.org/x/text v0.13.0
golang.org/x/time v0.3.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/appengine v1.6.8 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
Expand Down
Loading