Skip to content

Commit

Permalink
Change defaultresource to sharedresource
Browse files Browse the repository at this point in the history
  • Loading branch information
cb-github-robot authored Aug 19, 2024
2 parents cbae348 + 92745d1 commit 49b4552
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions src/api/rest/server/mcir/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,8 @@ func RestLoadSharedResource(c echo.Context) error {
return common.EndRequestWithLog(c, reqID, err, content)
}

// RestDelAllDefaultResources godoc
// @ID DelAllDefaultResources
// RestDelAllSharedResources godoc
// @ID DelAllSharedResources
// @Summary Delete all Default Resource Objects in the given namespace
// @Description Delete all Default Resource Objects in the given namespace
// @Tags [Infra resource] MCIR Common
Expand All @@ -366,15 +366,15 @@ func RestLoadSharedResource(c echo.Context) error {
// @Param nsId path string true "Namespace ID" default(default)
// @Success 200 {object} common.IdList
// @Failure 404 {object} common.SimpleMsg
// @Router /ns/{nsId}/defaultResources [delete]
func RestDelAllDefaultResources(c echo.Context) error {
// @Router /ns/{nsId}/sharedResources [delete]
func RestDelAllSharedResources(c echo.Context) error {
reqID, idErr := common.StartRequestWithLog(c)
if idErr != nil {
return c.JSON(http.StatusBadRequest, map[string]string{"message": idErr.Error()})
}
nsId := c.Param("nsId")

content, err := mcir.DelAllDefaultResources(nsId)
content, err := mcir.DelAllSharedResources(nsId)
return common.EndRequestWithLog(c, reqID, err, content)
}

Expand Down
2 changes: 1 addition & 1 deletion src/api/rest/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ func RunServer(port string) {

e.GET("/tumblebug/loadCommonResource", rest_mcir.RestLoadCommonResource)
e.GET("/tumblebug/ns/:nsId/loadSharedResource", rest_mcir.RestLoadSharedResource)
e.DELETE("/tumblebug/ns/:nsId/defaultResources", rest_mcir.RestDelAllDefaultResources)
e.DELETE("/tumblebug/ns/:nsId/sharedResources", rest_mcir.RestDelAllSharedResources)

e.POST("/tumblebug/forward/*", rest_common.RestForwardAnyReqToAny)

Expand Down
2 changes: 1 addition & 1 deletion src/core/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const (
StrContainer string = "container"
StrCommon string = "common"
StrEmpty string = "empty"
StrDefaultResourceName string = "-systemdefault-"
StrSharedResourceName string = "-shared-"
// StrFirewallRule string = "firewallRule"

// SystemCommonNs is const for SystemCommon NameSpace ID
Expand Down
4 changes: 2 additions & 2 deletions src/core/mci/provisioning.go
Original file line number Diff line number Diff line change
Expand Up @@ -1303,7 +1303,7 @@ func CreateMciDynamic(reqID string, nsId string, req *TbMciDynamicReq, deployOpt
// Rollback created default resources
time.Sleep(5 * time.Second)
log.Info().Msg("Try rollback created default resources")
rollbackResult, rollbackErr := mcir.DelAllDefaultResources(nsId)
rollbackResult, rollbackErr := mcir.DelAllSharedResources(nsId)
if rollbackErr != nil {
err = fmt.Errorf("Failed in rollback operation: %w", rollbackErr)
} else {
Expand Down Expand Up @@ -1432,7 +1432,7 @@ func getVmReqFromDynamicReq(reqID string, nsId string, req *TbVmDynamicReq) (*Tb
}

// Default resource name has this pattern (nsId + "-shared-" + vmReq.ConnectionName)
resourceName := nsId + common.StrDefaultResourceName + vmReq.ConnectionName
resourceName := nsId + common.StrSharedResourceName + vmReq.ConnectionName

vmReq.SpecId = specInfo.Id
osType := strings.ReplaceAll(k.CommonImage, " ", "")
Expand Down
8 changes: 4 additions & 4 deletions src/core/mcir/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -1859,7 +1859,7 @@ func LoadSharedResource(nsId string, resType string, connectionName string) erro

//resourceName := connectionName
// Default resource name has this pattern (nsId + "-shared-" + connectionName)
resourceName := nsId + common.StrDefaultResourceName + connectionName
resourceName := nsId + common.StrSharedResourceName + connectionName
description := "Generated Default Resource"

for _, resType := range resList {
Expand Down Expand Up @@ -1972,8 +1972,8 @@ func LoadSharedResource(nsId string, resType string, connectionName string) erro
return nil
}

// DelAllDefaultResources deletes all Default securityGroup, sshKey, vNet objects
func DelAllDefaultResources(nsId string) (common.IdList, error) {
// DelAllSharedResources deletes all Default securityGroup, sshKey, vNet objects
func DelAllSharedResources(nsId string) (common.IdList, error) {

output := common.IdList{}
err := common.CheckString(nsId)
Expand All @@ -1982,7 +1982,7 @@ func DelAllDefaultResources(nsId string) (common.IdList, error) {
return output, err
}

matchedSubstring := nsId + common.StrDefaultResourceName
matchedSubstring := nsId + common.StrSharedResourceName

list, err := DelAllResources(nsId, common.StrSecurityGroup, matchedSubstring, "false")
if err != nil {
Expand Down

0 comments on commit 49b4552

Please sign in to comment.