pkg/helper/helper.go (25 lines of code) (raw):
package helper
import (
"fmt"
"os"
"path/filepath"
"github.com/epam/edp-jenkins-operator/v2/pkg/service/jenkins/spec"
)
func GetExecutableFilePath() (string, error) {
executableFilePath, err := os.Executable()
if err != nil {
return "", fmt.Errorf("failed to get the path of the executable: %w", err)
}
return filepath.Dir(executableFilePath), nil
}
func FileExists(filename string) bool {
info, err := os.Stat(filename)
if os.IsNotExist(err) {
return false
}
return !info.IsDir()
}
func GenerateAnnotationKey(entitySuffix string) string {
key := fmt.Sprintf("%v/%v", spec.EdpAnnotationsPrefix, entitySuffix)
return key
}