remove zoopb from forge

This commit is contained in:
Jeff Carr 2025-02-22 06:53:42 -06:00
parent a170250cb4
commit f540aab434
4 changed files with 45 additions and 40 deletions

18
http.go
View File

@ -4,15 +4,14 @@ package forgepb
import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
"os/user"
"go.wit.com/lib/protobuf/zoopb"
"go.wit.com/log"
)
/*
func (f *Forge) HttpPostMachine(url string) ([]byte, error) {
if f.Machine == nil {
// run f.InitMachine() here?
@ -40,6 +39,7 @@ func (f *Forge) HttpPostMachine(url string) ([]byte, error) {
log.Info("good? check.hostname =", check.Hostname)
return f.HttpPost(url, msg)
}
*/
func (f *Forge) HttpPost(url string, data []byte) ([]byte, error) {
var err error
@ -50,12 +50,14 @@ func (f *Forge) HttpPost(url string, data []byte) ([]byte, error) {
usr, _ := user.Current()
req.Header.Set("author", usr.Username)
if f.Machine == nil {
// run f.InitMachine() here?
log.Info("you must run f.InitMachine()")
return nil, fmt.Errorf("you must run f.InitMachine()")
}
req.Header.Set("hostname", f.Machine.Hostname)
/*
if f.Machine == nil {
// run f.InitMachine() here?
log.Info("you must run f.InitMachine()")
return nil, fmt.Errorf("you must run f.InitMachine()")
}
*/
req.Header.Set("hostname", "fixme:hostname")
client := &http.Client{}
resp, err := client.Do(req)

40
init.go
View File

@ -6,12 +6,10 @@ import (
"os"
"os/user"
"path/filepath"
"strings"
"time"
"go.wit.com/lib/gui/shell"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/lib/protobuf/zoopb"
"go.wit.com/log"
)
@ -21,10 +19,12 @@ import (
func Init() *Forge {
f := InitPB()
f.Machine = new(zoopb.Machine)
if err := f.Machine.ConfigLoad(); err != nil {
log.Log(WARN, "zoopb.ConfigLoad() failed", err)
}
/*
f.Machine = new(zoopb.Machine)
if err := f.Machine.ConfigLoad(); err != nil {
log.Log(WARN, "zoopb.ConfigLoad() failed", err)
}
*/
if f.Config.Username == "" {
usr, _ := user.Current()
f.Config.Username = usr.Username
@ -40,7 +40,7 @@ func Init() *Forge {
f.SetConfigSave(true)
}
f.Machine.InitWit()
// f.Machine.InitWit()
if f.hasFullScan {
// duplicate time checking below. which one to keep?
@ -135,24 +135,28 @@ func (f *Forge) InitPB() {
}
func (f *Forge) InitMachine() {
f.Machine = new(zoopb.Machine)
if err := f.Machine.ConfigLoad(); err != nil {
log.Log(WARN, "zoopb.ConfigLoad() failed", err)
f.Machine.InitWit()
}
/*
f.Machine = new(zoopb.Machine)
if err := f.Machine.ConfigLoad(); err != nil {
log.Log(WARN, "zoopb.ConfigLoad() failed", err)
f.Machine.InitWit()
}
*/
if f.Config.Username == "" {
usr, _ := user.Current()
f.Config.Username = usr.Username
}
if f.Machine.Hostname == "" {
r, err := shell.RunVerbose([]string{"hostname", "-f"})
if err == nil {
tmp := strings.Join(r.Stdout, "\n")
f.Machine.Hostname = strings.TrimSpace(tmp)
/*
if f.Machine.Hostname == "" {
r, err := shell.RunVerbose([]string{"hostname", "-f"})
if err == nil {
tmp := strings.Join(r.Stdout, "\n")
f.Machine.Hostname = strings.TrimSpace(tmp)
}
}
}
*/
}
// only init's the protobuf. intended to not scan or change anything

View File

@ -43,11 +43,11 @@ func (f *Forge) MakeDevelPatchSet(name string) (*Patchset, error) {
for all.Scan() {
repo := all.Next()
if ! repo.IsLocalBranch(repo.GetUserBranchName()) {
if !repo.IsLocalBranch(repo.GetUserBranchName()) {
// log.Info("repo doesn't have user branch", repo.GetGoPath())
continue
}
if ! repo.IsLocalBranch(repo.GetDevelBranchName()) {
if !repo.IsLocalBranch(repo.GetDevelBranchName()) {
// log.Info("repo doesn't have devel branch", repo.GetGoPath())
continue
}

View File

@ -5,23 +5,22 @@ import (
"time"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/lib/protobuf/zoopb"
)
// maybe an interface someday?
type Forge struct {
// one-time initialized data
initOnce sync.Once
initErr error // init error, if any
goSrc string // the path to go/src
configDir string // normally ~/.config/forge
goWork bool // means the user is currently using a go.work file
Config *ForgeConfigs // config repos for readonly, private, etc
Repos *gitpb.Repos // the repo protobufs
Machine *zoopb.Machine // things for virtigo to track vm's
configSave bool // if you need to save the config because things changed
hasFullScan bool // track last scan so it can be throttled
fullscan time.Time // time of the last scan so it can be throttled
initOnce sync.Once
initErr error // init error, if any
goSrc string // the path to go/src
configDir string // normally ~/.config/forge
goWork bool // means the user is currently using a go.work file
Config *ForgeConfigs // config repos for readonly, private, etc
Repos *gitpb.Repos // the repo protobufs
// Machine *zoopb.Machine // things for virtigo to track vm's
configSave bool // if you need to save the config because things changed
hasFullScan bool // track last scan so it can be throttled
fullscan time.Time // time of the last scan so it can be throttled
}
func (f *Forge) GetGoSrc() string {