parent
84155e8590
commit
2f56639f5b
5 changed files with 96 additions and 51 deletions
@ -1,24 +1,3 @@ |
||||
package main |
||||
|
||||
import ( |
||||
"database/sql" |
||||
|
||||
"github.com/uptrace/bun" |
||||
"github.com/uptrace/bun/dialect/pgdialect" |
||||
"github.com/uptrace/bun/driver/pgdriver" |
||||
"github.com/uptrace/bun/extra/bundebug" |
||||
) |
||||
|
||||
func ConnectAnvilDB(dsn string) *bun.DB { |
||||
sqldb := sql.OpenDB(pgdriver.NewConnector(pgdriver.WithDSN(dsn))) |
||||
db := bun.NewDB(sqldb, pgdialect.New()) |
||||
|
||||
db.AddQueryHook(bundebug.NewQueryHook( |
||||
bundebug.WithVerbose(true), |
||||
bundebug.FromEnv("BUNDEBUG"), |
||||
)) |
||||
return db |
||||
|
||||
} |
||||
|
||||
//func GetFeeds(db *bun.DB)
|
||||
//anvildb.NewSelect().Model(&SSHKey{}).OrderExpr("ssh_key_user_name ASC").
|
||||
|
@ -0,0 +1 @@ |
||||
package main |
@ -0,0 +1,49 @@ |
||||
package main |
||||
|
||||
import ( |
||||
"database/sql" |
||||
"net/http" |
||||
|
||||
"golang.org/x/crypto/ssh" |
||||
) |
||||
|
||||
type Anvil struct { |
||||
Strikers []Striker |
||||
Hosts []Host |
||||
BMCs []BMC |
||||
Switches []Switch |
||||
PDUs []PDU |
||||
UPSes []UPS |
||||
} |
||||
|
||||
type Striker struct { |
||||
FQDN string |
||||
Endpoints struct { |
||||
StrikerWebUI *http.Client |
||||
Postgresql *sql.DB |
||||
SecureShell *ssh.Client |
||||
} |
||||
} |
||||
|
||||
type Host struct { |
||||
FQDN string |
||||
Endpoints struct { |
||||
SecureShell *ssh.Client |
||||
} |
||||
} |
||||
|
||||
type BMC struct { |
||||
} |
||||
|
||||
type Switch struct { |
||||
} |
||||
|
||||
type PDU struct { |
||||
} |
||||
|
||||
type UPS struct { |
||||
} |
||||
|
||||
//func (d *DB) GetManifests() *SelectQuery {
|
||||
//
|
||||
//}
|
Loading…
Reference in new issue