feat: openports
This commit is contained in:
30
internal/types/ports.go
Normal file
30
internal/types/ports.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user