remove zoopb from forge
This commit is contained in:
parent
a170250cb4
commit
f540aab434
18
http.go
18
http.go
|
@ -4,15 +4,14 @@ package forgepb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os/user"
|
"os/user"
|
||||||
|
|
||||||
"go.wit.com/lib/protobuf/zoopb"
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/*
|
||||||
func (f *Forge) HttpPostMachine(url string) ([]byte, error) {
|
func (f *Forge) HttpPostMachine(url string) ([]byte, error) {
|
||||||
if f.Machine == nil {
|
if f.Machine == nil {
|
||||||
// run f.InitMachine() here?
|
// run f.InitMachine() here?
|
||||||
|
@ -40,6 +39,7 @@ func (f *Forge) HttpPostMachine(url string) ([]byte, error) {
|
||||||
log.Info("good? check.hostname =", check.Hostname)
|
log.Info("good? check.hostname =", check.Hostname)
|
||||||
return f.HttpPost(url, msg)
|
return f.HttpPost(url, msg)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
func (f *Forge) HttpPost(url string, data []byte) ([]byte, error) {
|
func (f *Forge) HttpPost(url string, data []byte) ([]byte, error) {
|
||||||
var err error
|
var err error
|
||||||
|
@ -50,12 +50,14 @@ func (f *Forge) HttpPost(url string, data []byte) ([]byte, error) {
|
||||||
|
|
||||||
usr, _ := user.Current()
|
usr, _ := user.Current()
|
||||||
req.Header.Set("author", usr.Username)
|
req.Header.Set("author", usr.Username)
|
||||||
if f.Machine == nil {
|
/*
|
||||||
// run f.InitMachine() here?
|
if f.Machine == nil {
|
||||||
log.Info("you must run f.InitMachine()")
|
// run f.InitMachine() here?
|
||||||
return nil, fmt.Errorf("you must run f.InitMachine()")
|
log.Info("you must run f.InitMachine()")
|
||||||
}
|
return nil, fmt.Errorf("you must run f.InitMachine()")
|
||||||
req.Header.Set("hostname", f.Machine.Hostname)
|
}
|
||||||
|
*/
|
||||||
|
req.Header.Set("hostname", "fixme:hostname")
|
||||||
|
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
|
|
40
init.go
40
init.go
|
@ -6,12 +6,10 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/user"
|
"os/user"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.wit.com/lib/gui/shell"
|
"go.wit.com/lib/gui/shell"
|
||||||
"go.wit.com/lib/protobuf/gitpb"
|
"go.wit.com/lib/protobuf/gitpb"
|
||||||
"go.wit.com/lib/protobuf/zoopb"
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -21,10 +19,12 @@ import (
|
||||||
func Init() *Forge {
|
func Init() *Forge {
|
||||||
f := InitPB()
|
f := InitPB()
|
||||||
|
|
||||||
f.Machine = new(zoopb.Machine)
|
/*
|
||||||
if err := f.Machine.ConfigLoad(); err != nil {
|
f.Machine = new(zoopb.Machine)
|
||||||
log.Log(WARN, "zoopb.ConfigLoad() failed", err)
|
if err := f.Machine.ConfigLoad(); err != nil {
|
||||||
}
|
log.Log(WARN, "zoopb.ConfigLoad() failed", err)
|
||||||
|
}
|
||||||
|
*/
|
||||||
if f.Config.Username == "" {
|
if f.Config.Username == "" {
|
||||||
usr, _ := user.Current()
|
usr, _ := user.Current()
|
||||||
f.Config.Username = usr.Username
|
f.Config.Username = usr.Username
|
||||||
|
@ -40,7 +40,7 @@ func Init() *Forge {
|
||||||
f.SetConfigSave(true)
|
f.SetConfigSave(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
f.Machine.InitWit()
|
// f.Machine.InitWit()
|
||||||
|
|
||||||
if f.hasFullScan {
|
if f.hasFullScan {
|
||||||
// duplicate time checking below. which one to keep?
|
// duplicate time checking below. which one to keep?
|
||||||
|
@ -135,24 +135,28 @@ func (f *Forge) InitPB() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Forge) InitMachine() {
|
func (f *Forge) InitMachine() {
|
||||||
f.Machine = new(zoopb.Machine)
|
/*
|
||||||
if err := f.Machine.ConfigLoad(); err != nil {
|
f.Machine = new(zoopb.Machine)
|
||||||
log.Log(WARN, "zoopb.ConfigLoad() failed", err)
|
if err := f.Machine.ConfigLoad(); err != nil {
|
||||||
f.Machine.InitWit()
|
log.Log(WARN, "zoopb.ConfigLoad() failed", err)
|
||||||
}
|
f.Machine.InitWit()
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
if f.Config.Username == "" {
|
if f.Config.Username == "" {
|
||||||
usr, _ := user.Current()
|
usr, _ := user.Current()
|
||||||
f.Config.Username = usr.Username
|
f.Config.Username = usr.Username
|
||||||
}
|
}
|
||||||
|
|
||||||
if f.Machine.Hostname == "" {
|
/*
|
||||||
r, err := shell.RunVerbose([]string{"hostname", "-f"})
|
if f.Machine.Hostname == "" {
|
||||||
if err == nil {
|
r, err := shell.RunVerbose([]string{"hostname", "-f"})
|
||||||
tmp := strings.Join(r.Stdout, "\n")
|
if err == nil {
|
||||||
f.Machine.Hostname = strings.TrimSpace(tmp)
|
tmp := strings.Join(r.Stdout, "\n")
|
||||||
|
f.Machine.Hostname = strings.TrimSpace(tmp)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// only init's the protobuf. intended to not scan or change anything
|
// only init's the protobuf. intended to not scan or change anything
|
||||||
|
|
|
@ -43,11 +43,11 @@ func (f *Forge) MakeDevelPatchSet(name string) (*Patchset, error) {
|
||||||
for all.Scan() {
|
for all.Scan() {
|
||||||
repo := all.Next()
|
repo := all.Next()
|
||||||
|
|
||||||
if ! repo.IsLocalBranch(repo.GetUserBranchName()) {
|
if !repo.IsLocalBranch(repo.GetUserBranchName()) {
|
||||||
// log.Info("repo doesn't have user branch", repo.GetGoPath())
|
// log.Info("repo doesn't have user branch", repo.GetGoPath())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if ! repo.IsLocalBranch(repo.GetDevelBranchName()) {
|
if !repo.IsLocalBranch(repo.GetDevelBranchName()) {
|
||||||
// log.Info("repo doesn't have devel branch", repo.GetGoPath())
|
// log.Info("repo doesn't have devel branch", repo.GetGoPath())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
23
structs.go
23
structs.go
|
@ -5,23 +5,22 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.wit.com/lib/protobuf/gitpb"
|
"go.wit.com/lib/protobuf/gitpb"
|
||||||
"go.wit.com/lib/protobuf/zoopb"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// maybe an interface someday?
|
// maybe an interface someday?
|
||||||
type Forge struct {
|
type Forge struct {
|
||||||
// one-time initialized data
|
// one-time initialized data
|
||||||
initOnce sync.Once
|
initOnce sync.Once
|
||||||
initErr error // init error, if any
|
initErr error // init error, if any
|
||||||
goSrc string // the path to go/src
|
goSrc string // the path to go/src
|
||||||
configDir string // normally ~/.config/forge
|
configDir string // normally ~/.config/forge
|
||||||
goWork bool // means the user is currently using a go.work file
|
goWork bool // means the user is currently using a go.work file
|
||||||
Config *ForgeConfigs // config repos for readonly, private, etc
|
Config *ForgeConfigs // config repos for readonly, private, etc
|
||||||
Repos *gitpb.Repos // the repo protobufs
|
Repos *gitpb.Repos // the repo protobufs
|
||||||
Machine *zoopb.Machine // things for virtigo to track vm's
|
// Machine *zoopb.Machine // things for virtigo to track vm's
|
||||||
configSave bool // if you need to save the config because things changed
|
configSave bool // if you need to save the config because things changed
|
||||||
hasFullScan bool // track last scan so it can be throttled
|
hasFullScan bool // track last scan so it can be throttled
|
||||||
fullscan time.Time // time of the 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 {
|
func (f *Forge) GetGoSrc() string {
|
||||||
|
|
Loading…
Reference in New Issue