Skip to content

Commit

Permalink
Merge branch 'develop-0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
mologie committed Mar 16, 2022
2 parents d28b3e9 + 471e95c commit 33cc8b1
Show file tree
Hide file tree
Showing 882 changed files with 339 additions and 433,236 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.git
.github
deploy
11 changes: 11 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Test
on: [pull_request]
jobs:
test_container:
name: Build a container test image
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v2
- name: Docker
run: docker build . --file Dockerfile --tag talos-vmtoolsd:test
31 changes: 0 additions & 31 deletions .github/workflows/test.yml

This file was deleted.

1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/talos-vmtoolsd
/.idea
TODO.txt
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
FROM golang:1.17.2-alpine AS builder
FROM golang:1.17.8-alpine AS builder
WORKDIR /build
COPY . .
ENV CGO_ENABLED=0
ARG CGO_ENABLED=0
ARG GOARCH=amd64
RUN GOOS=linux GOARCH=${GOARCH} go build -ldflags="-s -w" -trimpath -o talos-vmtoolsd ./cmd/talos-vmtoolsd
ARG GOOS=linux
RUN go test -v ./... && \
go vet ./... && \
go build -ldflags="-s -w" -trimpath -o talos-vmtoolsd ./cmd/talos-vmtoolsd

FROM gcr.io/distroless/static-debian10
COPY --from=builder /build/talos-vmtoolsd /bin/talos-vmtoolsd
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ Install or upgrade `talos-vmtoolsd`:
kubectl apply -f https://raw.githubusercontent.com/mologie/talos-vmtoolsd/release-0.2/deploy/0.2.yaml
```

# Talos Compatibility Matrix

| ⬇️ Tools \ Talos ➡️ | 0.7 - 0.10 | 0.11 - 0.13 | 0.14+ |
| ----------------- | ---------- | ----------- | ----- |
| **0.3** (current) ||||
| **0.2** ||||

# Roadmap

* [x] Feature-complete integration of Talos apid and ESXi (restart/stop, IP, DNS, heartbeats)
Expand Down
53 changes: 48 additions & 5 deletions cmd/talos-vmtoolsd/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package main

import (
"flag"
"fmt"
vmtoolsd "github.com/mologie/talos-vmtoolsd"
"github.com/mologie/talos-vmtoolsd/internal/nanotoolbox"
"github.com/mologie/talos-vmtoolsd/internal/talosapi"
Expand All @@ -20,6 +22,11 @@ func main() {
DisableHTMLEscape: true,
})

// Debug flags
talosTestQuery := ""
flag.StringVar(&talosTestQuery, "test-apid-query", "", "query apid")
flag.Parse()

// Apply log level, default to "info"
if levelStr, ok := os.LookupEnv("LOG_LEVEL"); ok {
if level, err := logrus.ParseLevel(levelStr); err != nil {
Expand All @@ -32,7 +39,7 @@ func main() {
}

l.Infof("talos-vmtoolsd version %v\n"+
"Copyright 2020-2021 Oliver Kuckertz <[email protected]>\n"+
"Copyright 2020-2022 Oliver Kuckertz <[email protected]>\n"+
"This program is free software and available under the Apache 2.0 license.",
vmtoolsd.Version)

Expand All @@ -55,10 +62,7 @@ func main() {
l.Fatal("error: TALOS_HOST is required to point to a node's internal IP")
}

// Wires up VMware Toolbox commands to Talos apid.
vmguestmsg.DefaultLogger = l.WithField("module", "vmware-guestinfo")
rpcIn, rpcOut := nanotoolbox.NewHypervisorChannelPair()
svc := nanotoolbox.NewService(l, rpcIn, rpcOut)
// Connect to Talos apid
api, err := talosapi.NewLocalClient(l, configPath, k8sHost)
if err != nil {
l.WithError(err).Fatal("could not connect to apid")
Expand All @@ -68,6 +72,21 @@ func main() {
l.WithError(err).Warn("failed to close API client during process shutdown")
}
}()

// Manual test query mode for Talos apid client
if talosTestQuery != "" {
if err := testQuery(api, talosTestQuery); err != nil {
l.WithField("test_query", talosTestQuery).WithError(err).Fatal("test query failed")
os.Exit(1)
} else {
os.Exit(0)
}
}

// Wires up VMware Toolbox commands to Talos apid.
vmguestmsg.DefaultLogger = l.WithField("module", "vmware-guestinfo")
rpcIn, rpcOut := nanotoolbox.NewHypervisorChannelPair()
svc := nanotoolbox.NewService(l, rpcIn, rpcOut)
tboxcmds.RegisterGuestInfoCommands(svc, api)
tboxcmds.RegisterPowerDelegate(svc, api)
tboxcmds.RegisterVixCommand(svc, api)
Expand All @@ -87,3 +106,27 @@ func main() {
svc.Wait()
l.Info("graceful shutdown done, fair winds!")
}

func testQuery(api *talosapi.LocalClient, query string) error {
w := os.Stdout
switch query {
case "net-interfaces":
for idx, intf := range api.NetInterfaces() {
for _, addr := range intf.Addrs {
_, _ = fmt.Fprintf(w, "%d: name=%s mac=%s addr=%s\n", idx, intf.Name, intf.MAC, addr)
}
}
return nil
case "hostname":
_, _ = fmt.Fprintln(w, api.Hostname())
return nil
case "os-version":
_, _ = fmt.Fprintln(w, api.OSVersion())
return nil
case "os-version-short":
_, _ = fmt.Fprintln(w, api.OSVersionShort())
return nil
default:
return fmt.Errorf("unknown test query %q", query)
}
}
56 changes: 39 additions & 17 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,50 @@ go 1.17
require (
github.com/golang/protobuf v1.5.2
github.com/sirupsen/logrus v1.8.1
github.com/stellar/go-xdr v0.0.0-20211004181054-b95df30963cd
github.com/talos-systems/talos/pkg/machinery v0.12.3
github.com/vmware/govmomi v0.26.1
github.com/stellar/go-xdr v0.0.0-20211103144802-8017fc4bdfee
github.com/talos-systems/talos v0.13.0
github.com/talos-systems/talos/pkg/machinery v0.14.0
github.com/vmware/govmomi v0.27.2
github.com/vmware/vmw-guestinfo v0.0.0-20211006225857-cc1fd90d572c
gopkg.in/yaml.v2 v2.4.0
inet.af/netaddr v0.0.0-20211027220019-c74959edd3b6
)

require (
github.com/AlekSi/pointer v1.1.0 // indirect
github.com/containerd/containerd v1.3.6 // indirect
github.com/containerd/go-cni v1.0.2 // indirect
github.com/containernetworking/cni v0.8.1 // indirect
github.com/cosi-project/runtime v0.0.0-20210707150857-25f235cd0682 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/AlekSi/pointer v1.2.0 // indirect
github.com/BurntSushi/toml v0.4.1 // indirect
github.com/containerd/go-cni v1.1.1 // indirect
github.com/containernetworking/cni v1.0.1 // indirect
github.com/cosi-project/runtime v0.0.0-20211216175730-264f8fcd1a4f // indirect
github.com/gertd/go-pluralize v0.1.7 // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/talos-systems/crypto v0.3.2 // indirect
github.com/talos-systems/net v0.3.0 // indirect
golang.org/x/net v0.0.0-20210525063256-abc453219eb5 // indirect
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
golang.org/x/text v0.3.6 // indirect
google.golang.org/genproto v0.0.0-20210722135532-667f2b7c528f // indirect
google.golang.org/grpc v1.40.0 // indirect
github.com/josharian/native v0.0.0-20200817173448-b6b71def0850 // indirect
github.com/jsimonetti/rtnetlink v0.0.0-20211213041634-9dff439f7e79 // indirect
github.com/mdlayher/ethtool v0.0.0-20211214014908-bc8fdcf6e99c // indirect
github.com/mdlayher/genetlink v1.1.0 // indirect
github.com/mdlayher/netlink v1.5.0 // indirect
github.com/mdlayher/socket v0.1.1 // indirect
github.com/onsi/gomega v1.10.3 // indirect
github.com/stretchr/objx v0.2.0 // indirect
github.com/talos-systems/crypto v0.3.4 // indirect
github.com/talos-systems/net v0.3.1 // indirect
go4.org/intern v0.0.0-20211027215823-ae77deb06f29 // indirect
go4.org/unsafe/assume-no-moving-gc v0.0.0-20211027215541-db492cf91b37 // indirect
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 // indirect
golang.org/x/mod v0.5.1 // indirect
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/tools v0.1.8 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20211215182854-7a385b3431de // indirect
google.golang.org/genproto v0.0.0-20211221231510-d629cc9a93d5 // indirect
google.golang.org/grpc v1.43.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
honnef.co/go/tools v0.2.2 // indirect
)
Loading

0 comments on commit 33cc8b1

Please sign in to comment.