Skip to content

Commit

Permalink
Merge pull request #1222 from seokho-son/main
Browse files Browse the repository at this point in the history
Provide show or hide option for sshKey in access info
  • Loading branch information
jihoon-seo authored Oct 20, 2022
2 parents 9d46645 + aef070d commit bd7cb32
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 17 deletions.
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)"
// @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

0 comments on commit bd7cb32

Please sign in to comment.