From dc8bf02e4df6d8498aa9ccce73fa3cf8baaa5ad5 Mon Sep 17 00:00:00 2001 From: Ulrich Schreiner Date: Mon, 2 Mar 2026 08:58:18 +0100 Subject: [PATCH] add command for qualys --- cmd/cluster.go | 1 + cmd/cluster_qca.go | 81 ++++++++++++++++++++++++++++++++++++++++++++++ go.mod | 2 +- go.sum | 4 +-- 4 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 cmd/cluster_qca.go diff --git a/cmd/cluster.go b/cmd/cluster.go index e8594840..a53edcd3 100644 --- a/cmd/cluster.go +++ b/cmd/cluster.go @@ -460,6 +460,7 @@ func newClusterCmd(c *config) *cobra.Command { clusterCmd.AddCommand(clusterMonitoringSecretCmd) clusterCmd.AddCommand(newClusterAuditCmd(c)) clusterCmd.AddCommand(newClusterXdrCmd(c)) + clusterCmd.AddCommand(newClusterQCACmd(c)) return clusterCmd } diff --git a/cmd/cluster_qca.go b/cmd/cluster_qca.go new file mode 100644 index 00000000..c16c718e --- /dev/null +++ b/cmd/cluster_qca.go @@ -0,0 +1,81 @@ +package cmd + +import ( + "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" + "github.com/spf13/cobra" + "github.com/spf13/viper" +) + +type qcaCmd struct { + c *config +} + +func newClusterQCACmd(c *config) *cobra.Command { + w := qcaCmd{ + c: c, + } + + clusterQCACmd := &cobra.Command{ + Use: "qca", + Short: "configure a cluster's qualys cloud agent configuration", + Long: `qualys cloud agent scans and monitors the nodes of a cluster`, + } + + configureCmd := &cobra.Command{ + Use: "configure --cluster-id=", + Short: "configure the qca settings for this cluster (only allowed for provider tenant)", + RunE: func(cmd *cobra.Command, args []string) error { + return w.configure() + }, + } + + showCmd := &cobra.Command{ + Use: "show --cluster-id=", + Short: "show the current qca configuration for this cluster", + RunE: func(cmd *cobra.Command, args []string) error { + return w.show() + }, + } + + clusterQCACmd.PersistentFlags().String("cluster-id", "", "the id of the cluster to apply the xdr configuration to") + genericcli.Must(clusterQCACmd.MarkPersistentFlagRequired("cluster-id")) + genericcli.Must(clusterQCACmd.RegisterFlagCompletionFunc("cluster-id", c.comp.ClusterListCompletion)) + + configureCmd.Flags().Bool("disabled", false, "disables the entire xdr functionality") + + clusterQCACmd.AddCommand(configureCmd, showCmd) + + return clusterQCACmd +} + +func (c *qcaCmd) configure() error { + + qcaConfiguration := &models.V1QualysCloudAgent{} + + if viper.IsSet("disabled") { + qcaConfiguration.Disabled = new(viper.GetBool("disabled")) + } + + _, err := c.c.cloud.Cluster.UpdateCluster(cluster.NewUpdateClusterParams().WithBody(&models.V1ClusterUpdateRequest{ + ID: new(viper.GetString("cluster-id")), + QCAConfig: qcaConfiguration, + }), nil) + if err != nil { + return err + } + + return nil +} + +func (c *qcaCmd) show() error { + findRequest := cluster.NewFindClusterParams() + findRequest.SetID(viper.GetString("cluster-id")) + shoot, err := c.c.cloud.Cluster.FindCluster(findRequest, nil) + if err != nil { + return err + } + + return c.c.describePrinter.Print(shoot.Payload.QCAConfig) +} diff --git a/go.mod b/go.mod index 17921b3b..7a19d979 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/dustin/go-humanize v1.0.1 github.com/fatih/color v1.18.0 github.com/fi-ts/accounting-go v0.11.1 - github.com/fi-ts/cloud-go v0.30.16 + github.com/fi-ts/cloud-go v0.30.19-0.20260302072043-500980566cec github.com/gardener/gardener v1.123.5 github.com/gardener/machine-controller-manager v0.58.0 github.com/go-openapi/runtime v0.29.2 diff --git a/go.sum b/go.sum index 6b59e5bc..e56ae937 100644 --- a/go.sum +++ b/go.sum @@ -136,8 +136,8 @@ github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/fi-ts/accounting-go v0.11.1 h1:F4rFua+Q8wF03ASNPTgiUNEQ4vTgnZ1B/ac3B+ssiT8= github.com/fi-ts/accounting-go v0.11.1/go.mod h1:yX9yqzX+i23O/Bj9Gn22oM+/nd2QtjMsvVIWab9UAU4= -github.com/fi-ts/cloud-go v0.30.16 h1:dzcLcyHft3rmn6H1liPMdzPsQnuD3huqpGZC9TIhemk= -github.com/fi-ts/cloud-go v0.30.16/go.mod h1:gwsY2TQzq4DIu8pevHUZXI11uE1zePOnpYXkPtLYlsw= +github.com/fi-ts/cloud-go v0.30.19-0.20260302072043-500980566cec h1:zvQhlncYHa4pEvJVy6BgwoM2Ly42w68DefYlbasvTgI= +github.com/fi-ts/cloud-go v0.30.19-0.20260302072043-500980566cec/go.mod h1:gwsY2TQzq4DIu8pevHUZXI11uE1zePOnpYXkPtLYlsw= github.com/fluent/fluent-operator/v3 v3.3.0 h1:zBtt8IOVSyTiywnmom3V2byqIi2ZXMCCKBUx/4bnFBk= github.com/fluent/fluent-operator/v3 v3.3.0/go.mod h1:x54zzJ60QYJ6jnN7n9/Mseyaz9oWjSO99hbhVXJaar0= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=