2021-02-23 20:18:05 +00:00
|
|
|
package stackutils
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2021-08-17 01:12:07 +00:00
|
|
|
"path"
|
2021-02-23 20:18:05 +00:00
|
|
|
|
|
|
|
portainer "github.com/portainer/portainer/api"
|
|
|
|
)
|
|
|
|
|
|
|
|
// ResourceControlID returns the stack resource control id
|
|
|
|
func ResourceControlID(endpointID portainer.EndpointID, name string) string {
|
|
|
|
return fmt.Sprintf("%d_%s", endpointID, name)
|
|
|
|
}
|
2021-08-17 01:12:07 +00:00
|
|
|
|
|
|
|
// GetStackFilePaths returns a list of file paths based on stack project path
|
|
|
|
func GetStackFilePaths(stack *portainer.Stack) []string {
|
|
|
|
var filePaths []string
|
|
|
|
for _, file := range append([]string{stack.EntryPoint}, stack.AdditionalFiles...) {
|
|
|
|
filePaths = append(filePaths, path.Join(stack.ProjectPath, file))
|
|
|
|
}
|
|
|
|
return filePaths
|
|
|
|
}
|