Skip to content
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

Provide show or hide option for sshKey in access info #1222

Merged
merged 2 commits into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
12 changes: 8 additions & 4 deletions src/api/rest/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1792,17 +1792,21 @@ const docTemplate = `{
},
{
"type": "string",
"default": "connectionName",
"description": "(for option==id) Field key for filtering (ex: connectionName)",
"description": "(For option==id) Field key for filtering (ex: connectionName)",
"name": "filterKey",
"in": "query"
},
{
"type": "string",
"default": "aws-ap-northeast-2",
"description": "(for option==id) Field value for filtering (ex: aws-ap-northeast-2)",
"description": "(For option==id) Field value for filtering (ex: aws-ap-northeast-2)",
"name": "filterVal",
"in": "query"
},
{
"type": "string",
"description": "(For option==accessinfo) accessInfoOption (showSshKey)",
"name": "accessInfoOption",
"in": "query"
}
],
"responses": {
Expand Down
12 changes: 8 additions & 4 deletions src/api/rest/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1784,17 +1784,21 @@
},
{
"type": "string",
"default": "connectionName",
"description": "(for option==id) Field key for filtering (ex: connectionName)",
"description": "(For option==id) Field key for filtering (ex: connectionName)",
"name": "filterKey",
"in": "query"
},
{
"type": "string",
"default": "aws-ap-northeast-2",
"description": "(for option==id) Field value for filtering (ex: aws-ap-northeast-2)",
"description": "(For option==id) Field value for filtering (ex: aws-ap-northeast-2)",
"name": "filterVal",
"in": "query"
},
{
"type": "string",
"description": "(For option==accessinfo) accessInfoOption (showSshKey)",
"name": "accessInfoOption",
"in": "query"
}
],
"responses": {
Expand Down
10 changes: 6 additions & 4 deletions src/api/rest/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3589,16 +3589,18 @@ paths:
in: query
name: option
type: string
- default: connectionName
description: '(for option==id) Field key for filtering (ex: connectionName)'
- description: '(For option==id) Field key for filtering (ex: connectionName)'
in: query
name: filterKey
type: string
- default: aws-ap-northeast-2
description: '(for option==id) Field value for filtering (ex: aws-ap-northeast-2)'
- description: '(For option==id) Field value for filtering (ex: aws-ap-northeast-2)'
in: query
name: filterVal
type: string
- description: (For option==accessinfo) accessInfoOption (showSshKey)
in: query
name: accessInfoOption
type: string
produces:
- application/json
responses:
Expand Down
8 changes: 5 additions & 3 deletions src/api/rest/server/mcis/manageInfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ type JSONResult struct {
// @Param nsId path string true "Namespace ID" default(ns01)
// @Param mcisId path string true "MCIS ID" default(mcis01)
// @Param option query string false "Option" Enums(default, id, status, accessinfo)
// @Param filterKey query string false "(for option==id) Field key for filtering (ex: connectionName)" default(connectionName)
// @Param filterVal query string false "(for option==id) Field value for filtering (ex: aws-ap-northeast-2)" default(aws-ap-northeast-2)
// @Param filterKey query string false "(For option==id) Field key for filtering (ex: connectionName)"
// @Param filterVal query string false "(For option==id) Field value for filtering (ex: aws-ap-northeast-2)"
// @Param accessInfoOption query string false "(For option==accessinfo) accessInfoOption (showSshKey)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REST API 호출 시
http://.../ns/{nsId}/mcis/{mcisId}?option=id 와 같이 사용하고 있어서
아래와 같이 제안합니다.. ㅎㅎ
(option== 으로 찾아 보면 다른 곳에 3곳 더 있습니다)

Suggested change
// @Param filterKey query string false "(For option==id) Field key for filtering (ex: connectionName)"
// @Param filterVal query string false "(For option==id) Field value for filtering (ex: aws-ap-northeast-2)"
// @Param accessInfoOption query string false "(For option==accessinfo) accessInfoOption (showSshKey)"
// @Param filterKey query string false "(For option=id) Field key for filtering (ex: connectionName)"
// @Param filterVal query string false "(For option=id) Field value for filtering (ex: aws-ap-northeast-2)"
// @Param accessInfoOption query string false "(For option=accessinfo) accessInfoOption (showSshKey)"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jihoon-seo 바로 적용하였습니다!

// @success 200 {object} JSONResult{[DEFAULT]=mcis.TbMcisInfo,[ID]=common.IdList,[STATUS]=mcis.McisStatusInfo,[AccessInfo]=mcis.McisAccessInfo} "Different return structures by the given action param"
// @Failure 404 {object} common.SimpleMsg
// @Failure 500 {object} common.SimpleMsg
Expand All @@ -56,6 +57,7 @@ func RestGetMcis(c echo.Context) error {
option := c.QueryParam("option")
filterKey := c.QueryParam("filterKey")
filterVal := c.QueryParam("filterVal")
accessInfoOption := c.QueryParam("accessInfoOption")

if option == "id" {
content := common.IdList{}
Expand Down Expand Up @@ -85,7 +87,7 @@ func RestGetMcis(c echo.Context) error {

} else if option == "accessinfo" {

result, err := mcis.GetMcisAccessInfo(nsId, mcisId)
result, err := mcis.GetMcisAccessInfo(nsId, mcisId, accessInfoOption)
if err != nil {
mapA := map[string]string{"message": err.Error()}
return c.JSON(http.StatusInternalServerError, &mapA)
Expand Down
8 changes: 6 additions & 2 deletions src/core/mcis/manageInfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ func GetMcisInfo(nsId string, mcisId string) (*TbMcisInfo, error) {
}

// GetMcisAccessInfo is func to retrieve MCIS Access information
func GetMcisAccessInfo(nsId string, mcisId string) (*McisAccessInfo, error) {
func GetMcisAccessInfo(nsId string, mcisId string, option string) (*McisAccessInfo, error) {

output := &McisAccessInfo{}
temp := &McisAccessInfo{}
Expand Down Expand Up @@ -378,7 +378,11 @@ func GetMcisAccessInfo(nsId string, mcisId string) (*McisAccessInfo, error) {
vmAccessInfo.SSHPort = vmInfo.SSHPort

_, verifiedUserName, privateKey := GetVmSshKey(nsId, mcisId, vmId)
vmAccessInfo.PrivateKey = privateKey

if strings.EqualFold(option, "showSshKey") {
vmAccessInfo.PrivateKey = privateKey
}

vmAccessInfo.VmUserAccount = verifiedUserName
//vmAccessInfo.VmUserPassword

Expand Down