emissary/internal/agent/metadata/collector/buildinfo/collector.go

32 lines
610 B
Go
Raw Normal View History

package buildinfo
import (
"context"
"runtime/debug"
"forge.cadoles.com/Cadoles/emissary/internal/agent/metadata"
"github.com/pkg/errors"
)
const (
MetadataBuildInfo = "buildinfo"
)
type Collector struct{}
// Collect implements agent.MetadataCollector
func (c *Collector) Collect(ctx context.Context) (string, string, error) {
buildInfo, ok := debug.ReadBuildInfo()
if !ok {
return "", "", errors.WithStack(metadata.ErrMetadataNotAvailable)
}
return MetadataBuildInfo, buildInfo.String(), nil
}
func NewCollector() *Collector {
return &Collector{}
}
var _ metadata.Collector = &Collector{}