Fixup some annotations

This commit is contained in:
2021-12-01 15:17:34 +01:00
parent a536fcd369
commit 1085be2b53
8 changed files with 33 additions and 6 deletions

View File

@@ -1,18 +1,27 @@
package helm
import (
"crypto/sha256"
"fmt"
"io/ioutil"
"os"
"strings"
)
const K = "katenary.io"
var Appname = ""
var Version = "1.0" // should be set from main.Version
type Kinded interface {
Get() string
}
type Signable interface {
BuildSHA(filename string)
}
type Metadata struct {
Name string `yaml:"name,omitempty"`
Labels map[string]string `yaml:"labels"`
@@ -44,11 +53,20 @@ func NewBase() *K8sBase {
return b
}
func (k *K8sBase) BuildSHA(filename string) {
c, _ := ioutil.ReadFile(filename)
sum := sha256.Sum256(c)
k.Metadata.Annotations[K+"/docker-compose-sha256"] = fmt.Sprintf("%x", string(sum[:]))
}
func (k K8sBase) Get() string {
return k.Kind
}
func getProjectName() string {
if len(Appname) > 0 {
return Appname
}
p, _ := os.Getwd()
path := strings.Split(p, string(os.PathSeparator))
return path[len(path)-1]