Skip to content
This repository has been archived by the owner on Jul 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #25 from mrueg/bump-deps
Browse files Browse the repository at this point in the history
Bump dependencies
  • Loading branch information
David-VTUK authored Jun 4, 2023
2 parents da6d12b + 86a9e63 commit 8cf2d99
Show file tree
Hide file tree
Showing 10 changed files with 133 additions and 688 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-build-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19

- name: Create folder
run: mkdir ./bin/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19

- name: Run Go tests
run: |
Expand Down
5 changes: 3 additions & 2 deletions collector/collector.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package collector

import (
"time"

"github.com/david-vtuk/prometheus-rancher-exporter/query/rancher"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/log"
"time"
log "github.com/sirupsen/logrus"
)

type metrics struct {
Expand Down
60 changes: 26 additions & 34 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,53 +1,45 @@
module github.com/david-vtuk/prometheus-rancher-exporter

go 1.17
go 1.19

require (
github.com/prometheus/client_golang v1.11.0
github.com/prometheus/common v0.26.0
github.com/sirupsen/logrus v1.6.0
github.com/tidwall/gjson v1.13.0
golang.org/x/mod v0.4.2
k8s.io/apimachinery v0.23.1
k8s.io/client-go v0.23.1
github.com/prometheus/client_golang v1.15.1
github.com/sirupsen/logrus v1.9.1
golang.org/x/mod v0.10.0
k8s.io/apimachinery v0.26.4
k8s.io/client-go v0.26.4
)

require (
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-logr/logr v1.2.0 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.5 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/imdario/mergo v0.3.5 // indirect
github.com/imdario/mergo v0.3.6 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.43.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
golang.org/x/net v0.0.0-20211209124913-491a49abca63 // indirect
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect
golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e // indirect
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/oauth2 v0.7.0 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/term v0.7.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/alecthomas/kingpin.v2 v2.2.6 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/klog/v2 v2.30.0 // indirect
k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b // indirect
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.1.2 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
k8s.io/klog/v2 v2.80.1 // indirect
k8s.io/utils v0.0.0-20221107191617-1a15be271d1d // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)
688 changes: 67 additions & 621 deletions go.sum

Large diffs are not rendered by default.

24 changes: 13 additions & 11 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ package main
import (
"flag"
"fmt"
"net/http"
"os"
"os/user"
"strings"

"github.com/david-vtuk/prometheus-rancher-exporter/collector"
"github.com/david-vtuk/prometheus-rancher-exporter/query/rancher"
"github.com/prometheus/client_golang/prometheus/promhttp"
log "github.com/sirupsen/logrus"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"net/http"
"os"
"os/user"
"strings"
)

const (
Expand All @@ -39,11 +40,12 @@ func main() {

if InClusterConfig {
config, err = rest.InClusterConfig()
if err != nil {
log.Fatal("Unable to construct REST client")
}

config.Burst = k8sClientBurst
config.QPS = k8sClientQPS
if err != nil {
log.Fatal("Unable to construct REST client")
}
} else {
currentUser, err := user.Current()
if err != nil {
Expand All @@ -53,13 +55,13 @@ func main() {
kubeconfig := flag.String("kubeconfig", fmt.Sprintf("/home/%s/.kube/config", currentUser.Username), "absolute path to the kubeconfig file")
flag.Parse()
config, err = clientcmd.BuildConfigFromFlags("", *kubeconfig)
if err != nil {
log.Fatal("Unable to construct Rancher client Config")
}

config.Burst = k8sClientBurst
config.QPS = k8sClientQPS

if err != nil {
log.Fatal("Unable to construct Rancher client Config")
}

}

client, err := dynamic.NewForConfig(config)
Expand Down
7 changes: 4 additions & 3 deletions query/rancher/rancherBase.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import (
"context"
"encoding/json"
"fmt"
"net"
"net/http"
"regexp"

v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/rest"
"net"
"net/http"
"regexp"
)

var (
Expand Down
9 changes: 5 additions & 4 deletions query/rancher/rancherBase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ package rancher
import (
"flag"
"fmt"
"os"
"os/user"
"reflect"
"testing"

log "github.com/sirupsen/logrus"
"golang.org/x/mod/semver"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"os"
"os/user"
"reflect"
"testing"
)

type fields struct {
Expand Down
7 changes: 4 additions & 3 deletions query/rancher/rancherExtended.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package rancher

import (
"context"
"github.com/prometheus/common/log"
"strings"
"sync"

log "github.com/sirupsen/logrus"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
"strings"
"sync"
)

var (
Expand Down
17 changes: 9 additions & 8 deletions query/rancher/rancherProjects.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package rancher

import (
"context"

"k8s.io/apimachinery/pkg/api/resource"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/api/resource"
)

var (
Expand Down Expand Up @@ -146,13 +147,13 @@ func (r Client) GetProjectResourceQuota() ([]projectResource, error) {
if projectClusterName != "" {

for key, value := range projectResourceQuotas {
var convertedValue float64
var convertedValue float64
// Convert the Quota values to base numeric value, defined by unit
quantity, err := resource.ParseQuantity(value.(string))
if err != nil {
continue
}
convertedValue = float64(quantity.Value())
convertedValue = float64(quantity.Value())

resource := projectResource{
Projectid: projectValue.GetName(),
Expand All @@ -174,13 +175,13 @@ func (r Client) GetProjectResourceQuota() ([]projectResource, error) {
}

for key, value := range projectResourceQuotas {
var convertedValue float64
// Convert the Quota values to base numeric value, defined by unit
quantity, err := resource.ParseQuantity(value.(string))
var convertedValue float64
// Convert the Quota values to base numeric value, defined by unit
quantity, err := resource.ParseQuantity(value.(string))
if err != nil {
continue
continue
}
convertedValue = float64(quantity.Value())
convertedValue = float64(quantity.Value())
resource := projectResource{
Projectid: projectValue.GetName(),
ProjectDisplayName: projectDisplayName,
Expand Down

0 comments on commit 8cf2d99

Please sign in to comment.