Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
check:
name: Check
runs-on: ubuntu-latest
container: golangci/golangci-lint:v1.64.8
container: golangci/golangci-lint:v2.11.4
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -135,14 +135,19 @@ jobs:
env:
TAG_IMAGE_LATEST: "true"
REF_NAME: "${{ github.ref_name }}"
PROD_IMAGE_NAME: ghcr.io/${GITHUB_REPOSITORY}
#PROD_IMAGE_NAME: ghcr.io/${GITHUB_REPOSITORY}
# needs: [check, unit-test, integration-test-cli, integration-test-k8s, helm-chart-test]
needs: [check, unit-test, integration-test-cli, helm-chart-test]
name: Tagged release images
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Downcase REPO name
run: |
echo "PROD_IMAGE_NAME=ghcr.io/${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV
id: downcase_repo

- name: Extract tag
shell: bash
run: echo "tag=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/tags/}}" >> $GITHUB_OUTPUT
Expand Down
33 changes: 2 additions & 31 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
version: 2

run:
timeout: 3m
build-tags:
Expand All @@ -7,35 +9,4 @@ run:
linters:
enable:
- misspell
- goimports
- revive
- gofmt
- depguard
- godot

linters-settings:
depguard:
rules:
main:
#list-mode: lax # allow unless explicitely denied
files:
- $all
- "!$test"
allow:
- $gostd
- github.com/OpenSLO/oslo
- github.com/VictoriaMetrics/metricsql
- github.com/go-playground/validator
- github.com/oklog/run
- github.com/ostrovok-tech
- github.com/prometheus
- github.com/sirupsen/logrus
- github.com/slok/reload
- github.com/spotahome/kooper
- github.com/traefik
- k8s.io/api/core/v1
- k8s.io/apimachinery
- k8s.io/client-go
- gopkg.in/yaml.v2
- gopkg.in/alecthomas/kingpin.v2
deny: []
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [0.18.0] - 2025-04-24
### Changed
- Update to **Go 1.25.0**.
- `docker/dev/Dockerfile` update **golang** to **1.25.0**.
- `docker/prod/Dockerfile` update **golang** to **1.25.0-alpine**.
- All mentions of `ostrovok-tech` were changed to `emergingtravel`.
- Update `golangci-lint` up to `2.11.4`.
- Disable `revive` and `depguard` linters.

### Fixed
- Pipeline error if repo name is not lowercased.
- Fix appeared linter issues.

