Skip to content

Commit 5752fb0

Browse files
committed
fix(ws): Fix lint errors and typo
Signed-off-by: mohamedch7 <[email protected]>
1 parent 42e3ef9 commit 5752fb0

File tree

3 files changed

+38
-9
lines changed

3 files changed

+38
-9
lines changed

workspaces/backend/api/app.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ func (a *App) Routes() http.Handler {
9999
router.GET(WorkspacesByNamePath, a.GetWorkspaceHandler)
100100
router.POST(WorkspacesByNamespacePath, a.CreateWorkspaceHandler)
101101
router.DELETE(WorkspacesByNamePath, a.DeleteWorkspaceHandler)
102-
router.GET(WorkspaceYAMLPath, a.GetWorkspaceYAMLHandler)
102+
router.GET(WorkspaceYAMLPath, a.GetWorkspaceYAMLHandler)
103103

104104
// workspacekinds
105105
router.GET(AllWorkspaceKindsPath, a.GetWorkspaceKindsHandler)
106106
router.GET(WorkspaceKindsByNamePath, a.GetWorkspaceKindHandler)
107107

108-
return a.RecoverPanic(a.enableCORS(router))
108+
return a.recoverPanic(a.enableCORS(router))
109109
}

workspaces/backend/api/workspace_yaml_handler.go

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2024.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package api
216

317
import (
@@ -8,7 +22,7 @@ import (
822

923
"errors"
1024

11-
"github.com/kubeflow/notebooks/workspaces/backend/internal/repositories"
25+
"github.com/kubeflow/notebooks/workspaces/backend/internal/repositories/workspaces"
1226

1327
"sigs.k8s.io/yaml"
1428
)
@@ -28,7 +42,7 @@ func (a *App) GetWorkspaceYAMLHandler(w http.ResponseWriter, r *http.Request, ps
2842

2943
workspace, err := a.repositories.Workspace.GetWorkspace(r.Context(), namespace, workspaceName)
3044
if err != nil {
31-
if errors.Is(err, repositories.ErrWorkspaceNotFound) {
45+
if errors.Is(err, workspaces.ErrWorkspaceNotFound) {
3246
a.notFoundResponse(w, r)
3347
return
3448
}

workspaces/backend/api/workspace_yaml_handler_test.go

+20-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2024.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package api
216

317
import (
@@ -9,15 +23,16 @@ import (
923
"os"
1024

1125
"github.com/julienschmidt/httprouter"
12-
"github.com/kubeflow/notebooks/workspaces/backend/internal/config"
13-
"github.com/kubeflow/notebooks/workspaces/backend/internal/repositories"
1426
kubefloworgv1beta1 "github.com/kubeflow/notebooks/workspaces/controller/api/v1beta1"
1527
. "github.com/onsi/ginkgo/v2"
1628
. "github.com/onsi/gomega"
1729
corev1 "k8s.io/api/core/v1"
1830
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1931
"k8s.io/apimachinery/pkg/types"
2032
"sigs.k8s.io/controller-runtime/pkg/client"
33+
34+
"github.com/kubeflow/notebooks/workspaces/backend/internal/config"
35+
"github.com/kubeflow/notebooks/workspaces/backend/internal/repositories"
2136
)
2237

2338
var _ = Describe("Workspace YAML Handler", Ordered, func() {
@@ -38,7 +53,7 @@ var _ = Describe("Workspace YAML Handler", Ordered, func() {
3853
logger := slog.New(slog.NewJSONHandler(os.Stdout, nil))
3954
repos := repositories.NewRepositories(k8sClient)
4055
a = &App{
41-
Config: config.EnvConfig{
56+
Config: &config.EnvConfig{
4257
Port: 4000,
4358
},
4459
repositories: repos,
@@ -90,7 +105,7 @@ var _ = Describe("Workspace YAML Handler", Ordered, func() {
90105
})
91106

92107
It("should retrieve the workspace YAML successfully", func() {
93-
req := httptest.NewRequest(http.MethodGet, fmt.Sprintf("/api/v1/workspaces/%s/%s/details/yaml", namespaceName, workspaceKey.Name), nil)
108+
req := httptest.NewRequest(http.MethodGet, fmt.Sprintf("/api/v1/workspaces/%s/%s/details/yaml", namespaceName, workspaceKey.Name), http.NoBody)
94109
rr := httptest.NewRecorder()
95110

96111
ps := httprouter.Params{
@@ -110,7 +125,7 @@ var _ = Describe("Workspace YAML Handler", Ordered, func() {
110125
})
111126

112127
It("should return 404 when workspace doesn't exist", func() {
113-
req := httptest.NewRequest(http.MethodGet, fmt.Sprintf("/api/v1/workspaces/%s/non-existent/details/yaml", namespaceName), nil)
128+
req := httptest.NewRequest(http.MethodGet, fmt.Sprintf("/api/v1/workspaces/%s/non-existent/details/yaml", namespaceName), http.NoBody)
114129
rr := httptest.NewRecorder()
115130

116131
ps := httprouter.Params{

0 commit comments

Comments
 (0)