From f70738038726ebb5e8061aabe29f9d2470e85d06 Mon Sep 17 00:00:00 2001
From: laurentu <laurentu@gmail.com>
Date: Fri, 11 Aug 2023 15:45:43 +0200
Subject: [PATCH] zz

---
 conf.yaml |  6 ++++++
 go.mod    |  4 ++++
 main.go   | 18 ++++++++++++++++++
 3 files changed, 28 insertions(+)
 create mode 100644 conf.yaml

diff --git a/conf.yaml b/conf.yaml
new file mode 100644
index 0000000..c41ea02
--- /dev/null
+++ b/conf.yaml
@@ -0,0 +1,6 @@
+IDE:
+  tables:
+    - ide
+  hosts:
+    - 172.17.4.20
+    - 172.17.4.21
diff --git a/go.mod b/go.mod
index f1c9a88..345b38f 100644
--- a/go.mod
+++ b/go.mod
@@ -1,3 +1,7 @@
 module passke.org/hostchecker
 
 go 1.19
+
+require (
+	gopkg.in/yaml.v3 v3.0.1
+)
diff --git a/main.go b/main.go
index 83678ed..dac9b35 100644
--- a/main.go
+++ b/main.go
@@ -3,10 +3,28 @@ package main
 import "fmt"
 import "net/http"
 import "io"
+import "io/ioutil"
+import "log"
+import "gopkg.in/yaml.v3"
 
+type Group struct {
+  Name string `yaml:"group"`
+  Tables []string `yaml:"tables"`
+  Hosts []string `yaml:"hosts"`
+}
 func main() {
   fmt.Println("staring")
 
+  var conf map[string]Group
+  yamlFile, err := ioutil.ReadFile("conf.yaml")
+  if err != nil {
+    log.Printf("Configuration open error #%v ", err)
+  }
+  err = yaml.Unmarshal(yamlFile, &conf)
+  if err != nil {
+    log.Fatalf("Configuration read error #%v", err)
+  }
+
   resp, err := http.Head("http://example.com")
   if err != nil {
     fmt.Println("Failed")