aca2348a20
- .claude/CLAUDE.md - .claude/agents/fn-recopilador/SKILL.md - .claude/rules/INDEX.md - .claude/rules/cpp_apps.md - bash/functions/infra/build_cpp_windows.sh - cpp/CMakeLists.txt - cpp/PATTERNS.md - cpp/framework/app_base.cpp - cpp/framework/app_base.h - dev/issues/README.md - ... Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
46 lines
1.3 KiB
Markdown
46 lines
1.3 KiB
Markdown
---
|
|
name: ssh_config_write
|
|
kind: function
|
|
lang: go
|
|
domain: infra
|
|
version: "1.0.0"
|
|
purity: impure
|
|
signature: "func SSHConfigWrite(entries []SSHConfigEntry) error"
|
|
description: "Escribe entries a ~/.ssh/config con backup automatico del archivo previo."
|
|
tags: [ssh, config, write, remote]
|
|
uses_functions: [ssh_config_render_go_infra]
|
|
uses_types: [ssh_config_entry_go_infra]
|
|
returns: []
|
|
returns_optional: false
|
|
error_type: "error_go_core"
|
|
imports: [fmt, os, path/filepath]
|
|
params:
|
|
- name: entries
|
|
desc: "lista de SSHConfigEntry a escribir en ~/.ssh/config"
|
|
output: "nil si la escritura fue exitosa"
|
|
tested: true
|
|
tests:
|
|
- TestSSHConfigWrite_CreatesFileAndDir
|
|
- TestSSHConfigWrite_BackupExisting
|
|
- TestSSHConfigWrite_NoBackupWhenAbsent
|
|
- TestSSHConfigWriteRead_Roundtrip
|
|
test_file_path: "functions/infra/ssh_config_write_test.go"
|
|
file_path: "functions/infra/ssh_config_write.go"
|
|
---
|
|
|
|
## Ejemplo
|
|
|
|
```go
|
|
entries, _ := SSHConfigRead()
|
|
entries, _ = SSHConfigAddEntry(entries, SSHConfigEntry{
|
|
Alias: "prod", HostName: "10.0.0.1", User: "deploy",
|
|
})
|
|
if err := SSHConfigWrite(entries); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
```
|
|
|
|
## Notas
|
|
|
|
Crea `~/.ssh/` con permisos 0700 si no existe. Hace backup a `~/.ssh/config.bak` antes de sobrescribir. El archivo resultante tiene permisos 0600 (solo lectura/escritura para el owner).
|