Path: blob/main/pkg/integrations/snmp_exporter/common/common.go
5371 views
package common12import (3"bytes"4"compress/gzip"5_ "embed" // enables the go:embed directive6"io"78snmp_config "github.com/prometheus/snmp_exporter/config"9"gopkg.in/yaml.v2"10)1112//go:generate curl https://raw.githubusercontent.com/prometheus/snmp_exporter/v0.20.0/snmp.yml --output snmp.yml13//go:generate gzip -9 snmp.yml14//go:embed snmp.yml.gz15var content []byte1617// LoadEmbeddedConfig loads the SNMP config via a file using the go:embed directive.18func LoadEmbeddedConfig() (*snmp_config.Config, error) {19gzipReader, err := gzip.NewReader(bytes.NewReader(content))20if err != nil {21return nil, err22}2324b, err := io.ReadAll(gzipReader)25if err != nil {26return nil, err27}2829cfg := &snmp_config.Config{}30err = yaml.UnmarshalStrict(b, cfg)31if err != nil {32return nil, err33}34return cfg, nil35}363738