From 09e861c1b684a80bf5100c7a83bf8c4513562651 Mon Sep 17 00:00:00 2001 From: Sebastian Nickel Date: Mon, 20 Jan 2025 10:45:44 +0100 Subject: [PATCH 1/3] implement new basic auth password change mechansim --- get/all_test.go | 2 +- go.mod | 18 +++++++++++------- go.sum | 32 ++++++++++++++++++++------------ update/application.go | 4 ++++ update/application_test.go | 12 ++++++++++++ 5 files changed, 48 insertions(+), 20 deletions(-) diff --git a/get/all_test.go b/get/all_test.go index 590fb3a..a159c4d 100644 --- a/get/all_test.go +++ b/get/all_test.go @@ -59,7 +59,7 @@ dev pear Release apps.nine.ch objects: []client.Object{testApplication("banana", "dev"), testRelease("pear", "dev")}, outputFormat: yamlOut, projectName: "dev", - output: "apiVersion: apps.nine.ch/v1alpha1\nkind: Application\nmetadata:\n name: banana\n namespace: dev\nspec:\n forProvider:\n buildEnv: null\n config:\n env: null\n port: null\n replicas: null\n size: \"\"\n dockerfileBuild:\n enabled: false\n git:\n revision: \"\"\n subPath: \"\"\n url: \"\"\nstatus:\n atProvider:\n defaultURLs: null\n---\napiVersion: apps.nine.ch/v1alpha1\ncreationTimestampNano: 0\nkind: Release\nmetadata:\n name: pear\n namespace: dev\nspec:\n forProvider:\n build:\n name: \"\"\n config:\n env: null\n port: null\n replicas: null\n size: \"\"\n defaultHosts: null\n image: {}\nstatus:\n atProvider: {}\n", + output: "apiVersion: apps.nine.ch/v1alpha1\nkind: Application\nmetadata:\n name: banana\n namespace: dev\nspec:\n forProvider:\n buildEnv: null\n config:\n env: null\n port: null\n replicas: null\n size: \"\"\n dockerfileBuild:\n enabled: false\n git:\n revision: \"\"\n subPath: \"\"\n url: \"\"\nstatus:\n atProvider:\n defaultURLs: null\n---\napiVersion: apps.nine.ch/v1alpha1\ncreationTimestampNano: 0\nkind: Release\nmetadata:\n name: pear\n namespace: dev\nspec:\n forProvider:\n build:\n name: \"\"\n config:\n env: null\n port: null\n replicas: null\n size: \"\"\n defaultHosts: null\n image: {}\nstatus:\n atProvider:\n owning: false\n", }, "all projects, full format": { projects: test.Projects(organization, "dev", "staging", "prod"), diff --git a/go.mod b/go.mod index 1e37aa1..5e68c8d 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/charmbracelet/bubbles v0.20.0 github.com/charmbracelet/bubbletea v1.1.0 github.com/charmbracelet/lipgloss v0.13.0 - github.com/crossplane/crossplane-runtime v1.15.1 + github.com/crossplane/crossplane-runtime v1.17.0 github.com/docker/docker v27.3.1+incompatible github.com/fatih/color v1.17.0 github.com/gobuffalo/flect v1.0.2 @@ -26,15 +26,15 @@ require ( github.com/mattn/go-isatty v0.0.20 github.com/moby/moby v27.1.1+incompatible github.com/moby/term v0.5.0 - github.com/ninech/apis v0.0.0-20241023072837-ff94192f11d1 + github.com/ninech/apis v0.0.0-20250120083942-90d315ad8c32 github.com/posener/complete v1.2.3 github.com/prometheus/common v0.55.0 github.com/stretchr/testify v1.9.0 github.com/theckman/yacspin v0.13.12 golang.org/x/crypto v0.25.0 - golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 + golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f gotest.tools v2.2.0+incompatible - k8s.io/api v0.30.3 + k8s.io/api v0.30.5 k8s.io/apimachinery v0.31.0 k8s.io/client-go v0.30.1 k8s.io/kubectl v0.29.0 @@ -71,6 +71,7 @@ require ( github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/charmbracelet/x/ansi v0.2.3 // indirect github.com/charmbracelet/x/term v0.2.0 // indirect + github.com/containerd/log v0.1.0 // indirect github.com/coreos/go-oidc/v3 v3.10.0 // indirect github.com/coreos/go-semver v0.3.1 // indirect github.com/coreos/go-systemd/v22 v22.5.0 // indirect @@ -137,6 +138,7 @@ require ( github.com/hashicorp/serf v0.10.1 // indirect github.com/huandu/xstrings v1.4.0 // indirect github.com/imdario/mergo v0.3.16 // indirect + github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/influxdata/tdigest v0.0.2-0.20210216194612-fc98d27c9e8b // indirect github.com/int128/listener v1.1.0 // indirect github.com/int128/oauth2cli v1.14.0 // indirect @@ -198,6 +200,7 @@ require ( github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/spf13/afero v1.11.0 // indirect github.com/spf13/cast v1.6.0 // indirect + github.com/spf13/cobra v1.8.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/stretchr/objx v0.5.2 // indirect github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect @@ -206,7 +209,6 @@ require ( github.com/willf/bitset v1.1.11 // indirect github.com/willf/bloom v2.0.3+incompatible // indirect github.com/x448/float16 v0.8.4 // indirect - go.etcd.io/bbolt v1.3.8 // indirect go.etcd.io/etcd/api/v3 v3.5.13 // indirect go.etcd.io/etcd/client/pkg/v3 v3.5.13 // indirect go.etcd.io/etcd/client/v3 v3.5.13 // indirect @@ -235,15 +237,17 @@ require ( golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect gonum.org/v1/gonum v0.8.2 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240401170217-c3f982113cda // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect - google.golang.org/grpc v1.63.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be // indirect + google.golang.org/grpc v1.63.2 // indirect google.golang.org/protobuf v1.34.2 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect + k8s.io/apiextensions-apiserver v0.30.1 // indirect k8s.io/cli-runtime v0.29.0 // indirect k8s.io/klog/v2 v2.130.1 // indirect k8s.io/kube-openapi v0.0.0-20240403164606-bc84c2ddaf99 // indirect + sigs.k8s.io/controller-tools v0.14.0 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect sigs.k8s.io/yaml v1.4.0 // indirect diff --git a/go.sum b/go.sum index 7253aa0..09cdc55 100644 --- a/go.sum +++ b/go.sum @@ -157,11 +157,12 @@ github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec= github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= -github.com/crossplane/crossplane-runtime v1.15.1 h1:g1h75tNYOQT152IUNxs8ZgSsRFQKrZN9z69KefMujXs= -github.com/crossplane/crossplane-runtime v1.15.1/go.mod h1:kRcJjJQmBFrR2n/KhwL8wYS7xNfq3D8eK4JliEScOHI= +github.com/crossplane/crossplane-runtime v1.17.0 h1:y+GvxPT1M9s8BKt2AeZJdd2d6pg2xZeCO6LiR+VxEF8= +github.com/crossplane/crossplane-runtime v1.17.0/go.mod h1:vtglCrnnbq2HurAk9yLHa4qS0bbnCxaKL7C21cQcB/0= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= @@ -459,6 +460,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1: github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4= github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/influxdata/tdigest v0.0.2-0.20210216194612-fc98d27c9e8b h1:i44CesU68ZBRvtCjBi3QSosCIKrjmMbYlQMFAwVLds4= github.com/influxdata/tdigest v0.0.2-0.20210216194612-fc98d27c9e8b/go.mod h1:Z0kXnxzbTC2qrx4NaIzYkE1k66+6oEDQTvL95hQFh5Y= github.com/int128/kubelogin v1.28.1 h1:Bo8bByoBgjr9gEOyvXKhbQ87Ovpv8XhAuAsaOvUJxzw= @@ -592,8 +595,8 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRW github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J1GEMiLbxo1LJaP8RfCpH6pymGZus= github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/ninech/apis v0.0.0-20241023072837-ff94192f11d1 h1:EgvNzSWbl/6wri3qTedw9SnLfI2STsM+XyW7uMqVnJE= -github.com/ninech/apis v0.0.0-20241023072837-ff94192f11d1/go.mod h1:hrhn1IP1wHHyWfE8xvDAl39yVcT1RDr9qJOv1FYpDAU= +github.com/ninech/apis v0.0.0-20250120083942-90d315ad8c32 h1:0XaOKTYVCIVd+oqG+7Km9j2/hVqkB4U7ySyEw15KvF0= +github.com/ninech/apis v0.0.0-20250120083942-90d315ad8c32/go.mod h1:6srtlYi3nj8GRxQkbhvSbanIBc9vsoPLFOp5VQzNNhM= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= @@ -681,6 +684,7 @@ github.com/riywo/loginshell v0.0.0-20200815045211-7d26008be1ab/go.mod h1:/PfPXh0 github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/scaleway/scaleway-sdk-go v1.0.0-beta.21 h1:yWfiTPwYxB0l5fGMhl/G+liULugVIHD9AU77iNLrURQ= github.com/scaleway/scaleway-sdk-go v1.0.0-beta.21/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg= @@ -708,6 +712,8 @@ github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNo github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= +github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= +github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -831,8 +837,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 h1:aAcj0Da7eBAtrTp03QXWvm88pSyOt+UgdZw2BFZ+lEw= -golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8/go.mod h1:CQ1k9gNrJ50XIzaKCRR2hssIjF07kZFEiieALBM/ARQ= +golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f h1:99ci1mjWVBWwJiEKYY6jWa4d2nTQVIEhZIptnrVb1XY= +golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f/go.mod h1:/lliqkxwWAhPjf5oSOIJup2XcqJaw8RGS6k3TGEc7GI= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= @@ -1145,8 +1151,8 @@ google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto/googleapis/api v0.0.0-20240401170217-c3f982113cda h1:b6F6WIV4xHHD0FA4oIyzU6mHWg2WI2X1RBehwa5QN38= google.golang.org/genproto/googleapis/api v0.0.0-20240401170217-c3f982113cda/go.mod h1:AHcE/gZH76Bk/ROZhQphlRoWo5xKDEtz3eVEO1LfA8c= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda h1:LI5DOvAxUPMv/50agcLLoo+AdWc1irS9Rzz4vPuD1V4= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be h1:LG9vZxsWGOmUKieR8wPAUR3u3MpnYFQZROPIMaXh7/A= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= google.golang.org/grpc v1.12.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= @@ -1161,8 +1167,8 @@ google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKa google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.63.0 h1:WjKe+dnvABXyPJMD7KDNLxtoGk5tgk+YFWN6cBWjZE8= -google.golang.org/grpc v1.63.0/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= +google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM= +google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -1214,8 +1220,8 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -k8s.io/api v0.30.3 h1:ImHwK9DCsPA9uoU3rVh4QHAHHK5dTSv1nxJUapx8hoQ= -k8s.io/api v0.30.3/go.mod h1:GPc8jlzoe5JG3pb0KJCSLX5oAFIW3/qNJITlDj8BH04= +k8s.io/api v0.30.5 h1:Coz05sfEVywzGcA96AJPUfs2B8LBMnh+IIsM+HCfaz8= +k8s.io/api v0.30.5/go.mod h1:HfNBGFvq9iNK8dmTKjYIdAtMxu8BXTb9c1SJyO6QjKs= k8s.io/apiextensions-apiserver v0.30.1 h1:4fAJZ9985BmpJG6PkoxVRpXv9vmPUOVzl614xarePws= k8s.io/apiextensions-apiserver v0.30.1/go.mod h1:R4GuSrlhgq43oRY9sF2IToFh7PVlF1JjfWdoG3pixk4= k8s.io/apimachinery v0.31.0 h1:m9jOiSr3FoSSL5WO9bjm1n6B9KROYYgNZOb4tyZ1lBc= @@ -1240,6 +1246,8 @@ rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= sigs.k8s.io/controller-runtime v0.18.4 h1:87+guW1zhvuPLh1PHybKdYFLU0YJp4FhJRmiHvm5BZw= sigs.k8s.io/controller-runtime v0.18.4/go.mod h1:TVoGrfdpbA9VRFaRnKgk9P5/atA0pMwq+f+msb9M8Sg= +sigs.k8s.io/controller-tools v0.14.0 h1:rnNoCC5wSXlrNoBKKzL70LNJKIQKEzT6lloG6/LF73A= +sigs.k8s.io/controller-tools v0.14.0/go.mod h1:TV7uOtNNnnR72SpzhStvPkoS/U5ir0nMudrkrC4M9Sc= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= diff --git a/update/application.go b/update/application.go index e22f3f7..2f19869 100644 --- a/update/application.go +++ b/update/application.go @@ -30,6 +30,7 @@ type applicationCmd struct { Replicas *int32 `help:"Amount of replicas of the running app."` Hosts *[]string `help:"Host names where the application can be accessed. If empty, the application will just be accessible on a generated host name on the deploio.app domain."` BasicAuth *bool `help:"Enable/Disable basic authentication for the application."` + ChangeBasicAuthPassword *bool `help:"Generate a new basic auth password."` Env map[string]string `help:"Environment variables which are passed to the app at runtime."` DeleteEnv *[]string `help:"Runtime environment variables names which are to be deleted."` BuildEnv map[string]string `help:"Environment variables names which are passed to the app build process."` @@ -212,6 +213,9 @@ func (cmd *applicationCmd) applyUpdates(app *apps.Application) { if cmd.BasicAuth != nil { app.Spec.ForProvider.Config.EnableBasicAuth = cmd.BasicAuth } + if cmd.ChangeBasicAuthPassword != nil { + app.Spec.ForProvider.BasicAuthPasswordChange = ptr.To(metav1.Now()) + } if cmd.DeployJob != nil { cmd.DeployJob.applyUpdates(&app.Spec.ForProvider.Config) } diff --git a/update/application_test.go b/update/application_test.go index f1c75b4..61f2362 100644 --- a/update/application_test.go +++ b/update/application_test.go @@ -186,6 +186,18 @@ func TestApplication(t *testing.T) { assert.NotEmpty(t, updated.Spec.ForProvider.Config.Env) }, }, + "change basic auth password": { + orig: existingApp, + cmd: applicationCmd{ + resourceCmd: resourceCmd{ + Name: existingApp.Name, + }, + ChangeBasicAuthPassword: ptr.To(true), + }, + checkApp: func(t *testing.T, cmd applicationCmd, orig, updated *apps.Application) { + assert.NotNil(t, updated.Spec.ForProvider.BasicAuthPasswordChange) + }, + }, "git auth update user/pass": { orig: existingApp, gitAuth: &util.GitAuth{ From a75fc69bab81a248f9843c55647abef3b0f4349f Mon Sep 17 00:00:00 2001 From: Sebastian Nickel Date: Mon, 20 Jan 2025 11:27:46 +0100 Subject: [PATCH 2/3] update golangci-lint version --- .github/workflows/go.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index a67c831..35ad064 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -19,7 +19,7 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v6 with: - version: v1.54 + version: v1.63.4 args: --timeout=10m - uses: dominikh/staticcheck-action@v1 with: From b02c97780709aa9bcba72f7811d3663426c3f88b Mon Sep 17 00:00:00 2001 From: Sebastian Nickel Date: Mon, 20 Jan 2025 11:50:08 +0100 Subject: [PATCH 3/3] fix linter error messages golangci-lint reported "printf: non-constant format string in call..." which happens if the format string of a printf like function is a variable and not a constant. --- auth/login.go | 2 +- create/application.go | 2 +- create/create.go | 4 ++-- delete/delete.go | 2 +- internal/format/print.go | 31 +++++++++++++++++++++++++++---- 5 files changed, 32 insertions(+), 9 deletions(-) diff --git a/auth/login.go b/auth/login.go index 5666ed3..cfa54c9 100644 --- a/auth/login.go +++ b/auth/login.go @@ -238,7 +238,7 @@ func login(ctx context.Context, newConfig *clientcmdapi.Config, kubeconfigPath, if strings.TrimSpace(userName) != "" { loginMessage = fmt.Sprintf("logged into cluster %s as %s", newConfig.CurrentContext, userName) } - format.PrintSuccessf("🚀", loginMessage) + format.PrintSuccess("🚀", loginMessage) return nil } diff --git a/create/application.go b/create/application.go index 312e057..89e4b5c 100644 --- a/create/application.go +++ b/create/application.go @@ -245,7 +245,7 @@ func (app *applicationCmd) Run(ctx context.Context, client *api.Client) error { } func spinnerMessage(msg, icon string, sleepTime time.Duration) error { - fullMsg := format.ProgressMessagef(icon, msg) + fullMsg := format.ProgressMessage(icon, msg) spinner, err := format.NewSpinner(fullMsg, fullMsg) if err != nil { return err diff --git a/create/create.go b/create/create.go index 2230fb1..4a5a998 100644 --- a/create/create.go +++ b/create/create.go @@ -82,7 +82,7 @@ func (m *message) progress() string { return "" } - return format.ProgressMessagef(m.icon, m.text) + return format.ProgressMessage(m.icon, m.text) } func (m *message) printSuccess() { @@ -90,7 +90,7 @@ func (m *message) printSuccess() { return } - format.PrintSuccessf(m.icon, m.text) + format.PrintSuccess(m.icon, m.text) } func newCreator(client *api.Client, mg resource.Managed, resourceName string) *creator { diff --git a/delete/delete.go b/delete/delete.go index a1186aa..4e57eac 100644 --- a/delete/delete.go +++ b/delete/delete.go @@ -95,7 +95,7 @@ func (d *deleter) deleteResource(ctx context.Context, client *api.Client, waitTi } if !force { - ok, err := format.Confirmf(d.prompt(d.kind, d.mg.GetName())) + ok, err := format.Confirm(d.prompt(d.kind, d.mg.GetName())) if err != nil { return err } diff --git a/internal/format/print.go b/internal/format/print.go index af6befc..4a1a713 100644 --- a/internal/format/print.go +++ b/internal/format/print.go @@ -40,16 +40,32 @@ func ProgressMessagef(icon, format string, a ...any) string { return fmt.Sprintf(" %s %s", fmt.Sprintf(format, a...), icon) } +// ProgressMessage is a formatted message for use with a spinner.Suffix. An +// icon can be added which is displayed at the end of the message. +func ProgressMessage(icon, message string) string { + return fmt.Sprintf(" %s %s", message, icon) +} + // SuccessMessagef is a formatted message for indicating a successful step. func SuccessMessagef(icon, format string, a ...any) string { return fmt.Sprintf(" %s %s %s", SuccessChar, fmt.Sprintf(format, a...), icon) } +// SuccessMessage returns a message for indicating a successful step. +func SuccessMessage(icon, message string) string { + return fmt.Sprintf(" %s %s %s", SuccessChar, message, icon) +} + // PrintSuccessf prints a success message. func PrintSuccessf(icon, format string, a ...any) { fmt.Print(SuccessMessagef(icon, format, a...) + "\n") } +// PrintSuccess prints a success message. +func PrintSuccess(icon, message string) { + fmt.Print(SuccessMessage(icon, message) + "\n") +} + // FailureMessagef is a formatted message for indicating a failed step. func FailureMessagef(icon, format string, a ...any) string { return fmt.Sprintf(" %s %s %s", FailureChar, fmt.Sprintf(format, a...), icon) @@ -64,12 +80,13 @@ func PrintWarningf(msg string, a ...any) { fmt.Printf(color.YellowString("Warning: ")+msg, a...) } -// Confirmf prints a confirm dialog using format and then waits until prompt -// is confirmed or denied. Only y and yes are accepted for confirmation. -func Confirmf(format string, a ...any) (bool, error) { +// Confirm prints a confirm dialog using the supplied message and then waits +// until prompt is confirmed or denied. Only y and yes are accepted for +// confirmation. +func Confirm(message string) (bool, error) { var input string - fmt.Printf("%s [y|n]: ", fmt.Sprintf(format, a...)) + fmt.Printf("%s [y|n]: ", message) _, err := fmt.Scanln(&input) if err != nil { return false, err @@ -82,6 +99,12 @@ func Confirmf(format string, a ...any) (bool, error) { return false, nil } +// Confirmf prints a confirm dialog using format and then waits until prompt +// is confirmed or denied. Only y and yes are accepted for confirmation. +func Confirmf(format string, a ...any) (bool, error) { + return Confirm(fmt.Sprintf(format, a...)) +} + // NewSpinner returns a new spinner with the default config func NewSpinner(message, stopMessage string) (*yacspin.Spinner, error) { return yacspin.New(spinnerConfig(message, stopMessage))