Skip to content

Commit

Permalink
Adopt to cloud-api v0.28.0
Browse files Browse the repository at this point in the history
  • Loading branch information
majst01 committed Sep 11, 2024
1 parent f0caa9d commit 39f648b
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 179 deletions.
27 changes: 0 additions & 27 deletions cmd/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,7 @@ func newClusterCmd(c *config) *cobra.Command {
clusterCreateCmd.Flags().StringSlice("labels", []string{}, "labels of the cluster")
clusterCreateCmd.Flags().StringSlice("external-networks", []string{}, "external networks of the cluster")
clusterCreateCmd.Flags().StringSlice("egress", []string{}, "static egress ips per network, must be in the form <network>:<ip>; e.g.: --egress internet:1.2.3.4,extnet:123.1.1.1 --egress internet:1.2.3.5 [optional]")
clusterCreateCmd.Flags().BoolP("allowprivileged", "", false, "allow privileged containers the cluster (this is achieved through pod security policies and has no effect anymore on clusters >= v1.25")
clusterCreateCmd.Flags().String("default-pod-security-standard", "", "sets default pod security standard for clusters >= v1.23.x, defaults to restricted on clusters >= v1.25 (valid values: empty string, privileged, baseline, restricted)")
clusterCreateCmd.Flags().BoolP("disable-pod-security-policies", "", false, "disable pod security policies")
clusterCreateCmd.Flags().Duration("healthtimeout", 0, "period (e.g. \"24h\") after which an unhealthy node is declared failed and will be replaced. [optional]")
clusterCreateCmd.Flags().Duration("draintimeout", 0, "period (e.g. \"3h\") after which a draining node will be forcefully deleted. [optional]")
clusterCreateCmd.Flags().Bool("encrypted-storage-classes", false, "enables the deployment of encrypted duros storage classes into the cluster. please refer to the user manual to properly use volume encryption. [optional]")
Expand Down Expand Up @@ -320,9 +318,7 @@ func newClusterCmd(c *config) *cobra.Command {
clusterUpdateCmd.Flags().String("machineimage", "", "machine image to use for the nodes, must be in the form of <name>-<version> ")
clusterUpdateCmd.Flags().StringSlice("addlabels", []string{}, "labels to add to the cluster")
clusterUpdateCmd.Flags().StringSlice("removelabels", []string{}, "labels to remove from the cluster")
clusterUpdateCmd.Flags().BoolP("allowprivileged", "", false, "allow privileged containers the cluster (this is achieved through pod security policies and has no effect anymore on clusters >=v1.25")
clusterUpdateCmd.Flags().String("default-pod-security-standard", "", "set default pod security standard for cluster >=v 1.23.x, send empty string explicitly to disable pod security standards (valid values: empty string, privileged, baseline, restricted)")
clusterUpdateCmd.Flags().BoolP("disable-pod-security-policies", "", false, "disable pod security policies")
clusterUpdateCmd.Flags().String("purpose", "", fmt.Sprintf("purpose of the cluster, can be one of %s. SLA is only given on production clusters.", strings.Join(completion.ClusterPurposes, "|")))
clusterUpdateCmd.Flags().StringSlice("egress", []string{}, "static egress ips per network, must be in the form <networkid>:<semicolon-separated ips>; e.g.: --egress internet:1.2.3.4;1.2.3.5 --egress extnet:123.1.1.1 [optional]. Use \"--egress none\" to remove all egress rules.")
clusterUpdateCmd.Flags().StringSlice("external-networks", []string{}, "external networks of the cluster")
Expand Down Expand Up @@ -470,18 +466,10 @@ func (c *config) clusterCreate() error {
healthtimeout := viper.GetDuration("healthtimeout")
draintimeout := viper.GetDuration("draintimeout")

var allowprivileged *bool
if viper.IsSet("allowprivileged") {
allowprivileged = pointer.Pointer(viper.GetBool("allowprivileged"))
}
var defaultPodSecurityStandard *string
if viper.IsSet("default-pod-security-standard") {
defaultPodSecurityStandard = pointer.Pointer(viper.GetString("default-pod-security-standard"))
}
var disablePodSecurityPolicies *bool
if viper.IsSet("disable-pod-security-policies") {
disablePodSecurityPolicies = pointer.Pointer(viper.GetBool("disable-pod-security-policies"))
}

var networkAccessType *string
if viper.IsSet("network-isolation") {
Expand Down Expand Up @@ -599,17 +587,14 @@ WARNING: You are going to create a cluster that has no default internet access w
MaxUnavailable: &maxunavailable,
MachineType: &machineType,
MachineImage: &machineImage,
CRI: &cri,
},
},
FirewallSize: &firewallType,
FirewallImage: &firewallImage,
FirewallControllerVersion: &firewallController,
Kubernetes: &models.V1Kubernetes{
AllowPrivilegedContainers: allowprivileged,
Version: &version,
DefaultPodSecurityStandard: defaultPodSecurityStandard,
DisablePodSecurityPolicies: disablePodSecurityPolicies,
},
Maintenance: &models.V1Maintenance{
TimeWindow: &models.V1MaintenanceTimeWindow{
Expand Down Expand Up @@ -1282,24 +1267,12 @@ func (c *config) updateCluster(args []string) error {
if version != "" {
k8s.Version = &version
}
if viper.IsSet("allowprivileged") {
if !viper.GetBool("yes-i-really-mean-it") {
return fmt.Errorf("--allowprivileged is set but you forgot to add --yes-i-really-mean-it")
}
k8s.AllowPrivilegedContainers = pointer.Pointer(viper.GetBool("allowprivileged"))
}
if viper.IsSet("default-pod-security-standard") {
if !viper.GetBool("yes-i-really-mean-it") {
return fmt.Errorf("--default-pod-security-standard is set but you forgot to add --yes-i-really-mean-it")
}
k8s.DefaultPodSecurityStandard = pointer.Pointer(viper.GetString("default-pod-security-standard"))
}
if viper.IsSet("disable-pod-security-policies") {
if !viper.GetBool("yes-i-really-mean-it") {
return fmt.Errorf("--disable-pod-security-policies set but you forgot to add --yes-i-really-mean-it")
}
k8s.DisablePodSecurityPolicies = pointer.Pointer(viper.GetBool("disable-pod-security-policies"))
}

cur.Kubernetes = k8s
cur.EgressRules = makeEgressRules(egress)
Expand Down
8 changes: 4 additions & 4 deletions cmd/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/metal-stack/metal-lib/pkg/cache"
"github.com/metal-stack/metal-lib/pkg/genericcli"
"github.com/metal-stack/metal-lib/pkg/healthstatus"
"github.com/metal-stack/metal-lib/pkg/pointer"
"github.com/metal-stack/metal-lib/rest"
"github.com/metal-stack/v"
"github.com/spf13/cobra"
"github.com/spf13/viper"
Expand Down Expand Up @@ -305,11 +305,11 @@ func (d *dashboard) Render() {
defer func() {
var coloredHealth string
switch apiHealth {
case string(rest.HealthStatusHealthy):
case string(healthstatus.HealthStatusHealthy):
coloredHealth = "[" + apiHealth + "](fg:green)"
case string(rest.HealthStatusDegraded), string(rest.HealthStatusPartiallyUnhealthy):
case string(healthstatus.HealthStatusDegraded), string(healthstatus.HealthStatusPartiallyUnhealthy):
coloredHealth = "[" + apiHealth + "](fg:yellow)"
case string(rest.HealthStatusUnhealthy):
case string(healthstatus.HealthStatusUnhealthy):
if apiHealthMessage != "" {
coloredHealth = "[" + apiHealth + fmt.Sprintf(" (%s)](fg:red)", apiHealthMessage)
} else {
Expand Down
11 changes: 6 additions & 5 deletions cmd/output/healthprinter.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package output

import (
"maps"
"slices"
"sort"

"github.com/fi-ts/cloud-go/api/models"
"golang.org/x/exp/maps"
)

type (
Expand Down Expand Up @@ -34,7 +35,7 @@ func (p HealthTablePrinter) Print(health *models.RestHealthResponse) {
p.render()
}

func (p HealthTablePrinter) PrintServices(services map[string]models.RestHealthResult) {
func (p HealthTablePrinter) PrintServices(services map[string]models.RestHealthResponse) {
p.wideHeader = []string{"Service", "Status", "Message"}
p.shortHeader = p.wideHeader

Expand Down Expand Up @@ -62,9 +63,9 @@ func (p HealthTablePrinter) PrintServices(services map[string]models.RestHealthR

i := 0
skeys := maps.Keys(s.Services)
sort.Strings(skeys)

for _, sname := range skeys {
sortedServiceKeys := slices.Collect(skeys)
slices.Sort(sortedServiceKeys)
for _, sname := range sortedServiceKeys {
sresult := s.Services[sname]
prefix := "├"
if i == len(s.Services)-1 {
Expand Down
2 changes: 1 addition & 1 deletion cmd/output/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func (t tablePrinter) Print(data interface{}) error {
TenantTablePrinter{t}.Print([]*models.V1TenantResponse{d})
case *models.RestHealthResponse:
HealthTablePrinter{t}.Print(d)
case map[string]models.RestHealthResult:
case map[string]models.RestHealthResponse:
HealthTablePrinter{t}.PrintServices(d)
case []*models.ModelsV1IPResponse:
IPTablePrinter{t}.Print(d)
Expand Down
17 changes: 2 additions & 15 deletions cmd/output/shootprinter.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type (
)

const (
imageExpirationDaysDefault = 14
imageExpirationDaysDefault = 14
)

type shootStats struct {
Expand Down Expand Up @@ -121,7 +121,7 @@ func (s ShootTablePrinter) Print(data []*models.V1ClusterResponse) {
}

func (s ShootIssuesTablePrinter) Print(data []*models.V1ClusterResponse) {
s.wideHeader = []string{"UID", "", "Name", "Version", "Partition", "Seed", "Domain", "Operation", "Progress", "Api", "Control", "Nodes", "System", "Size", "Age", "Purpose", "Privileged", "Audit", "Runtime", "Firewall", "Firewall Controller", "Log accepted conns", "Egress IPs"}
s.wideHeader = []string{"UID", "", "Name", "Version", "Partition", "Seed", "Domain", "Operation", "Progress", "Api", "Control", "Nodes", "System", "Size", "Age", "Purpose", "Audit", "Firewall", "Firewall Controller", "Log accepted conns", "Egress IPs"}
s.shortHeader = []string{"UID", "", "Tenant", "Project", "Name", "Version", "Partition", "Operation", "Progress", "Api", "Control", "Nodes", "System", "Size", "Age", "Purpose"}

if s.order == "" {
Expand Down Expand Up @@ -238,11 +238,6 @@ func shootData(shoot *models.V1ClusterResponse, withIssues bool) ([]string, []st
purpose = p[:4]
}

privileged := ""
if shoot.Kubernetes.AllowPrivilegedContainers != nil {
privileged = fmt.Sprintf("%t", *shoot.Kubernetes.AllowPrivilegedContainers)
}

audit := "Off"
if shoot.ControlPlaneFeatureGates != nil {
var ca, as bool
Expand All @@ -262,17 +257,11 @@ func shootData(shoot *models.V1ClusterResponse, withIssues bool) ([]string, []st
}
}

runtimes := []string{}
autoScaleMin := int32(0)
autoScaleMax := int32(0)
for _, w := range shoot.Workers {
autoScaleMin += *w.Minimum
autoScaleMax += *w.Maximum
if w.CRI != nil && *w.CRI != "" {
runtimes = append(runtimes, *w.CRI)
} else {
runtimes = append(runtimes, "docker")
}
}
currentMachines := "x"
if shoot.Machines != nil {
Expand Down Expand Up @@ -330,9 +319,7 @@ func shootData(shoot *models.V1ClusterResponse, withIssues bool) ([]string, []st
age,
lastReconciliation,
purpose,
privileged,
audit,
strings.Join(uniqueStringSlice(runtimes), "\n"),
firewallImage,
firewallController,
logAcceptedConnections,
Expand Down
2 changes: 1 addition & 1 deletion cmd/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,7 @@ func (c *config) postgresBackupCreate(autocreate bool) error {
name := viper.GetString("name")
project := viper.GetString("project")
schedule := viper.GetString("schedule")
retention := viper.GetInt32("retention")
retention := viper.GetInt64("retention")
partition := viper.GetString("partition")
s3Endpoint := viper.GetString("s3-endpoint")
s3Region := viper.GetString("s3-region")
Expand Down
82 changes: 41 additions & 41 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
module github.com/fi-ts/cloudctl

go 1.22
go 1.23.0

require (
github.com/Masterminds/semver/v3 v3.2.1
github.com/Masterminds/semver/v3 v3.3.0
github.com/dcorbe/termui-dpc v0.0.0-20211125210512-9d2673a82dd6
github.com/dustin/go-humanize v1.0.1
github.com/fatih/color v1.17.0
github.com/fi-ts/accounting-go v0.10.0
github.com/fi-ts/cloud-go v0.27.0
github.com/gardener/gardener v1.80.0
github.com/gardener/machine-controller-manager v0.50.1
github.com/fi-ts/cloud-go v0.27.1-0.20240911105933-238ee51af07d
github.com/gardener/gardener v1.91.0
github.com/gardener/machine-controller-manager v0.53.1
github.com/go-openapi/runtime v0.28.0
github.com/go-openapi/strfmt v0.23.0
github.com/go-playground/validator/v10 v10.22.0
github.com/go-playground/validator/v10 v10.22.1
github.com/go-task/slim-sprig/v3 v3.0.0
github.com/google/go-cmp v0.6.0
github.com/gosimple/slug v1.14.0
github.com/jinzhu/now v1.1.5
github.com/metal-stack/duros-go v0.5.0
github.com/metal-stack/metal-go v0.32.1
github.com/metal-stack/metal-lib v0.17.1
github.com/metal-stack/duros-go v0.5.1
github.com/metal-stack/metal-go v0.34.0
github.com/metal-stack/metal-lib v0.18.2
github.com/metal-stack/updater v1.2.2
github.com/metal-stack/v v1.0.3
github.com/olekukonko/tablewriter v0.0.5
github.com/spf13/afero v1.11.0
github.com/spf13/cobra v1.8.1
github.com/spf13/viper v1.19.0
github.com/stretchr/testify v1.9.0
golang.org/x/exp v0.0.0-20240707233637-46b078467d37
golang.org/x/sync v0.7.0
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0
golang.org/x/sync v0.8.0
gopkg.in/yaml.v3 v3.0.1
k8s.io/api v0.28.2
k8s.io/apimachinery v0.28.2
k8s.io/api v0.29.8
k8s.io/apimachinery v0.29.8
sigs.k8s.io/yaml v1.4.0
)

Expand All @@ -42,7 +42,7 @@ require (
github.com/akutz/memconn v0.1.0 // indirect
github.com/alexbrainman/sspi v0.0.0-20231016080023-1a75b4708caa // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/avast/retry-go/v4 v4.5.1 // indirect
github.com/avast/retry-go/v4 v4.6.0 // indirect
github.com/aws/aws-sdk-go-v2 v1.25.0 // indirect
github.com/aws/aws-sdk-go-v2/config v1.27.0 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.17.0 // indirect
Expand All @@ -63,15 +63,15 @@ require (
github.com/coreos/go-oidc/v3 v3.11.0 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dblohm7/wingoes v0.0.0-20240123200102-b75a8a7d7eb0 // indirect
github.com/dblohm7/wingoes v0.0.0-20240801171404-fc12d7c70140 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
github.com/digitalocean/go-smbios v0.0.0-20180907143718-390a4f403a8e // indirect
github.com/emicklei/go-restful-openapi/v2 v2.10.2 // indirect
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/fxamacker/cbor/v2 v2.6.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/go-jose/go-jose/v4 v4.0.2 // indirect
github.com/go-jose/go-jose/v4 v4.0.4 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
Expand All @@ -86,7 +86,7 @@ require (
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/goccy/go-json v0.10.3 // indirect
github.com/goccy/go-yaml v1.11.3 // indirect
github.com/goccy/go-yaml v1.12.0 // indirect
github.com/godbus/dbus/v5 v5.1.1-0.20230522191255-76236955d466 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
Expand Down Expand Up @@ -114,14 +114,14 @@ require (
github.com/josharian/native v1.1.1-0.20230202152459-5c7d0dd6ab86 // indirect
github.com/jsimonetti/rtnetlink v1.4.1 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.7 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/kortschak/wol v0.0.0-20200729010619-da482cc4850a // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/lestrrat-go/blackmagic v1.0.2 // indirect
github.com/lestrrat-go/httpcc v1.0.1 // indirect
github.com/lestrrat-go/httprc v1.0.5 // indirect
github.com/lestrrat-go/httprc v1.0.6 // indirect
github.com/lestrrat-go/iter v1.0.2 // indirect
github.com/lestrrat-go/jwx/v2 v2.1.0 // indirect
github.com/lestrrat-go/jwx/v2 v2.1.1 // indirect
github.com/lestrrat-go/option v1.0.1 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
Expand All @@ -132,7 +132,7 @@ require (
github.com/mdlayher/netlink v1.7.2 // indirect
github.com/mdlayher/sdnotify v1.0.0 // indirect
github.com/mdlayher/socket v0.5.0 // indirect
github.com/metal-stack/security v0.8.0 // indirect
github.com/metal-stack/security v0.8.1 // indirect
github.com/miekg/dns v1.1.58 // indirect
github.com/mitchellh/go-ps v1.0.0 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
Expand All @@ -151,7 +151,7 @@ require (
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/segmentio/asm v1.2.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/cast v1.7.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
Expand All @@ -168,36 +168,36 @@ require (
github.com/vishvananda/netlink v1.2.1-beta.2 // indirect
github.com/vishvananda/netns v0.0.4 // indirect
github.com/x448/float16 v0.8.4 // indirect
go.mongodb.org/mongo-driver v1.16.0 // indirect
go.opentelemetry.io/otel v1.28.0 // indirect
go.opentelemetry.io/otel/metric v1.28.0 // indirect
go.opentelemetry.io/otel/trace v1.28.0 // indirect
go.mongodb.org/mongo-driver v1.16.1 // indirect
go.opentelemetry.io/otel v1.30.0 // indirect
go.opentelemetry.io/otel/metric v1.30.0 // indirect
go.opentelemetry.io/otel/trace v1.30.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go4.org/mem v0.0.0-20220726221520-4f986261bf13 // indirect
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/mod v0.19.0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/term v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.23.0 // indirect
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/term v0.24.0 // indirect
golang.org/x/text v0.18.0 // indirect
golang.org/x/time v0.6.0 // indirect
golang.org/x/tools v0.25.0 // indirect
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect
golang.zx2c4.com/wireguard/windows v0.5.3 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240701130421-f6361c86f094 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
google.golang.org/grpc v1.65.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240812133136-8ffd90a71988 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240812133136-8ffd90a71988 // indirect
google.golang.org/grpc v1.66.1 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gvisor.dev/gvisor v0.0.0-20230928000133-4fe30062272c // indirect
inet.af/peercred v0.0.0-20210906144145-0893ea02156a // indirect
k8s.io/klog/v2 v2.120.1 // indirect
k8s.io/utils v0.0.0-20240102154912-e7106e64919e // indirect
k8s.io/utils v0.0.0-20240902221715-702e33fdd3c3 // indirect
nhooyr.io/websocket v1.8.10 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
Expand Down
Loading

0 comments on commit 39f648b

Please sign in to comment.