Enhancements, see details
- Added a message to explain to the user that it needs to build and push images - The Release Name string is now a constant ins source code, later we will be able to change it to (for example) a template call - SHA256 injected label (from docker-compose file content) is a bit long, SHA1 is shorter - We now add compose command line and generation date in the Values file - Code cleanup, refactorisation and enhancements - More documentation in the source code
This commit is contained in:
@@ -22,7 +22,7 @@ func NewConfigMap(name string) *ConfigMap {
|
||||
base := NewBase()
|
||||
base.ApiVersion = "v1"
|
||||
base.Kind = "ConfigMap"
|
||||
base.Metadata.Name = "{{ .Release.Name }}-" + name
|
||||
base.Metadata.Name = RELEASE_NAME + "-" + name
|
||||
base.Metadata.Labels[K+"/component"] = name
|
||||
return &ConfigMap{
|
||||
K8sBase: base,
|
||||
@@ -66,7 +66,7 @@ func NewSecret(name string) *Secret {
|
||||
base := NewBase()
|
||||
base.ApiVersion = "v1"
|
||||
base.Kind = "Secret"
|
||||
base.Metadata.Name = "{{ .Release.Name }}-" + name
|
||||
base.Metadata.Name = RELEASE_NAME + "-" + name
|
||||
base.Metadata.Labels[K+"/component"] = name
|
||||
return &Secret{
|
||||
K8sBase: base,
|
||||
|
@@ -10,7 +10,7 @@ type Deployment struct {
|
||||
|
||||
func NewDeployment(name string) *Deployment {
|
||||
d := &Deployment{K8sBase: NewBase(), Spec: NewDepSpec()}
|
||||
d.K8sBase.Metadata.Name = "{{ .Release.Name }}-" + name
|
||||
d.K8sBase.Metadata.Name = RELEASE_NAME + "-" + name
|
||||
d.K8sBase.ApiVersion = "apps/v1"
|
||||
d.K8sBase.Kind = "Deployment"
|
||||
d.K8sBase.Metadata.Labels[K+"/component"] = name
|
||||
@@ -67,7 +67,7 @@ func NewContainer(name, image string, environment, labels map[string]string) *Co
|
||||
for n, v := range environment {
|
||||
for _, name := range toServices {
|
||||
if name == n {
|
||||
v = "{{ .Release.Name }}-" + v
|
||||
v = RELEASE_NAME + "-" + v
|
||||
}
|
||||
}
|
||||
container.Env[idx] = Value{Name: n, Value: v}
|
||||
|
@@ -8,7 +8,7 @@ type Ingress struct {
|
||||
func NewIngress(name string) *Ingress {
|
||||
i := &Ingress{}
|
||||
i.K8sBase = NewBase()
|
||||
i.K8sBase.Metadata.Name = "{{ .Release.Name }}-" + name
|
||||
i.K8sBase.Metadata.Name = RELEASE_NAME + "-" + name
|
||||
i.K8sBase.Kind = "Ingress"
|
||||
i.ApiVersion = "networking.k8s.io/v1"
|
||||
i.K8sBase.Metadata.Labels[K+"/component"] = name
|
||||
|
@@ -10,7 +10,7 @@ Your application is now deployed. This may take a while to be up and responding.
|
||||
__list__
|
||||
`
|
||||
|
||||
func GenNotes(ingressess map[string]*Ingress) string {
|
||||
func GenerateNotesFile(ingressess map[string]*Ingress) string {
|
||||
|
||||
list := make([]string, 0)
|
||||
|
||||
|
@@ -10,7 +10,7 @@ func NewService(name string) *Service {
|
||||
K8sBase: NewBase(),
|
||||
Spec: NewServiceSpec(),
|
||||
}
|
||||
s.K8sBase.Metadata.Name = "{{ .Release.Name }}-" + name
|
||||
s.K8sBase.Metadata.Name = RELEASE_NAME + "-" + name
|
||||
s.K8sBase.Kind = "Service"
|
||||
s.K8sBase.ApiVersion = "v1"
|
||||
s.K8sBase.Metadata.Labels[K+"/component"] = name
|
||||
|
@@ -11,7 +11,7 @@ func NewPVC(name, storageName string) *Storage {
|
||||
pvc.K8sBase.Kind = "PersistentVolumeClaim"
|
||||
pvc.K8sBase.Metadata.Labels[K+"/pvc-name"] = storageName
|
||||
pvc.K8sBase.ApiVersion = "v1"
|
||||
pvc.K8sBase.Metadata.Name = "{{ .Release.Name }}-" + storageName
|
||||
pvc.K8sBase.Metadata.Name = RELEASE_NAME + "-" + storageName
|
||||
pvc.K8sBase.Metadata.Labels[K+"/component"] = name
|
||||
pvc.Spec = &PVCSpec{
|
||||
Resouces: map[string]interface{}{
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package helm
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"crypto/sha1"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
)
|
||||
|
||||
const K = "katenary.io"
|
||||
const RELEASE_NAME = "{{ .Release.Name }}"
|
||||
const (
|
||||
LABEL_ENV_SECRET = K + "/secret-envfiles"
|
||||
LABEL_PORT = K + "/ports"
|
||||
@@ -17,9 +18,10 @@ const (
|
||||
LABEL_VOL_CM = K + "/configmap-volumes"
|
||||
)
|
||||
|
||||
var Appname = ""
|
||||
|
||||
var Version = "1.0" // should be set from main.Version
|
||||
var (
|
||||
Appname = ""
|
||||
Version = "1.0" // should be set from main.Version
|
||||
)
|
||||
|
||||
type Kinded interface {
|
||||
Get() string
|
||||
@@ -58,16 +60,18 @@ func NewBase() *K8sBase {
|
||||
b := &K8sBase{
|
||||
Metadata: NewMetadata(),
|
||||
}
|
||||
// add some information of the build
|
||||
b.Metadata.Labels[K+"/project"] = GetProjectName()
|
||||
b.Metadata.Labels[K+"/release"] = "{{ .Release.Name }}"
|
||||
b.Metadata.Labels[K+"/release"] = RELEASE_NAME
|
||||
b.Metadata.Annotations[K+"/version"] = Version
|
||||
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[:]))
|
||||
//sum := sha256.Sum256(c)
|
||||
sum := sha1.Sum(c)
|
||||
k.Metadata.Annotations[K+"/docker-compose-sha1"] = fmt.Sprintf("%x", string(sum[:]))
|
||||
}
|
||||
|
||||
func (k *K8sBase) Get() string {
|
||||
|
Reference in New Issue
Block a user