Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

Commit

Permalink
[#84] fix pod build and update pod logs
Browse files Browse the repository at this point in the history
  • Loading branch information
n0rad committed Dec 29, 2015
1 parent de7d5de commit 73a352f
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 24 deletions.
3 changes: 1 addition & 2 deletions builder/pod-build.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package builder

import (
"errors"
log "github.com/Sirupsen/logrus"
"github.com/appc/spec/schema"
"github.com/appc/spec/schema/types"
"github.com/blablacar/cnt/spec"
Expand All @@ -13,7 +12,7 @@ import (
const PATH_POD_MANIFEST = "/pod-manifest.json"

func (p *Pod) Build() error {
log.Info("Building POD : ", p.manifest.Name)
p.log.Info("Building")

os.RemoveAll(p.target)
os.MkdirAll(p.target, 0777)
Expand Down
5 changes: 2 additions & 3 deletions builder/pod-clean.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package builder

import (
log "github.com/Sirupsen/logrus"
"os"
)

func (p *Pod) Clean() {
log.Info("Cleaning POD", p.manifest.Name)
p.log.Info("Cleaning")

if err := os.RemoveAll(p.target + "/"); err != nil {
panic("Cannot clean" + p.manifest.Name.String() + err.Error())
Expand All @@ -17,7 +16,7 @@ func (p *Pod) Clean() {
for _, e := range p.manifest.Pod.Apps {
aci, err := NewAciWithManifest(p.path+"/"+e.Name, p.args, p.toAciManifest(e), &checkVersion)
if err != nil {
panic(err)
p.log.WithError(err).WithField("name", e.Name).Fatal("Cannot prepare aci")
}
aci.podName = &p.manifest.Name
aci.Clean()
Expand Down
3 changes: 1 addition & 2 deletions builder/pod-graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ package builder

import (
"bytes"
log "github.com/Sirupsen/logrus"
"io/ioutil"
"os"
)

func (p *Pod) Graph() {
log.Info("Graph POD", p.manifest.Name)
p.log.Info("Graphing")
os.MkdirAll(p.target, 0777)

var buffer bytes.Buffer
Expand Down
8 changes: 2 additions & 6 deletions builder/pod-install.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package builder

import (
log "github.com/Sirupsen/logrus"
)

func (p *Pod) Install() {
log.Info("Installing POD", p.manifest.Name)
p.log.Info("Installing")

p.Build()

Expand All @@ -14,7 +10,7 @@ func (p *Pod) Install() {
for _, e := range p.manifest.Pod.Apps {
aci, err := NewAciWithManifest(p.path+"/"+e.Name, p.args, p.toAciManifest(e), &checkVersion)
if err != nil {
panic(err)
p.log.WithError(err).WithField("name", e.Name).Fatal("Cannot prepare aci")
}
aci.podName = &p.manifest.Name
aci.Install()
Expand Down
7 changes: 3 additions & 4 deletions builder/pod-push.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package builder

import (
log "github.com/Sirupsen/logrus"
"github.com/blablacar/cnt/cnt"
"github.com/blablacar/cnt/utils"
)

func (p *Pod) Push() {
log.Info("Push POD", p.manifest.Name)
p.log.Info("Pushing")

p.Build()

Expand All @@ -16,7 +15,7 @@ func (p *Pod) Push() {
for _, e := range p.manifest.Pod.Apps {
aci, err := NewAciWithManifest(p.path+"/"+e.Name, p.args, p.toAciManifest(e), &checkVersion)
if err != nil {
panic(err)
p.log.WithError(err).WithField("name", e.Name).Fatal("Cannot prepare aci")
}
aci.podName = &p.manifest.Name
aci.Push()
Expand All @@ -37,7 +36,7 @@ func (p *Pod) Push() {
"-F", "file=@"+p.target+"/pod-manifest.json",
"-u", cnt.Home.Config.Push.Username+":"+cnt.Home.Config.Push.Password,
cnt.Home.Config.Push.Url+"/service/local/artifact/maven/content"); err != nil {
panic("Cannot push pod" + err.Error())
p.log.WithError(err).Fatal("Cannot push pod")
}

}
8 changes: 2 additions & 6 deletions builder/pod-test.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
package builder

import (
log "github.com/Sirupsen/logrus"
)

func (p *Pod) Test() {
log.Info("Testing POD", p.manifest.Name)
p.log.Info("Testing")

checkVersion := make(chan bool, 1)

for _, e := range p.manifest.Pod.Apps {
aci, err := NewAciWithManifest(p.path+"/"+e.Name, p.args, p.toAciManifest(e), &checkVersion)
if err != nil {
panic(err)
p.log.WithError(err).WithField("name", e.Name).Fatal("Cannot prepare aci")
}
aci.podName = &p.manifest.Name
aci.Test()
Expand Down
2 changes: 1 addition & 1 deletion commands/cnt.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func checkRktVersion() {
func buildAciOrPod(path string, args builder.BuildArgs) spec.CntCommand {
if aci, err := builder.NewAci(path, args); err == nil {
return aci
} else if pod, err2 := builder.NewPod(path, args); err == nil {
} else if pod, err2 := builder.NewPod(path, args); err2 == nil {
return pod
} else {
logrus.WithField("path", path).WithError(err).WithField("error2", err2).Fatal("Cannot construct aci or pod")
Expand Down

0 comments on commit 73a352f

Please sign in to comment.