Skip to content

Commit 04aa169

Browse files
committed
Fix template
Signed-off-by: Matheus Cruz <[email protected]>
1 parent ae6e4f0 commit 04aa169

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

workspaces/controller/internal/controller/suite_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ func NewExampleWorkspaceKind1(name string) *kubefloworgv1beta1.WorkspaceKind {
218218
HTTPProxy: &kubefloworgv1beta1.HTTPProxy{
219219
RemovePathPrefix: ptr.To(false),
220220
RequestHeaders: &kubefloworgv1beta1.IstioHeaderOperations{
221-
Set: map[string]string{"X-RStudio-Root-Path": "{{ httpPathPrefix 'rstudio' }}"},
221+
Set: map[string]string{"X-RStudio-Root-Path": "{{ httpPathPrefix '.PathPrefix' }}"},
222222
Add: map[string]string{},
223223
Remove: []string{},
224224
},
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,35 @@
11
package helper
22

3-
import "github.com/onsi/ginkgo/v2"
3+
import (
4+
kubefloworgv1beta1 "github.com/kubeflow/notebooks/workspaces/controller/api/v1beta1"
5+
"github.com/onsi/ginkgo/v2"
6+
"github.com/onsi/gomega"
7+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
8+
)
49

510
var _ = ginkgo.Describe("helper", func() {
611

712
ginkgo.It("should render request headers correctly", func() {
813

9-
m := make(map[string]string, 1)
10-
m["X-RStudio"] = "{{ httpPathPrefix 'rstudio' }}"
14+
containerPortsIdMap := make(map[string]kubefloworgv1beta1.ImagePort)
15+
containerPortsIdMap["rstudio"] = kubefloworgv1beta1.ImagePort{
16+
Port: 8080,
17+
Id: "rstudio",
18+
}
19+
20+
headers := map[string]string{"X-RStudio-Root-Path": `{{ httpPathPrefix "rstudio" }}`}
21+
22+
ws := &kubefloworgv1beta1.Workspace{
23+
ObjectMeta: metav1.ObjectMeta{
24+
Name: "simple",
25+
Namespace: "default",
26+
},
27+
}
28+
29+
function := GenerateHttpPathPrefixFunc(ws, containerPortsIdMap)
30+
31+
out := RenderHeadersWithHttpPathPrefix(headers, function)
32+
33+
gomega.Expect(out["X-RStudio-Root-Path"]).To(gomega.Equal("/workspace/default/simple/rstudio/"))
1134
})
1235
})

0 commit comments

Comments
 (0)