Skip to content

Commit 98b70b5

Browse files
authored
Merge pull request #2 from sedkis/feat/add-policies
Feat/add policies
2 parents 8f6dbf8 + 3425e9a commit 98b70b5

36 files changed

Lines changed: 4879 additions & 244 deletions

.github/workflows/ci.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Lint & Tests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
lint_and_test:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Go
20+
uses: actions/setup-go@v5
21+
with:
22+
go-version: "1.24"
23+
24+
- name: Lint
25+
uses: golangci/golangci-lint-action@v6
26+
with:
27+
version: latest
28+
29+
- name: Build
30+
run: go build ./...
31+
32+
- name: Test
33+
run: go test ./...

README.md

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ tyk --version
6666
```bash
6767
git clone https://github.com/sedkis/tyk-cli.git
6868
cd tyk-cli
69-
go build -o tyk .
69+
go build -o tyk ./cmd/
7070
sudo mv tyk /usr/local/bin/
7171
```
7272

@@ -121,6 +121,30 @@ tyk api delete <api-id> --yes # Delete without confirmation
121121
tyk api convert --file api.yaml --format apidef # Convert OAS to Tyk format
122122
```
123123

124+
### Policy Management
125+
```bash
126+
# Scaffold a new policy file
127+
tyk policy init --id gold --name "Gold Plan"
128+
129+
# List policies
130+
tyk policy list # Paginated table
131+
tyk policy list --json # JSON output
132+
133+
# Get a policy (outputs CLI-schema YAML)
134+
tyk policy get <policy-id> # YAML to stdout, summary to stderr
135+
tyk policy get <policy-id> --json # JSON output
136+
137+
# Apply a policy (idempotent upsert — creates or updates)
138+
tyk policy apply -f policy.yaml # From file
139+
tyk policy apply -f - # From stdin
140+
141+
# Delete a policy
142+
tyk policy delete <policy-id> # Interactive confirmation
143+
tyk policy delete <policy-id> --yes # Skip confirmation
144+
```
145+
146+
Policies use a human-friendly **CLI schema** with readable durations (`30d`, `1h`) and API selectors by name, listen path, or tags. The CLI converts to Dashboard wire format on apply. See the [Policy Guide](https://sedkis.github.io/tyk-cli/manage-policies) for the full YAML reference.
147+
124148
## ⚙️ Configuration
125149

126150
The Tyk CLI uses a unified environment/configuration system with the following precedence (highest to lowest):
@@ -196,7 +220,7 @@ cd tyk-cli
196220
go mod download
197221

198222
# Build the CLI
199-
go build -o tyk .
223+
go build -o tyk ./cmd/
200224

201225
# Run tests
202226
go test ./...
@@ -210,20 +234,22 @@ make test
210234

211235
```
212236
tyk-cli/
213-
├── cmd/ # CLI commands and subcommands
214-
├── internal/ # Internal packages
215-
│ ├── config/ # Configuration management
216-
│ ├── client/ # HTTP client for Tyk Dashboard API
217-
│ └── util/ # Utilities and helpers
218-
├── pkg/ # Public packages (if any)
219-
├── test/ # Integration tests
220-
└── docs/ # Documentation
237+
├── cmd/ # Entry point
238+
├── internal/ # Internal packages
239+
│ ├── cli/ # Cobra command definitions (api, policy, config)
240+
│ ├── config/ # Configuration management
241+
│ ├── client/ # HTTP client for Tyk Dashboard API
242+
│ ├── policy/ # Policy domain logic (duration, validation, selectors, conversion)
243+
│ ├── oas/ # OAS file handling
244+
│ └── filehandler/ # File utilities
245+
├── pkg/types/ # Shared types (API, policy, config)
246+
├── test/ # Integration tests
247+
└── docs/ # Documentation (Jekyll site)
221248
```
222249

223250
## 🗺️ Roadmap
224251

225252
### 🔧 Other lifecycle objects
226-
- Tyk Security Policies
227253
- Tyk API Tokens / Credentials
228254

229255
### 🔧 Enhanced Features

0 commit comments

Comments
 (0)