add ability to store/create encrypted vcenter password
Some checks are pending
CI / Lint (push) Waiting to run
CI / Test (push) Waiting to run
CI / End-to-End (push) Waiting to run
CI / Publish Docker (push) Blocked by required conditions
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-09-27 17:02:02 +10:00
parent 5a00f4a8c7
commit 3501967c9e
13 changed files with 235 additions and 772 deletions

View File

@@ -5,21 +5,12 @@ import (
"database/sql"
"log/slog"
"time"
"vctp/db"
"vctp/db/queries"
"vctp/internal/settings"
"vctp/internal/vcenter"
"github.com/vmware/govmomi/vim25/types"
)
// Handler handles requests.
type CronTask struct {
Logger *slog.Logger
Database db.Database
Settings settings.SettingsYML
}
// use gocron to check events in the Events table
func (c *CronTask) RunVmCheck(ctx context.Context, logger *slog.Logger) error {
var (
@@ -42,6 +33,8 @@ func (c *CronTask) RunVmCheck(ctx context.Context, logger *slog.Logger) error {
if err != nil {
logger.Error("Unable to query for unprocessed events", "error", err)
return nil // TODO - what to do with this error?
} else {
logger.Debug("Successfully queried for unprocessed events", "count", len(events))
}
for _, evt := range events {
@@ -51,7 +44,7 @@ func (c *CronTask) RunVmCheck(ctx context.Context, logger *slog.Logger) error {
// to avoid doing unnecessary login/logout of vcenter
c.Logger.Debug("connecting to vcenter")
vc := vcenter.New(c.Logger)
vc := vcenter.New(c.Logger, c.VcCreds)
vc.Login(evt.Source)
//datacenter = evt.DatacenterName.String