feat: add Go SSH config management functions and type
7 funciones Go del dominio infra para gestion programatica de ~/.ssh/config: ssh_config_parse (parser de bloques Host/Match), ssh_config_read (lectura del archivo), ssh_config_find (busqueda por host), ssh_config_add_entry y ssh_config_remove_entry (CRUD), ssh_config_render (serializacion a texto), ssh_config_write (escritura atomica). Incluye tipo SshConfigEntry (product type) y tests unitarios del parser.
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
---
|
||||
name: ssh_config_parse
|
||||
kind: function
|
||||
lang: go
|
||||
domain: infra
|
||||
version: "1.0.0"
|
||||
purity: pure
|
||||
signature: "func SSHConfigParse(content string) []SSHConfigEntry"
|
||||
description: "Parsea el contenido de un archivo ~/.ssh/config y retorna una lista de SSHConfigEntry."
|
||||
tags: [ssh, config, parser, remote]
|
||||
uses_functions: []
|
||||
uses_types: [ssh_config_entry_go_infra]
|
||||
returns: []
|
||||
returns_optional: false
|
||||
error_type: ""
|
||||
imports: [bufio, strconv, strings]
|
||||
params:
|
||||
- name: content
|
||||
desc: "texto completo del archivo ~/.ssh/config"
|
||||
output: "lista de SSHConfigEntry, uno por cada bloque Host (sin wildcards)"
|
||||
tested: true
|
||||
tests: ["parsea config con multiples hosts", "ignora comentarios y lineas vacias", "ignora hosts con wildcards", "parsea opciones extra en Options map"]
|
||||
test_file_path: "functions/infra/ssh_config_parse_test.go"
|
||||
file_path: "functions/infra/ssh_config_parse.go"
|
||||
---
|
||||
|
||||
## Ejemplo
|
||||
|
||||
```go
|
||||
content := `Host myserver
|
||||
HostName 192.168.1.100
|
||||
User deploy
|
||||
Port 2222
|
||||
IdentityFile ~/.ssh/id_ed25519`
|
||||
|
||||
entries := SSHConfigParse(content)
|
||||
// entries[0].Alias == "myserver"
|
||||
// entries[0].HostName == "192.168.1.100"
|
||||
```
|
||||
|
||||
## Notas
|
||||
|
||||
Ignora bloques `Host *` y `Host 192.168.?.*` (wildcards). Soporta directivas con separador espacio o `=`. Las directivas no reconocidas se almacenan en el map `Options`.
|
||||
Reference in New Issue
Block a user