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

Commit

Permalink
change logger and add back pod manifest generation
Browse files Browse the repository at this point in the history
  • Loading branch information
n0rad committed Oct 23, 2015
1 parent 1bcbbe0 commit afe545a
Show file tree
Hide file tree
Showing 29 changed files with 306 additions and 364 deletions.
2 changes: 1 addition & 1 deletion builder/aci-build.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package builder

import (
log "github.com/Sirupsen/logrus"
"github.com/blablacar/cnt/dist"
"github.com/blablacar/cnt/log"
"github.com/blablacar/cnt/utils"
"io/ioutil"
"os"
Expand Down
2 changes: 1 addition & 1 deletion builder/aci-clean.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package builder

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

Expand Down
2 changes: 1 addition & 1 deletion builder/aci-graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package builder

import (
"bytes"
"github.com/blablacar/cnt/log"
log "github.com/Sirupsen/logrus"
"io/ioutil"
"os"
)
Expand Down
2 changes: 1 addition & 1 deletion builder/aci-init.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package builder

import (
"github.com/blablacar/cnt/log"
log "github.com/Sirupsen/logrus"
"github.com/blablacar/cnt/utils"
"io/ioutil"
"os"
Expand Down
2 changes: 1 addition & 1 deletion builder/aci-test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package builder

import (
log "github.com/Sirupsen/logrus"
"github.com/appc/spec/schema/types"
"github.com/blablacar/cnt/dist"
"github.com/blablacar/cnt/log"
"github.com/blablacar/cnt/spec"
"github.com/blablacar/cnt/utils"
"io/ioutil"
Expand Down
2 changes: 1 addition & 1 deletion builder/aci-update.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package builder

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

Expand Down
2 changes: 1 addition & 1 deletion builder/aci.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package builder

import (
log "github.com/Sirupsen/logrus"
"github.com/appc/spec/schema/types"
"github.com/blablacar/cnt/log"
"github.com/blablacar/cnt/spec"
"github.com/blablacar/cnt/utils"
"github.com/ghodss/yaml"
Expand Down
31 changes: 17 additions & 14 deletions builder/pod-build.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@ package builder

import (
"errors"
log "github.com/Sirupsen/logrus"
"github.com/appc/spec/schema"
"github.com/appc/spec/schema/types"
"github.com/blablacar/cnt/log"
"github.com/blablacar/cnt/spec"
"github.com/blablacar/cnt/utils"
"os"
"strconv"
"text/template"
)

const PATH_POD_MANIFEST = "/pod-manifest.json"

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

Expand All @@ -21,6 +23,7 @@ func (p *Pod) Build() {
apps := p.processAci()

p.writeSystemdUnit(apps)
p.writePodManifest(apps)
}

func (p *Pod) processAci() []schema.RuntimeApp {
Expand Down Expand Up @@ -84,19 +87,19 @@ func (p *Pod) buildAciIfNeeded(e spec.RuntimeApp) *spec.ACFullname {
return nil
}

//func (p *Pod) writePodManifest(apps []schema.RuntimeApp) {
// m := p.manifest.Pod
// ver, _ := types.NewSemVer("0.6.1")
// manifest := schema.PodManifest{
// ACKind: "PodManifest",
// ACVersion: *ver,
// Apps: apps,
// Volumes: m.Volumes,
// Isolators: m.Isolators,
// Annotations: m.Annotations,
// Ports: m.Ports}
// utils.WritePodManifest(&manifest, p.target+POD_TARGET_MANIFEST)
//}
func (p *Pod) writePodManifest(apps []schema.RuntimeApp) {
m := p.manifest.Pod
ver, _ := types.NewSemVer("0.6.1")
manifest := schema.PodManifest{
ACKind: "PodManifest",
ACVersion: *ver,
Apps: apps,
Volumes: m.Volumes,
Isolators: m.Isolators,
Annotations: m.Annotations,
Ports: m.Ports}
utils.WritePodManifest(&manifest, p.target+PATH_POD_MANIFEST)
}

const SYSTEMD_TEMPLATE = `[Unit]
Description={{ .Shortname }} %i
Expand Down
2 changes: 1 addition & 1 deletion builder/pod-clean.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package builder

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

Expand Down
2 changes: 1 addition & 1 deletion builder/pod-graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package builder

import (
"bytes"
"github.com/blablacar/cnt/log"
log "github.com/Sirupsen/logrus"
"io/ioutil"
"os"
)
Expand Down
2 changes: 1 addition & 1 deletion builder/pod-install.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package builder

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

func (p *Pod) Install() {
Expand Down
16 changes: 15 additions & 1 deletion builder/pod-push.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package builder

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

Expand All @@ -26,6 +26,20 @@ func (p *Pod) Push() {
<-checkVersion
}

if err := utils.ExecCmd("curl", "-i",
"-F", "r=releases",
"-F", "hasPom=false",
"-F", "e=pod",
"-F", "g=com.blablacar.aci.linux.amd64",
"-F", "p=pod",
"-F", "v="+p.manifest.Name.Version(),
"-F", "a="+p.manifest.Name.ShortName(),
"-F", "file=@"+p.target+"/pod-manifest.json",
"-u", config.GetConfig().Push.Username+":"+config.GetConfig().Push.Password,
config.GetConfig().Push.Url+"/service/local/artifact/maven/content"); err != nil {
panic("Cannot push pod" + err.Error())
}

if err := utils.ExecCmd("curl", "-i",
"-F", "r=releases",
"-F", "hasPom=false",
Expand Down
2 changes: 1 addition & 1 deletion builder/pod-test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package builder

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

func (p *Pod) Test() {
Expand Down
4 changes: 2 additions & 2 deletions builder/pod.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package builder

import (
"github.com/blablacar/cnt/log"
log "github.com/Sirupsen/logrus"
"github.com/blablacar/cnt/spec"
"github.com/ghodss/yaml"
"io/ioutil"
Expand Down Expand Up @@ -50,7 +50,7 @@ func (p *Pod) readManifest(manifestPath string) {

//TODO check that there is no app name conflict

log.Trace("Pod manifest : ", p.manifest.Name, p.manifest)
log.Debug("Pod manifest : ", p.manifest.Name, p.manifest)
}

func (p *Pod) toAciManifest(e spec.RuntimeApp) spec.AciManifest {
Expand Down
20 changes: 16 additions & 4 deletions commands/cnt.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package commands

import (
"bufio"
"fmt"
log "github.com/Sirupsen/logrus"
"github.com/blablacar/cnt/builder"
"github.com/blablacar/cnt/config"
"github.com/blablacar/cnt/log"
"github.com/blablacar/cnt/logger"
"github.com/blablacar/cnt/utils"
"github.com/coreos/go-semver/semver"
"github.com/spf13/cobra"
"os"
"strings"
)

Expand All @@ -17,12 +18,23 @@ var buildArgs = builder.BuildArgs{}
const RKT_SUPPORTED_VERSION = "0.8.1"

func Execute() {
log.Logger = logger.NewLogger()
checkRktVersion()

var rootCmd = &cobra.Command{Use: "cnt"}
var logLevel string
var rootCmd = &cobra.Command{
Use: "cnt",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
level, err := log.ParseLevel(logLevel)
if err != nil {
fmt.Printf("Unknown log level : %s", logLevel)
os.Exit(1)
}
log.SetLevel(level)
},
}
rootCmd.PersistentFlags().BoolVarP(&buildArgs.Clean, "clean", "c", false, "Clean before doing anything")
rootCmd.PersistentFlags().StringVarP(&buildArgs.TargetPath, "target-path", "p", "", "Set target path")
rootCmd.PersistentFlags().StringVarP(&logLevel, "loglevel", "L", "debug", "Set log level")

rootCmd.AddCommand(buildCmd, cleanCmd, pushCmd, installCmd, testCmd, versionCmd, initCmd, updateCmd, graphCmd)

Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package config

import (
"github.com/blablacar/cnt/log"
log "github.com/Sirupsen/logrus"
"github.com/blablacar/cnt/utils"
"gopkg.in/yaml.v2"
"io/ioutil"
Expand Down
35 changes: 0 additions & 35 deletions log/dummy-logger.go

This file was deleted.

Loading

0 comments on commit afe545a

Please sign in to comment.