Skip to content

Commit

Permalink
fix: rename check to client
Browse files Browse the repository at this point in the history
Signed-off-by: Eray Ates <eates23@gmail.com>
  • Loading branch information
rytsh committed Sep 17, 2022
1 parent 57f9f0c commit c7f15fa
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ builds:
- CGO_ENABLED=0
goos:
- linux
# - windows
# - darwin
- windows
- darwin
main: ./cmd/pong
ldflags:
- -s -w -X main.version={{.Version}} -X main.commit={{.ShortCommit}} -X main.date={{.Date}}
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Give a json or yaml file with the following structure:
# LogLevel is the log level, default info
log_level: "debug"

check:
client:
rest:
- concurrent: 1
check:
Expand Down Expand Up @@ -62,7 +62,7 @@ Example of playbook
```yaml
- name: Check image exists
pong:
check:
client:
rest:
- concurrent: 1
check:
Expand Down
16 changes: 8 additions & 8 deletions internal/load/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ func ReadConfig(file string) (*model.ModuleArgs, error) {
}

func defaultArgs(args *model.ModuleArgs) {
for i := range args.Check.Rest {
if args.Check.Rest[i].Concurrent == 0 {
args.Check.Rest[i].Concurrent = model.DefaultRestClient.Concurrent
for i := range args.Client.Rest {
if args.Client.Rest[i].Concurrent == 0 {
args.Client.Rest[i].Concurrent = model.DefaultRestClient.Concurrent
}
for j := range args.Check.Rest[i].Check {
if args.Check.Rest[i].Check[j].Method == "" {
args.Check.Rest[i].Check[j].Method = model.DefaultRestCheck.Method
for j := range args.Client.Rest[i].Check {
if args.Client.Rest[i].Check[j].Method == "" {
args.Client.Rest[i].Check[j].Method = model.DefaultRestCheck.Method
}
if args.Check.Rest[i].Check[j].Status == 0 {
args.Check.Rest[i].Check[j].Status = model.DefaultRestCheck.Status
if args.Client.Rest[i].Check[j].Status == 0 {
args.Client.Rest[i].Check[j].Status = model.DefaultRestCheck.Status
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions internal/model/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ type RestClient struct {
Check []RestCheck `json:"check" yaml:"check"`
}

type Check struct {
type Client struct {
Rest []RestClient `json:"rest" yaml:"rest"`
}

type ModuleArgs struct {
Check Check `json:"check" yaml:"check"`
Client Client `json:"client" yaml:"client"`
// LogLevel is the log level, default info
LogLevel string `json:"log_level" yaml:"log_level"`
}
Expand Down
2 changes: 1 addition & 1 deletion internal/route/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func Request(ctx context.Context, args *model.ModuleArgs) []error {

// call rest requests
wg.Add(1)
go RestRequest(ctx, wg, errs, args.Check.Rest)
go RestRequest(ctx, wg, errs, args.Client.Rest)

wg.Wait()

Expand Down
2 changes: 1 addition & 1 deletion testdata/ansible/roles/imagecheck/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

- name: Check image exists
pong:
check:
client:
rest:
- concurrent: 1
check:
Expand Down
2 changes: 1 addition & 1 deletion testdata/test.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
log_level: "warn"
check:
client:
rest:
- concurrent: 5
check:
Expand Down

0 comments on commit c7f15fa

Please sign in to comment.