Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Uptimedog/Agent
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.1.0
Choose a base ref
...
head repository: Uptimedog/Agent
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Loading
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github: # clivern
custom: buymeacoffee.com/clivern
custom: clivern.com/sponsor
7 changes: 4 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -10,12 +10,13 @@ jobs:
strategy:
fail-fast: false
matrix:
go: ["1.17", "1.18", "1.18.1", "1.19"]
go: ["1.19", "1.20.4", "1.21.3"]

name: Go ${{ matrix.go }} run
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}

9 changes: 4 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -10,20 +10,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: 1.17
go-version: 1.20.4

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAP_GITHUB_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }}
7 changes: 4 additions & 3 deletions .github/workflows/release_package.yml
Original file line number Diff line number Diff line change
@@ -10,13 +10,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: 1.17
go-version: 1.20.4

- name: Update checksum database
run: |
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.17
1.20.4
51 changes: 31 additions & 20 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,45 @@
# Make sure to check the documentation at http://goreleaser.com
---
archives:
- replacements:
'386': i386
amd64: x86_64
darwin: Darwin
linux: Linux
windows: Windows
files:
- LICENSE
- README.md
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
before:
hooks:
- go mod download
- go generate ./...
- "go mod download"
- "go mod tidy"
- "go generate ./..."
builds:
- env:
- CGO_ENABLED=0
goarch:
- amd64
goos:
- linux
- darwin
- windows
- darwin

archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of uname.
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
format: zip
files:
- LICENSE
- README.md
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
sort: asc
checksum:
name_template: checksums.txt
snapshot:
name_template: '{{ .Tag }}-next'
project_name: agent
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<img alt="Agent Logo" src="/assets/logo.png" height="120" />
<img alt="Agent Logo" src="logo.png" height="120" />
<h3 align="center">Uptimedog Agent</h3>
<p align="center">
<a href="https://github.com/Uptimedog/Agent/actions/workflows/build.yml">
16 changes: 0 additions & 16 deletions agent_test.go

This file was deleted.

Binary file removed assets/logo.png
Binary file not shown.
4 changes: 2 additions & 2 deletions bin/release
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# Fetch latest version
export LATEST_VERSION=$(curl --silent "https://api.github.com/repos/spacewalkio/agent/releases/latest" | jq '.tag_name' | sed -E 's/.*"([^"]+)".*/\1/')
export LATEST_VERSION=$(curl --silent "https://api.github.com/repos/Uptimedog/Agent/releases/latest" | jq '.tag_name' | sed -E 's/.*"([^"]+)".*/\1/')

# Update go checksum database (sum.golang.org) immediately after release
curl --silent https://sum.golang.org/lookup/github.com/spacewalkio/agent@{$LATEST_VERSION}
curl --silent https://sum.golang.org/lookup/github.com/Uptimedog/Agent@{$LATEST_VERSION}
12 changes: 12 additions & 0 deletions cache/os-release
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
NAME="Ubuntu"
VERSION="20.04.5 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.5 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
Empty file added core/module/.gitkeep
Empty file.
5 changes: 5 additions & 0 deletions core/service/linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Copyright 2020 Uptimedog. All rights reserved.
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.

package service
98 changes: 98 additions & 0 deletions core/service/os_release.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
// Copyright 2020 Uptimedog. All rights reserved.
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.

package service

import (
"errors"
"os"

envparse "github.com/hashicorp/go-envparse"
)

const (
// etcOSRelease path
etcOSRelease = "/etc/os-release"
// usrLibOSRelease path
usrLibOSRelease = "/usr/lib/os-release"
)

// OsRelease types
type OsRelease struct {
Name string
ID string
IDLike string
PrettyName string
Variant string
VariantID string
Version string
VersionID string
VersionCodename string
BuildID string
ImageID string
ImageVersion string
}

// GetOsRelease gets OsRelease instance
func GetOsRelease(paths []string) (*OsRelease, error) {

if len(paths) == 0 {
paths = []string{etcOSRelease, usrLibOSRelease}
}

release := &OsRelease{}
err := release.parse(paths)

return release, err
}

// parse parses the OS release file
func (o *OsRelease) parse(paths []string) error {

for _, path := range paths {

if o.Name != "" {
return nil
}

releaseFile, err := os.Open(path)

if err != nil {
return err
}

defer releaseFile.Close()

_, err = releaseFile.Stat()

if err != nil {
return err
}

env, err := envparse.Parse(releaseFile)

if err != nil {
return err
}

o.Name = env["NAME"]
o.ID = env["ID"]
o.IDLike = env["ID_LIKE"]
o.PrettyName = env["PRETTY_NAME"]
o.Variant = env["VARIANT"]
o.VariantID = env["VARIANT_ID"]
o.Version = env["VERSION"]
o.VersionID = env["VERSION_ID"]
o.VersionCodename = env["VERSION_CODENAME"]
o.BuildID = env["BUILD_ID"]
o.ImageID = env["IMAGE_ID"]
o.ImageVersion = env["IMAGE_VERSION"]
}

if o.Name == "" {
return errors.New("could parse os release files")
}

return nil
}
38 changes: 38 additions & 0 deletions core/service/os_release_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2022 Clivern. All rights reserved.
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.

package service

import (
"fmt"
"testing"

"github.com/uptimedog/agent/pkg"

"github.com/franela/goblin"
)

// TestUnitOsRelease
func TestUnitOsRelease(t *testing.T) {
g := goblin.Goblin(t)

g.Describe("#OsRelease", func() {
g.It("It should satisfy test cases", func() {
path := fmt.Sprintf(
"%s/cache/os-release",
pkg.GetBaseDir("cache"),
)

result, err := GetOsRelease([]string{path})

g.Assert(result.Name).Equal("Ubuntu")
g.Assert(err).Equal(nil)

result, err = GetOsRelease([]string{"/etc/not-found"})

g.Assert(result.Name).Equal("")
g.Assert(err.Error()).Equal("open /etc/not-found: no such file or directory")
})
})
}
5 changes: 5 additions & 0 deletions core/service/platform.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Copyright 2020 Uptimedog. All rights reserved.
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.

package service
Empty file added core/util/.gitkeep
Empty file.
10 changes: 6 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
module github.com/uptimedog/agent

go 1.17
go 1.20

require (
github.com/sirupsen/logrus v1.9.0
github.com/spf13/cobra v1.5.0
github.com/franela/goblin v0.0.0-20211003143422-0a4f594942bf
github.com/hashicorp/go-envparse v0.1.0
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.8.0
)

require (
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
)
22 changes: 13 additions & 9 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/franela/goblin v0.0.0-20211003143422-0a4f594942bf h1:NrF81UtW8gG2LBGkXFQFqlfNnvMt9WdB46sfdJY4oqc=
github.com/franela/goblin v0.0.0-20211003143422-0a4f594942bf/go.mod h1:VzmDKDJVZI3aJmnRI9VjAn9nJ8qPPsN1fqzr9dqInIo=
github.com/hashicorp/go-envparse v0.1.0 h1:bE++6bhIsNCPLvgDZkYqo3nA+/PFI51pkrHdmPSDFPY=
github.com/hashicorp/go-envparse v0.1.0/go.mod h1:OHheN1GoygLlAkTlXLXvAdnXdZxy8JUweQ1rAXx1xnc=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU=
github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
@@ -19,6 +23,6 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Binary file added logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading