-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: separate state per cloud (#395)
- Loading branch information
1 parent
b033aab
commit 3e55ab1
Showing
23 changed files
with
247 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package services | ||
|
||
import ( | ||
"fmt" | ||
"github.com/multycloud/multy/api/proto/commonpb" | ||
"github.com/multycloud/multy/resources" | ||
"github.com/multycloud/multy/resources/common" | ||
"github.com/multycloud/multy/resources/types/metadata" | ||
"google.golang.org/protobuf/proto" | ||
"strings" | ||
) | ||
|
||
func GetConfigPrefixForCloud(userId string, cloud commonpb.CloudProvider) string { | ||
return fmt.Sprintf("%s/%s", userId, strings.ToLower(cloud.String())) | ||
} | ||
|
||
func GetConfigPrefix(req WithResourceId, userId string) string { | ||
cloud := common.ParseCloudFromResourceId(req.GetResourceId()) | ||
if cloud == commonpb.CloudProvider_UNKNOWN_PROVIDER { | ||
return userId | ||
} | ||
|
||
return GetConfigPrefixForCloud(userId, cloud) | ||
} | ||
|
||
func getConfigPrefixForCreateReq(r proto.Message, userId string) string { | ||
converter, err := resources.ResourceMetadatas(metadata.Metadatas).GetConverter(proto.MessageName(r)) | ||
if err != nil { | ||
return "" | ||
} | ||
cloud := converter.ParseCloud(r) | ||
if cloud == commonpb.CloudProvider_UNKNOWN_PROVIDER { | ||
return userId | ||
} | ||
|
||
return GetConfigPrefixForCloud(userId, cloud) | ||
} |
Oops, something went wrong.