f-8: code: add params for meta_cli #8
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
f1492acd85
commit
a1f7c43888
1 changed files with 41 additions and 4 deletions
|
|
@ -1,17 +1,54 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
configuration "git.g3e.fr/syonad/two/internal/config/agent"
|
||||
"git.g3e.fr/syonad/two/pkg/db/kv"
|
||||
"github.com/dgraph-io/badger/v4"
|
||||
)
|
||||
|
||||
var (
|
||||
bin_name = os.Args[0]
|
||||
)
|
||||
var DB *badger.DB
|
||||
|
||||
func AddInDB(dbName string, line string) error {
|
||||
// ID = partie avant le premier ';'
|
||||
id := strings.Split(line, ";")[0] + "/bash"
|
||||
key := []byte(dbName + "/" + id)
|
||||
|
||||
return DB.Update(func(txn *badger.Txn) error {
|
||||
return txn.Set(key, []byte(line))
|
||||
})
|
||||
}
|
||||
|
||||
func main() {
|
||||
conf_file := flag.String("conf", "/etc/two/agent.yml", "configuration file")
|
||||
vm_name := flag.String("vm_name", "", "Nom de la vm")
|
||||
vpc := flag.String("vpc_name", "", "vpc name")
|
||||
bind_ip := flag.String("ip", "", "bind ip")
|
||||
bind_port := flag.String("port", "", "bind port")
|
||||
ssh_key := flag.String("key", "", "Clef ssh")
|
||||
password := flag.String("pass", "", "password user")
|
||||
start := flag.Bool("start", false, "start metadata server")
|
||||
stop := flag.Bool("stop", false, "stop metadata server")
|
||||
|
||||
fmt.Printf("Start %s conf\n", bin_name)
|
||||
flag.Parse()
|
||||
|
||||
conf, err := configuration.LoadConfig(*conf_file)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
fmt.Print(conf)
|
||||
|
||||
DB = kv.InitDB(kv.Config{
|
||||
Path: conf.Database.Path,
|
||||
})
|
||||
defer DB.Close()
|
||||
|
||||
fmt.Printf("conf metadata for %s\n - this key %s\n - this password %s\n", *vm_name, *ssh_key, *password)
|
||||
|
||||
os.Exit(0)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue