Compare commits

...

21 commits
v0.1.1 ... main

Author SHA1 Message Date
Winni Neessen d6ce76b1ad
Remove sudo usage for jq installation in sonarqube.yml
All checks were successful
Codecov workflow / run (push) Successful in 1m39s
golangci-lint / lint (push) Successful in 48s
REUSE Compliance Check / test (push) Successful in 4s
SonarQube / Build (push) Successful in 1m40s
The use of sudo keyword for installing 'jq' in the SonarQube workflow file, sonarqube.yml, has been removed. This change is due to the fact that the root permission is not necessary during the installation process, adhering better to the principle of least privilege.
2024-02-14 00:50:25 +01:00
Winni Neessen 072a2aed5d
Remove sudo usage for jq installation in sonarqube.yml
All checks were successful
golangci-lint / lint (push) Successful in 47s
REUSE Compliance Check / test (push) Successful in 4s
SonarQube / Build (push) Successful in 1m37s
The use of sudo keyword for installing 'jq' in the SonarQube workflow file, sonarqube.yml, has been removed. This change is due to the fact that the root permission is not necessary during the installation process, adhering better to the principle of least privilege.
2024-02-14 00:46:07 +01:00
Winni Neessen a536ac3bde
Remove sudo usage for jq installation in sonarqube.yml
Some checks failed
golangci-lint / lint (push) Successful in 47s
REUSE Compliance Check / test (push) Successful in 4s
SonarQube / Build (push) Failing after 1m12s
The use of sudo keyword for installing 'jq' in the SonarQube workflow file, sonarqube.yml, has been removed. This change is due to the fact that the root permission is not necessary during the installation process, adhering better to the principle of least privilege.
2024-02-14 00:39:16 +01:00
Winni Neessen eb675388f0
reports. Simultaneously, the installation of 'jq' has been removed from the sonarqube.yml workflow as it's no longer needed there.
Some checks failed
golangci-lint / lint (push) Successful in 48s
REUSE Compliance Check / test (push) Successful in 4s
SonarQube / Build (push) Failing after 1m12s
2024-02-14 00:36:34 +01:00
Winni Neessen e4cbab4e43
Install jq in the codecov workflow
Some checks failed
golangci-lint / lint (push) Successful in 47s
REUSE Compliance Check / test (push) Successful in 4s
SonarQube / Build (push) Failing after 1m29s
This commit adds a new step to the codecov.yml workflow. This step installs 'jq', a command-line JSON processor, which might be necessary for the processing of test results or coverage
2024-02-14 00:33:51 +01:00
Winni Neessen 8923b88e07
Simplify workflow settings and upgrade setup-go to v4
Some checks failed
REUSE Compliance Check / test (push) Successful in 4s
SonarQube / Build (push) Failing after 1m29s
golangci-lint / lint (push) Failing after 11m20s
This commit simplifies the Forgejo workflow settings by hardcoding the 'docker' and '1.22' options for the 'runs-on' and 'go-version' respectively, instead of using a matrix. The version of setup-go action is also upgraded to v4.
2024-02-13 23:33:37 +01:00
Winni Neessen 94eca2f3fe
Fix Forgejo workflows
Some checks failed
golangci-lint / lint (push) Successful in 47s
REUSE Compliance Check / test (push) Successful in 19s
SonarQube / Build (push) Failing after 1m30s
2024-02-13 22:25:23 +01:00
Winni Neessen 759300d066
Move Github workflows to Forgejo workflows
Some checks failed
REUSE Compliance Check / test (push) Waiting to run
SonarQube / Build (push) Waiting to run
golangci-lint / lint (push) Successful in 47s
Codecov workflow / run (1.20, macos-latest) (push) Has been cancelled
Codecov workflow / run (1.20, ubuntu-latest) (push) Has been cancelled
Codecov workflow / run (1.20, windows-latest) (push) Has been cancelled
2024-02-13 22:21:35 +01:00
Winni Neessen 3c69f36748
Update Go version setup in golangci-lint workflow
All checks were successful
golangci-lint / lint (push) Successful in 48s
The workflow file for golangci-lint has been updated to use the newer version of setup-go action. This change moves from version v3 to v4
2024-02-13 19:51:27 +01:00
Winni Neessen 0b88d11fdf
Update Go version setup in golangci-lint workflow
Some checks failed
golangci-lint / lint (push) Has been cancelled
The workflow file for golangci-lint has been updated to use the newer version of setup-go action. This change moves from version v3 to v4 under
2024-02-13 19:45:53 +01:00
Winni Neessen d6b551cc5e
Correct URL format in Github Actions of golangci-lint workflow
Some checks failed
golangci-lint / lint (push) Has been cancelled
The URLs in the golangci-lint workflow file have been corrected. The extraneous "https://github.com/" part of each URL has been removed in each 'uses' section to ensure the correct working of Github actions. Now, actions/setup-go@v3, actions/checkout@v3, and golangci/g
2024-02-13 19:26:11 +01:00
Winni Neessen 5297342603
Update golangci-lint workflow's 'runs-on' value
Some checks failed
golangci-lint / lint (push) Has been cancelled
The 'runs-on' value of the golangci-lint workflow file has been updated from 'ubuntu-latest' to 'docker'. This change improves the replication of the production environment conditions for linting, ensuring more accurate code quality checks.
2024-02-13 18:58:18 +01:00
Winni Neessen c3af61791e
Update golangci-lint workflow's 'runs-on' value
Some checks failed
golangci-lint / lint (push) Failing after 40s
The 'runs-on' value of the golangci-lint workflow file has been updated from 'ubuntu-latest' to 'docker'. This change improves the replication of the production environment conditions for linting, ensuring more accurate code quality checks.
2024-02-13 18:56:24 +01:00
Winni Neessen b8c117c056
Add golangci-lint workflow
Some checks are pending
golangci-lint / lint (push) Waiting to run
A new Github Actions workflow file named golangci-lint.yml has been added to the workflows directory. This will ensure that the linting tool golangci-lint is run for every push and pull request to this project, thus improving the code quality.
2024-02-13 18:55:16 +01:00
Winni Neessen 3f7cccb511 Merge pull request 'Update URLs to point to new repository domain' (#12) from switch-gh-to-forgejo into main
Reviewed-on: #12
2024-02-11 15:28:32 +01:00
Winni Neessen c9fa7eb1d7
Add mirror repository information to README
A new section called "Mirror" was added to the README.md file indicating that the Github repository is only a mirror of the main repository. The main repository is located at "https://src.neessen.cloud/wneessen/go-meteologix". This change improves project transparency and informs contributors of the primary source of the code.
2024-02-11 15:27:34 +01:00
Winni Neessen 878c4dfe71
Update URLs to point to new repository domain
The URLs in all the files that reference the old domain (github.com) have been updated to reference the new domain (src.neessen.cloud). This includes URLs in badges, links in the README.md, import paths in .go files, and module paths in go.mod and .golangci.toml.
2024-02-11 15:24:46 +01:00
Winni Neessen 27c8542f76
Merge pull request #11 from wneessen/bearer-auth
Add bearer token authentication
2023-08-02 16:13:09 +02:00
Winni Neessen a5667bb828
Add bearer token authentication
In this commit, we've added the capability to authenticate via bearer token to Meteologix's HTTP client. A new method "WithBearerToken" has been implemented, allowing a bearer token to be set in 'meteologix.go'. Additionally, in 'httpclient.go', the token is attached to the "Authorization" header for API requests. Tests asserting token setting functionality have been added in 'meteologix_test.go'. These changes open up an alternative authentication option for our API users. The bearer auth is not public yet, so there is no way for us to test this auth
2023-08-02 16:08:38 +02:00
Winni Neessen 173c6eb8ec
Update Go versions in CI workflow
Removed versions 1.18 and 1.19 from the Go matrix in the codecov.yml file. Now, CI workflow only tests for Go version '1.20'. This change simplifies the CI testing process and removes the change of running into CI failures due to rate limiting.
2023-06-28 10:23:33 +02:00
Winni Neessen a51644fbb6
Remove redundant package comment
The comment referencing bindings to the Meteologix/Kachelmann-Wetter weather API was incorrectly placed in the astroinfo.go file. This comment was irrelevant to the respective package and therefore, has been removed for accuracy and clarity.
2023-06-27 19:37:26 +02:00
12 changed files with 78 additions and 29 deletions

6
.forgejo/FUNDING.yml Normal file
View file

@ -0,0 +1,6 @@
# SPDX-FileCopyrightText: 2023 Winni Neessen <wn@neessen.dev>
#
# SPDX-License-Identifier: CC0-1.0
github: wneessen
ko_fi: winni

View file

@ -10,7 +10,7 @@ on:
paths:
- '**.go'
- 'go.*'
- '.github/**'
- '.forgejo/**'
- 'codecov.yml'
pull_request:
branches:
@ -18,29 +18,24 @@ on:
paths:
- '**.go'
- 'go.*'
- '.github/**'
- '.forgejo/**'
- 'codecov.yml'
env:
API_KEY: ${{ secrets.API_KEY }}
jobs:
run:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
go: [1.18, 1.19, '1.20']
runs-on: docker
steps:
- name: Checkout Code
uses: actions/checkout@master
- name: Setup go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}
go-version: '1.22'
- name: Run Tests
run: |
go test -v -shuffle=on -race --coverprofile=coverage.coverprofile --covermode=atomic ./...
- name: Upload coverage to Codecov
if: success() && matrix.go == '1.20' && matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos

View file

@ -17,11 +17,11 @@ permissions:
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
runs-on: docker
steps:
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: '1.20'
go-version: '1.21'
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3

View file

@ -8,7 +8,7 @@ on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
runs-on: docker
steps:
- uses: actions/checkout@v2
- name: REUSE Compliance Check

View file

@ -15,7 +15,7 @@ env:
jobs:
build:
name: Build
runs-on: ubuntu-latest
runs-on: docker
steps:
- uses: actions/checkout@v2
with:
@ -24,12 +24,16 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: '1.20.x'
go-version: '1.22'
- name: Run unit Tests
run: |
go test -v -shuffle=on -race --coverprofile=./cov.out ./...
- name: Install jq
run: |
apt-get update; apt-get -y install jq; which jq
- uses: sonarsource/sonarqube-scan-action@master
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

View file

@ -11,5 +11,5 @@ enable = ["stylecheck", "whitespace", "containedctx", "contextcheck", "decorder"
"errname", "errorlint", "gofmt", "gofumpt", "goimports"]
[linters-settings.goimports]
local-prefixes = "github.com/wneessen/go-meteologix"
local-prefixes = "src.neessen.cloud/wneessen/go-meteologix"

View file

@ -6,11 +6,11 @@ SPDX-License-Identifier: CC0-1.0
# go-meteologix - Go packages for accessing Meteologix/Kachelmann Wetter/WeatherUS data
[![GoDoc](https://godoc.org/github.com/wneessen/go-mail?status.svg)](https://pkg.go.dev/github.com/wneessen/go-meteologix)
[![GoDoc](https://godoc.org/src.neessen.cloud/wneessen/go-mail?status.svg)](https://pkg.go.dev/src.neessen.cloud/wneessen/go-meteologix)
[![codecov](https://codecov.io/gh/wneessen/go-meteologix/branch/main/graph/badge.svg?token=W4QI1RMR4L)](https://codecov.io/gh/wneessen/go-meteologix)
[![Go Report Card](https://goreportcard.com/badge/github.com/wneessen/go-meteologix)](https://goreportcard.com/report/github.com/wneessen/go-meteologix)
[![Go Report Card](https://goreportcard.com/badge/src.neessen.cloud/wneessen/go-meteologix)](https://goreportcard.com/report/src.neessen.cloud/wneessen/go-meteologix)
[![#go-meteologix on Discord](https://img.shields.io/badge/Discord-%23gometeologix-blue.svg)](https://discord.gg/TvNMuDh4pK)
[![REUSE status](https://api.reuse.software/badge/github.com/wneessen/go-meteologix)](https://api.reuse.software/info/github.com/wneessen/go-meteologix)
[![REUSE status](https://api.reuse.software/badge/src.neessen.cloud/wneessen/go-meteologix)](https://api.reuse.software/info/src.neessen.cloud/wneessen/go-meteologix)
<a href="https://ko-fi.com/D1D24V9IX"><img src="https://uploads-ssl.webflow.com/5c14e387dab576fe667689cf/5cbed8a4ae2b88347c06c923_BuyMeACoffee_blue.png" height="20" alt="buy ma a coffee"></a>
<p align="center"><img src="./assets/gopher43.svg" width="250" alt="go-meteologx logo"/></p>
@ -32,7 +32,7 @@ For Geolocation lookups, the package makes use of the
## Usage
The library is fully documented using the execellent GoDoc functionality. Check out
the [full reference on pkg.go.dev](https://pkg.go.dev/github.com/wneessen/go-hibp) for
the [full reference on pkg.go.dev](https://pkg.go.dev/src.neessen.cloud/wneessen/go-hibp) for
details.
## Examples
@ -48,7 +48,7 @@ import (
"fmt"
"os"
"github.com/wneessen/go-meteologix"
"src.neessen.cloud/wneessen/go-meteologix"
)
func main() {
@ -76,7 +76,7 @@ import (
"fmt"
"os"
"github.com/wneessen/go-meteologix"
"src.neessen.cloud/wneessen/go-meteologix"
)
func main() {
@ -106,7 +106,7 @@ import (
"math"
"os"
"github.com/wneessen/go-meteologix"
"src.neessen.cloud/wneessen/go-meteologix"
)
func main() {
@ -139,7 +139,7 @@ import (
"fmt"
"os"
"github.com/wneessen/go-meteologix"
"src.neessen.cloud/wneessen/go-meteologix"
)
func main() {
@ -158,8 +158,14 @@ func main() {
```
## Authors/Contributors
go-meteologix was authored and developed by [Winni Neessen](https://github.com/wneessen/).
go-meteologix was authored and developed by [Winni Neessen](https://src.neessen.cloud/wneessen/).
Big thanks to the following people, for contributing to the go-meteologix project
(either in form of code, reviewing code, writing documenation or contributing in any other form):
* [Maria Letta](https://github.com/MariaLetta) (designed the go-meteologix logo)
## Mirror
Please note that the repository on Github is just a mirror of
[https://src.neessen.cloud/wneessen/go-meteologix](https://src.neessen.cloud/wneessen/go-meteologix)
for ease of access and reachability.

View file

@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: MIT
// Package meteologix provides bindings to the Meteologix/Kachelmann-Wetter weather API
package meteologix
import (

2
go.mod
View file

@ -2,6 +2,6 @@
//
// SPDX-License-Identifier: MIT
module github.com/wneessen/go-meteologix
module src.neessen.cloud/wneessen/go-meteologix
go 1.20

View file

@ -133,6 +133,10 @@ func (hc *HTTPClient) setAuthentication(hr *http.Request) {
hr.Header.Set("X-API-Key", hc.Config.apiKey)
return
}
if hc.bearerToken != "" {
hr.Header.Set("Authorization", "Bearer"+hc.bearerToken)
return
}
if hc.authUser != "" && hc.authPass != "" {
hr.SetBasicAuth(url.QueryEscape(hc.authUser), url.QueryEscape(hc.authPass))
}

View file

@ -22,7 +22,7 @@ const (
// DefaultUserAgent is the default User-Agent presented by the HTTPClient
var DefaultUserAgent = fmt.Sprintf("go-meteologix/fv%s (%s; %s; "+
"+https://github.com/wneessen/go-meteologix)", VERSION, runtime.GOOS,
"+https://src.neessen.cloud/wneessen/go-meteologix)", VERSION, runtime.GOOS,
runtime.Version())
// Client represents the Meteologix API Client
@ -46,6 +46,8 @@ type Config struct {
authPass string
// authUser holds the (optional) username for the API user authentication
authUser string
// bearerToken holds the (optional) bearer token for the API authentication
bearerToken string
// userAgent represents an alternative User-Agent HTTP header string
userAgent string
}
@ -97,6 +99,17 @@ func WithAPIKey(k string) Option {
}
}
// WithBearerToken uses a bearer token for the client authentication of the
// HTTP client
func WithBearerToken(t string) Option {
if t == "" {
return nil
}
return func(co *Config) {
co.bearerToken = t
}
}
// WithPassword sets the HTTP Basic auth authPass for the HTTP client
func WithPassword(p string) Option {
if p == "" {

View file

@ -66,6 +66,28 @@ func TestNew_WithAPIKey(t *testing.T) {
}
}
func TestNew_WithBearerToken(t *testing.T) {
e := "BEARER-TOKEN"
c := New(WithBearerToken(e))
if c == nil {
t.Errorf("NewWithBearerToken failed, expected Client, got nil")
return
}
if c.config.bearerToken != e {
t.Errorf("NewWithBearerToken failed, expected token value: %s, got: %s", e,
c.config.bearerToken)
}
c = New(WithBearerToken(""))
if c == nil {
t.Errorf("NewWithBearerToken failed, expected Client, got nil")
return
}
if c.config.bearerToken != "" {
t.Errorf("NewWithBearerToken failed, expected empty token, got: %s",
c.config.bearerToken)
}
}
func TestNew_WithUsername(t *testing.T) {
e := "username"
c := New(WithUsername(e))