Skip to content

Commit 9b96040

Browse files
committed
Added ip type. Some changes for release
1 parent 742cb98 commit 9b96040

File tree

7 files changed

+72
-34
lines changed

7 files changed

+72
-34
lines changed

.github/workflows/release.yml

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,19 @@ env:
99
REGISTRY: ghcr.io
1010
IMAGE_NAME: ${{ github.repository }}
1111

12+
permissions:
13+
contents: read
14+
packages: write
15+
1216
jobs:
13-
release:
17+
release-gocli:
1418
runs-on: ubuntu-latest
15-
permissions:
16-
contents: write
17-
1819
steps:
1920
- name: Checkout code
20-
uses: actions/checkout@v3
21+
uses: actions/checkout@v4
2122

2223
- name: Setup Go
23-
uses: actions/setup-go@v4
24+
uses: actions/setup-go@v5
2425
with:
2526
go-version: 1.19
2627

@@ -30,30 +31,14 @@ jobs:
3031
- name: Build
3132
run: go build -o fake
3233

33-
- name: Create release
34-
id: create_release
35-
uses: softprops/action-gh-release@v1
36-
env:
37-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38-
with:
39-
tag_name: ${{github.ref_name}}
40-
draft: false
41-
files: |
42-
./fake
43-
./LICENSE
44-
4534
- name: Publish
4635
run: GOPROXY=proxy.golang.org go list -m github.com/${{ github.repository }}@${{ github.ref_name }}
4736

48-
build-and-push:
37+
release-docker:
4938
runs-on: ubuntu-latest
50-
permissions:
51-
contents: read
52-
packages: write
53-
5439
steps:
5540
- name: Checkout Code
56-
uses: actions/checkout@v3
41+
uses: actions/checkout@v4
5742

5843
- name: Set up QEMU
5944
uses: docker/setup-qemu-action@v2
@@ -82,3 +67,25 @@ jobs:
8267
platforms: linux/amd64,linux/arm64
8368
tags: ${{ steps.meta.outputs.tags }}
8469
labels: ${{ steps.meta.outputs.labels }}
70+
71+
release-bins:
72+
runs-on: ubuntu-latest
73+
permissions:
74+
contents: write
75+
steps:
76+
- name: Checkout
77+
uses: actions/checkout@v4
78+
with:
79+
fetch-depth: 0
80+
- name: Set up Go
81+
uses: actions/setup-go@v5
82+
with:
83+
go-version: 1.19
84+
- name: Run GoReleaser
85+
uses: goreleaser/goreleaser-action@v6
86+
with:
87+
distribution: goreleaser
88+
version: "~> v2"
89+
args: release --clean
90+
env:
91+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33

44
# ignore build
55
fake-cli
6+
7+
dist/

.goreleaser.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
version: 2
2+
3+
builds:
4+
- id: fake-cli
5+
binary: fake
6+
env:
7+
- CGO_ENABLED=0
8+
goos:
9+
- linux
10+
- windows
11+
- darwin
12+
goarch:
13+
- amd64
14+
- arm
15+
- arm64
16+
17+
sboms:
18+
- artifacts: package
19+
20+
release:
21+
github:
22+
owner: paqstd-team
23+
name: fake-cli
24+
draft: true
25+
skip_upload: false
26+
extra_files:
27+
- glob: ./LICENSE
28+
29+
report_sizes: true

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 paqstd-team
3+
Copyright (c) 2024 paqstd-team
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Fake API Generator
1+
# Fake API (CLI)
22

33
This is a command-line tool for generating fake API responses based on a JSON configuration file. The tool is written in Go and uses the gofakeit library to generate random data.
44

@@ -7,12 +7,13 @@ This is a command-line tool for generating fake API responses based on a JSON co
77
To install the fakeapi command-line tool, you must have Go installed on your system. You can download and install Go from the official Go website.
88

99
Once you have Go installed, you can install the fakeapi tool by running the following command:
10-
1110
```bash
1211
go install -v github.com/paqstd-team/fake-cli@latest
1312
```
1413

15-
## Build
14+
Also you can install the binary by downloading it from [one of the latest releases](https://github.com/paqstd-team/fake-cli/releases).
15+
16+
## Local development
1617
Use commands:
1718

1819
```bash
@@ -111,6 +112,7 @@ List of types:
111112
- year
112113
- url
113114
- domain
115+
- ip
114116
- int
115117
- float
116118

@@ -150,8 +152,6 @@ docker run --name fake-cli -it -v ${PWD}/config.json:/app/config.json -p 8080:80
150152
### Docker Compose
151153
Here is an example of usage `fake-cli` with docker-compose and other containers:
152154
```yml
153-
version: '3'
154-
155155
services:
156156
# ...other services
157157
fake-cli:
@@ -174,8 +174,6 @@ services:
174174
175175
If you find a bug or would like to suggest a new feature, you can create an issue on the GitHub repository for this project. If you'd like to contribute code, you can fork the repository and submit a pull request with your changes.
176176
177-
For create new release use git tags. Create new tag `git tag vX.Y.Z` and push it `git push origin vX.Y.Z`.
178-
179177
## License
180178
181179
This project is licensed under the MIT License. See the LICENSE file for more information.

handler/data.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ func generateField(value string) interface{} {
7878
return gofakeit.URL()
7979
case "domain":
8080
return fmt.Sprintf("%s.%s", gofakeit.DomainName(), gofakeit.DomainSuffix())
81+
case "ip":
82+
return gofakeit.IPv4Address()
8183
// numbers
8284
case "int":
8385
return gofakeit.Int32()

handler/handler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@ func MakeHandler(config config.Config) http.Handler {
2424

2525
func makeHandlerFunc(fields any, responseType string, cache *cache.Cache) http.HandlerFunc {
2626
return func(w http.ResponseWriter, r *http.Request) {
27+
w.Header().Set("Content-Type", "application/json")
28+
2729
cacheKey := r.URL.Path + r.URL.RawQuery
2830
cacheValue, cacheHit := cache.Get(cacheKey)
2931
if cacheHit {
30-
w.Header().Set("Content-Type", "application/json")
3132
w.Write([]byte(cacheValue.(string)))
3233
return
3334
}
@@ -47,7 +48,6 @@ func makeHandlerFunc(fields any, responseType string, cache *cache.Cache) http.H
4748
}
4849

4950
cache.Set(cacheKey, string(jsonData))
50-
w.Header().Set("Content-Type", "application/json")
5151
w.Write(jsonData)
5252
}
5353
}

0 commit comments

Comments
 (0)