diff --git a/.commitlintrc.js b/.commitlintrc.js deleted file mode 100644 index 3347cb9..0000000 --- a/.commitlintrc.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = {extends: ['@commitlint/config-conventional']}; diff --git a/.dagger/.gitattributes b/.dagger/.gitattributes deleted file mode 100644 index 3a45493..0000000 --- a/.dagger/.gitattributes +++ /dev/null @@ -1,4 +0,0 @@ -/dagger.gen.go linguist-generated -/internal/dagger/** linguist-generated -/internal/querybuilder/** linguist-generated -/internal/telemetry/** linguist-generated diff --git a/.dagger/.gitignore b/.dagger/.gitignore deleted file mode 100644 index 773338b..0000000 --- a/.dagger/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -/dagger.gen.go -/internal/dagger -/internal/querybuilder -/internal/telemetry -/.env diff --git a/.dagger/build.go b/.dagger/build.go deleted file mode 100644 index 5abb126..0000000 --- a/.dagger/build.go +++ /dev/null @@ -1,93 +0,0 @@ -package main - -import ( - "context" - "errors" - "fmt" - "strings" - "sync" - "time" - - "dagger/simplelogin-cli/internal/dagger" - - cplatforms "github.com/containerd/platforms" - "github.com/juli3nk/go-utils/ci" -) - -// Build container images -func (m *SimpleloginCli) Build( - // +optional - version string, -) (*SimpleloginCli, error) { - platformSpecifiers := []string{ - "linux/amd64", - } - platforms, err := cplatforms.ParseAll(platformSpecifiers) - if err != nil { - return nil, err - } - - appVersion := ci.ResolveVersion(version, m.Git.Tag, m.Git.Commit, m.Git.Uncommitted) - goAppVersionPkgPath := fmt.Sprintf("%s/pkg/version", appSourceUrl) - tsNow := time.Now() - - goBuildPackages := []string{"./cmd/simplelogin-cli/"} - goBuildLdflags := []string{ - fmt.Sprintf("-X %s.Version=%s", goAppVersionPkgPath, appVersion), - fmt.Sprintf("-X %s.GitCommit=%s", goAppVersionPkgPath, m.Git.Commit), - fmt.Sprintf("-X %s.BuildDate=%d", goAppVersionPkgPath, tsNow.Unix()), - } - - var wg sync.WaitGroup - errorsChan := make(chan error, len(platforms)) - - for _, platform := range platforms { - wg.Add(1) - go func(platform cplatforms.Platform) { - defer wg.Done() - - opts := dagger.GoBuildOpts{ - CgoEnabled: "1", - Ldflags: goBuildLdflags, - Musl: true, - Arch: platform.Architecture, - Os: platform.OS, - } - goBuilder := dag.Go(goVersion, m.Worktree).Build(appName, goBuildPackages, opts) - - m.Files = append(m.Files, goBuilder) - errorsChan <- nil - }(platform) - } - - wg.Wait() - close(errorsChan) - - var buildErrors []error - for err := range errorsChan { - if err != nil { - buildErrors = append(buildErrors, err) - } - } - - if len(buildErrors) > 0 { - return nil, fmt.Errorf("build failed: %w", errors.Join(buildErrors...)) - } - - return m, nil -} - -func (m *SimpleloginCli) Stdout(ctx context.Context) (string, error) { - outputs := []string{} - - for _, file := range m.Files { - name, err := file.Name(ctx) - if err != nil { - return "", err - } - - outputs = append(outputs, name) - } - - return strings.Join(outputs, "\n"), nil -} diff --git a/.dagger/ci.go b/.dagger/ci.go deleted file mode 100644 index 69c5482..0000000 --- a/.dagger/ci.go +++ /dev/null @@ -1,17 +0,0 @@ -package main - -import ( - "context" - - "dagger/simplelogin-cli/internal/dagger" -) - -// Lint commit messages -func (m *SimpleloginCli) LintCommitMsg( - ctx context.Context, - args []string, -) (string, error) { - return dag.Commitlint(). - Lint(m.Worktree, dagger.CommitlintLintOpts{Args: args}). - Stdout(ctx) -} diff --git a/.dagger/format.go b/.dagger/format.go deleted file mode 100644 index 1a3347f..0000000 --- a/.dagger/format.go +++ /dev/null @@ -1,30 +0,0 @@ -package main - -import ( - "context" - "log" - - "dagger/simplelogin-cli/internal/dagger" - - "github.com/juli3nk/go-utils/filedir" -) - -// Format Golang files -func (m *SimpleloginCli) FormatGo( - ctx context.Context, - checkOnlyModifiedFiles bool, -) (string, error) { - opts := dagger.GoFmtOpts{} - - if checkOnlyModifiedFiles { - files := filedir.FilterFileByExtension(m.Git.ModifiedFiles, "go") - if len(files) == 0 { - log.Println("No modified Go files to lint.") - return "", nil - } - - opts.Filedir = files - } - - return dag.Go(goVersion, m.Worktree).Fmt(ctx, opts) -} diff --git a/.dagger/go.mod b/.dagger/go.mod deleted file mode 100644 index f74b64e..0000000 --- a/.dagger/go.mod +++ /dev/null @@ -1,60 +0,0 @@ -module dagger/simplelogin-cli - -go 1.24.6 - -require ( - github.com/99designs/gqlgen v0.17.75 - github.com/Khan/genqlient v0.8.1 - github.com/containerd/platforms v0.2.1 - github.com/juli3nk/go-utils v0.0.0-20250227104410-da0fdcd45243 - github.com/vektah/gqlparser/v2 v2.5.28 - go.opentelemetry.io/otel v1.36.0 - go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.12.2 - go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.12.2 - go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.32.0 - go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.32.0 - go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.32.0 - go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.32.0 - go.opentelemetry.io/otel/log v0.12.2 - go.opentelemetry.io/otel/metric v1.36.0 - go.opentelemetry.io/otel/sdk v1.36.0 - go.opentelemetry.io/otel/sdk/log v0.12.2 - go.opentelemetry.io/otel/sdk/metric v1.36.0 - go.opentelemetry.io/otel/trace v1.36.0 - go.opentelemetry.io/proto/otlp v1.6.0 - golang.org/x/sync v0.15.0 - google.golang.org/grpc v1.73.0 -) - -require ( - github.com/containerd/log v0.1.0 // indirect - github.com/opencontainers/go-digest v1.0.0 // indirect - github.com/opencontainers/image-spec v1.1.1 // indirect - github.com/sirupsen/logrus v1.9.3 // indirect -) - -require ( - github.com/cenkalti/backoff/v4 v4.3.0 // indirect - github.com/cenkalti/backoff/v5 v5.0.2 // indirect - github.com/go-logr/logr v1.4.2 // indirect - github.com/go-logr/stdr v1.2.2 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 // indirect - github.com/sosodev/duration v1.3.1 // indirect - go.opentelemetry.io/auto/sdk v1.1.0 // indirect - go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.32.0 // indirect - golang.org/x/net v0.41.0 // indirect - golang.org/x/sys v0.33.0 // indirect - golang.org/x/text v0.26.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20250519155744-55703ea1f237 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250519155744-55703ea1f237 // indirect - google.golang.org/protobuf v1.36.6 // indirect -) - -replace go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc => go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.12.2 - -replace go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp => go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.12.2 - -replace go.opentelemetry.io/otel/log => go.opentelemetry.io/otel/log v0.12.2 - -replace go.opentelemetry.io/otel/sdk/log => go.opentelemetry.io/otel/sdk/log v0.12.2 diff --git a/.dagger/go.sum b/.dagger/go.sum deleted file mode 100644 index 94bf713..0000000 --- a/.dagger/go.sum +++ /dev/null @@ -1,107 +0,0 @@ -github.com/99designs/gqlgen v0.17.75 h1:GwHJsptXWLHeY7JO8b7YueUI4w9Pom6wJTICosDtQuI= -github.com/99designs/gqlgen v0.17.75/go.mod h1:p7gbTpdnHyl70hmSpM8XG8GiKwmCv+T5zkdY8U8bLog= -github.com/Khan/genqlient v0.8.1 h1:wtOCc8N9rNynRLXN3k3CnfzheCUNKBcvXmVv5zt6WCs= -github.com/Khan/genqlient v0.8.1/go.mod h1:R2G6DzjBvCbhjsEajfRjbWdVglSH/73kSivC9TLWVjU= -github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= -github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= -github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= -github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= -github.com/cenkalti/backoff/v5 v5.0.2 h1:rIfFVxEf1QsI7E1ZHfp/B4DF/6QBAUhmgkxc0H7Zss8= -github.com/cenkalti/backoff/v5 v5.0.2/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw= -github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= -github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= -github.com/containerd/platforms v0.2.1 h1:zvwtM3rz2YHPQsF2CHYM8+KtB5dvhISiXh5ZpSBQv6A= -github.com/containerd/platforms v0.2.1/go.mod h1:XHCb+2/hzowdiut9rkudds9bE5yJ7npe7dG/wG+uFPw= -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/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= -github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= -github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= -github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= -github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 h1:5ZPtiqj0JL5oKWmcsq4VMaAW5ukBEgSGXEN89zeH1Jo= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3/go.mod h1:ndYquD05frm2vACXE1nsccT4oJzjhw2arTS2cpUD1PI= -github.com/juli3nk/go-utils v0.0.0-20250227104410-da0fdcd45243 h1:f4NoZ3godH2bkiuYvn99m8Z3sIda2bcCS8wueAVQ9Lk= -github.com/juli3nk/go-utils v0.0.0-20250227104410-da0fdcd45243/go.mod h1:B274D7iAr87jTS11XNlSPJGxp8Aj71KTRn+gG5pZjnk= -github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= -github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= -github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040= -github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M= -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/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= -github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= -github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= -github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/sosodev/duration v1.3.1 h1:qtHBDMQ6lvMQsL15g4aopM4HEfOaYuhWBw3NPTtlqq4= -github.com/sosodev/duration v1.3.1/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= -github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/vektah/gqlparser/v2 v2.5.28 h1:bIulcl3LF69ba6EiZVGD88y4MkM+Jxrf3P2MX8xLRkY= -github.com/vektah/gqlparser/v2 v2.5.28/go.mod h1:D1/VCZtV3LPnQrcPBeR/q5jkSQIPti0uYCP/RI0gIeo= -go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= -go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= -go.opentelemetry.io/otel v1.36.0 h1:UumtzIklRBY6cI/lllNZlALOF5nNIzJVb16APdvgTXg= -go.opentelemetry.io/otel v1.36.0/go.mod h1:/TcFMXYjyRNh8khOAO9ybYkqaDBb/70aVwkNML4pP8E= -go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.12.2 h1:06ZeJRe5BnYXceSM9Vya83XXVaNGe3H1QqsvqRANQq8= -go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.12.2/go.mod h1:DvPtKE63knkDVP88qpatBj81JxN+w1bqfVbsbCbj1WY= -go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.12.2 h1:tPLwQlXbJ8NSOfZc4OkgU5h2A38M4c9kfHSVc4PFQGs= -go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.12.2/go.mod h1:QTnxBwT/1rBIgAG1goq6xMydfYOBKU6KTiYF4fp5zL8= -go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.32.0 h1:j7ZSD+5yn+lo3sGV69nW04rRR0jhYnBwjuX3r0HvnK0= -go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.32.0/go.mod h1:WXbYJTUaZXAbYd8lbgGuvih0yuCfOFC5RJoYnoLcGz8= -go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.32.0 h1:t/Qur3vKSkUCcDVaSumWF2PKHt85pc7fRvFuoVT8qFU= -go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.32.0/go.mod h1:Rl61tySSdcOJWoEgYZVtmnKdA0GeKrSqkHC1t+91CH8= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.32.0 h1:IJFEoHiytixx8cMiVAO+GmHR6Frwu+u5Ur8njpFO6Ac= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.32.0/go.mod h1:3rHrKNtLIoS0oZwkY2vxi+oJcwFRWdtUyRII+so45p8= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.32.0 h1:9kV11HXBHZAvuPUZxmMWrH8hZn/6UnHX4K0mu36vNsU= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.32.0/go.mod h1:JyA0FHXe22E1NeNiHmVp7kFHglnexDQ7uRWDiiJ1hKQ= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.32.0 h1:cMyu9O88joYEaI47CnQkxO1XZdpoTF9fEnW2duIddhw= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.32.0/go.mod h1:6Am3rn7P9TVVeXYG+wtcGE7IE1tsQ+bP3AuWcKt/gOI= -go.opentelemetry.io/otel/log v0.12.2 h1:yob9JVHn2ZY24byZeaXpTVoPS6l+UrrxmxmPKohXTwc= -go.opentelemetry.io/otel/log v0.12.2/go.mod h1:ShIItIxSYxufUMt+1H5a2wbckGli3/iCfuEbVZi/98E= -go.opentelemetry.io/otel/metric v1.36.0 h1:MoWPKVhQvJ+eeXWHFBOPoBOi20jh6Iq2CcCREuTYufE= -go.opentelemetry.io/otel/metric v1.36.0/go.mod h1:zC7Ks+yeyJt4xig9DEw9kuUFe5C3zLbVjV2PzT6qzbs= -go.opentelemetry.io/otel/sdk v1.36.0 h1:b6SYIuLRs88ztox4EyrvRti80uXIFy+Sqzoh9kFULbs= -go.opentelemetry.io/otel/sdk v1.36.0/go.mod h1:+lC+mTgD+MUWfjJubi2vvXWcVxyr9rmlshZni72pXeY= -go.opentelemetry.io/otel/sdk/log v0.12.2 h1:yNoETvTByVKi7wHvYS6HMcZrN5hFLD7I++1xIZ/k6W0= -go.opentelemetry.io/otel/sdk/log v0.12.2/go.mod h1:DcpdmUXHJgSqN/dh+XMWa7Vf89u9ap0/AAk/XGLnEzY= -go.opentelemetry.io/otel/sdk/log/logtest v0.0.0-20250521073539-a85ae98dcedc h1:uqxdywfHqqCl6LmZzI3pUnXT1RGFYyUgxj0AkWPFxi0= -go.opentelemetry.io/otel/sdk/log/logtest v0.0.0-20250521073539-a85ae98dcedc/go.mod h1:TY/N/FT7dmFrP/r5ym3g0yysP1DefqGpAZr4f82P0dE= -go.opentelemetry.io/otel/sdk/metric v1.36.0 h1:r0ntwwGosWGaa0CrSt8cuNuTcccMXERFwHX4dThiPis= -go.opentelemetry.io/otel/sdk/metric v1.36.0/go.mod h1:qTNOhFDfKRwX0yXOqJYegL5WRaW376QbB7P4Pb0qva4= -go.opentelemetry.io/otel/trace v1.36.0 h1:ahxWNuqZjpdiFAyrIoQ4GIiAIhxAunQR6MUoKrsNd4w= -go.opentelemetry.io/otel/trace v1.36.0/go.mod h1:gQ+OnDZzrybY4k4seLzPAWNwVBBVlF2szhehOBB/tGA= -go.opentelemetry.io/proto/otlp v1.6.0 h1:jQjP+AQyTf+Fe7OKj/MfkDrmK4MNVtw2NpXsf9fefDI= -go.opentelemetry.io/proto/otlp v1.6.0/go.mod h1:cicgGehlFuNdgZkcALOCh3VE6K/u2tAjzlRhDwmVpZc= -go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= -go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= -golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw= -golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA= -golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8= -golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= -golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= -golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M= -golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA= -google.golang.org/genproto/googleapis/api v0.0.0-20250519155744-55703ea1f237 h1:Kog3KlB4xevJlAcbbbzPfRG0+X9fdoGM+UBRKVz6Wr0= -google.golang.org/genproto/googleapis/api v0.0.0-20250519155744-55703ea1f237/go.mod h1:ezi0AVyMKDWy5xAncvjLWH7UcLBB5n7y2fQ8MzjJcto= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250519155744-55703ea1f237 h1:cJfm9zPbe1e873mHJzmQ1nwVEeRDU/T1wXDK2kUSU34= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250519155744-55703ea1f237/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= -google.golang.org/grpc v1.73.0 h1:VIWSmpI2MegBtTuFt5/JWy2oXxtjJ/e89Z70ImfD2ok= -google.golang.org/grpc v1.73.0/go.mod h1:50sbHOUqWoCQGI8V2HQLJM0B+LMlIUjNSZmow7EVBQc= -google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= -google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -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= diff --git a/.dagger/lint.go b/.dagger/lint.go deleted file mode 100644 index e62b396..0000000 --- a/.dagger/lint.go +++ /dev/null @@ -1,48 +0,0 @@ -package main - -import ( - "context" - "log" - - "dagger/simplelogin-cli/internal/dagger" - - "github.com/juli3nk/go-utils/filedir" -) - -// Lint Golang files -func (m *SimpleloginCli) LintGolang( - ctx context.Context, - checkOnlyModifiedFiles bool, -) (string, error) { - opts := dagger.GoLintOpts{} - - if checkOnlyModifiedFiles { - files := filedir.FilterFileByExtension(m.Git.ModifiedFiles, "go") - if len(files) == 0 { - log.Println("No modified Go files to lint.") - return "", nil - } - opts.Filedir = files - } - - return dag.Go(goVersion, m.Worktree).Lint(ctx, opts) -} - -// Lint JSON files -func (m *SimpleloginCli) LintJsonFile( - ctx context.Context, - checkOnlyModifiedFiles bool, -) (string, error) { - opts := dagger.JsonfileLintOpts{} - - if checkOnlyModifiedFiles { - files := filedir.FilterFileByExtension(m.Git.ModifiedFiles, "json") - if len(files) == 0 { - log.Println("No modified JSON files to lint.") - return "", nil - } - opts.Filedir = files - } - - return dag.Jsonfile().Lint(ctx, m.Worktree, opts) -} diff --git a/.dagger/main.go b/.dagger/main.go deleted file mode 100644 index b13ade3..0000000 --- a/.dagger/main.go +++ /dev/null @@ -1,68 +0,0 @@ -package main - -import ( - "context" - "fmt" - - "dagger/simplelogin-cli/internal/dagger" -) - -const ( - appName = "simplelogin-cli" - appSourceUrl = "github.com/juli3nk/simplelogin-cli" -) - -type Git struct { - Commit string - Tag string - Uncommitted bool - ModifiedFiles []string -} - -type SimpleloginCli struct { - Worktree *dagger.Directory - Git *Git - Files []*dagger.File -} - -func fetchGitInfo(ctx context.Context, source *dagger.Directory) (*Git, error) { - git := dag.Gitlocal(source) - - commit, err := git.GetLatestCommit(ctx) - if err != nil { - return nil, fmt.Errorf("failed to get latest commit: %w", err) - } - tag, err := git.GetLatestTag(ctx) - if err != nil { - return nil, fmt.Errorf("failed to get latest tag: %w", err) - } - uncommitted, err := git.Uncommitted(ctx) - if err != nil { - return nil, fmt.Errorf("failed to check uncommitted changes: %w", err) - } - modifiedFiles, err := git.GetModifiedFiles(ctx, false) - if err != nil { - return nil, fmt.Errorf("failed to get modified files: %w", err) - } - - return &Git{ - Commit: commit, - Tag: tag, - Uncommitted: uncommitted, - ModifiedFiles: modifiedFiles, - }, nil -} - -func New( - ctx context.Context, - source *dagger.Directory, -) (*SimpleloginCli, error) { - git, err := fetchGitInfo(ctx, source) - if err != nil { - return nil, err - } - - app := SimpleloginCli{Worktree: source, Git: git} - - return &app, nil -} diff --git a/.dagger/publish.go b/.dagger/publish.go deleted file mode 100644 index cf37930..0000000 --- a/.dagger/publish.go +++ /dev/null @@ -1,36 +0,0 @@ -package main - -import ( - "context" - "fmt" - "net/url" - - "dagger/simplelogin-cli/internal/dagger" -) - -// Publish the containers to registry -func (m *SimpleloginCli) Publish( - ctx context.Context, - Token *dagger.Secret, -) error { - if len(m.Files) == 0 { - return fmt.Errorf("error: build files first") - } - - url, err := url.Parse(appSourceUrl) - if err != nil { - return fmt.Errorf("error: failed to parse app source url: %w", err) - } - - opts := dagger.GhReleaseCreateOpts{ - GenerateNotes: true, - Files: m.Files, - VerifyTag: true, - Repo: url.Path, - Token: Token, - } - - err = dag.Gh().Release().Create(ctx, m.Git.Tag, m.Git.Tag, opts) - - return err -} diff --git a/.dagger/release.go b/.dagger/release.go deleted file mode 100644 index 8739625..0000000 --- a/.dagger/release.go +++ /dev/null @@ -1,38 +0,0 @@ -package main - -import ( - "context" - - "dagger/simplelogin-cli/internal/dagger" -) - -// Release triggers a semantic release process for a repository -func (m *SimpleloginCli) Release( - ctx context.Context, - githubToken *dagger.Secret, - // +optional - repositoryUrl string, - // +optional - // +default=false - dryRun bool, - // +optional - // +default=false - ci bool, - // +optional - // +default=false - debugMode bool, -) (string, error) { - opts := dagger.SemanticReleaseRunOpts{ - DryRun: dryRun, - Ci: ci, - DebugMode: debugMode, - } - - if repositoryUrl != "" { - opts.RepositoryURL = repositoryUrl - } - - secretEnvVarName := "GITHUB_TOKEN" - - return dag.SemanticRelease().Run(ctx, m.Worktree, secretEnvVarName, githubToken, opts) -} diff --git a/.dagger/versions.go b/.dagger/versions.go deleted file mode 100644 index 5cd535f..0000000 --- a/.dagger/versions.go +++ /dev/null @@ -1,6 +0,0 @@ -package main - -const ( - alpineVersion = "3.20" - goVersion = "1.24" -) diff --git a/.devcontainer-lock.json b/.devcontainer-lock.json new file mode 100644 index 0000000..5edfae5 --- /dev/null +++ b/.devcontainer-lock.json @@ -0,0 +1,19 @@ +{ + "features": { + "ghcr.io/devcontainers-extra/features/asdf-package:1": { + "version": "1.0.10", + "resolved": "ghcr.io/devcontainers-extra/features/asdf-package@sha256:109f8d310417ee982eb6fb89bfe027a0353f2b9aea010a3019d6efd3f7ffc284", + "integrity": "sha256:109f8d310417ee982eb6fb89bfe027a0353f2b9aea010a3019d6efd3f7ffc284" + }, + "ghcr.io/devcontainers/features/docker-outside-of-docker:1": { + "version": "1.10.0", + "resolved": "ghcr.io/devcontainers/features/docker-outside-of-docker@sha256:c2c2cf829505ead8e4892c88c31b6594ae94a2bbb209e16e1fac456c1a3a624e", + "integrity": "sha256:c2c2cf829505ead8e4892c88c31b6594ae94a2bbb209e16e1fac456c1a3a624e" + }, + "ghcr.io/devcontainers/features/go:1": { + "version": "1.3.4", + "resolved": "ghcr.io/devcontainers/features/go@sha256:d85e921f91b41340055bb12b325d9d551170ed04b3b832e33530bf42f167c032", + "integrity": "sha256:d85e921f91b41340055bb12b325d9d551170ed04b3b832e33530bf42f167c032" + } + } +} diff --git a/.devcontainer.json b/.devcontainer.json index 743c76c..bf5aab2 100644 --- a/.devcontainer.json +++ b/.devcontainer.json @@ -6,15 +6,15 @@ "dockerDashComposeVersion": "none" }, "ghcr.io/devcontainers/features/go:1": { - "version": "1.24" + "version": "1.26" }, "ghcr.io/devcontainers-extra/features/asdf-package:1": { "plugin": "dagger", - "version": "0.18.16" + "version": "0.21.8" } }, "containerEnv": { "DAGGER_NO_NAG": "1" }, - "workspaceMount": "type=bind,source=${localWorkspaceFolder},target=${containerWorkspaceFolder}" + "workspaceMount": "type=bind,source=${localWorkspaceFolder},target=${containerWorkspaceFolder}" } diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5b05b9d..02aedb6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -4,72 +4,132 @@ on: push: branches: - develop + pull_request: + branches: + - develop + +env: + DAGGER_NO_NAG: "1" jobs: - ci: + changes: runs-on: ubuntu-latest permissions: contents: read - env: - DAGGER_NO_NAG: "1" + outputs: + refs_base: ${{ steps.git-change-refs.outputs.base_ref }} + refs_head: ${{ steps.git-change-refs.outputs.head_ref }} + files_all: ${{ steps.files.outputs.all }} + files_md: ${{ steps.files.outputs.md }} + files_go: ${{ steps.files.outputs.go }} + files_yaml: ${{ steps.files.outputs.yaml }} + files_json: ${{ steps.files.outputs.json }} steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v7 + with: + fetch-depth: 0 + + - name: Resolve git range + id: git-change-refs + uses: juli3nk/ci-context@main - - name: Call Dagger Function to lint commit message - uses: dagger/dagger-for-github@8.0.0 + - name: Detect changed files + id: git-changed-files + uses: dagger/dagger-for-github@v8.4.1 with: - call: --source . lint-commit-msg --args '--last' + call: gitlocal changed-files --base-ref=${{ steps.git-change-refs.outputs.base_ref }} --head-ref="${{ steps.git-change-refs.outputs.head_ref }}" --ext="md" --ext="go" --ext="yaml:yaml" --ext="yaml:yml" --ext="json" github-output - lint: + - name: Export changed files outputs + id: files + run: | + echo '${{ steps.git-changed-files.outputs.output }}' >> "$GITHUB_OUTPUT" + + git-checks: + needs: changes runs-on: ubuntu-latest - needs: [ci] permissions: contents: read - env: - DAGGER_NO_NAG: "1" steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v7 + with: + fetch-depth: 0 - - name: Call Dagger Function to lint go files - uses: dagger/dagger-for-github@8.0.0 + - name: Lint commits + uses: dagger/dagger-for-github@v8.4.1 with: - call: --source . lint-golang --check-only-modified-files=true + call: commitlint lint --from ${{ needs.changes.outputs.refs_base }} --to ${{ needs.changes.outputs.refs_head }} --default-config - - name: Call Dagger Function to lint json files - uses: dagger/dagger-for-github@8.0.0 + - name: Scan for secrets + uses: dagger/dagger-for-github@v8.4.1 with: - call: --source . lint-json-file --check-only-modified-files=true + verb: check + args: gitleaks:detect + + lint: + needs: [changes, git-checks] + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Checkout + uses: actions/checkout@v7 + + - name: Install Dagger + uses: dagger/dagger-for-github@v8.4.1 + + - name: Lint Markdown + if: ${{ fromJSON(needs.changes.outputs.files_md)[0] != null }} + run: | + dagger call markdown lint --paths-json='${{ needs.changes.outputs.files_md }}' - format: + - name: Lint JSON + if: ${{ fromJSON(needs.changes.outputs.files_json)[0] != null }} + run: | + dagger call jsonfile lint --paths-json='${{ needs.changes.outputs.files_json }}' + + - name: Lint Go + if: ${{ fromJSON(needs.changes.outputs.files_go)[0] != null }} + run: | + dagger call go lint --paths-json='${{ needs.changes.outputs.files_go }}' + + - name: Check Go formatting + if: ${{ fromJSON(needs.changes.outputs.files_go)[0] != null }} + run: | + dagger call go fmt --paths-json='${{ needs.changes.outputs.files_go }}' + + deps: + needs: [changes, git-checks] + if: ${{ fromJSON(needs.changes.outputs.files_go)[0] != null }} runs-on: ubuntu-latest - needs: [ci] permissions: contents: read - env: - DAGGER_NO_NAG: "1" steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v7 + + - name: Verify Go modules + uses: dagger/dagger-for-github@v8.4.1 + with: + verb: check + args: go:modcheck - - name: Call Dagger Function to format go files - uses: dagger/dagger-for-github@8.0.0 + - name: Scan vulnerabilities + uses: dagger/dagger-for-github@v8.4.1 with: - call: --source . format-go --check-only-modified-files=true + call: go vuln-check build: + needs: [lint, deps] runs-on: ubuntu-latest - needs: [ci, lint, format] permissions: contents: read - env: - DAGGER_NO_NAG: "1" steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v7 - - name: Call Dagger Function to build - uses: dagger/dagger-for-github@8.0.0 + - name: Build + uses: dagger/dagger-for-github@v8.4.1 with: - call: --source . build stdout + call: goreleaser build stdout diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 1bd48cb..2d6c950 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -5,41 +5,32 @@ on: branches: - main +env: + DAGGER_NO_NAG: "1" + jobs: release: runs-on: ubuntu-latest permissions: contents: write - env: - DAGGER_NO_NAG: "1" - outputs: - tag: ${{ steps.get_tag.outputs.tag }} steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v7 - name: Call Dagger Function to release - uses: dagger/dagger-for-github@8.0.0 + uses: dagger/dagger-for-github@v8.4.1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - call: --source . release --github-token env:GITHUB_TOKEN --ci=true --dry-run=false - - - name: Set Output Tag - id: get_tag - run: | - git fetch --tags --force - echo "tag=$(git describe --tags --abbrev=0)" >> "$GITHUB_OUTPUT" + call: semantic-release run --repo-token-env GITHUB_TOKEN --repo-token env:GITHUB_TOKEN --ci=true --dry-run=false publish: + needs: release runs-on: ubuntu-latest - needs: [release] permissions: contents: write - env: - DAGGER_NO_NAG: "1" steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v7 with: ref: ${{ needs.release.outputs.tag }} fetch-depth: 0 @@ -47,6 +38,6 @@ jobs: - name: Call Dagger Function to build and push env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - uses: dagger/dagger-for-github@8.0.0 + uses: dagger/dagger-for-github@v8.4.1 with: - call: --source . build publish --token env:GITHUB_TOKEN + call: goreleaser release --token-env GITHUB_TOKEN --token env:GITHUB_TOKEN diff --git a/.gitignore b/.gitignore index e660fd9..a5d8f72 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ bin/ +dist/ diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..aede010 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,17 @@ +version: 2 + +project_name: simplelogin-cli + +builds: + - id: simplelogin-cli + main: ./cmd/simplelogin-cli + binary: ./simplelogin-cli + env: + - CGO_ENABLED=0 + ldflags: + - -s + - -w + goos: + - linux + goarch: + - amd64 diff --git a/command/alias/list.go b/command/alias/list.go index 2a97b7b..bf04e8c 100644 --- a/command/alias/list.go +++ b/command/alias/list.go @@ -40,6 +40,8 @@ func newListCommand(outputFormat *string) *cobra.Command { flags.BoolVarP(&aliasListEnabled, "enabled", "e", false, "Enabled aliases") flags.StringVarP(&aliasListQuery, "query", "q", "", "Query aliases") + cmd.MarkFlagsMutuallyExclusive("pinned", "disabled", "enabled") + return cmd } diff --git a/dagger.json b/dagger.json index bcc43c6..df4e3f2 100644 --- a/dagger.json +++ b/dagger.json @@ -1,40 +1,46 @@ { "name": "simplelogin-cli", - "engineVersion": "v0.18.16", - "sdk": { - "source": "go" - }, - "dependencies": [ + "engineVersion": "v0.21.8", + "toolchains": [ { "name": "commitlint", - "source": "github.com/cloudnative-pg/daggerverse/commitlint", - "pin": "6b024d94e8661e87ede84039fd2e3e256dc08fb6" + "source": "github.com/juli3nk/daggerverse/commitlint@main", + "pin": "06374bd5978d6e512b29a4bd30270c08d02b613c" }, { - "name": "gh", - "source": "github.com/sagikazarmark/daggerverse/gh", - "pin": "ceffda4aebd349a24fc00e591b4ed9b801535b65" + "name": "gitleaks", + "source": "github.com/juli3nk/daggerverse/gitleaks@main", + "pin": "06374bd5978d6e512b29a4bd30270c08d02b613c" }, { "name": "gitlocal", - "source": "github.com/juli3nk/daggerverse/gitlocal", - "pin": "13251b94e0cc875b6ea663dcf5e7375f206a0296" + "source": "github.com/juli3nk/daggerverse/gitlocal@main", + "pin": "06374bd5978d6e512b29a4bd30270c08d02b613c" }, { "name": "go", - "source": "github.com/juli3nk/daggerverse/go", - "pin": "13251b94e0cc875b6ea663dcf5e7375f206a0296" + "source": "github.com/juli3nk/daggerverse/go@main", + "pin": "06374bd5978d6e512b29a4bd30270c08d02b613c" + }, + { + "name": "goreleaser", + "source": "github.com/juli3nk/daggerverse/goreleaser@main", + "pin": "06374bd5978d6e512b29a4bd30270c08d02b613c" }, { "name": "jsonfile", - "source": "github.com/juli3nk/daggerverse/jsonfile", - "pin": "13251b94e0cc875b6ea663dcf5e7375f206a0296" + "source": "github.com/juli3nk/daggerverse/jsonfile@main", + "pin": "06374bd5978d6e512b29a4bd30270c08d02b613c" + }, + { + "name": "markdown", + "source": "github.com/juli3nk/daggerverse/markdown@main", + "pin": "06374bd5978d6e512b29a4bd30270c08d02b613c" }, { "name": "semantic-release", - "source": "github.com/juli3nk/daggerverse/semantic-release", - "pin": "13251b94e0cc875b6ea663dcf5e7375f206a0296" + "source": "github.com/juli3nk/daggerverse/semantic-release@main", + "pin": "06374bd5978d6e512b29a4bd30270c08d02b613c" } - ], - "source": ".dagger" + ] } diff --git a/go.mod b/go.mod index 8cdbd33..aad5d57 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/juli3nk/simplelogin-cli -go 1.24.5 +go 1.26.7 require ( github.com/go-playground/validator/v10 v10.27.0 @@ -21,8 +21,8 @@ require ( github.com/leodido/go-urn v1.4.0 // indirect github.com/mattn/go-runewidth v0.0.9 // indirect github.com/spf13/pflag v1.0.6 // indirect - golang.org/x/crypto v0.33.0 // indirect - golang.org/x/net v0.34.0 // indirect - golang.org/x/sys v0.30.0 // indirect + golang.org/x/crypto v0.36.0 // indirect + golang.org/x/net v0.38.0 // indirect + golang.org/x/sys v0.31.0 // indirect golang.org/x/text v0.28.0 // indirect ) diff --git a/go.sum b/go.sum index 6fa4249..421a4d1 100644 --- a/go.sum +++ b/go.sum @@ -42,12 +42,12 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/zalando/go-keyring v0.2.6 h1:r7Yc3+H+Ux0+M72zacZoItR3UDxeWfKTcabvkI8ua9s= github.com/zalando/go-keyring v0.2.6/go.mod h1:2TCrxYrbUNYfNS/Kgy/LSrkSQzZ5UPVH85RwfczwvcI= -golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus= -golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M= -golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0= -golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k= -golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= -golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= +golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= +golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8= +golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= +golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= +golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng= golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/pkg/simplelogin/auth.go b/pkg/simplelogin/auth.go index 56b5039..377ced9 100644 --- a/pkg/simplelogin/auth.go +++ b/pkg/simplelogin/auth.go @@ -4,7 +4,9 @@ import ( "bytes" "encoding/json" "fmt" + "io" "net/http" + "time" ) // LoginRequest represents the login request payload @@ -21,7 +23,9 @@ type LoginResponse struct { // Login authenticates a user and returns an API key func Login(email, password, device string) (string, error) { - client := &http.Client{} + client := &http.Client{ + Timeout: 30 * time.Second, + } data := LoginRequest{ Email: email, @@ -41,7 +45,7 @@ func Login(email, password, device string) (string, error) { defer resp.Body.Close() if resp.StatusCode != http.StatusOK { - body, _ := json.Marshal(resp.Body) + body, _ := io.ReadAll(resp.Body) return "", fmt.Errorf("login failed (status %d): %s", resp.StatusCode, string(body)) }