Skip to content

Commit

Permalink
Enhance functionality and fix some issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadhamzh committed Jan 16, 2025
1 parent 37e12bb commit 3e56a71
Show file tree
Hide file tree
Showing 38 changed files with 760 additions and 231 deletions.
44 changes: 42 additions & 2 deletions modules/api/cmd/kubermatic-api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1453,6 +1453,38 @@
}
}
},
"/api/v1/me/readannouncements": {
"patch": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"users"
],
"summary": "Updates read announcements of the current user.",
"operationId": "patchCurrentUserReadAnnouncements",
"responses": {
"200": {
"description": "User",
"schema": {
"$ref": "#/definitions/User"
}
},
"401": {
"$ref": "#/responses/empty"
},
"default": {
"description": "errorResponse",
"schema": {
"$ref": "#/definitions/errorResponse"
}
}
}
}
},
"/api/v1/me/settings": {
"get": {
"produces": [
Expand Down Expand Up @@ -1504,9 +1536,9 @@
],
"responses": {
"200": {
"description": "UserSettings",
"description": "User",
"schema": {
"$ref": "#/definitions/UserSettings"
"$ref": "#/definitions/User"
}
},
"401": {
Expand Down Expand Up @@ -39564,6 +39596,14 @@
},
"x-go-name": "Projects"
},
"readAnnouncements": {
"description": "ReadAnnouncements holds the IDs of admin announcements that the user has read.\n+optional",
"type": "array",
"items": {
"type": "string"
},
"x-go-name": "ReadAnnouncements"
},
"userSettings": {
"$ref": "#/definitions/UserSettings"
}
Expand Down
6 changes: 4 additions & 2 deletions modules/api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ replace k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20240903163716-9e1beec

replace k8s.io/client-go => k8s.io/client-go v0.31.1

require github.com/kubeovn/kube-ovn v1.13.0
require (
github.com/google/uuid v1.6.0
github.com/kubeovn/kube-ovn v1.13.0
)

require (
cel.dev/expr v0.19.0 // indirect
Expand Down Expand Up @@ -172,7 +175,6 @@ require (
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/gofuzz v1.2.1-0.20210504230335-f78f29fc09ea // indirect
github.com/google/s2a-go v0.1.8 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.4 // indirect
github.com/googleapis/gax-go/v2 v2.14.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
Expand Down
6 changes: 3 additions & 3 deletions modules/api/pkg/handler/routes_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -1634,7 +1634,7 @@ func (r Routing) getCurrentUserSettings() http.Handler {
//
// Responses:
// default: errorResponse
// 200: UserSettings
// 200: User
// 401: empty
func (r Routing) patchCurrentUserSettings() http.Handler {
return httptransport.NewServer(
Expand All @@ -1648,7 +1648,7 @@ func (r Routing) patchCurrentUserSettings() http.Handler {
)
}

// swagger:route PATCH /api/v1/me/readannouncements readannouncements patchCurrentUserReadAnnouncements
// swagger:route PATCH /api/v1/me/readannouncements users patchCurrentUserReadAnnouncements
//
// Updates read announcements of the current user.
//
Expand All @@ -1660,7 +1660,7 @@ func (r Routing) patchCurrentUserSettings() http.Handler {
//
// Responses:
// default: errorResponse
// 200: []string
// 200: User
// 401: empty
func (r Routing) patchCurrentUserReadAnnouncements() http.Handler {
return httptransport.NewServer(
Expand Down
3 changes: 3 additions & 0 deletions modules/api/pkg/handler/v1/admin/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"io"
"net/http"
"slices"
"time"

jsonpatch "github.com/evanphx/json-patch"
"github.com/go-kit/kit/endpoint"
Expand All @@ -35,6 +36,7 @@ import (
utilerrors "k8c.io/kubermatic/v2/pkg/util/errors"

corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/ptr"
)

Expand Down Expand Up @@ -93,6 +95,7 @@ func UpdateKubermaticSettingsEndpoint(userInfoGetter provider.UserInfoGetter, se
}
newAnnouncement := "newAnnouncement"
if announcements, ok := patchedGlobalSettingsSpec.Announcements[newAnnouncement]; ok {
announcements.CreatedAt = metav1.NewTime(time.Now())
newUUID := uuid.New().String()
delete(patchedGlobalSettingsSpec.Announcements, newAnnouncement)
patchedGlobalSettingsSpec.Announcements[newUUID] = announcements
Expand Down
4 changes: 1 addition & 3 deletions modules/api/pkg/handler/v1/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,7 @@ func PatchReadAnnouncementsEndpoint(userProvider provider.UserProvider) endpoint
if err != nil {
return nil, common.KubernetesErrorToHTTPError(err)
}

return updatedUser.Spec.ReadAnnouncements, nil

}
}

Expand Down Expand Up @@ -579,7 +577,7 @@ type PatchSettingsReq struct {
}

// PatchReadAnnouncementsReq defines HTTP request for patchCurrentUserReadAnnouncements
// swagger:parameters patchCurrentUserReadAnnouncements
// swagger:parameters readAnnouncements
type PatchReadAnnouncementsReq struct {
// in: body
Body []string
Expand Down

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

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

Loading

0 comments on commit 3e56a71

Please sign in to comment.