From 7afcd670d57f4c4e025b4b7528e15d612609f655 Mon Sep 17 00:00:00 2001 From: labbs Date: Fri, 26 Mar 2021 11:46:25 +0100 Subject: [PATCH] add comments --- pkg/config/config.go | 2 +- pkg/metrics/get_billable_from_github.go | 1 + pkg/metrics/get_runners_from_github.go | 1 + pkg/metrics/get_runners_organization_from_github.go | 1 + pkg/metrics/get_workflow_runs_from_github.go | 1 + pkg/metrics/metrics.go | 1 + pkg/metrics/workflows_cache.go | 1 + pkg/server/routes.go | 1 + pkg/server/server.go | 1 + 9 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 5cc6497..ef330d3 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -14,7 +14,7 @@ var ( Debug bool ) -// InitConfiguration => set configuration from env vars or command parameters +// InitConfiguration - set configuration from env vars or command parameters func InitConfiguration() []cli.Flag { return []cli.Flag{ &cli.IntFlag{ diff --git a/pkg/metrics/get_billable_from_github.go b/pkg/metrics/get_billable_from_github.go index 8136f6b..9394a53 100644 --- a/pkg/metrics/get_billable_from_github.go +++ b/pkg/metrics/get_billable_from_github.go @@ -21,6 +21,7 @@ var ( ) ) +// getBillableFromGithub - return billable informations for MACOS, WINDOWS and UBUNTU runners. func getBillableFromGithub() { for { for _, repo := range config.Github.Repositories.Value() { diff --git a/pkg/metrics/get_runners_from_github.go b/pkg/metrics/get_runners_from_github.go index 65ff3be..f29c7c0 100644 --- a/pkg/metrics/get_runners_from_github.go +++ b/pkg/metrics/get_runners_from_github.go @@ -21,6 +21,7 @@ var ( ) ) +// getRunnersFromGithub - return information about runners and their status for a specific repo func getRunnersFromGithub() { for { for _, repo := range config.Github.Repositories.Value() { diff --git a/pkg/metrics/get_runners_organization_from_github.go b/pkg/metrics/get_runners_organization_from_github.go index 34b2cf0..2d4a661 100644 --- a/pkg/metrics/get_runners_organization_from_github.go +++ b/pkg/metrics/get_runners_organization_from_github.go @@ -21,6 +21,7 @@ var ( ) ) +// getRunnersOrganizationFromGithub - return information about runners and their status for an organization func getRunnersOrganizationFromGithub() { opt := &github.ListOptions{PerPage: 10} for { diff --git a/pkg/metrics/get_workflow_runs_from_github.go b/pkg/metrics/get_workflow_runs_from_github.go index 20e34bb..f13bac1 100644 --- a/pkg/metrics/get_workflow_runs_from_github.go +++ b/pkg/metrics/get_workflow_runs_from_github.go @@ -35,6 +35,7 @@ var ( ) ) +// getWorkflowRunsFromGithub - return informations and status about a worflow func getWorkflowRunsFromGithub() { for { for _, repo := range config.Github.Repositories.Value() { diff --git a/pkg/metrics/metrics.go b/pkg/metrics/metrics.go index 0737f88..4f2ebf4 100644 --- a/pkg/metrics/metrics.go +++ b/pkg/metrics/metrics.go @@ -16,6 +16,7 @@ var ( err error ) +// InitMetrics - register metrics in prometheus lib and start func for monitor func InitMetrics() { prometheus.MustRegister(runnersGauge) prometheus.MustRegister(runnersOrganizationGauge) diff --git a/pkg/metrics/workflows_cache.go b/pkg/metrics/workflows_cache.go index f0de935..cbd2dd1 100644 --- a/pkg/metrics/workflows_cache.go +++ b/pkg/metrics/workflows_cache.go @@ -15,6 +15,7 @@ var ( workflows map[string]map[int64]github.Workflow ) +// workflowCache - used for limit calls to github api func workflowCache() { for { ww := make(map[string]map[int64]github.Workflow) diff --git a/pkg/server/routes.go b/pkg/server/routes.go index 6f46043..7f7d7be 100644 --- a/pkg/server/routes.go +++ b/pkg/server/routes.go @@ -18,6 +18,7 @@ var ( index = fasthttpadaptor.NewFastHTTPHandlerFunc(pprof.Index) ) +// prometheusHandler - fastHTTP handler for prometheus metrics func prometheusHandler() fasthttp.RequestHandler { return fasthttpadaptor.NewFastHTTPHandler(promhttp.Handler()) } diff --git a/pkg/server/server.go b/pkg/server/server.go index 1783cc9..2a9f3c7 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -12,6 +12,7 @@ import ( "github-actions-exporter/pkg/metrics" ) +// RunServer - run http server for expose metrics func RunServer(ctx *cli.Context) error { metrics.InitMetrics()