@@ -12,391 +12,6 @@ CtrlC (`ctrlc`) is a powerful CLI tool that enables you to:
1212- 🔍 ** Query and manage resources** via intuitive API commands
1313- 📝 ** Apply infrastructure as code** using YAML configurations
1414
15- ## Installation
16-
17- ### Using Go Install
18-
19- ``` bash
20- go install github.com/ctrlplanedev/cli/cmd/ctrlc@latest
21- ```
22-
23- ### Building from Source
24-
25- ``` bash
26- git clone https://github.com/ctrlplanedev/cli.git
27- cd cli
28- make build
29- # Binary will be available at ./bin/ctrlc
30- ```
31-
32- ### Using Make Install
33-
34- ``` bash
35- make install
36- ```
37-
38- ## Configuration
39-
40- CtrlC can be configured using a config file, environment variables, or command-line flags.
41-
42- ### Config File
43-
44- By default, CtrlC looks for a config file at ` $HOME/.ctrlc.yaml ` . You can specify a custom location:
45-
46- ``` bash
47- ctrlc --config /path/to/config.yaml < command>
48- ```
49-
50- Example ` ~/.ctrlc.yaml ` :
51-
52- ``` yaml
53- url : https://app.ctrlplane.dev
54- api-key : your-api-key-here
55- workspace : your-workspace-id
56- ` ` `
57-
58- ### Environment Variables
59-
60- ` ` ` bash
61- export CTRLPLANE_URL="https://app.ctrlplane.dev"
62- export CTRLPLANE_API_KEY="your-api-key-here"
63- export CTRLPLANE_WORKSPACE="your-workspace-id"
64- export CTRLPLANE_CLUSTER_IDENTIFIER="my-cluster"
65- ```
66-
67- ### Command-Line Flags
68-
69- ``` bash
70- ctrlc --url https://app.ctrlplane.dev \
71- --api-key your-api-key \
72- --workspace your-workspace-id \
73- < command>
74- ```
75-
76- ### Setting Configuration Values
77-
78- Use the ` config set ` command to persist configuration:
79-
80- ``` bash
81- ctrlc config set url https://app.ctrlplane.dev
82- ctrlc config set api-key your-api-key
83- ctrlc config set workspace your-workspace-id
84- ```
85-
86- ## Commands
87-
88- ### Agent
89-
90- Run deployment agents to execute jobs and workflows:
91-
92- ``` bash
93- # Start an agent
94- ctrlc agent run
95- ```
96-
97- ### Sync
98-
99- Synchronize infrastructure resources from various providers into CtrlPlane:
100-
101- #### Cloud Providers
102-
103- ``` bash
104- # AWS Resources
105- ctrlc sync aws ec2 # Sync EC2 instances
106- ctrlc sync aws eks # Sync EKS clusters
107- ctrlc sync aws rds # Sync RDS databases
108- ctrlc sync aws networks # Sync VPCs and networks
109-
110- # Google Cloud Resources
111- ctrlc sync google gke # Sync GKE clusters
112- ctrlc sync google vms # Sync Compute Engine VMs
113- ctrlc sync google cloudsql # Sync Cloud SQL instances
114- ctrlc sync google cloudrun # Sync Cloud Run services
115- ctrlc sync google buckets # Sync Cloud Storage buckets
116- ctrlc sync google redis # Sync Memorystore Redis
117- ctrlc sync google bigtable # Sync Bigtable instances
118- ctrlc sync google secrets # Sync Secret Manager secrets
119- ctrlc sync google projects # Sync GCP projects
120- ctrlc sync google networks # Sync VPCs and networks
121-
122- # Azure Resources
123- ctrlc sync azure aks # Sync AKS clusters
124- ctrlc sync azure networks # Sync virtual networks
125- ```
126-
127- #### Kubernetes & Helm
128-
129- ``` bash
130- # Kubernetes Resources
131- ctrlc sync kubernetes # Sync Kubernetes resources
132- ctrlc sync vcluster # Sync vcluster instances
133-
134- # Helm Releases
135- ctrlc sync helm # Sync Helm releases
136- ```
137-
138- #### Other Integrations
139-
140- ``` bash
141- # Terraform
142- ctrlc sync terraform # Sync Terraform workspaces
143-
144- # GitHub
145- ctrlc sync github # Sync GitHub resources
146-
147- # Tailscale
148- ctrlc sync tailscale # Sync Tailscale devices
149-
150- # ClickHouse
151- ctrlc sync clickhouse # Sync ClickHouse resources
152-
153- # Salesforce
154- ctrlc sync salesforce # Sync Salesforce data
155- ```
156-
157- #### Running Sync on an Interval
158-
159- All sync commands support the ` --interval ` flag to run continuously:
160-
161- ``` bash
162- # Sync every 5 minutes
163- ctrlc sync terraform --interval 5m
164-
165- # Sync every hour
166- ctrlc sync kubernetes --interval 1h
167-
168- # Sync every day
169- ctrlc sync aws eks --interval 1d
170- ```
171-
172- ### Apply
173-
174- Apply declarative YAML configurations to create and manage infrastructure:
175-
176- ``` bash
177- ctrlc apply -f config.yaml
178- ```
179-
180- Example configuration file:
181-
182- ``` yaml
183- systems :
184- - name : my-app
185- slug : my-app
186- description : My application system
187-
188- providers :
189- - name : my-provider
190- type : kubernetes
191-
192- relationships :
193- - type : depends-on
194- source : resource-a
195- target : resource-b
196-
197- policies :
198- - name : auto-deploy
199- system : my-app
200- rules :
201- - condition : status == "ready"
202- action : deploy
203- ` ` `
204-
205- ### API Commands
206-
207- Direct API access for resource management:
208-
209- #### Get Resources
210-
211- ` ` ` bash
212- # Get a specific resource
213- ctrlc api get resource <resource-id>
214-
215- # List resources
216- ctrlc api get resources
217-
218- # Get system information
219- ctrlc api get system <system-id>
220-
221- # Get workspace information
222- ctrlc api get workspace
223- ```
224-
225- #### Create Resources
226-
227- ``` bash
228- # Create a deployment version
229- ctrlc api create deploymentversion --deployment < id> --version < version>
230-
231- # Create an environment
232- ctrlc api create environment --name < name> --system < system-id>
233-
234- # Create a release
235- ctrlc api create release --deployment < id>
236-
237- # Create a system
238- ctrlc api create system --name < name> --slug < slug>
239-
240- # Create relationships
241- ctrlc api create relationship job-to-resource --job < job-id> --resource < resource-id>
242- ctrlc api create relationship resource-to-resource --source < id> --target < id>
243- ```
244-
245- #### Update Resources
246-
247- ``` bash
248- # Update a deployment version
249- ctrlc api update deploymentversion < id> --status deployed
250-
251- # Update a release
252- ctrlc api update release < id> --status completed
253-
254- # Update a system
255- ctrlc api update system < id> --name < new-name>
256- ```
257-
258- #### Upsert Resources
259-
260- ``` bash
261- # Upsert a resource (create or update)
262- ctrlc api upsert resource --identifier < id> --kind < kind>
263-
264- # Upsert a deployment version
265- ctrlc api upsert deploymentversion --deployment < id> --version < version>
266-
267- # Upsert a policy
268- ctrlc api upsert policy --name < name> --system < system-id>
269-
270- # Upsert a release
271- ctrlc api upsert release --name < name>
272- ```
273-
274- #### Delete Resources
275-
276- ``` bash
277- # Delete an environment
278- ctrlc api delete environment < environment-id>
279-
280- # Delete a policy
281- ctrlc api delete policy < policy-id>
282-
283- # Delete a resource
284- ctrlc api delete resource < resource-id>
285- ```
286-
287- ### Run
288-
289- Execute jobs and workflows:
290-
291- ``` bash
292- # Execute a command
293- ctrlc run exec < command>
294-
295- # List Kubernetes jobs
296- ctrlc run kubernetes jobs
297- ```
298-
299- ### Version
300-
301- Display version information:
302-
303- ``` bash
304- ctrlc version
305- ```
306-
307- ## Output Formats
308-
309- Most commands support multiple output formats:
310-
311- ``` bash
312- # JSON output (default)
313- ctrlc api get resource < id> --format json
314-
315- # YAML output
316- ctrlc api get resource < id> --format yaml
317-
318- # GitHub Actions output
319- ctrlc api get resource < id> --format github-action
320-
321- # Custom Go template
322- ctrlc api get resource < id> --template ' {{.name}}'
323- ```
324-
325- ## Logging
326-
327- Control logging verbosity with the ` --log-level ` flag:
328-
329- ``` bash
330- ctrlc --log-level debug sync kubernetes
331- ctrlc --log-level warn api get resources
332- ctrlc --log-level error agent run
333- ```
334-
335- Available log levels: ` debug ` , ` info ` , ` warn ` , ` error `
336-
337- ## Development
338-
339- ### Prerequisites
340-
341- - Go 1.24.2 or later
342- - Make
343-
344- ### Building
345-
346- ``` bash
347- # Build the binary
348- make build
349-
350- # Install locally
351- make install
352-
353- # Run tests
354- make test
355-
356- # Run linter
357- make lint
358-
359- # Format code
360- make format
361-
362- # Clean build artifacts
363- make clean
364- ```
365-
366- ### Project Structure
367-
368- ```
369- cli/
370- ├── cmd/ctrlc/ # Main CLI entry point
371- │ └── root/ # Command implementations
372- │ ├── agent/ # Agent commands
373- │ ├── api/ # API commands
374- │ ├── apply/ # Apply command
375- │ ├── config/ # Configuration commands
376- │ ├── run/ # Run commands
377- │ ├── sync/ # Sync integrations
378- │ └── version/ # Version command
379- ├── internal/ # Internal packages
380- │ ├── api/ # API client
381- │ ├── cliutil/ # CLI utilities
382- │ ├── kinds/ # Resource kinds
383- │ └── options/ # Common options
384- ├── pkg/ # Public packages
385- │ ├── agent/ # Agent implementation
386- │ └── jobagent/ # Job agent
387- └── Makefile # Build scripts
388- ```
389-
390- ### Version Information
391-
392- Version information is embedded at build time using ldflags:
393-
394- ``` bash
395- make build
396- # or
397- go build -ldflags " -X github.com/ctrlplanedev/cli/cmd/ctrlc/root/version.Version=1.0.0" ./cmd/ctrlc
398- ```
399-
40015## GitHub Actions
40116
40217The CLI includes GitHub Actions for CI/CD workflows. See the ` actions/ ` directory for available actions.
0 commit comments