From 831f518e0572a757ca949ceaad28ebd60ceafee7 Mon Sep 17 00:00:00 2001 From: Yunus Sandikci Date: Sat, 20 Jan 2024 14:18:15 +0300 Subject: [PATCH 1/7] . --- cmd/manager/main.go | 2 +- examples/combination.yaml | 4 +- examples/expiration.yaml | 2 +- go.mod | 59 ++++++------ go.sum | 169 ++++++++++++++-------------------- pkg/common/config.go | 4 +- pkg/common/metrics.go | 19 +--- pkg/common/scheduler.go | 77 ++++++++-------- pkg/controllers/expiration.go | 75 +++++++-------- 9 files changed, 185 insertions(+), 226 deletions(-) diff --git a/cmd/manager/main.go b/cmd/manager/main.go index afb416d..71ee91e 100644 --- a/cmd/manager/main.go +++ b/cmd/manager/main.go @@ -51,7 +51,7 @@ func main() { } client := manager.GetClient() - scheduler := common.NewScheduler(config, client) + scheduler := common.NewScheduler(config) for _, resource := range config.Resources { if expirationControllerErr := controllers.NewExpirationController(config, client, resource, scheduler). diff --git a/examples/combination.yaml b/examples/combination.yaml index da66c61..f8cc478 100644 --- a/examples/combination.yaml +++ b/examples/combination.yaml @@ -3,7 +3,7 @@ kind: ScheduledResource metadata: name: combination-example annotations: - mayfly.cloud.namecheap.com/expire: 10s + mayfly.cloud.spacehip.com/expire: 10s spec: in: "5s" content: | @@ -13,6 +13,6 @@ spec: name: combination-example namespace: default annotations: - mayfly.cloud.namecheap.com/expire: 10s + mayfly.cloud.spaceship.com/expire: 10s data: .secret-file: dmFsdWUtMg0KDQo= \ No newline at end of file diff --git a/examples/expiration.yaml b/examples/expiration.yaml index b89a0fe..286ea5f 100644 --- a/examples/expiration.yaml +++ b/examples/expiration.yaml @@ -4,6 +4,6 @@ metadata: name: expiration-example namespace: default annotations: - mayfly.cloud.namecheap.com/expire: 10s + mayfly.cloud.namecheap.com/expire: "19 Jan 2024, 14:13" data: .secret-file: dmFsdWUtMg0KDQo= \ No newline at end of file diff --git a/go.mod b/go.mod index 959c585..5a5c2cd 100644 --- a/go.mod +++ b/go.mod @@ -3,15 +3,17 @@ module github.com/NCCloud/mayfly go 1.21 require ( - github.com/caarlos0/env/v9 v9.0.0 - github.com/go-co-op/gocron v1.37.0 - github.com/go-echarts/go-echarts/v2 v2.3.2 - github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 - github.com/prometheus/client_golang v1.17.0 - k8s.io/api v0.29.0 - k8s.io/apimachinery v0.29.0 - k8s.io/client-go v0.29.0 - sigs.k8s.io/controller-runtime v0.16.3 + github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de + github.com/caarlos0/env/v10 v10.0.0 + github.com/elliotchance/pie/v2 v2.8.0 + github.com/go-co-op/gocron/v2 v2.2.0 + github.com/go-echarts/go-echarts/v2 v2.3.3 + github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c + github.com/prometheus/client_golang v1.18.0 + k8s.io/api v0.29.1 + k8s.io/apimachinery v0.29.1 + k8s.io/client-go v0.29.1 + sigs.k8s.io/controller-runtime v0.17.0 ) require ( @@ -19,10 +21,10 @@ require ( github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/emicklei/go-restful/v3 v3.11.0 // indirect - github.com/evanphx/json-patch/v5 v5.6.0 // indirect - github.com/fsnotify/fsnotify v1.6.0 // indirect - github.com/go-logr/logr v1.3.0 // indirect - github.com/go-logr/zapr v1.2.4 // indirect + github.com/evanphx/json-patch/v5 v5.8.0 // indirect + github.com/fsnotify/fsnotify v1.7.0 // indirect + github.com/go-logr/logr v1.4.1 // indirect + github.com/go-logr/zapr v1.3.0 // indirect github.com/go-openapi/jsonpointer v0.19.6 // indirect github.com/go-openapi/jsonreference v0.20.2 // indirect github.com/go-openapi/swag v0.22.3 // indirect @@ -34,29 +36,28 @@ require ( github.com/google/gofuzz v1.2.0 // indirect github.com/google/uuid v1.5.0 // indirect github.com/imdario/mergo v0.3.6 // indirect + github.com/jonboulle/clockwork v0.4.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/mailru/easyjson v0.7.7 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect + github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 // indirect - github.com/prometheus/common v0.44.0 // indirect - github.com/prometheus/procfs v0.11.1 // indirect + github.com/prometheus/client_model v0.5.0 // indirect + github.com/prometheus/common v0.45.0 // indirect + github.com/prometheus/procfs v0.12.0 // indirect github.com/robfig/cron/v3 v3.0.1 // indirect github.com/spf13/pflag v1.0.5 // indirect - go.uber.org/atomic v1.10.0 // indirect - go.uber.org/goleak v1.3.0 // indirect go.uber.org/multierr v1.11.0 // indirect - go.uber.org/zap v1.25.0 // indirect - golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb // indirect - golang.org/x/net v0.17.0 // indirect - golang.org/x/oauth2 v0.10.0 // indirect - golang.org/x/sys v0.13.0 // indirect - golang.org/x/term v0.13.0 // indirect - golang.org/x/text v0.13.0 // indirect + go.uber.org/zap v1.26.0 // indirect + golang.org/x/exp v0.0.0-20231219180239-dc181d75b848 // indirect + golang.org/x/net v0.19.0 // indirect + golang.org/x/oauth2 v0.12.0 // indirect + golang.org/x/sys v0.16.0 // indirect + golang.org/x/term v0.15.0 // indirect + golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.3.0 // indirect gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect google.golang.org/appengine v1.6.7 // indirect @@ -64,12 +65,12 @@ require ( 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.28.3 // indirect - k8s.io/component-base v0.28.3 // indirect + k8s.io/apiextensions-apiserver v0.29.0 // indirect + k8s.io/component-base v0.29.0 // indirect k8s.io/klog/v2 v2.110.1 // indirect k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect k8s.io/utils v0.0.0-20230726121419-3b25d923346b // 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.3.0 // indirect + sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/go.sum b/go.sum index 690b329..9a491d1 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ -github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= -github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= -github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de h1:FxWPpzIjnTlhPwqqXc4/vE0f7GvRjuAsbW+HOIe8KnA= +github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de/go.mod h1:DCaWoUhZrYW9p1lxo/cm8EmUOOzAPSEZNGF2DK1dJgw= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/caarlos0/env/v10 v10.0.0/go.mod h1:ZfulV76NvVPw3tm591U4SwL3Xx9ldzBP9aGxzeN7G18= github.com/caarlos0/env/v9 v9.0.0 h1:SI6JNsOA+y5gj9njpgybykATIylrRMklbs5ch6wO6pc= github.com/caarlos0/env/v9 v9.0.0/go.mod h1:ye5mlCVMYh6tZ+vCgrs/B95sj88cg5Tlnc0XIzgZ020= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= @@ -11,24 +11,25 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/elliotchance/pie/v2 v2.8.0 h1://QS43W8sEha8XV/fjngO5iMudN3XARJV5cpBayAcVY= +github.com/elliotchance/pie/v2 v2.8.0/go.mod h1:18t0dgGFH006g4eVdDtWfgFZPQEgl10IoEO8YWEq3Og= github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= -github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U= -github.com/evanphx/json-patch v5.6.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= -github.com/evanphx/json-patch/v5 v5.6.0 h1:b91NhWfaz02IuVxO9faSllyAtNXHMPkC5J8sJCLunww= -github.com/evanphx/json-patch/v5 v5.6.0/go.mod h1:G79N1coSVB93tBe7j6PhzjmR3/2VvlbKOFpnXhI9Bw4= -github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= -github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= -github.com/go-co-op/gocron v1.37.0 h1:ZYDJGtQ4OMhTLKOKMIch+/CY70Brbb1dGdooLEhh7b0= -github.com/go-co-op/gocron v1.37.0/go.mod h1:3L/n6BkO7ABj+TrfSVXLRzsP26zmikL4ISkLQ0O8iNY= -github.com/go-co-op/gocron/v2 v2.1.0/go.mod h1:yuQ4a9rIMpkdBVU+Rd5EyuEKaFjl/c7ykupXHnXB6MU= -github.com/go-echarts/go-echarts/v2 v2.3.2 h1:imRxqF5sLtEPBsv5HGwz9KklNuwCo0fTITZ31mrgfzo= -github.com/go-echarts/go-echarts/v2 v2.3.2/go.mod h1:56YlvzhW/a+du15f3S2qUGNDfKnFOeJSThBIrVFHDtI= -github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= +github.com/evanphx/json-patch v4.12.0+incompatible h1:4onqiflcdA9EOZ4RxV643DvftH5pOlLGNtQ5lPWQu84= +github.com/evanphx/json-patch v4.12.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= +github.com/evanphx/json-patch/v5 v5.8.0 h1:lRj6N9Nci7MvzrXuX6HFzU8XjmhPiXPlsKEy1u0KQro= +github.com/evanphx/json-patch/v5 v5.8.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq14uClGH4abBuQ= +github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= +github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= +github.com/go-co-op/gocron/v2 v2.2.0 h1:yJBOoKTYJQ7DSGBSM6vL01jJA2rEQi3wYvWg8DTJf40= +github.com/go-co-op/gocron/v2 v2.2.0/go.mod h1:0MfNAXEchzeSH1vtkZrTAcSMWqyL435kL6CA4b0bjrg= +github.com/go-echarts/go-echarts/v2 v2.3.3 h1:uImZAk6qLkC6F9ju6mZ5SPBqTyK8xjZKwSmwnCg4bxg= +github.com/go-echarts/go-echarts/v2 v2.3.3/go.mod h1:56YlvzhW/a+du15f3S2qUGNDfKnFOeJSThBIrVFHDtI= github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-logr/zapr v1.2.4 h1:QHVo+6stLbfJmYGkQ7uGHUCu5hnAFAj6mDe6Ea0SeOo= -github.com/go-logr/zapr v1.2.4/go.mod h1:FyHWQIzQORZ0QVE1BtVHv3cKtNLuXsbNLtpuhNapBOA= +github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= +github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ= +github.com/go-logr/zapr v1.3.0/go.mod h1:YKepepNBd1u/oyhd/yQmtjVXmm9uML4IXUgMOwR8/Gg= github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= @@ -41,7 +42,6 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= @@ -57,21 +57,19 @@ github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/imdario/mergo v0.3.6 h1:xTNEAn+kxVO7dTZGu0CegyqKZmoWFI0rF8UxjlB2d28= github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= -github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jonboulle/clockwork v0.4.0 h1:p4Cf1aMWXnXAUh8lVfewRBx1zaTSYKrKMF2g3ST4RZ4= +github.com/jonboulle/clockwork v0.4.0/go.mod h1:xgRqUGwRcjKCO1vbZUEtSLrqKoPSsUpK7fnezOII0kc= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -80,8 +78,9 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= -github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= -github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= +github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= +github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg= +github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0/go.mod h1:QUyp042oQthUoa9bqDv0ER0wrtXnBruoNd7aNjkbP+k= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -89,32 +88,30 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/onsi/ginkgo/v2 v2.13.0 h1:0jY9lJquiL8fcf3M4LAXN5aMlS/b2BV86HFFPCPMgE4= -github.com/onsi/ginkgo/v2 v2.13.0/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o= -github.com/onsi/gomega v1.29.0 h1:KIA/t2t5UBzoirT4H9tsML45GEbo3ouUnBHsCfD2tVg= -github.com/onsi/gomega v1.29.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= -github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= -github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= -github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/onsi/ginkgo/v2 v2.14.0 h1:vSmGj2Z5YPb9JwCWT6z6ihcUvDhuXLc3sJiqd3jMKAY= +github.com/onsi/ginkgo/v2 v2.14.0/go.mod h1:JkUdW7JkN0V6rFvsHcJ478egV3XH9NxpD27Hal/PhZw= +github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8= +github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.17.0 h1:rl2sfwZMtSthVU752MqfjQozy7blglC+1SOtjMAMh+Q= -github.com/prometheus/client_golang v1.17.0/go.mod h1:VeL+gMmOAxkS2IqfCq0ZmHSL+LjWfWDUmp1mBz9JgUY= -github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 h1:v7DLqVdK4VrYkVD5diGdl4sxJurKJEMnODWRJlxV9oM= -github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= -github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY= -github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= -github.com/prometheus/procfs v0.11.1 h1:xRC8Iq1yyca5ypa9n1EZnWZkt7dwcoRPQwX/5gwaUuI= -github.com/prometheus/procfs v0.11.1/go.mod h1:eesXgaPo1q7lBpVMoMy0ZOFTth9hBn4W/y0/p/ScXhY= +github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= +github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw= +github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI= +github.com/prometheus/common v0.45.0 h1:2BGz0eBc2hdMDLnO/8n0jeB3oPrt2D08CekT0lneoxM= +github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGyv9MZjVOJsY= +github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= +github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= +github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= -github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= -github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= +github.com/scylladb/termtables v0.0.0-20191203121021-c4c0b6d42ff4/go.mod h1:C1a7PQSMz9NShzorzCiG2fk9+xuCgLkPeCvMHYR2OWg= 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= @@ -125,78 +122,56 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= -go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= -go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= -go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= -go.uber.org/zap v1.25.0 h1:4Hvk6GtkucQ790dqmj7l1eEnRdKm3k3ZUrUMS2d5+5c= -go.uber.org/zap v1.25.0/go.mod h1:JIAUzQIH94IC4fOJQm7gMmBJP5k7wQfdcnYdPoEXJYk= +go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= +go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/exp v0.0.0-20231219180239-dc181d75b848 h1:+iq7lrkxmFNBM7xx+Rae2W6uyPfhPeDWD+n+JgppptE= +golang.org/x/exp v0.0.0-20231219180239-dc181d75b848/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= -golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= -golang.org/x/oauth2 v0.10.0 h1:zHCpF2Khkwy4mMB4bv0U37YtJdTGW8jI0glAApi0Kh8= -golang.org/x/oauth2 v0.10.0/go.mod h1:kTpgurOux7LqtuxjuyZa4Gj2gdezIt/jQtGnNFfypQI= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= +golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= +golang.org/x/oauth2 v0.12.0 h1:smVPGxink+n1ZI5pkQa8y6fZT0RW0MgCO5bFpepy4B4= +golang.org/x/oauth2 v0.12.0/go.mod h1:A74bZ3aGXgCY0qaIC9Ahg6Lglin4AMAco8cIv9baba4= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= -golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= -golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= +golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= -golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.16.0 h1:GO788SKMRunPIBCXiQyo2AaexLstOrVhuAL5YwsckQM= -golang.org/x/tools v0.16.0/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= +golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA= +golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -210,10 +185,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -222,27 +195,27 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/api v0.29.0 h1:NiCdQMY1QOp1H8lfRyeEf8eOwV6+0xA6XEE44ohDX2A= -k8s.io/api v0.29.0/go.mod h1:sdVmXoz2Bo/cb77Pxi71IPTSErEW32xa4aXwKH7gfBA= -k8s.io/apiextensions-apiserver v0.28.3 h1:Od7DEnhXHnHPZG+W9I97/fSQkVpVPQx2diy+2EtmY08= -k8s.io/apiextensions-apiserver v0.28.3/go.mod h1:NE1XJZ4On0hS11aWWJUTNkmVB03j9LM7gJSisbRt8Lc= -k8s.io/apimachinery v0.29.0 h1:+ACVktwyicPz0oc6MTMLwa2Pw3ouLAfAon1wPLtG48o= -k8s.io/apimachinery v0.29.0/go.mod h1:eVBxQ/cwiJxH58eK/jd/vAk4mrxmVlnpBH5J2GbMeis= -k8s.io/client-go v0.29.0 h1:KmlDtFcrdUzOYrBhXHgKw5ycWzc3ryPX5mQe0SkG3y8= -k8s.io/client-go v0.29.0/go.mod h1:yLkXH4HKMAywcrD82KMSmfYg2DlE8mepPR4JGSo5n38= -k8s.io/component-base v0.28.3 h1:rDy68eHKxq/80RiMb2Ld/tbH8uAE75JdCqJyi6lXMzI= -k8s.io/component-base v0.28.3/go.mod h1:fDJ6vpVNSk6cRo5wmDa6eKIG7UlIQkaFmZN2fYgIUD8= +k8s.io/api v0.29.1 h1:DAjwWX/9YT7NQD4INu49ROJuZAAAP/Ijki48GUPzxqw= +k8s.io/api v0.29.1/go.mod h1:7Kl10vBRUXhnQQI8YR/R327zXC8eJ7887/+Ybta+RoQ= +k8s.io/apiextensions-apiserver v0.29.0 h1:0VuspFG7Hj+SxyF/Z/2T0uFbI5gb5LRgEyUVE3Q4lV0= +k8s.io/apiextensions-apiserver v0.29.0/go.mod h1:TKmpy3bTS0mr9pylH0nOt/QzQRrW7/h7yLdRForMZwc= +k8s.io/apimachinery v0.29.1 h1:KY4/E6km/wLBguvCZv8cKTeOwwOBqFNjwJIdMkMbbRc= +k8s.io/apimachinery v0.29.1/go.mod h1:6HVkd1FwxIagpYrHSwJlQqZI3G9LfYWRPAkUvLnXTKU= +k8s.io/client-go v0.29.1 h1:19B/+2NGEwnFLzt0uB5kNJnfTsbV8w6TgQRz9l7ti7A= +k8s.io/client-go v0.29.1/go.mod h1:TDG/psL9hdet0TI9mGyHJSgRkW3H9JZk2dNEUS7bRks= +k8s.io/component-base v0.29.0 h1:T7rjd5wvLnPBV1vC4zWd/iWRbV8Mdxs+nGaoaFzGw3s= +k8s.io/component-base v0.29.0/go.mod h1:sADonFTQ9Zc9yFLghpDpmNXEdHyQmFIGbiuZbqAXQ1M= k8s.io/klog/v2 v2.110.1 h1:U/Af64HJf7FcwMcXyKm2RPM22WZzyR7OSpYj5tg3cL0= k8s.io/klog/v2 v2.110.1/go.mod h1:YGtd1984u+GgbuZ7e08/yBuAfKLSO0+uR1Fhi6ExXjo= k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 h1:aVUu9fTY98ivBPKR9Y5w/AuzbMm96cd3YHRTU83I780= k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00/go.mod h1:AsvuZPBlUDVuCdzJ87iajxtXuR9oktsTctW/R9wwouA= k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI= k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -sigs.k8s.io/controller-runtime v0.16.3 h1:2TuvuokmfXvDUamSx1SuAOO3eTyye+47mJCigwG62c4= -sigs.k8s.io/controller-runtime v0.16.3/go.mod h1:j7bialYoSn142nv9sCOJmQgDXQXxnroFU4VnX/brVJ0= +sigs.k8s.io/controller-runtime v0.17.0 h1:fjJQf8Ukya+VjogLO6/bNX9HE6Y2xpsO5+fyS26ur/s= +sigs.k8s.io/controller-runtime v0.17.0/go.mod h1:+MngTvIQQQhfXtwfdGw/UOQ/aIaqsYywfCINOtwMO/s= 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= sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= -sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= -sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= +sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= +sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/pkg/common/config.go b/pkg/common/config.go index fdb4068..e4ca7bc 100644 --- a/pkg/common/config.go +++ b/pkg/common/config.go @@ -2,14 +2,12 @@ package common import ( "time" - - "github.com/caarlos0/env/v9" ) type Config struct { EnableLeaderElection bool `env:"ENABLE_LEADER_ELECTION" envDefault:"false"` SyncPeriod time.Duration `env:"SYNC_PERIOD" envDefault:"30m"` - MonitoringInterval time.Duration `env:"MONITORING_INTERVAL" envDefault:"5s"` + MonitoringInterval time.Duration `env:"MONITORING_INTERVAL" envDefault:"1s"` ExpirationLabel string `env:"EXPIRATION_LABEL" envDefault:"mayfly.cloud.namecheap.com/expire"` Resources []string `env:"RESOURCES" envSeparator:"," envDefault:"v1;Secret,cloud.namecheap.com/v1alpha1;ScheduledResource"` } diff --git a/pkg/common/metrics.go b/pkg/common/metrics.go index 31ee926..249d721 100644 --- a/pkg/common/metrics.go +++ b/pkg/common/metrics.go @@ -7,26 +7,11 @@ import ( var mayflyTotalJobs = prometheus.NewGauge( prometheus.GaugeOpts{ - Name: "mayfly_jobs", + Name: "mayfly_total_jobs", Help: "Number of scheduled Mayfly Jobs", }, ) -var mayflyPastJobs = prometheus.NewGauge( - prometheus.GaugeOpts{ - Name: "mayfly_jobs_past_jobs", - Help: "Number of past Mayfly Jobs", - }, -) - func init() { - metrics.Registry.MustRegister(mayflyTotalJobs, mayflyPastJobs) -} - -func exportMayflyTotalJobsMetrics(jobs float64) { - mayflyTotalJobs.Set(jobs) -} - -func exportMayflyPastJobsMetrics(jobs float64) { - mayflyPastJobs.Set(jobs) + metrics.Registry.MustRegister(mayflyTotalJobs) } diff --git a/pkg/common/scheduler.go b/pkg/common/scheduler.go index d64822d..2494112 100644 --- a/pkg/common/scheduler.go +++ b/pkg/common/scheduler.go @@ -1,65 +1,66 @@ package common import ( + "slices" "time" - "github.com/go-co-op/gocron" - - "sigs.k8s.io/controller-runtime/pkg/client" + "github.com/elliotchance/pie/v2" + "github.com/go-co-op/gocron/v2" ) type Scheduler struct { config *Config - client client.Client - scheduler *gocron.Scheduler + scheduler gocron.Scheduler } -func NewScheduler(config *Config, client client.Client) *Scheduler { - scheduler := &Scheduler{ - config: config, - client: client, - scheduler: gocron.NewScheduler(time.UTC), +func NewScheduler(config *Config) *Scheduler { + schedulerInstance := &Scheduler{ + config: config, + } + + scheduler, newSchedulerErr := gocron.NewScheduler() + if newSchedulerErr != nil { + panic(newSchedulerErr) } - scheduler.startMonitoring() - scheduler.scheduler.StartAsync() + if _, newJobErr := scheduler.NewJob(gocron.DurationJob(config.MonitoringInterval), gocron.NewTask(func() { + mayflyTotalJobs.Set(float64(len(scheduler.Jobs())) - 1) + }), gocron.WithTags("monitoring")); newJobErr != nil { + panic(newJobErr) + } + + schedulerInstance.scheduler = scheduler + scheduler.Start() - return scheduler + return schedulerInstance } func (s *Scheduler) CreateOrUpdateTask(tag string, date time.Time, task func() error) error { - if jobs, _ := s.scheduler.FindJobsByTag(tag); len(jobs) > 0 { - if jobs[0].NextRun().Equal(date) { - return nil - } - - if removeJobErr := s.scheduler.RemoveByTag(tag); removeJobErr != nil { - return removeJobErr - } + job := pie.Of(s.scheduler.Jobs()).Filter(func(job gocron.Job) bool { + return slices.Contains(job.Tags(), tag) + }).First() + + if job != nil { + _, updateErr := s.scheduler.Update(job.ID(), gocron.OneTimeJob( + gocron.OneTimeJobStartDateTime(date)), gocron.NewTask(task), gocron.WithTags(tag)) + + return updateErr } - _, jobErr := s.scheduler.StartAt(date).Every(1).LimitRunsTo(1).Tag(tag).Do(task) + _, jobErr := s.scheduler.NewJob(gocron.OneTimeJob( + gocron.OneTimeJobStartDateTime(date)), gocron.NewTask(task), gocron.WithTags(tag)) return jobErr } func (s *Scheduler) DeleteTask(tag string) error { - return s.scheduler.RemoveByTag(tag) -} - -func (s *Scheduler) startMonitoring() { - if _, doErr := s.scheduler.SingletonMode().Every(s.config.MonitoringInterval).Do(func() { - exportMayflyTotalJobsMetrics(float64(len(s.scheduler.Jobs()))) + job := pie.Of(s.scheduler.Jobs()).Filter(func(job gocron.Job) bool { + return slices.Contains(job.Tags(), tag) + }).First() - pastJobs := 0 - for _, job := range s.scheduler.Jobs() { - if job.NextRun().Before(time.Now()) { - pastJobs++ - } - } - - exportMayflyPastJobsMetrics(float64(pastJobs)) - }); doErr != nil { - panic(doErr) + if job != nil { + return s.scheduler.RemoveJob(job.ID()) } + + return nil } diff --git a/pkg/controllers/expiration.go b/pkg/controllers/expiration.go index 4c41923..f9c23f9 100644 --- a/pkg/controllers/expiration.go +++ b/pkg/controllers/expiration.go @@ -2,16 +2,20 @@ package controllers import ( "context" + "errors" "fmt" + "time" + + "github.com/araddon/dateparse" + "github.com/go-co-op/gocron/v2" + errors2 "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/NCCloud/mayfly/pkg/common" - "k8s.io/apimachinery/pkg/api/errors" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/event" "sigs.k8s.io/controller-runtime/pkg/log" - "sigs.k8s.io/controller-runtime/pkg/predicate" ) type ExpirationController struct { @@ -40,58 +44,55 @@ func (r *ExpirationController) Reconcile(ctx context.Context, req ctrl.Request) tag = fmt.Sprintf("%s/%s/%s/%s/delete", apiVersion, kind, req.Name, req.Namespace) ) - logger.Info("Reconciliation started.") - defer logger.Info("Reconciliation finished.") - if getErr := r.client.Get(ctx, req.NamespacedName, resource); getErr != nil { - if errors.IsNotFound(getErr) { - _ = r.scheduler.DeleteTask(tag) + if errors2.IsNotFound(getErr) { + return ctrl.Result{}, r.scheduler.DeleteTask(tag) } return ctrl.Result{}, client.IgnoreNotFound(getErr) } - hasExpired, expirationDate, hasExpiredErr := common.IsExpired(resource, r.config) - if hasExpiredErr != nil { - logger.Error(hasExpiredErr, "Error while checking if resource has expired.") + annotation, hasAnnotation := resource.GetAnnotations()[r.config.ExpirationLabel] + if !hasAnnotation { + return ctrl.Result{}, r.scheduler.DeleteTask(tag) + } - return ctrl.Result{}, hasExpiredErr + expiration, expirationErr := r.ResolveExpiration(resource.GetCreationTimestamp(), annotation) + if expirationErr != nil { + return ctrl.Result{}, expirationErr } - if hasExpired { - logger.Info("Resource already expired will be removed.") + createOrUpdateTaskErr := r.scheduler.CreateOrUpdateTask(tag, expiration, func() error { + logger.Info("Deleted") + + return client.IgnoreNotFound(r.client.Delete(ctx, resource)) + }) - _ = r.scheduler.DeleteTask(tag) + if errors.Is(createOrUpdateTaskErr, gocron.ErrOneTimeJobStartDateTimePast) { + logger.Info("Deleted") return ctrl.Result{}, client.IgnoreNotFound(r.client.Delete(ctx, resource)) } - if createOrUpdateTaskErr := r.scheduler.CreateOrUpdateTask(tag, expirationDate, func() error { - return r.client.Delete(context.Background(), resource) - }); createOrUpdateTaskErr != nil { - logger.Error(createOrUpdateTaskErr, "Error while creating or updating task.") + logger.Info("Scheduled") + + return ctrl.Result{}, createOrUpdateTaskErr +} + +func (r *ExpirationController) ResolveExpiration(creationTimestamp metav1.Time, expiration string) (time.Time, error) { + duration, parseDurationErr := time.ParseDuration(expiration) + if parseDurationErr == nil { + return creationTimestamp.Add(duration), nil + } - return ctrl.Result{}, createOrUpdateTaskErr + date, parseDateErr := dateparse.ParseAny(expiration) + if parseDateErr == nil { + return date, nil } - return ctrl.Result{}, nil + return time.Time{}, errors.Join(parseDurationErr, parseDateErr) } func (r *ExpirationController) SetupWithManager(mgr ctrl.Manager) error { - return ctrl.NewControllerManagedBy(mgr). - For(common.NewResourceInstance(r.apiVersionKind)). - WithEventFilter(predicate.Funcs{ - CreateFunc: func(createEvent event.CreateEvent) bool { - return len(createEvent.Object.GetAnnotations()[r.config.ExpirationLabel]) != 0 - }, - DeleteFunc: func(deleteEvent event.DeleteEvent) bool { - return len(deleteEvent.Object.GetAnnotations()[r.config.ExpirationLabel]) != 0 - }, - UpdateFunc: func(updateEvent event.UpdateEvent) bool { - oldMayFlyAnnotation := updateEvent.ObjectOld.GetAnnotations()[r.config.ExpirationLabel] - newMayFlyAnnotation := updateEvent.ObjectNew.GetAnnotations()[r.config.ExpirationLabel] - - return len(newMayFlyAnnotation) != 0 && oldMayFlyAnnotation != newMayFlyAnnotation - }, - }).Complete(r) + return ctrl.NewControllerManagedBy(mgr).For(common.NewResourceInstance(r.apiVersionKind)).Complete(r) } From cabcc34ce824cceae6e6f4321aa2522edf15476e Mon Sep 17 00:00:00 2001 From: Yunus Sandikci Date: Sat, 20 Jan 2024 14:25:22 +0300 Subject: [PATCH 2/7] . --- examples/combination.yaml | 4 ++-- examples/expiration.yaml | 2 +- go.sum | 3 +-- pkg/common/config.go | 5 +++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/combination.yaml b/examples/combination.yaml index f8cc478..da66c61 100644 --- a/examples/combination.yaml +++ b/examples/combination.yaml @@ -3,7 +3,7 @@ kind: ScheduledResource metadata: name: combination-example annotations: - mayfly.cloud.spacehip.com/expire: 10s + mayfly.cloud.namecheap.com/expire: 10s spec: in: "5s" content: | @@ -13,6 +13,6 @@ spec: name: combination-example namespace: default annotations: - mayfly.cloud.spaceship.com/expire: 10s + mayfly.cloud.namecheap.com/expire: 10s data: .secret-file: dmFsdWUtMg0KDQo= \ No newline at end of file diff --git a/examples/expiration.yaml b/examples/expiration.yaml index 286ea5f..2fb2c74 100644 --- a/examples/expiration.yaml +++ b/examples/expiration.yaml @@ -4,6 +4,6 @@ metadata: name: expiration-example namespace: default annotations: - mayfly.cloud.namecheap.com/expire: "19 Jan 2024, 14:13" + mayfly.cloud.namecheap.com/expire: "50s" data: .secret-file: dmFsdWUtMg0KDQo= \ No newline at end of file diff --git a/go.sum b/go.sum index 9a491d1..912e8fa 100644 --- a/go.sum +++ b/go.sum @@ -2,9 +2,8 @@ github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de h1:FxWPpzIjnTlhP github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de/go.mod h1:DCaWoUhZrYW9p1lxo/cm8EmUOOzAPSEZNGF2DK1dJgw= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/caarlos0/env/v10 v10.0.0 h1:yIHUBZGsyqCnpTkbjk8asUlx6RFhhEs+h7TOBdgdzXA= github.com/caarlos0/env/v10 v10.0.0/go.mod h1:ZfulV76NvVPw3tm591U4SwL3Xx9ldzBP9aGxzeN7G18= -github.com/caarlos0/env/v9 v9.0.0 h1:SI6JNsOA+y5gj9njpgybykATIylrRMklbs5ch6wO6pc= -github.com/caarlos0/env/v9 v9.0.0/go.mod h1:ye5mlCVMYh6tZ+vCgrs/B95sj88cg5Tlnc0XIzgZ020= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= diff --git a/pkg/common/config.go b/pkg/common/config.go index e4ca7bc..9c66b74 100644 --- a/pkg/common/config.go +++ b/pkg/common/config.go @@ -1,13 +1,14 @@ package common import ( + "github.com/caarlos0/env/v10" "time" ) type Config struct { EnableLeaderElection bool `env:"ENABLE_LEADER_ELECTION" envDefault:"false"` - SyncPeriod time.Duration `env:"SYNC_PERIOD" envDefault:"30m"` - MonitoringInterval time.Duration `env:"MONITORING_INTERVAL" envDefault:"1s"` + SyncPeriod time.Duration `env:"SYNC_PERIOD" envDefault:"60m"` + MonitoringInterval time.Duration `env:"MONITORING_INTERVAL" envDefault:"5s"` ExpirationLabel string `env:"EXPIRATION_LABEL" envDefault:"mayfly.cloud.namecheap.com/expire"` Resources []string `env:"RESOURCES" envSeparator:"," envDefault:"v1;Secret,cloud.namecheap.com/v1alpha1;ScheduledResource"` } From a92f28c2a517a4bc5eb3ff31d9cad169b7d91c36 Mon Sep 17 00:00:00 2001 From: Yunus Sandikci Date: Sat, 20 Jan 2024 14:39:46 +0300 Subject: [PATCH 3/7] . --- pkg/common/config.go | 3 +- pkg/common/utils.go | 24 ++++++------ pkg/controllers/expiration.go | 28 +++----------- pkg/controllers/scheduled_resource.go | 54 +++++++++++++-------------- 4 files changed, 44 insertions(+), 65 deletions(-) diff --git a/pkg/common/config.go b/pkg/common/config.go index 9c66b74..0c3b6df 100644 --- a/pkg/common/config.go +++ b/pkg/common/config.go @@ -1,8 +1,9 @@ package common import ( - "github.com/caarlos0/env/v10" "time" + + "github.com/caarlos0/env/v10" ) type Config struct { diff --git a/pkg/common/utils.go b/pkg/common/utils.go index b7f2a5c..3b008dc 100644 --- a/pkg/common/utils.go +++ b/pkg/common/utils.go @@ -1,29 +1,29 @@ package common import ( + "errors" "fmt" "strings" "time" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "github.com/araddon/dateparse" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "sigs.k8s.io/controller-runtime/pkg/client" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" ) -func IsExpired(resource client.Object, config *Config) (bool, time.Time, error) { - duration, parseDurationErr := time.ParseDuration(resource.GetAnnotations()[config.ExpirationLabel]) - if parseDurationErr != nil { - return false, time.Time{}, parseDurationErr +func ResolveSchedule(creationTimestamp metav1.Time, dateTimeDuration string) (time.Time, error) { + duration, parseDurationErr := time.ParseDuration(dateTimeDuration) + if parseDurationErr == nil { + return creationTimestamp.Add(duration), nil } - creationTime := resource.GetCreationTimestamp() - expirationDate := creationTime.Add(duration) - - if expirationDate.Before(time.Now()) { - return true, expirationDate, nil + date, parseDateErr := dateparse.ParseAny(dateTimeDuration) + if parseDateErr == nil { + return date, nil } - return false, expirationDate, nil + return time.Time{}, errors.Join(parseDurationErr, parseDateErr) } func NewResourceInstance(apiVersionKind string) *unstructured.Unstructured { diff --git a/pkg/controllers/expiration.go b/pkg/controllers/expiration.go index f9c23f9..4795c85 100644 --- a/pkg/controllers/expiration.go +++ b/pkg/controllers/expiration.go @@ -4,14 +4,10 @@ import ( "context" "errors" "fmt" - "time" - "github.com/araddon/dateparse" + "github.com/NCCloud/mayfly/pkg/common" "github.com/go-co-op/gocron/v2" errors2 "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - "github.com/NCCloud/mayfly/pkg/common" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" @@ -57,12 +53,12 @@ func (r *ExpirationController) Reconcile(ctx context.Context, req ctrl.Request) return ctrl.Result{}, r.scheduler.DeleteTask(tag) } - expiration, expirationErr := r.ResolveExpiration(resource.GetCreationTimestamp(), annotation) - if expirationErr != nil { - return ctrl.Result{}, expirationErr + schedule, scheduleErr := common.ResolveSchedule(resource.GetCreationTimestamp(), annotation) + if scheduleErr != nil { + return ctrl.Result{}, scheduleErr } - createOrUpdateTaskErr := r.scheduler.CreateOrUpdateTask(tag, expiration, func() error { + createOrUpdateTaskErr := r.scheduler.CreateOrUpdateTask(tag, schedule, func() error { logger.Info("Deleted") return client.IgnoreNotFound(r.client.Delete(ctx, resource)) @@ -79,20 +75,6 @@ func (r *ExpirationController) Reconcile(ctx context.Context, req ctrl.Request) return ctrl.Result{}, createOrUpdateTaskErr } -func (r *ExpirationController) ResolveExpiration(creationTimestamp metav1.Time, expiration string) (time.Time, error) { - duration, parseDurationErr := time.ParseDuration(expiration) - if parseDurationErr == nil { - return creationTimestamp.Add(duration), nil - } - - date, parseDateErr := dateparse.ParseAny(expiration) - if parseDateErr == nil { - return date, nil - } - - return time.Time{}, errors.Join(parseDurationErr, parseDateErr) -} - func (r *ExpirationController) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr).For(common.NewResourceInstance(r.apiVersionKind)).Complete(r) } diff --git a/pkg/controllers/scheduled_resource.go b/pkg/controllers/scheduled_resource.go index 5b025f2..3c813e5 100644 --- a/pkg/controllers/scheduled_resource.go +++ b/pkg/controllers/scheduled_resource.go @@ -4,7 +4,6 @@ import ( "context" errors2 "errors" "fmt" - "time" "k8s.io/apimachinery/pkg/api/errors" @@ -56,46 +55,43 @@ func (r *ScheduledResourceController) Reconcile(ctx context.Context, req ctrl.Re return ctrl.Result{}, nil } - duration, parseDurationErr := time.ParseDuration(scheduledResource.Spec.In) - if parseDurationErr != nil { - logger.Error(parseDurationErr, "Error while parsing duration.") - - return ctrl.Result{}, parseDurationErr + schedule, scheduleErr := common.ResolveSchedule(scheduledResource.CreationTimestamp, scheduledResource.Spec.In) + if scheduleErr != nil { + return ctrl.Result{}, scheduleErr } - if createOrUpdateTaskErr := r.scheduler.CreateOrUpdateTask(tag, scheduledResource.CreationTimestamp.Add(duration), - func() error { - content, contentErr := scheduledResource.GetContent() - if contentErr != nil { - logger.Error(contentErr, "Error while parsing content.") + if createOrUpdateTaskErr := r.scheduler.CreateOrUpdateTask(tag, schedule, func() error { + content, contentErr := scheduledResource.GetContent() + if contentErr != nil { + logger.Error(contentErr, "Error while parsing content.") - return contentErr - } + return contentErr + } - if getErr := r.client.Get(context.Background(), client. - ObjectKeyFromObject(scheduledResource), scheduledResource); client.IgnoreNotFound(getErr) != nil { - logger.Error(contentErr, "Error while getting resource.") + if getErr := r.client.Get(context.Background(), client. + ObjectKeyFromObject(scheduledResource), scheduledResource); client.IgnoreNotFound(getErr) != nil { + logger.Error(contentErr, "Error while getting resource.") - return getErr - } + return getErr + } - if createErr := r.client.Create(context.Background(), - content); client.IgnoreAlreadyExists(createErr) != nil { - logger.Error(contentErr, "An error occurred while creating resource.") + if createErr := r.client.Create(context.Background(), + content); client.IgnoreAlreadyExists(createErr) != nil { + logger.Error(contentErr, "An error occurred while creating resource.") - scheduledResource.Status.Condition = v1alpha1.ConditionFailed + scheduledResource.Status.Condition = v1alpha1.ConditionFailed - return errors2.Join(createErr, r.client.Status().Update(context.Background(), scheduledResource)) - } + return errors2.Join(createErr, r.client.Status().Update(context.Background(), scheduledResource)) + } - logger.Info(fmt.Sprintf("%s created.", tag)) + logger.Info(fmt.Sprintf("%s created.", tag)) - _ = r.scheduler.DeleteTask(tag) + _ = r.scheduler.DeleteTask(tag) - scheduledResource.Status.Condition = v1alpha1.ConditionCreated + scheduledResource.Status.Condition = v1alpha1.ConditionCreated - return r.client.Status().Update(context.Background(), scheduledResource) - }); createOrUpdateTaskErr != nil { + return r.client.Status().Update(context.Background(), scheduledResource) + }); createOrUpdateTaskErr != nil { logger.Error(createOrUpdateTaskErr, "Error while creating or updating task.") return ctrl.Result{}, createOrUpdateTaskErr From 662d8b8c9a8eec3ccdaef09f94ddbc68eb18628a Mon Sep 17 00:00:00 2001 From: Yunus Sandikci Date: Sun, 21 Jan 2024 14:06:12 +0300 Subject: [PATCH 4/7] Create dependabot.yaml --- .github/dependabot.yaml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/dependabot.yaml diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml new file mode 100644 index 0000000..5ad9ce6 --- /dev/null +++ b/.github/dependabot.yaml @@ -0,0 +1,20 @@ +version: 2 +updates: + - package-ecosystem: gomod + directory: / + schedule: + day: friday + time: 12:00 + interval: weekly + timezone: Europe/Rome + reviewers: + - "yunussandikci" + - package-ecosystem: docker + directory: / + schedule: + day: friday + time: 12:00 + interval: weekly + timezone: Europe/Rome + reviewers: + - "yunussandikci" From 2a3cc175978b0b7bd5190840d66b5a96603c58dc Mon Sep 17 00:00:00 2001 From: Yunus Sandikci Date: Sun, 21 Jan 2024 14:06:51 +0300 Subject: [PATCH 5/7] Update dependabot.yaml --- .github/dependabot.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml index 5ad9ce6..31ef2a1 100644 --- a/.github/dependabot.yaml +++ b/.github/dependabot.yaml @@ -3,18 +3,18 @@ updates: - package-ecosystem: gomod directory: / schedule: - day: friday - time: 12:00 - interval: weekly - timezone: Europe/Rome + day: "friday" + time: "12:00" + interval: "weekly" + timezone: "Europe/Rome" reviewers: - "yunussandikci" - package-ecosystem: docker directory: / schedule: - day: friday - time: 12:00 - interval: weekly - timezone: Europe/Rome + day: "friday" + time: "12:00" + interval: "weekly" + timezone: "Europe/Rome" reviewers: - "yunussandikci" From 9a8d0353a927f6202ec4e24210f302dd789b4b19 Mon Sep 17 00:00:00 2001 From: Yunus Sandikci Date: Sun, 21 Jan 2024 15:23:52 +0300 Subject: [PATCH 6/7] Update scheduled_resource.go --- pkg/controllers/scheduled_resource.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pkg/controllers/scheduled_resource.go b/pkg/controllers/scheduled_resource.go index 3c813e5..5520db3 100644 --- a/pkg/controllers/scheduled_resource.go +++ b/pkg/controllers/scheduled_resource.go @@ -37,9 +37,7 @@ func (r *ScheduledResourceController) Reconcile(ctx context.Context, req ctrl.Re scheduledResource = &v1alpha1.ScheduledResource{} tag = fmt.Sprintf("v1alpha1/ScheduledResource/%s/%s/create", req.Name, req.Namespace) ) - - scheduledResource.GroupVersionKind().ToAPIVersionAndKind() - + logger.Info("Reconciliation started.") defer logger.Info("Reconciliation finished.") From 55eca4243cc5f9e1fd32c650f17296ee56fe7a4a Mon Sep 17 00:00:00 2001 From: Yunus Sandikci Date: Sun, 21 Jan 2024 17:37:18 +0300 Subject: [PATCH 7/7] Update scheduled_resource.go --- pkg/controllers/scheduled_resource.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/controllers/scheduled_resource.go b/pkg/controllers/scheduled_resource.go index 5520db3..2a2dd88 100644 --- a/pkg/controllers/scheduled_resource.go +++ b/pkg/controllers/scheduled_resource.go @@ -37,7 +37,7 @@ func (r *ScheduledResourceController) Reconcile(ctx context.Context, req ctrl.Re scheduledResource = &v1alpha1.ScheduledResource{} tag = fmt.Sprintf("v1alpha1/ScheduledResource/%s/%s/create", req.Name, req.Namespace) ) - + logger.Info("Reconciliation started.") defer logger.Info("Reconciliation finished.")