Archived
1

feat: openports

This commit is contained in:
2025-02-04 22:17:24 +03:00
parent ba6f27e7b2
commit 8c05af8135
4 changed files with 138 additions and 1 deletions

30
internal/types/ports.go Normal file
View File

@@ -0,0 +1,30 @@
package types
import (
"gopkg.in/yaml.v3"
"os"
"path/filepath"
)
type PortDef struct {
Name string `yaml:"name"`
LocalPort uint16 `yaml:"local"`
RemotePort uint16 `yaml:"remote"`
Url string `yaml:"url"`
}
func ReadPortsDef(workDir string) (*[]PortDef, error) {
var portsDef []PortDef
{
bb, err := os.ReadFile(filepath.Join(workDir, "ports.yml"))
if err != nil {
return nil, err
}
if err := yaml.Unmarshal(bb, &portsDef); err != nil {
return nil, err
}
}
return &portsDef, nil
}