DeployNodeConfig deploys the node configuration
()
| 69 | |
| 70 | // DeployNodeConfig deploys the node configuration |
| 71 | func (d *Deployer) DeployNodeConfig() error { |
| 72 | log.Println("Deploying node configuration") |
| 73 | // Create a directory for the node configuration |
| 74 | dir, err := os.MkdirTemp("", "node-config-") |
| 75 | if err != nil { |
| 76 | return err |
| 77 | } |
| 78 | defer os.RemoveAll(dir) |
| 79 | |
| 80 | // Create a file for the node configuration |
| 81 | file, err := os.Create(filepath.Join(dir, "node.config")) |
| 82 | if err != nil { |
| 83 | return err |
| 84 | } |
| 85 | defer file.Close() |
| 86 | |
| 87 | // Write the node configuration to the file |
| 88 | _, err = file.WriteString(fmt.Sprintf("id=%s\n", d.nodeConfig.id)) |
| 89 | if err != nil { |
| 90 | return err |
| 91 | } |
| 92 | |
| 93 | // Write the neighbors to the file |
| 94 | for _, neighbor := range d.nodeConfig.neighbors { |
| 95 | _, err = file.WriteString(fmt.Sprintf("neighbor=%s\n", neighbor.id)) |
| 96 | if err != nil { |
| 97 | return err |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | return nil |
| 102 | } |
| 103 | |
| 104 | // Deploy deploys both the satellite and node configurations |
| 105 | func (d *Deployer) Deploy() error { |