Fixup some annotations
This commit is contained in:
@@ -23,6 +23,7 @@ func NewConfigMap(name string) *ConfigMap {
|
||||
base.ApiVersion = "v1"
|
||||
base.Kind = "ConfigMap"
|
||||
base.Metadata.Name = "{{ .Release.Name }}-" + name
|
||||
base.Metadata.Labels[K+"/component"] = name
|
||||
return &ConfigMap{
|
||||
K8sBase: base,
|
||||
Data: make(map[string]string),
|
||||
@@ -66,6 +67,7 @@ func NewSecret(name string) *Secret {
|
||||
base.ApiVersion = "v1"
|
||||
base.Kind = "Secret"
|
||||
base.Metadata.Name = "{{ .Release.Name }}-" + name
|
||||
base.Metadata.Labels[K+"/component"] = name
|
||||
return &Secret{
|
||||
K8sBase: base,
|
||||
Data: make(map[string]string),
|
||||
|
@@ -8,10 +8,12 @@ type Deployment struct {
|
||||
Spec *DepSpec `yaml:"spec"`
|
||||
}
|
||||
|
||||
func NewDeployment() *Deployment {
|
||||
func NewDeployment(name string) *Deployment {
|
||||
d := &Deployment{K8sBase: NewBase(), Spec: NewDepSpec()}
|
||||
d.K8sBase.Metadata.Name = "{{ .Release.Name }}-" + name
|
||||
d.K8sBase.ApiVersion = "apps/v1"
|
||||
d.K8sBase.Kind = "Deployment"
|
||||
d.K8sBase.Metadata.Labels[K+"/component"] = name
|
||||
return d
|
||||
}
|
||||
|
||||
|
@@ -11,6 +11,7 @@ func NewIngress(name string) *Ingress {
|
||||
i.K8sBase.Metadata.Name = "{{ .Release.Name }}-" + name
|
||||
i.K8sBase.Kind = "Ingress"
|
||||
i.ApiVersion = "networking.k8s.io/v1"
|
||||
i.K8sBase.Metadata.Labels[K+"/component"] = name
|
||||
|
||||
return i
|
||||
}
|
||||
|
@@ -5,13 +5,15 @@ type Service struct {
|
||||
Spec *ServiceSpec `yaml:"spec"`
|
||||
}
|
||||
|
||||
func NewService() *Service {
|
||||
func NewService(name string) *Service {
|
||||
s := &Service{
|
||||
K8sBase: NewBase(),
|
||||
Spec: NewServiceSpec(),
|
||||
}
|
||||
s.K8sBase.Metadata.Name = "{{ .Release.Name }}-" + name
|
||||
s.K8sBase.Kind = "Service"
|
||||
s.K8sBase.ApiVersion = "v1"
|
||||
s.K8sBase.Metadata.Labels[K+"/component"] = name
|
||||
return s
|
||||
}
|
||||
|
||||
|
@@ -12,6 +12,7 @@ func NewPVC(name, storageName string) *Storage {
|
||||
pvc.K8sBase.Metadata.Labels[K+"/pvc-name"] = storageName
|
||||
pvc.K8sBase.ApiVersion = "v1"
|
||||
pvc.K8sBase.Metadata.Name = "{{ .Release.Name }}-" + storageName
|
||||
pvc.K8sBase.Metadata.Labels[K+"/component"] = name
|
||||
pvc.Spec = &PVCSpec{
|
||||
Resouces: map[string]interface{}{
|
||||
"requests": map[string]string{
|
||||
|
@@ -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]
|
||||
|
Reference in New Issue
Block a user