Skip to content

Commit

Permalink
Merge branch 'NETDEV-1189/underlying-interface' into 'anx-prod'
Browse files Browse the repository at this point in the history
update anx-prod from upstream and fix ci

See merge request neteng/junos_exporter!4
  • Loading branch information
Jakob Gastinger committed Feb 14, 2024
2 parents 53535c7 + 45cc0a8 commit eb29055
Show file tree
Hide file tree
Showing 33 changed files with 902 additions and 821 deletions.
45 changes: 22 additions & 23 deletions .github/workflows/anx-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,29 @@ on:

name: anx-ci
jobs:
# test:
# # if: github.repository == ‘anexia/junos_exporter’
# strategy:
# matrix:
# go-version: [1.18.x]
# platform: [ubuntu-latest, macos-latest, windows-latest]
# runs-on: ${{ matrix.platform }}
# steps:
# - name: Install Go
# if: success()
# uses: actions/setup-go@v3
# with:
# go-version: ${{ matrix.go-version }}
# - name: Checkout code
# uses: actions/checkout@v3
# - name: Build
# run: go build
# - name: Run tests
# run: go test ./... -v -covermode=count
test:
strategy:
matrix:
go-version: ["1.21.x"]
platform: [ubuntu-latest, macos-latest, windows-latest, ubuntu-20.04]
runs-on: ${{ matrix.platform }}
steps:
- name: Install Go
if: success()
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v3
- name: Build
run: go build
- name: Run tests
run: go test ./... -v -covermode=count

publish:
# if: github.repository == ‘anexia/junos_exporter’
# needs: test
runs-on: ubuntu-latest
needs: test
runs-on: ubuntu-20.04

env:
S3_URL: ${{ vars.S3_URL }}
S3_BUCKET: ${{ vars.S3_BUCKET }}
Expand All @@ -44,7 +43,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.21

- name: Build
run: go build .
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.20"
go-version: "1.21"

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
test:
strategy:
matrix:
go-version: ["1.20.x"]
go-version: ["1.21.x"]
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ config.yml
artifacts
config/tests/config_local.yml
.vscode*
notes.txt
notes.txt
.DS_Store/
2 changes: 2 additions & 0 deletions collectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/czerwonk/junos_exporter/pkg/features/rpki"
"github.com/czerwonk/junos_exporter/pkg/features/rpm"
"github.com/czerwonk/junos_exporter/pkg/features/security"
"github.com/czerwonk/junos_exporter/pkg/features/securityike"
"github.com/czerwonk/junos_exporter/pkg/features/securitypolicies"
"github.com/czerwonk/junos_exporter/pkg/features/storage"
"github.com/czerwonk/junos_exporter/pkg/features/subscriber"
Expand Down Expand Up @@ -105,6 +106,7 @@ func (c *collectors) initCollectorsForDevices(device *connector.Device) {
c.addCollectorIfEnabledForDevice(device, "rpki", f.RPKI, rpki.NewCollector)
c.addCollectorIfEnabledForDevice(device, "rpm", f.RPM, rpm.NewCollector)
c.addCollectorIfEnabledForDevice(device, "security", f.Security, security.NewCollector)
c.addCollectorIfEnabledForDevice(device, "security_ike", f.SecurityIKE, securityike.NewCollector)
c.addCollectorIfEnabledForDevice(device, "security_policies", f.SecurityPolicies, securitypolicies.NewCollector)
c.addCollectorIfEnabledForDevice(device, "storage", f.Storage, storage.NewCollector)
c.addCollectorIfEnabledForDevice(device, "system", (f.System || f.License), system.NewCollector)
Expand Down
8 changes: 4 additions & 4 deletions devices.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ func authForDevice(device *config.DeviceConfig, cfg *config.Config) (connector.A
}

if device.KeyFile != "" {
return authForKeyFile(user, device.KeyFile)
return authForKeyFile(user, device.KeyFile, device.KeyPassphrase)
}

if *sshKeyFile != "" {
return authForKeyFile(user, *sshKeyFile)
return authForKeyFile(user, *sshKeyFile, *sshKeyPassphrase)
}

if device.Password != "" {
Expand All @@ -97,14 +97,14 @@ func authForDevice(device *config.DeviceConfig, cfg *config.Config) (connector.A
return nil, errors.New("no valid authentication method available")
}

func authForKeyFile(username, keyFile string) (connector.AuthMethod, error) {
func authForKeyFile(username, keyFile, keyPassphrase string) (connector.AuthMethod, error) {
f, err := os.Open(keyFile)
if err != nil {
return nil, errors.Wrap(err, "could not open ssh key file")
}
defer f.Close()

auth, err := connector.AuthByKey(username, f)
auth, err := connector.AuthByKey(username, f, keyPassphrase)
if err != nil {
return nil, errors.Wrap(err, "could not load ssh private key file")
}
Expand Down
56 changes: 29 additions & 27 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,46 +1,48 @@
module github.com/czerwonk/junos_exporter

go 1.20
go 1.21

require (
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.14.0
github.com/prometheus/client_model v0.3.0
github.com/sirupsen/logrus v1.9.0
github.com/stretchr/testify v1.8.1
go.opentelemetry.io/otel v1.12.0
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.12.0
go.opentelemetry.io/otel/sdk v1.12.0
go.opentelemetry.io/otel/trace v1.12.0
golang.org/x/crypto v0.3.0
github.com/prometheus/client_golang v1.17.0
github.com/prometheus/client_model v0.5.0
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.8.4
go.opentelemetry.io/otel v1.20.0
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.20.0
go.opentelemetry.io/otel/sdk v1.20.0
go.opentelemetry.io/otel/trace v1.20.0
golang.org/x/crypto v0.17.0
gopkg.in/yaml.v2 v2.4.0
)

require (
github.com/cenkalti/backoff/v4 v4.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.12.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/text v0.7.0 // indirect
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect
google.golang.org/grpc v1.53.0 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.1 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
go.opentelemetry.io/otel/metric v1.20.0 // indirect
golang.org/x/net v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto v0.0.0-20231106174013-bbf56f31fb17 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 // indirect
google.golang.org/grpc v1.59.0 // indirect
)

require (
github.com/beorn7/perks v1.0.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.3 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.12.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.12.0
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
golang.org/x/sys v0.5.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
github.com/prometheus/common v0.45.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.20.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.20.0
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
golang.org/x/sys v0.15.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit eb29055

Please sign in to comment.