Skip to content

Commit

Permalink
Add support for directDownload to UI Spec (#257)
Browse files Browse the repository at this point in the history
  • Loading branch information
kozubaeff authored Jun 28, 2024
1 parent 263159b commit 8afeb53
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 1 deletion.
4 changes: 4 additions & 0 deletions api/v1/ytsaurus_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,10 @@ type UISpec struct {
Theme string `json:"theme,omitempty"`
Description *string `json:"description,omitempty"`
Group *string `json:"group,omitempty"`
// When this is set to false, UI will use backend for downloading instead of proxy.
// If this is set to true or omitted, UI use proxies, which is a default behaviour.
//+optional
DirectDownload *bool `json:"directDownload,omitempty"`
}

type QueryTrackerSpec struct {
Expand Down
5 changes: 5 additions & 0 deletions api/v1/zz_generated.deepcopy.go

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

4 changes: 4 additions & 0 deletions config/crd/bases/cluster.ytsaurus.tech_ytsaurus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34137,6 +34137,10 @@ spec:
properties:
description:
type: string
directDownload:
description: When this is set to false, UI will use backend for
downloading instead of proxy.
type: boolean
environment:
default: testing
type: string
Expand Down
1 change: 1 addition & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1534,6 +1534,7 @@ _Appears in:_
| `theme` _string_ | | lavander | |
| `description` _string_ | | | |
| `group` _string_ | | | |
| `directDownload` _boolean_ | When this is set to false, UI will use backend for downloading instead of proxy.<br />If this is set to true or omitted, UI use proxies, which is a default behaviour. | | |


#### UpdateFlow
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
odinBaseUrl="http://odin-webservice.odin.svc.cluster.local";
}
11 changes: 11 additions & 0 deletions pkg/ytconfig/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -699,13 +699,24 @@ func (g *Generator) GetUIClustersConfig() ([]byte, error) {
})
}

func (g *Generator) GetUICustomSettings() *UICustomSettings {
directDownload := g.ytsaurus.Spec.UI.DirectDownload
if directDownload == nil {
return nil
}
return &UICustomSettings{
DirectDownload: directDownload,
}
}

func (g *Generator) GetUICustomConfig() ([]byte, error) {
if g.ytsaurus.Spec.UI == nil {
return []byte{}, nil
}

c := UICustom{
OdinBaseUrl: g.ytsaurus.Spec.UI.OdinBaseUrl,
Settings: g.GetUICustomSettings(),
}

return marshallYsonConfig(c)
Expand Down
16 changes: 16 additions & 0 deletions pkg/ytconfig/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,13 @@ func TestGetUICustomConfig(t *testing.T) {
canonize.Assert(t, cfg)
}

func TestGetUICustomConfigWithSettings(t *testing.T) {
g := NewGenerator(withUICustomSettings(getYtsaurus()), testClusterDomain)
cfg, err := g.GetUICustomConfig()
require.NoError(t, err)
canonize.Assert(t, cfg)
}

func TestGetYQLAgentConfig(t *testing.T) {
ytsaurus := getYtsaurusWithEverything()
g := NewGenerator(ytsaurus, testClusterDomain)
Expand Down Expand Up @@ -615,6 +622,15 @@ func withUICustom(ytsaurus *ytv1.Ytsaurus) *ytv1.Ytsaurus {
return ytsaurus
}

func withUICustomSettings(ytsaurus *ytv1.Ytsaurus) *ytv1.Ytsaurus {
odinUrl := "http://odin-webservice.odin.svc.cluster.local"
ytsaurus.Spec.UI = &ytv1.UISpec{
OdinBaseUrl: &odinUrl,
DirectDownload: nil,
}
return ytsaurus
}

func withMasterCaches(ytsaurus *ytv1.Ytsaurus) *ytv1.Ytsaurus {
ytsaurus.Spec.MasterCaches = &ytv1.MasterCachesSpec{InstanceSpec: testBasicInstanceSpec}
ytsaurus.Spec.MasterCaches.InstanceSpec.MonitoringPort = ptr.Int32(consts.MasterCachesMonitoringPort)
Expand Down
7 changes: 6 additions & 1 deletion pkg/ytconfig/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ func getUIClusterCarcass() UICluster {
}
}

type UICustomSettings struct {
DirectDownload *bool `yson:"directDownload,omitempty"`
}

type UICustom struct {
OdinBaseUrl *string `yson:"odinBaseUrl,omitempty"`
OdinBaseUrl *string `yson:"odinBaseUrl,omitempty"`
Settings *UICustomSettings `yson:"uiSettings,omitempty"`
}
4 changes: 4 additions & 0 deletions ytop-chart/templates/ytsaurus-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33926,6 +33926,10 @@ spec:
properties:
description:
type: string
directDownload:
description: When this is set to false, UI will use backend for
downloading instead of proxy.
type: boolean
environment:
default: testing
type: string
Expand Down

0 comments on commit 8afeb53

Please sign in to comment.