From 8897058bdfd828d11de837d5fb404ac393b80a78 Mon Sep 17 00:00:00 2001 From: Ulrich Schreiner Date: Sat, 12 Sep 2026 15:41:46 +0200 Subject: [PATCH 1/2] allow the user to specify a custom proxy for the qualys cloud agent --- cmd/cluster_qca.go | 37 +++++++++++++++++++++++++++++++++++++ go.mod | 2 ++ go.sum | 2 -- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/cmd/cluster_qca.go b/cmd/cluster_qca.go index c16c718e..ee6f18c6 100644 --- a/cmd/cluster_qca.go +++ b/cmd/cluster_qca.go @@ -1,6 +1,11 @@ package cmd import ( + "fmt" + "net" + "net/url" + "strings" + "github.com/fi-ts/cloud-go/api/client/cluster" "github.com/fi-ts/cloud-go/api/models" "github.com/metal-stack/metal-lib/pkg/genericcli" @@ -44,6 +49,7 @@ func newClusterQCACmd(c *config) *cobra.Command { genericcli.Must(clusterQCACmd.RegisterFlagCompletionFunc("cluster-id", c.comp.ClusterListCompletion)) configureCmd.Flags().Bool("disabled", false, "disables the entire xdr functionality") + configureCmd.Flags().String("proxy", "", "the proxy for the qca configuration, either in the form ip:port or as a parseable url") clusterQCACmd.AddCommand(configureCmd, showCmd) @@ -58,6 +64,14 @@ func (c *qcaCmd) configure() error { qcaConfiguration.Disabled = new(viper.GetBool("disabled")) } + if viper.IsSet("proxy") { + proxy, err := parseQCAProxy(viper.GetString("proxy")) + if err != nil { + return err + } + qcaConfiguration.Proxy = proxy + } + _, err := c.c.cloud.Cluster.UpdateCluster(cluster.NewUpdateClusterParams().WithBody(&models.V1ClusterUpdateRequest{ ID: new(viper.GetString("cluster-id")), QCAConfig: qcaConfiguration, @@ -69,6 +83,29 @@ func (c *qcaCmd) configure() error { return nil } +func parseQCAProxy(proxy string) (string, error) { + if proxy == "" { + return "", fmt.Errorf("proxy must not be empty") + } + + if strings.Contains(proxy, "://") { + u, err := url.Parse(proxy) + if err != nil { + return "", fmt.Errorf("unable to parse proxy url %q: %w", proxy, err) + } + if u.Host == "" { + return "", fmt.Errorf("invalid proxy url %q: missing host", proxy) + } + return proxy, nil + } + + if _, _, err := net.SplitHostPort(proxy); err != nil { + return "", fmt.Errorf("invalid proxy %q, must be in the form ip:port or a parseable url", proxy) + } + + return proxy, nil +} + func (c *qcaCmd) show() error { findRequest := cluster.NewFindClusterParams() findRequest.SetID(viper.GetString("cluster-id")) diff --git a/go.mod b/go.mod index 6fb57e4d..3053cddd 100644 --- a/go.mod +++ b/go.mod @@ -37,6 +37,8 @@ require ( sigs.k8s.io/yaml v1.6.0 ) +replace github.com/fi-ts/cloud-go => ../../cloud-go/extend-xdr-qca-proxy + require ( buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.12-20260825204119-511051f7f437.2 // indirect buf.build/go/protovalidate v1.4.0 // indirect diff --git a/go.sum b/go.sum index cf47e081..f2a18eb8 100644 --- a/go.sum +++ b/go.sum @@ -122,8 +122,6 @@ github.com/fatih/color v1.19.0 h1:Zp3PiM21/9Ld6FzSKyL5c/BULoe/ONr9KlbYVOfG8+w= github.com/fatih/color v1.19.0/go.mod h1:zNk67I0ZUT1bEGsSGyCZYZNrHuTkJJB+r6Q9VuMi0LE= github.com/fi-ts/accounting-go v0.11.2 h1:bCDMeUiz+mJB+sH/XKU/FEFK24MTlZ6qNWGoHZcSI0U= github.com/fi-ts/accounting-go v0.11.2/go.mod h1:HIbq56OpPJILxHnZ8bXJcOmCPnhhMJdbBJPJLXmcYNQ= -github.com/fi-ts/cloud-go v0.34.0 h1:qVbVlXvpeZEk1KDxVpNvAaHMqz4q+dpLThpd4M8dUeI= -github.com/fi-ts/cloud-go v0.34.0/go.mod h1:gwsY2TQzq4DIu8pevHUZXI11uE1zePOnpYXkPtLYlsw= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.10.1 h1:b0/UzAf9yR5rhf3RPm9gf3ehBPpf0oZKIjtpKrx59Ho= From 9f7a9450416e4a06930f186afd19a2ea2a9d8ff3 Mon Sep 17 00:00:00 2001 From: Ulrich Schreiner Date: Fri, 18 Sep 2026 08:09:04 +0200 Subject: [PATCH 2/2] repair dependencies --- go.mod | 4 +--- go.sum | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 3053cddd..90d5a010 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/dustin/go-humanize v1.0.1 github.com/fatih/color v1.19.0 github.com/fi-ts/accounting-go v0.11.2 - github.com/fi-ts/cloud-go v0.34.0 + github.com/fi-ts/cloud-go v0.35.0 github.com/gardener/gardener/pkg/apis v1.140.0 github.com/gardener/machine-controller-manager v0.62.1 github.com/gizak/termui/v3 v3.1.0 @@ -37,8 +37,6 @@ require ( sigs.k8s.io/yaml v1.6.0 ) -replace github.com/fi-ts/cloud-go => ../../cloud-go/extend-xdr-qca-proxy - require ( buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.12-20260825204119-511051f7f437.2 // indirect buf.build/go/protovalidate v1.4.0 // indirect diff --git a/go.sum b/go.sum index f2a18eb8..0d24ed72 100644 --- a/go.sum +++ b/go.sum @@ -122,6 +122,8 @@ github.com/fatih/color v1.19.0 h1:Zp3PiM21/9Ld6FzSKyL5c/BULoe/ONr9KlbYVOfG8+w= github.com/fatih/color v1.19.0/go.mod h1:zNk67I0ZUT1bEGsSGyCZYZNrHuTkJJB+r6Q9VuMi0LE= github.com/fi-ts/accounting-go v0.11.2 h1:bCDMeUiz+mJB+sH/XKU/FEFK24MTlZ6qNWGoHZcSI0U= github.com/fi-ts/accounting-go v0.11.2/go.mod h1:HIbq56OpPJILxHnZ8bXJcOmCPnhhMJdbBJPJLXmcYNQ= +github.com/fi-ts/cloud-go v0.35.0 h1:f6m8SRvEYYC+RIjQqSDchkg77XR3JYO0036tgbddoRA= +github.com/fi-ts/cloud-go v0.35.0/go.mod h1:gwsY2TQzq4DIu8pevHUZXI11uE1zePOnpYXkPtLYlsw= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.10.1 h1:b0/UzAf9yR5rhf3RPm9gf3ehBPpf0oZKIjtpKrx59Ho=