54 lines
1.1 KiB
Go
54 lines
1.1 KiB
Go
package upgrade
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.cycore.io/scm/talos-upgrade/pkg/node"
|
|
"github.com/charmbracelet/lipgloss"
|
|
"github.com/google/go-github/v55/github"
|
|
"github.com/pkg/errors"
|
|
"github.com/siderolabs/talos/pkg/machinery/client"
|
|
clientconfig "github.com/siderolabs/talos/pkg/machinery/client/config"
|
|
)
|
|
|
|
var docStyle = lipgloss.NewStyle().Margin(1, 2)
|
|
|
|
func NewCore(ctx context.Context) (*CoreState,error) {
|
|
cfg, err := clientconfig.Open("/home/scmccord/.config/talos/config.yaml")
|
|
if err != nil {
|
|
return nil, errors.Wrap(err, "failed to open Talos configuration")
|
|
}
|
|
|
|
tc, err := client.New(ctx, client.WithConfig(cfg))
|
|
if err != nil {
|
|
return nil, errors.Wrap(err, "failed to create Talos client")
|
|
}
|
|
|
|
return &CoreState{
|
|
ctx: ctx,
|
|
TalosClient: tc,
|
|
}, nil
|
|
}
|
|
|
|
type CoreState struct {
|
|
ctx context.Context
|
|
|
|
SelectedVersion string
|
|
SelectedImage string
|
|
|
|
CurrentReleases []*github.RepositoryRelease
|
|
|
|
Nodes []*node.Node
|
|
|
|
Talosconfig string
|
|
TalosContext string
|
|
TalosClient *client.Client
|
|
LowestTalosVersion string
|
|
HighestTalosVersion string
|
|
|
|
Kubeconfig string
|
|
KubeContext string
|
|
|
|
Width, Height int
|
|
}
|
|
|