Merge conflict resolved.
This commit is contained in:
parent
a734197c54
commit
a2252170db
33
functions.go
33
functions.go
@ -1,7 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
|
||||
"github.com/uptrace/bun"
|
||||
@ -14,35 +13,3 @@ func OpenDB(dsn string) PostgresClient {
|
||||
r := PostgresClient{bun.NewDB(sqldb, pgdialect.New())}
|
||||
return r
|
||||
}
|
||||
<<<<<<< Updated upstream
|
||||
=======
|
||||
|
||||
func SelectUsers(c *PostgresClient) {
|
||||
ctx := context.Background()
|
||||
users := new(UserModel)
|
||||
c.NewSelect().
|
||||
Model(&UserModel{}).
|
||||
Scan(ctx, &users)
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
Prepared for development of the ssh client procedures
|
||||
*/
|
||||
//func OpenSSH(dsn string) *SSHClient {
|
||||
// sshconn := new(SSHClient)
|
||||
// sshconn.NewSession()
|
||||
// return sshconn
|
||||
//}
|
||||
|
||||
/*
|
||||
Prepared for development of the web client procedures
|
||||
*/
|
||||
//func OpenWeb(dsn string) WebClient {
|
||||
// webconn := new(http.Client)
|
||||
// webreq := NewRequest(MethodGet, dsn,
|
||||
//
|
||||
// webconn.Do
|
||||
// return webconn
|
||||
//}
|
||||
>>>>>>> Stashed changes
|
||||
|
26
main.go
26
main.go
@ -23,31 +23,6 @@ import (
|
||||
|
||||
func main() {
|
||||
var (
|
||||
<<<<<<< Updated upstream
|
||||
// ctx = context.Background()
|
||||
dsn = "postgres://postgres:Initial1@localhost:15432/anvil?sslmode=disable"
|
||||
// dsn := "unix://user:pass@dbname/var/run/postgresql/.s.PGSQL.5432"
|
||||
)
|
||||
anvil := new(Anvil)
|
||||
anvil.AddStriker(Striker{})
|
||||
anvil.Strikers[0].SetFQDN("mh-striker01.libre.audio")
|
||||
anvil.Strikers[0].AddEndpoint(PostgresClient(OpenDB(dsn)))
|
||||
|
||||
fmt.Printf("%s\n", anvil.Strikers[0])
|
||||
// Turn these into funcs with error handling, logging, return vals etc.
|
||||
// if usererr := anvildb.NewSelect().
|
||||
// // Turning *User into an interface &User{}
|
||||
// Model(&UserModel{}).
|
||||
// OrderExpr("user_uuid ASC").
|
||||
// Limit(10).
|
||||
// Scan(ctx, &users); usererr != nil {
|
||||
// errors.Join(usererr, err)
|
||||
// }
|
||||
// fmt.Printf("##\n## Users\n###\n\n")
|
||||
// for _, val := range users {
|
||||
// fmt.Printf("%s\n", val.Username)
|
||||
// }
|
||||
=======
|
||||
pgdsn = "postgres://postgres:Initial1@localhost:15432/anvil?sslmode=disable"
|
||||
)
|
||||
anvil := new(Anvil)
|
||||
@ -58,5 +33,4 @@ func main() {
|
||||
anvil.Strikers[0].AddEndpoint(e)
|
||||
fmt.Printf("Strikers[0].Endpoints.PostgresClient = %s.\n", anvil.Strikers[0].Endpoints.PostgresClient)
|
||||
// fmt.Printf("Strikers[0].FQDN = %s.\n", anvil.Strikers[0].FQDN)
|
||||
>>>>>>> Stashed changes
|
||||
}
|
||||
|
10
methods.go
10
methods.go
@ -1,19 +1,14 @@
|
||||
package main
|
||||
|
||||
<<<<<<< Updated upstream
|
||||
=======
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
>>>>>>> Stashed changes
|
||||
func (p PostgresClient) IsEndpoint() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
<<<<<<< Updated upstream
|
||||
=======
|
||||
func (w WebClient) IsEndpoint() bool {
|
||||
return true
|
||||
}
|
||||
@ -22,15 +17,11 @@ func (s SSHClient) IsEndpoint() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
>>>>>>> Stashed changes
|
||||
func (s *Striker) SetFQDN(fqdn string) {
|
||||
s.FQDN = fqdn
|
||||
}
|
||||
|
||||
func (s *Striker) AddEndpoint(e Endpoint) {
|
||||
<<<<<<< Updated upstream
|
||||
s.Endpoints = append(s.Endpoints, e)
|
||||
=======
|
||||
// type switch statement
|
||||
// https://go.dev/tour/methods/16
|
||||
fmt.Printf("e value = %s.\n", reflect.TypeOf(e))
|
||||
@ -44,7 +35,6 @@ func (s *Striker) AddEndpoint(e Endpoint) {
|
||||
default:
|
||||
fmt.Println("Undefined behavior for type %s.\n", t)
|
||||
}
|
||||
>>>>>>> Stashed changes
|
||||
}
|
||||
|
||||
func (a *Anvil) AddStriker(s Striker) {
|
||||
|
13
types.go
13
types.go
@ -16,6 +16,12 @@ type Anvil struct {
|
||||
UPSes []UPS
|
||||
}
|
||||
|
||||
type Endpoints struct {
|
||||
WebClient Endpoint
|
||||
SSHClient Endpoint
|
||||
PostgresClient Endpoint
|
||||
}
|
||||
|
||||
type WebClient struct {
|
||||
*http.Client
|
||||
}
|
||||
@ -30,16 +36,11 @@ type PostgresClient struct {
|
||||
|
||||
type Striker struct {
|
||||
FQDN string
|
||||
Endpoints []Endpoint
|
||||
Endpoints Endpoints
|
||||
}
|
||||
|
||||
type Host struct {
|
||||
<<<<<<< Updated upstream
|
||||
FQDN string
|
||||
Endpoints []Endpoint
|
||||
=======
|
||||
FQDN string
|
||||
>>>>>>> Stashed changes
|
||||
}
|
||||
|
||||
type BMC struct {
|
||||
|
Loading…
Reference in New Issue
Block a user