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
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
module github.com/containeroo/never

go 1.24.2
go 1.24.4

toolchain go1.24.5

require (
github.com/containeroo/dynflags v0.1.1
github.com/containeroo/httputils v0.0.1
github.com/containeroo/resolver v0.1.0
github.com/spf13/pflag v1.0.7
github.com/containeroo/tinyflags v0.0.26
github.com/stretchr/testify v1.10.0
golang.org/x/net v0.42.0
golang.org/x/sync v0.16.0
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
github.com/containeroo/dynflags v0.1.1 h1:p6039AhBuKjfeylNwQwlQVsCEgufJDgFncrtCQmrjKE=
github.com/containeroo/dynflags v0.1.1/go.mod h1:YmSfpL9trViFWdXOz+RUXQMTFiUBkcOeVajzoh+rMVw=
github.com/containeroo/httputils v0.0.1 h1:W9SbW6nbmnGgaEOXRH5nY9ZwLarBo3+FLUCx6EtS2mc=
github.com/containeroo/httputils v0.0.1/go.mod h1:TrmDptapH6SBe6CeHFWY2kxy63O/9ZWBWrLKpc2SFjI=
github.com/containeroo/resolver v0.1.0 h1:2QGuMeY9H1T6GE53zPCnM3Zgpp/4XtGjN0eBSR8epSs=
github.com/containeroo/resolver v0.1.0/go.mod h1:98QSZmbWP7A2YR2EU2SJZe34iFPKh2SDI9zJr2vO+Z8=
github.com/containeroo/tinyflags v0.0.26 h1:iEDu1sl5I13zgqYK6E6eKDVfNR7uldps38lpBqdTjD4=
github.com/containeroo/tinyflags v0.0.26/go.mod h1:eiIeqRE1uTvO0n4oVkA27oQuKVBj46Rm+TiuNv5lT60=
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/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
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/spf13/pflag v1.0.7 h1:vN6T9TfwStFPFM5XzjsvmzZkLuaLX+HS+0SeFLRgU6M=
github.com/spf13/pflag v1.0.7/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs=
Expand Down
13 changes: 8 additions & 5 deletions internal/app/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import (
"os/signal"
"syscall"

"github.com/containeroo/never/internal/config"
"github.com/containeroo/never/internal/factory"
"github.com/containeroo/never/internal/flag"
"github.com/containeroo/never/internal/logging"
"github.com/containeroo/never/internal/wait"
"github.com/containeroo/tinyflags"
"golang.org/x/sync/errgroup"
)

Expand All @@ -23,16 +24,18 @@ func Run(ctx context.Context, version string, args []string, output io.Writer) e
defer cancel()

// Parse command-line flags
parsedFlags, err := config.ParseFlags(args, version)
flags, err := flag.ParseFlags(args, version)
if err != nil {
if config.IsHelpRequested(err, output) {
return nil
if tinyflags.IsHelpRequested(err) || tinyflags.IsVersionRequested(err) {
fmt.Fprint(output, err.Error()) // nolint:errcheck
os.Exit(0)
}

return fmt.Errorf("configuration error: %w", err)
}

// Initialize target checkers
checkers, err := factory.BuildCheckers(parsedFlags.DynFlags, parsedFlags.DefaultCheckInterval)
checkers, err := factory.BuildCheckers(flags.DynamicGroups, flags.DefaultCheckInterval)
if err != nil {
return fmt.Errorf("failed to initialize target checkers: %w", err)
}
Expand Down
23 changes: 2 additions & 21 deletions internal/app/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func TestRunConfigErrorUnsupportedCheckType(t *testing.T) {
err := Run(ctx, version, args, &output)

assert.Error(t, err)
assert.EqualError(t, err, "configuration error: flag parsing error: unknown flag: --target.unsupported.name")
assert.EqualError(t, err, "configuration error: unknown dynamic group: target")
}

func TestRunConfigErrorInvalidHeaders(t *testing.T) {
Expand Down Expand Up @@ -149,24 +149,5 @@ func TestRunParseError(t *testing.T) {
err := Run(ctx, version, args, &output)

assert.Error(t, err)
assert.EqualError(t, err, "configuration error: flag parsing error: unknown flag: --invalid")
}

func TestRunShowVersion(t *testing.T) {
t.Parallel()

args := []string{
"--http.invalidheaders.name=TestService",
"--http.invalidheaders.address=http://localhost:8080",
"--version",
}

ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()

var output bytes.Buffer

err := Run(ctx, version, args, &output)

assert.NoError(t, err)
assert.EqualError(t, err, "configuration error: unknown flag: --invalid")
}
187 changes: 0 additions & 187 deletions internal/config/config.go

This file was deleted.

Loading
Loading