Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve #8

Merged
merged 3 commits into from
Jan 27, 2022
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
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.2.3
current_version = 1.3.0
commit = True
tag = True

Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Lint Dockerfile

on: push

jobs:
linter:
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v2

- name: Lint Dockerfile
uses: hadolint/hadolint-action@master
with:
dockerfile: "Dockerfile"
5 changes: 1 addition & 4 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@ on:
push:
branches:
- main
- development
- ST-*
pull_request:
branches:
- main
- development

jobs:
build:
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/golang-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: golangci-lint
on:
push:
branches:
- main
- ST-*
pull_request:

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: latest
82 changes: 82 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
run:
concurrency: 4
timeout: 1m

linters-settings:
revive:
ignore-generated-header: true
severity: warning
rules:
- name: exported
severity: warning
- name: error-return
severity: warning
- name: error-naming
severity: warning
- name: if-return
severity: warning
- name: var-naming
severity: warning
- name: var-declaration
severity: warning
- name: receiver-naming
severity: warning
- name: errorf
severity: warning
- name: empty-block
severity: warning
- name: unused-parameter
severity: warning
- name: unreachable-code
severity: warning
- name: redefines-builtin-id
severity: warning
- name: superfluous-else
severity: warning
- name: unexported-return
severity: warning
- name: indent-error-flow
severity: warning
- name: blank-imports
severity: warning
- name: range
severity: warning
- name: time-naming
severity: warning
- name: context-as-argument
severity: warning
- name: context-keys-type
severity: warning
- name: indent-error-flow
severity: warning

linters:
disable-all: true
enable:
- asciicheck
- durationcheck
- errcheck
- errorlint
- exhaustive
- gosec
- govet
- makezero
- nilerr
- rowserrcheck
- exportloopref
- sqlclosecheck
- staticcheck
- typecheck
- bodyclose
- noctx
- prealloc
- gosimple
presets:
- comment
- error
- format
- metalinter
- unused

issues:
exclude-use-default: false
11 changes: 7 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
FROM golang:1.16-alpine AS builder
WORKDIR /go/src/github.com/vigo/statoo
COPY . .
RUN apk add --no-cache git
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o statoo .
RUN apk add --no-cache git=2.34.1-r0 \
ca-certificates=20211220-r0 \
&& CGO_ENABLED=0 \
GOOS=linux \
go build -a -installsuffix cgo -o statoo .

FROM alpine:latest
RUN apk --no-cache add ca-certificates
FROM alpine:3.15
RUN apk --no-cache add
COPY --from=builder /go/src/github.com/vigo/statoo/statoo /bin/statoo
ENTRYPOINT ["/bin/statoo"]
49 changes: 27 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
![Version](https://img.shields.io/badge/version-1.2.3-orange.svg)
![Version](https://img.shields.io/badge/version-1.3.0-orange.svg)
![Go](https://img.shields.io/github/go-mod/go-version/vigo/statoo)
[![Documentation](https://godoc.org/github.com/vigo/statoo?status.svg)](https://pkg.go.dev/github.com/vigo/statoo)
[![Go Report Card](https://goreportcard.com/badge/github.com/vigo/statoo)](https://goreportcard.com/report/github.com/vigo/statoo)
[![Build Status](https://travis-ci.org/vigo/statoo.svg?branch=main)](https://travis-ci.org/vigo/statoo)
![Go Build Status](https://github.com/vigo/statoo/actions/workflows/go.yml/badge.svg)
![Test Coverage](https://img.shields.io/badge/coverage-80.2%25-orange.svg)
![GolangCI-Lint Status](https://github.com/vigo/statoo/actions/workflows/golang-lint.yml/badge.svg)
![Docker Status](https://github.com/vigo/statoo/actions/workflows/docker.yml/badge.svg)
![Test Coverage](https://img.shields.io/badge/coverage-82.6%25-orange.svg)
![Docker Pulls](https://img.shields.io/docker/pulls/vigo/statoo)
![Docker Size](https://img.shields.io/docker/image-size/vigo/statoo)

Expand Down Expand Up @@ -47,22 +49,22 @@ usage: ./statoo [-flags] URL
-version display version information (X.X.X)
-verbose verbose output (default: false)
-header request header, multiple allowed
-t, -timeout default timeout in seconds (default: 10)
-t, -timeout default timeout in seconds (default: 10, min: 1, max: 100)
-h, -help display help
-j, -json provides json output
-f, -find find text in response body if -json is set
-a, -auth basic auth "username:password"
-s, -skip skip certificate check and hostname in that certificate (default: false)

examples:

$ ./statoo "https://ugur.ozyilmazel.com"
$ ./statoo -timeout 30 "https://ugur.ozyilmazel.com"
$ ./statoo -verbose "https://ugur.ozyilmazel.com"
$ ./statoo -json https://vigo.io
$ ./statoo -json -find "python" https://vigo.io
$ ./statoo -json -find "Golang" https://vigo.io
$ ./statoo -header "Authorization: Bearer TOKEN" https://vigo.io
$ ./statoo -header "Authorization: Bearer TOKEN" -header "X-Api-Key: APIKEY" https://vigo.io
$ ./statoo -json -find "Meetup organization" https://vigo.io
$ ./statoo -auth "user:secret" https://vigo.io
```

Expand Down Expand Up @@ -92,45 +94,47 @@ response;
"status": 200,
"checked_at": "2021-05-13T18:09:26.342012Z",
"elapsed": 210.587871,
"length": 1453
"skipcc": false
}
```

- `elapsed` represents response is in milliseconds.
- `length` represents response size in bytes (*gzipped*)
`elapsed` represents response is in milliseconds.

Let’s find text inside of the response body. This feature is only available
if the `-json` flag is set!
Let’s find text inside of the response body. This feature is only available if
the `-json` flag is set! `length` represents response size in bytes
(*gzipped*) when you search something in body!

```bash
statoo -json -find "Meetup organization" https://vigo.io
statoo -json -find "Golang" https://vigo.io
```

```json
{
"url": "https://vigo.io",
"status": 200,
"checked_at": "2021-05-13T18:10:38.196705Z",
"elapsed": 183.128016,
"length": 1453,
"find": "Meetup organization",
"found": true
"checked_at": "2022-01-26T20:08:33.735768Z",
"elapsed": 242.93925,
"length": 7827,
"find": "Golang",
"found": true,
"skipcc": false
}
```

```bash
statoo -json -find "meetup organization" https://vigo.io # case sensitive
statoo -json -find "golang" https://vigo.io # case sensitive
```

```json
{
"url": "https://vigo.io",
"status": 200,
"checked_at": "2021-05-13T18:10:58.100932Z",
"elapsed": 189.403753,
"length": 1453,
"find": "meetup organization",
"found": false
"checked_at": "2022-01-26T20:14:03.487002Z",
"elapsed": 253.665083,
"length": 7827,
"find": "golang",
"found": false,
"skipcc": false
}
```

Expand Down Expand Up @@ -168,6 +172,7 @@ rake -T
rake default # show avaliable tasks (default task)
rake docker:build # Build (locally)
rake docker:build_and_push # Build and push to docker hub (latest)
rake docker:lint # Lint
rake docker:rmi # Delete image (locally)
rake docker:run # Run (locally)
rake release[revision] # Release new version major,minor,patch, default: patch
Expand Down
5 changes: 5 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ end
# docker
# -----------------------------------------------------------------------------
namespace :docker do
desc "Lint"
task :lint do
system "hadolint Dockerfile"
end

desc "Build (locally)"
task :build do
system "docker build -t statoo:latest ."
Expand Down
Loading