← Back to team overview

sts-sponsors team mailing list archive

[Merge] ~ack/maas:drop-unused-hardware-sync into maas:master

 

Alberto Donato has proposed merging ~ack/maas:drop-unused-hardware-sync into maas:master.

Commit message:
drop unused hardware-sync binaries



Requested reviews:
  MAAS Maintainers (maas-maintainers)

For more details, see:
https://code.launchpad.net/~ack/maas/+git/maas/+merge/435719
-- 
Your team MAAS Maintainers is requested to review the proposed merge of ~ack/maas:drop-unused-hardware-sync into maas:master.
diff --git a/src/host-info/Makefile b/src/host-info/Makefile
index f82b555..98b139a 100644
--- a/src/host-info/Makefile
+++ b/src/host-info/Makefile
@@ -13,12 +13,10 @@ DEB_GO_ARCH_riscv64 = riscv64
 DEB_GO_ARCH_s390x = s390x
 
 BINDIR := bin
-MACHINE_RESOURCES_BINARIES := $(addprefix $(BINDIR)/machine-resources/,$(DEB_ARCHES))
-HARDWARE_SYNC_BINARIES := $(addprefix $(BINDIR)/hardware-sync/,$(DEB_ARCHES))
+BINARIES := $(addprefix $(BINDIR)/,$(DEB_ARCHES))
 
 CMD_DIR := ./cmd
 PACKAGE_DIR := $(CMD_DIR)/machine-resources
-HARDWARE_SYNC_DIR := $(CMD_DIR)/hardware-sync
 VENDOR_DIR := $(PACKAGE_DIR)/vendor
 # Explicitly set cache dirs to avoid situations where we can't mkdir under $HOME (e.g. Launchpad builds)
 export GOCACHE := $(shell [ -d $(HOME)/.cache ] && echo $(HOME)/.cache/go-cache || mktemp --tmpdir -d tmp.go-cacheXXX)
@@ -29,19 +27,17 @@ GO_BUILD := CGO_ENABLED=0 go build -mod=vendor -ldflags '-s -w -extldflags "-sta
 
 .DEFAULT_GOAL := build
 
-$(MACHINE_RESOURCES_BINARIES): TARGET_DIR=$(PACKAGE_DIR)
-$(HARDWARE_SYNC_BINARIES): TARGET_DIR=$(HARDWARE_SYNC_DIR)
-$(HARDWARE_SYNC_BINARIES) $(MACHINE_RESOURCES_BINARIES):
-	GOARCH=$(DEB_GO_ARCH_$(notdir $@)) $(GO_BUILD) -o $@ $(TARGET_DIR)
+$(BINARIES):
+	GOARCH=$(DEB_GO_ARCH_$(notdir $@)) $(GO_BUILD) -o $@ $(PACKAGE_DIR)
 
 build:
 # call targets separately to work with parallel builds
 	$(MAKE) vendor/modules.txt
-	$(MAKE) $(MACHINE_RESOURCES_BINARIES) $(HARDWARE_SYNC_BINARIES)
+	$(MAKE) $(BINARIES)
 .PHONY: build
 
 # don't vendor dependencies before building binaries
-build-no-vendor: $(MACHINE_RESOURCES_BINARIES) $(HARDWARE_SYNC_BINARIES)
+build-no-vendor: $(BINARIES)
 .PHONY: build-no-vendor
 
 clean:
@@ -52,8 +48,8 @@ format:
 	@go fmt $(PACKAGE_DIR)
 .PHONY: format
 
-install: $(MACHINE_RESOURCES_BINARIES)
-	install -t $(DESTDIR)/usr/share/maas/machine-resources -D $(MACHINE_RESOURCES_BINARIES)
+install: $(BINARIES)
+	install -t $(DESTDIR)/usr/share/maas/machine-resources -D $(BINARIES)
 .PHONY: install
 
 vendor: vendor/modules.txt
diff --git a/src/host-info/cmd/hardware-sync/main.go b/src/host-info/cmd/hardware-sync/main.go
deleted file mode 100644
index a35bcc1..0000000
--- a/src/host-info/cmd/hardware-sync/main.go
+++ /dev/null
@@ -1,92 +0,0 @@
-// Copyright 2022 Canonical Ltd.  This software is licensed under the
-// GNU Affero General Public License version 3 (see the file LICENSE).
-
-package main
-
-import (
-	"encoding/json"
-	"flag"
-	"fmt"
-	"os"
-
-	"host-info/pkg/info"
-)
-
-// MAASVersion corresponds with the running MAAS version hardware-sync reports to
-var MAASVersion = "" // set at compile time
-
-const TokenFormat = "'consumer-key:token-key:token-secret[:consumer_secret]'"
-
-type getMachineTokenOptions struct {
-	SystemId  string
-	TokenFile string
-}
-
-type reportResultsOptions struct {
-	Config       string
-	MachineToken string
-	MetadataUrl  string
-}
-
-type cmdOptions struct {
-	Debug              bool
-	MachineResourceRun bool
-	GetMachineToken    getMachineTokenOptions
-	ReportResults      reportResultsOptions
-}
-
-func parseCmdLine() (opts cmdOptions) {
-	flag.BoolVar(&opts.Debug, "debug", false, "print verbose debug messages")
-	flag.BoolVar(&opts.MachineResourceRun, "machine-resources", false, "when set, will read machine resources and print the info to stdout")
-	flag.StringVar(&opts.GetMachineToken.SystemId, "system-id", "", "system ID for the machine to get credentials for")
-	flag.StringVar(&opts.GetMachineToken.TokenFile, "token-file", "", "path for the file to write the token to")
-	flag.StringVar(
-		&opts.ReportResults.Config,
-		"config",
-		"",
-		"cloud-init config with MAAS credentials and endpoint, (e.g. /etc/cloud/cloud.cfg.d/90_dpkg_local_cloud_config.cfg)",
-	)
-	flag.StringVar(
-		&opts.ReportResults.MachineToken,
-		"machine-token",
-		"",
-		fmt.Sprintf("Machine OAuth token, in the %s form", TokenFormat),
-	)
-	flag.StringVar(
-		&opts.ReportResults.MetadataUrl,
-		"metadata-url",
-		"",
-		"MAAS metadata URL",
-	)
-	flag.Parse()
-	return opts
-}
-
-func getMachineResources() error {
-	machineResources, err := info.GetInfo()
-	if err != nil {
-		return err
-	}
-	encoder := json.NewEncoder(os.Stdout)
-	return encoder.Encode(machineResources)
-}
-
-func run() int {
-	opts := parseCmdLine()
-
-	if opts.MachineResourceRun {
-		err := getMachineResources()
-		if err != nil {
-			fmt.Printf("an error occurred while fetching machine resources: %s\n", err)
-			return 1
-		}
-		return 0
-	}
-
-	// TODO embed scripts and call out to maas_run_scripts
-	return 0
-}
-
-func main() {
-	os.Exit(run())
-}

Follow ups