forked from gjbae1212/gossm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
assets.go
36 lines (30 loc) · 797 Bytes
/
assets.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package internal
import (
"embed"
"fmt"
"runtime"
"strings"
)
//go:embed assets/*
var assets embed.FS
// GetAsset returns asset file.
// cannot be accessed from outer package.
func GetAsset(filename string) ([]byte, error) {
return assets.ReadFile("assets/" + filename)
}
// GetSsmPluginName returns filename for aws ssm plugin.
func GetSsmPluginName() string {
if strings.ToLower(runtime.GOOS) == "windows" {
return "session-manager-plugin.exe"
} else {
return "session-manager-plugin"
}
}
// GetSsmPlugin returns filepath for aws ssm plugin.
func GetSsmPlugin() ([]byte, error) {
return GetAsset(getSSMPluginKey())
}
func getSSMPluginKey() string {
return fmt.Sprintf("plugin/%s_%s/%s",
strings.ToLower(runtime.GOOS), strings.ToLower(runtime.GOARCH), GetSsmPluginName())
}