Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ func newClusterCmd(c *config) *cobra.Command {
clusterCmd.AddCommand(clusterMonitoringSecretCmd)
clusterCmd.AddCommand(newClusterAuditCmd(c))
clusterCmd.AddCommand(newClusterXdrCmd(c))
clusterCmd.AddCommand(newClusterQCACmd(c))

return clusterCmd
}
Expand Down
81 changes: 81 additions & 0 deletions cmd/cluster_qca.go
Original file line number Diff line number Diff line change
@@ -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=<clusterid>",
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=<clusterid>",
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)
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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.1
github.com/fi-ts/cloud-go v0.33.0
github.com/fi-ts/cloud-go v0.34.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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,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.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.33.0 h1:GMU+dUnJVGAjSORB9Sqkxg62SdOwQ+1hOXdx+MaUK4g=
github.com/fi-ts/cloud-go v0.33.0/go.mod h1:gwsY2TQzq4DIu8pevHUZXI11uE1zePOnpYXkPtLYlsw=
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.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
Expand Down