## [0.17.0] - 2025-12-03
### Added
Expand Down Expand Up @@ -73,7 +85,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Changed
- Update to **Go 1.23**.
- `docker/dev/Dockerfile` Update **golangci** to **1.60.3**, **mokery** to **2.45.0**, **gomarkdoc** to **1.1.0**.
- Retarget URLs and imports from [slok/sloth](https://github.com/slok/sloth/tree/main) to [ostrovok-tech/sloth](https://github.com/ostrovok-tech/sloth) repository.
- Retarget URLs and imports from [slok/sloth](https://github.com/slok/sloth/tree/main) to [emergingtravel/sloth](https://github.com/emergingtravel/sloth) repository.
- `CI` actions updated, docker build version changed.

## [v0.11.0] - 2022-10-22
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
</p>

# Sloth
[![Apache 2 licensed](https://img.shields.io/badge/license-Apache2-blue.svg)](https://raw.githubusercontent.com/ostrovok-tech/sloth/main/LICENSE)
[![CI](https://github.com/ostrovok-tech/sloth/actions/workflows/ci.yaml/badge.svg?branch=main)](https://github.com/ostrovok-tech/sloth/actions/workflows/ci.yaml)
[![Go Report Card](https://goreportcard.com/badge/github.com/ostrovok-tech/sloth)](https://goreportcard.com/report/github.com/ostrovok-tech/sloth)
[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/ostrovok-tech/sloth)](https://github.com/ostrovok-tech/sloth/releases/latest)
[![Apache 2 licensed](https://img.shields.io/badge/license-Apache2-blue.svg)](https://raw.githubusercontent.com/emergingtravel/sloth/main/LICENSE)
[![CI](https://github.com/emergingtravel/sloth/actions/workflows/ci.yaml/badge.svg?branch=main)](https://github.com/emergingtravel/sloth/actions/workflows/ci.yaml)
[![Go Report Card](https://goreportcard.com/badge/github.com/emergingtravel/sloth)](https://goreportcard.com/report/github.com/emergingtravel/sloth)
[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/emergingtravel/sloth)](https://github.com/emergingtravel/sloth/releases/latest)
[![OpenSLO](https://img.shields.io/badge/OpenSLO-v1alpha-green?color=4974EA&style=flat)](https://github.com/OpenSLO/OpenSLO#slo)
<!-- ![Kubernetes release](https://img.shields.io/badge/Kubernetes-v1.25-green?logo=Kubernetes&style=flat&color=326CE5&logoColor=white) -->

Expand Down
2 changes: 1 addition & 1 deletion cmd/sloth/commands/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"gopkg.in/alecthomas/kingpin.v2"

"github.com/ostrovok-tech/sloth/internal/log"
"github.com/emergingtravel/sloth/internal/log"
)

const (
Expand Down
46 changes: 33 additions & 13 deletions cmd/sloth/commands/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ import (
prometheusmodel "github.com/prometheus/common/model"
"gopkg.in/alecthomas/kingpin.v2"

"github.com/ostrovok-tech/sloth/internal/alert"
"github.com/ostrovok-tech/sloth/internal/app/generate"
"github.com/ostrovok-tech/sloth/internal/info"
"github.com/ostrovok-tech/sloth/internal/k8sprometheus"
"github.com/ostrovok-tech/sloth/internal/log"
"github.com/ostrovok-tech/sloth/internal/openslo"
"github.com/ostrovok-tech/sloth/internal/prometheus"
kubernetesv1 "github.com/ostrovok-tech/sloth/pkg/kubernetes/api/sloth/v1"
prometheusv1 "github.com/ostrovok-tech/sloth/pkg/prometheus/api/v1"
"github.com/emergingtravel/sloth/internal/alert"
"github.com/emergingtravel/sloth/internal/app/generate"
"github.com/emergingtravel/sloth/internal/info"
"github.com/emergingtravel/sloth/internal/k8sprometheus"
"github.com/emergingtravel/sloth/internal/log"
"github.com/emergingtravel/sloth/internal/openslo"
"github.com/emergingtravel/sloth/internal/prometheus"
kubernetesv1 "github.com/emergingtravel/sloth/pkg/kubernetes/api/sloth/v1"
prometheusv1 "github.com/emergingtravel/sloth/pkg/prometheus/api/v1"
)

type generateCommand struct {
Expand Down Expand Up @@ -150,7 +150,12 @@ func (g generateCommand) Run(ctx context.Context, config RootConfig) error {
if err != nil {
return fmt.Errorf("could not open SLOs spec file: %w", err)
}
defer f.Close()
defer func(f *os.File) {
err := f.Close()
if err != nil {
logger.Errorf("could not close SLOs spec file: %w", err)
}
}(f)

slxData, err := io.ReadAll(f)
if err != nil {
Expand All @@ -167,7 +172,12 @@ func (g generateCommand) Run(ctx context.Context, config RootConfig) error {
if err != nil {
return fmt.Errorf("could not create out file: %w", err)
}
defer f.Close()
defer func(f *os.File) {
err := f.Close()
if err != nil {
logger.Errorf("could not close out file: %w", err)
}
}(f)
out = outFile
}
for _, s := range splittedSLOsData {
Expand Down Expand Up @@ -208,7 +218,12 @@ func (g generateCommand) Run(ctx context.Context, config RootConfig) error {
if err != nil {
return fmt.Errorf("could not open SLOs spec file: %w", err)
}
defer f.Close()
defer func(f *os.File) {
err := f.Close()
if err != nil {
logger.Errorf("could not close SLOs spec file: %w", err)
}
}(f)

slxData, err := io.ReadAll(f)
if err != nil {
Expand All @@ -230,7 +245,12 @@ func (g generateCommand) Run(ctx context.Context, config RootConfig) error {
if err != nil {
return fmt.Errorf("could not create out file: %w", err)
}
defer outFile.Close()
defer func(outFile *os.File) {
err := outFile.Close()
if err != nil {
logger.Errorf("could not close out file: %w", err)
}
}(outFile)

// Split YAMLs in case we have multiple yaml files in a single file.
splittedSLOsData := splitYAML(slxData)
Expand Down
4 changes: 2 additions & 2 deletions cmd/sloth/commands/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"regexp"
"strings"

"github.com/ostrovok-tech/sloth/internal/log"
"github.com/ostrovok-tech/sloth/internal/prometheus"
"github.com/emergingtravel/sloth/internal/log"
"github.com/emergingtravel/sloth/internal/prometheus"
)

var (
Expand Down
18 changes: 9 additions & 9 deletions cmd/sloth/commands/k8scontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ import (
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/util/homedir"

"github.com/ostrovok-tech/sloth/internal/alert"
"github.com/ostrovok-tech/sloth/internal/app/generate"
"github.com/ostrovok-tech/sloth/internal/app/kubecontroller"
"github.com/ostrovok-tech/sloth/internal/k8sprometheus"
"github.com/ostrovok-tech/sloth/internal/log"
"github.com/ostrovok-tech/sloth/internal/prometheus"
slothv1 "github.com/ostrovok-tech/sloth/pkg/kubernetes/api/sloth/v1"
slothclientset "github.com/ostrovok-tech/sloth/pkg/kubernetes/gen/clientset/versioned"
"github.com/emergingtravel/sloth/internal/alert"
"github.com/emergingtravel/sloth/internal/app/generate"
"github.com/emergingtravel/sloth/internal/app/kubecontroller"
"github.com/emergingtravel/sloth/internal/k8sprometheus"
"github.com/emergingtravel/sloth/internal/log"
"github.com/emergingtravel/sloth/internal/prometheus"
slothv1 "github.com/emergingtravel/sloth/pkg/kubernetes/api/sloth/v1"
slothclientset "github.com/emergingtravel/sloth/pkg/kubernetes/gen/clientset/versioned"
)

var controllerModes = []string{controllerModeDefault, controllerModeDryRun, controllerModeFake}
Expand Down Expand Up @@ -464,7 +464,7 @@ type kooperlogger struct {
}

func (k kooperlogger) WithKV(kv kooperlog.KV) kooperlog.Logger {
return kooperlogger{Logger: k.Logger.WithValues(log.Kv(kv))}
return kooperlogger{Logger: k.WithValues(log.Kv(kv))}
}

// generatorLogger is app service generator logger that will set the info messages as debug,
Expand Down
22 changes: 11 additions & 11 deletions cmd/sloth/commands/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import (
prometheusmodel "github.com/prometheus/common/model"
"gopkg.in/alecthomas/kingpin.v2"

"github.com/ostrovok-tech/sloth/internal/alert"
"github.com/ostrovok-tech/sloth/internal/k8sprometheus"
"github.com/ostrovok-tech/sloth/internal/log"
"github.com/ostrovok-tech/sloth/internal/openslo"
"github.com/ostrovok-tech/sloth/internal/prometheus"
"github.com/emergingtravel/sloth/internal/alert"
"github.com/emergingtravel/sloth/internal/k8sprometheus"
"github.com/emergingtravel/sloth/internal/log"
"github.com/emergingtravel/sloth/internal/openslo"
"github.com/emergingtravel/sloth/internal/prometheus"
)

type validateCommand struct {
Expand Down Expand Up @@ -152,12 +152,12 @@ func (v validateCommand) Run(ctx context.Context, config RootConfig) error {
if promErr == nil {
err := gen.GeneratePrometheus(ctx, *slos, io.Discard)
if err != nil {
validation.Errs = []error{fmt.Errorf("Could not generate Prometheus format rules: %w", err)}
validation.Errs = []error{fmt.Errorf("could not generate Prometheus format rules: %w", err)}
}
continue
}

validation.Errs = []error{fmt.Errorf("Tried loading raw prometheus SLOs spec, it couldn't: %w", promErr)}
validation.Errs = []error{fmt.Errorf("tried loading raw prometheus SLOs spec, it couldn't: %w", promErr)}

case kubeYAMLLoader.IsSpecType(ctx, dataB):
sloGroup, k8sErr := kubeYAMLLoader.LoadSpec(ctx, dataB)
Expand All @@ -169,22 +169,22 @@ func (v validateCommand) Run(ctx context.Context, config RootConfig) error {
continue
}

validation.Errs = []error{fmt.Errorf("Tried loading Kubernetes prometheus SLOs spec, it couldn't: %w", k8sErr)}
validation.Errs = []error{fmt.Errorf("tried loading Kubernetes prometheus SLOs spec, it couldn't: %w", k8sErr)}

case openSLOYAMLLoader.IsSpecType(ctx, dataB):
slos, openSLOErr := openSLOYAMLLoader.LoadSpec(ctx, dataB)
if openSLOErr == nil {
err := gen.GenerateOpenSLO(ctx, *slos, io.Discard)
if err != nil {
validation.Errs = []error{fmt.Errorf("Could not generate OpenSLO format rules: %w", err)}
validation.Errs = []error{fmt.Errorf("could not generate OpenSLO format rules: %w", err)}
}
continue
}

validation.Errs = []error{fmt.Errorf("Tried loading OpenSLO SLOs spec, it couldn't: %s", openSLOErr)}
validation.Errs = []error{fmt.Errorf("tried loading OpenSLO SLOs spec, it couldn't: %s", openSLOErr)}

default:
validation.Errs = []error{fmt.Errorf("Unknown spec type")}
validation.Errs = []error{fmt.Errorf("unknown spec type")}
}
}

Expand Down
7 changes: 5 additions & 2 deletions cmd/sloth/commands/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"gopkg.in/alecthomas/kingpin.v2"

"github.com/ostrovok-tech/sloth/internal/info"
"github.com/emergingtravel/sloth/internal/info"
)

type versionCommand struct{}
Expand All @@ -24,6 +24,9 @@ func (versionCommand) Name() string {
}

func (versionCommand) Run(_ context.Context, config RootConfig) error {
fmt.Fprintf(config.Stdout, "%s\n", info.Version)
_, err := fmt.Fprintf(config.Stdout, "%s\n", info.Version)
if err != nil {
return err
}
return nil
}
8 changes: 4 additions & 4 deletions cmd/sloth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (
"github.com/sirupsen/logrus"
"gopkg.in/alecthomas/kingpin.v2"

"github.com/ostrovok-tech/sloth/cmd/sloth/commands"
"github.com/ostrovok-tech/sloth/internal/info"
"github.com/ostrovok-tech/sloth/internal/log"
loglogrus "github.com/ostrovok-tech/sloth/internal/log/logrus"
"github.com/emergingtravel/sloth/cmd/sloth/commands"
"github.com/emergingtravel/sloth/internal/info"
"github.com/emergingtravel/sloth/internal/log"
loglogrus "github.com/emergingtravel/sloth/internal/log/logrus"
)

// Run runs the main application.
Expand Down
2 changes: 1 addition & 1 deletion deploy/kubernetes/helm/sloth/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ apiVersion: v2
name: sloth
description: Base chart for Sloth.
type: application
home: https://github.com/ostrovok-tech/sloth
home: https://github.com/emergingtravel/sloth
kubeVersion: ">= 1.19.0-0"
version: 0.8.2
2 changes: 1 addition & 1 deletion deploy/kubernetes/helm/sloth/tests/go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/ostrovok-tech/sloth/helm
module github.com/emergingtravel/sloth/helm

go 1.25.0

Expand Down
4 changes: 2 additions & 2 deletions docker/dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM golang:1.24.1
FROM golang:1.25.0

LABEL org.opencontainers.image.source https://github.com/ostrovok-tech/sloth
LABEL org.opencontainers.image.source https://github.com/emergingtravel/sloth

ARG GOLANGCI_LINT_VERSION="1.60.3"
ARG MOCKERY_VERSION="2.45.0"
Expand Down
6 changes: 3 additions & 3 deletions docker/prod/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Set also `ALPINE_ARCH` ARG here so we can use it on all the `FROM`s.
ARG ALPINE_ARCH

FROM golang:1.24.1-alpine as build-stage
FROM golang:1.25.0-alpine as build-stage

# hadolint global ignore=DL3018
RUN apk --no-cache add g++ git make curl bash tree
Expand All @@ -26,8 +26,8 @@ FROM ${ALPINE_ARCH}/alpine:3.14

ARG REF_NAME

LABEL org.opencontainers.image.source="https://github.com/ostrovok-tech/sloth"
LABEL org.opencontainers.image.description="Images of Sloth fork from https://github.com/ostrovok-tech/sloth"
LABEL org.opencontainers.image.source="https://github.com/emergingtravel/sloth"
LABEL org.opencontainers.image.description="Images of Sloth fork from https://github.com/emergingtravel/sloth"
LABEL org.opencontainers.image.licenses="Apache-2.0"
LABEL org.opencontainers.image.ref.name="${REF_NAME}"

Expand Down
2 changes: 1 addition & 1 deletion examples/_gen/getting-started.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

---
# Code generated by Sloth (dev): https://github.com/ostrovok-tech/sloth.
# Code generated by Sloth (dev): https://github.com/emergingtravel/sloth.
# DO NOT EDIT.

groups:
Expand Down
Loading
Loading