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,39 @@
|
||||
---
|
||||
name: ssh_config_render
|
||||
kind: function
|
||||
lang: go
|
||||
domain: infra
|
||||
version: "1.0.0"
|
||||
purity: pure
|
||||
signature: "func SSHConfigRender(entries []SSHConfigEntry) string"
|
||||
description: "Convierte una lista de SSHConfigEntry al formato texto de ~/.ssh/config."
|
||||
tags: [ssh, config, render, remote]
|
||||
uses_functions: []
|
||||
uses_types: [ssh_config_entry_go_infra]
|
||||
returns: []
|
||||
returns_optional: false
|
||||
error_type: ""
|
||||
imports: [fmt, sort, strings]
|
||||
params:
|
||||
- name: entries
|
||||
desc: "lista de SSHConfigEntry a renderizar"
|
||||
output: "texto en formato ~/.ssh/config con bloques Host separados por linea en blanco"
|
||||
tested: true
|
||||
tests: ["renderiza entry completo", "renderiza entry minimo solo con alias", "separa bloques con linea en blanco", "ordena opciones extra alfabeticamente"]
|
||||
test_file_path: "functions/infra/ssh_config_parse_test.go"
|
||||
file_path: "functions/infra/ssh_config_render.go"
|
||||
---
|
||||
|
||||
## Ejemplo
|
||||
|
||||
```go
|
||||
entries := []SSHConfigEntry{{
|
||||
Alias: "prod", HostName: "10.0.0.1", User: "admin", Port: 22,
|
||||
}}
|
||||
text := SSHConfigRender(entries)
|
||||
// "Host prod\n HostName 10.0.0.1\n User admin\n Port 22\n"
|
||||
```
|
||||
|
||||
## Notas
|
||||
|
||||
Campos vacios o Port=0 se omiten. Las opciones extra se renderizan en orden alfabetico para determinismo.
|
||||
Reference in New Issue
Block a user