forked from openshift/backplane-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinfo.go
More file actions
87 lines (68 loc) · 2.19 KB
/
info.go
File metadata and controls
87 lines (68 loc) · 2.19 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// This file contains information about backplane-cli.
package info
import (
"fmt"
"strings"
)
const (
// Environment Variables
BackplaneURLEnvName = "BACKPLANE_URL"
BackplaneProxyEnvName = "HTTPS_PROXY"
BackplaneAWSProxyEnvName = "BACKPLANE_AWS_PROXY"
BackplaneConfigPathEnvName = "BACKPLANE_CONFIG"
BackplaneKubeconfigEnvName = "KUBECONFIG"
BackplaneJiraAPITokenEnvName = "JIRA_API_TOKEN" //nolint:gosec
// Configuration
BackplaneConfigDefaultFilePath = ".config/backplane"
BackplaneConfigDefaultFileName = "config.json"
// Session
BackplaneDefaultSessionDirectory = "backplane"
// GitHub API get fetch the latest tag
UpstreamReleaseAPI = "https://api.github.com/repos/openshift/backplane-cli/releases/latest"
// Upstream git module
UpstreamGitModule = "https://github.com/openshift/backplane-cli/cmd/ocm-backplane"
// GitHub README page
UpstreamREADMETemplate = "https://github.com/openshift/backplane-cli/-/blob/%s/README.md"
// GitHub Host
GitHubHost = "github.com"
// Nginx configuration template for monitoring-plugin
MonitoringPluginNginxConfigTemplate = `
error_log /dev/stdout info;
events {}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
keepalive_timeout 65;
server {
listen %s;
root /usr/share/nginx/html;
}
}
`
MonitoringPluginNginxConfigFilename = "monitoring-plugin-nginx-%s.conf"
)
var (
// Version of the backplane-cli
// This will be set via Goreleaser during the build process
Version string
UpstreamREADMETagged = fmt.Sprintf(UpstreamREADMETemplate, Version)
)
type InfoService interface {
// get the current binary version from available sources
GetVersion() string
}
type DefaultInfoServiceImpl struct {
}
func (i *DefaultInfoServiceImpl) GetVersion() string {
// If the Version is set by Goreleaser, return it directly.
if Version != "" {
return Version
}
// otherwise, return the build info from Go build if available.
buildInfo, available := DefaultBuildInfoService.GetBuildInfo()
if available {
return strings.TrimLeft(buildInfo.Main.Version, "v")
}
return "unknown"
}
var DefaultInfoService InfoService = &DefaultInfoServiceImpl{}