-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
61 lines (48 loc) · 1.55 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright 2020 VMware, Inc.
// SPDX-License-Identifier: Apache-2.0
package resource
import (
"errors"
"fmt"
)
// AppVersion will be specified by the build
var AppVersion = "0.0.0-dev"
// Source is what is configured for the concourse resource
//
// resources:
// - name: events
// type: wavefront
// source:
// tenant_url: http://<mywavefronttenant>.wavefront.com
// api_token: ((my-secret-token))
type Source struct {
WavefrontURL string `json:"tenant_url"`
WavefrontToken string `json:"api_token"`
Debug bool `json:"debug"`
}
// Validate ensures that the source's required properties are set
func (s Source) Validate() error {
if s.WavefrontURL == "" {
return fmt.Errorf("could not validate source configuration: %w", ErrMissingWavefrontURL)
}
if s.WavefrontToken == "" {
return fmt.Errorf("could not validate source configuration: %w", ErrMissingWavefrontToken)
}
return nil
}
// Version is used by the in and out script and represents an event's ID
type Version struct {
ID string `json:"id"`
}
// Metadatum is a key value pair
type Metadatum struct {
Name string `json:"name"`
Value string `json:"value"`
}
// Metadata is a slice of Metadatum
type Metadata []Metadatum
// ERRORS
// ErrMissingWavefrontURL will be emitted or wrapped when the source is missing the wavefront URL
var ErrMissingWavefrontURL = errors.New("wavefront url is missing")
// ErrMissingWavefrontToken will be emitted or wrapped when the source is missing the wavefront token
var ErrMissingWavefrontToken = errors.New("wavefront token is missing")