@@ -30,6 +30,7 @@ import (
30
30
var version = "undefined"
31
31
var transport * http.Transport
32
32
33
+ // Config stores handler's configuration
33
34
type Config struct {
34
35
Version bool `short:"V" long:"version" description:"Display version."`
35
36
PuppetDBURL string `short:"u" long:"puppetdb-url" description:"PuppetDB base URL." env:"PROMETHEUS_PUPPETDB_URL" default:"http://puppetdb:8080"`
@@ -46,38 +47,18 @@ type Config struct {
46
47
Manpage bool `short:"m" long:"manpage" description:"Output manpage."`
47
48
}
48
49
50
+ // Node contains Puppet node informations
49
51
type Node struct {
50
52
Certname string `json:"certname"`
51
53
Exporters map [string ][]string `json:"value"`
52
54
}
53
55
56
+ // StaticConfig contains Prometheus static targets
54
57
type StaticConfig struct {
55
58
Targets []string `yaml:"targets"`
56
59
Labels map [string ]string `yaml:"labels"`
57
60
}
58
61
59
- type FileSdConfig struct {
60
- Files []string `yaml:"files,omitempty"`
61
- }
62
-
63
- type RelabelConfig struct {
64
- SourceLabels []string `yaml:"source_labels,omitempty"`
65
- Regex string `yaml:"regex,omitempty"`
66
- Action string `yaml:"action,omitempty"`
67
- TargetLabel string `yaml:"target_label,omitempty"`
68
- Replacement string `yaml:"replacement,omitempty"`
69
- }
70
-
71
- type ScrapeConfig struct {
72
- JobName string `yaml:"job_name,omitempty"`
73
- FileSdConfigs []FileSdConfig `yaml:"file_sd_configs,omitempty"`
74
- RelabelConfigs []RelabelConfig `yaml:"relabel_configs,omitempty"`
75
- }
76
-
77
- type PrometheusConfig struct {
78
- ScrapeConfigs []ScrapeConfig `yaml:"scrape_configs,omitempty"`
79
- }
80
-
81
62
func loadConfig (version string ) (c Config , err error ) {
82
63
parser := flags .NewParser (& c , flags .Default )
83
64
_ , err = parser .Parse ()
@@ -94,7 +75,7 @@ func loadConfig(version string) (c Config, err error) {
94
75
var buf bytes.Buffer
95
76
parser .ShortDescription = "Prometheus scrape lists based on PuppetDB"
96
77
parser .WriteManPage (& buf )
97
- fmt .Printf (buf .String ())
78
+ fmt .Printf ("%s" , buf .String ())
98
79
os .Exit (0 )
99
80
}
100
81
return
@@ -221,7 +202,7 @@ func main() {
221
202
if err != nil {
222
203
log .Fatalf ("failed to get exporters: %v" , err )
223
204
}
224
- fmt .Printf (string (c ))
205
+ fmt .Printf ("%s" , string (c ))
225
206
}
226
207
if cfg .Output == "file" {
227
208
os .MkdirAll (filepath .Dir (cfg .File ), 0755 )
0 commit comments