Testing Anvil ssh struct modified: go.mod modified: go.sum modified: main.go modified: models.go Challenge: storing AuthorizedKey record as ssh datatypedata-work
parent
5bbe08ded5
commit
2f095a8928
5 changed files with 104 additions and 71 deletions
@ -0,0 +1,11 @@ |
|||||||
|
package main |
||||||
|
|
||||||
|
import ( |
||||||
|
"golang.org/x/crypto/ssh" |
||||||
|
"golang.org/x/term" |
||||||
|
) |
||||||
|
|
||||||
|
type AnvilSSHConnection struct { |
||||||
|
thing ssh.Client |
||||||
|
otherthing term.Terminal |
||||||
|
} |
@ -1,37 +1,73 @@ |
|||||||
package main |
package main |
||||||
|
|
||||||
import ( |
import ( |
||||||
|
"github.com/google/uuid" |
||||||
"github.com/uptrace/bun" |
"github.com/uptrace/bun" |
||||||
) |
) |
||||||
|
|
||||||
type User struct { |
type User struct { |
||||||
bun.BaseModel `bun:"table:users"` |
bun.BaseModel `bun:"table:users"` |
||||||
|
|
||||||
ID int64 `bun:"id,pk,autoincrement"` |
UUID uuid.UUID `bun:"user_uuid,pk"` |
||||||
Username string `bun:"username"` |
Username string `bun:"user_name"` |
||||||
|
IsExperienced bool `bun:"user_is_experienced"` |
||||||
|
IsTrusted bool `bun:"user_is_trusted"` |
||||||
|
// https://pkg.go.dev/github.com/google/uuid#UUID
|
||||||
|
// SELECT user_uuid,user_name,user_is_experienced,user_is_trusted FROM \
|
||||||
|
// users ORDER BY user_uuid;
|
||||||
} |
} |
||||||
|
|
||||||
type Feed struct { |
type SSHKey struct { |
||||||
bun.BaseModel `bun:"table:feeds"` |
bun.BaseModel `bun:"table:ssh_keys"` |
||||||
|
|
||||||
ID int64 `bun:"id,pk,autoincrement"` |
UUID uuid.UUID `bun:"ssh_key_uuid,pk"` |
||||||
CategoryID int64 `bun:"category_id"` |
Username string `bun:"ssh_key_user_name"` |
||||||
Title string `bun:"title"` |
PublicKey []byte `bun:"ssh_key_public_key"` |
||||||
// SELECT id,category_id,title FROM feeds ORDER BY id;
|
// https://pkg.go.dev/golang.org/x/crypto/ssh#PublicKey
|
||||||
|
// SELECT ssh_key_uuid,ssh_key_user_name FROM ssh_keys ORDER BY ssh_key_user_name;
|
||||||
} |
} |
||||||
type Entry struct { |
|
||||||
bun.BaseModel `bun:"table:entries"` |
|
||||||
|
|
||||||
ID int64 `bun:"id,pk,autoincrement"` |
type Server struct { |
||||||
Title string `bun:"title"` |
|
||||||
Author string `bun:"author"` |
|
||||||
// SELECT id,title,author FROM entries ORDER BY published_at LIMIT 10;
|
|
||||||
} |
} |
||||||
type Category struct { |
|
||||||
bun.BaseModel `bun:"table:categories"` |
|
||||||
|
|
||||||
ID int64 `bun:"id,pk,autoincrement"` |
type ServerDefinition struct { |
||||||
Title string `bun:"title"` |
} |
||||||
//SELECT id,title from categories;
|
|
||||||
|
type Manifest struct { |
||||||
|
bun.BaseModel `bun:"table:manifests"` |
||||||
|
|
||||||
|
UUID uuid.UUID `bun:"mainifest_uuid,pk"` |
||||||
|
Name string `bun:"manifest_name"` |
||||||
|
LastRan string `bun:"manifest_last_ran"` |
||||||
|
XML string `bun:"manifest_xml"` |
||||||
|
Note string `bun:"manifest_note"` |
||||||
|
// https://pkg.go.dev/encoding/xml#CharData
|
||||||
|
} |
||||||
|
|
||||||
|
type Job struct { |
||||||
|
bun.BaseModel `bun:"table:jobs"` |
||||||
|
|
||||||
|
UUID uuid.UUID `bun:"job_uuid,pk"` |
||||||
|
HostUUID uuid.UUID `bun:"host_uuid"` |
||||||
|
Command string `bun:"job_command"` |
||||||
|
Data string `bun:"job_data"` |
||||||
|
PickedUpBy string `bun:"job_picked_up_by"` |
||||||
|
PickedUpAt string `bun:"job_picked_up_at"` |
||||||
|
Updated string `bun:"job_updated"` |
||||||
|
Name string `bun:"job_name"` |
||||||
|
Progress int64 `bun:"job_progress"` |
||||||
|
Title string `bun:"job_title"` |
||||||
|
Description string `bun:"job_description"` |
||||||
|
Status string `bun:"job_status"` |
||||||
|
} |
||||||
|
|
||||||
|
type Host struct { |
||||||
|
bun.BaseModel `bun:"table:hosts"` |
||||||
|
|
||||||
|
UUID uuid.UUID `bun:"host_uuid,pk"` |
||||||
|
HostName string `bun:"host_name"` |
||||||
|
HostType string `bun:"host_type"` |
||||||
|
HostKey string `bun:"host_key"` |
||||||
|
HostIPMI string `bun:"host_ipmi"` |
||||||
|
HostStatus string `bun:"host_status"` |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue