Skip to content

Commit 0956b1f

Browse files
authored
Add S3 support (#416)
* support s3 upload * delete old s3 objects * calculate max archive age * add ctx * print config * add support for google cloud storage * merge with main
1 parent 748cfe4 commit 0956b1f

File tree

12 files changed

+147
-118
lines changed

12 files changed

+147
-118
lines changed

.config.yaml

Lines changed: 0 additions & 75 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ dist
2020
kubexporter
2121
gomock_*
2222
bin
23+
.config.yaml

cmd/root.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cmd
22

33
import (
4+
"context"
45
"flag"
56
"fmt"
67
"io"
@@ -38,7 +39,7 @@ var rootCmd = &cobra.Command{
3839
return err
3940
}
4041

41-
return ex.Export()
42+
return ex.Export(context.TODO())
4243
},
4344
}
4445

config.yaml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ encrypted:
1313
aesKey: "12345678901234567890123456789012"
1414
kindFields:
1515
Secret:
16-
- [ data ]
17-
- [ stringData ]
16+
- [data]
17+
- [stringData]
1818
masked:
1919
replacement: '***'
2020
checksum: md5
2121
kindFields:
2222
Secret:
23-
- [ stringData ]
23+
- [stringData]
2424
considerOwnerReferences: true
2525
excluded:
2626
kinds:
@@ -49,22 +49,22 @@ excluded:
4949
- metrics.k8s.io.NodeMetrics
5050
- coordination.k8s.io.Lease
5151
fields:
52-
- [ status ]
53-
- [ metadata, uid ]
54-
- [ metadata, selfLink ]
55-
- [ metadata, resourceVersion ]
56-
- [ metadata, creationTimestamp ]
57-
- [ metadata, deletionTimestamp ]
58-
- [ metadata, deletionGracePeriodSeconds ]
59-
- [ metadata, generation ]
60-
- [ metadata, annotations, "kubectl.kubernetes.io/last-applied-configuration" ]
52+
- [status]
53+
- [metadata, uid]
54+
- [metadata, selfLink]
55+
- [metadata, resourceVersion]
56+
- [metadata, creationTimestamp]
57+
- [metadata, deletionTimestamp]
58+
- [metadata, deletionGracePeriodSeconds]
59+
- [metadata, generation]
60+
- [metadata, annotations, "kubectl.kubernetes.io/last-applied-configuration"]
6161
kindFields:
6262
Service:
63-
- [ spec, clusterIP ]
63+
- [spec, clusterIP]
6464
Secret:
65-
- [ metadata, annotations, "openshift.io/token-secret.name" ]
66-
- [ metadata, annotations, "openshift.io/token-secret.value" ]
65+
- [metadata, annotations, "openshift.io/token-secret.name"]
66+
- [metadata, annotations, "openshift.io/token-secret.value"]
6767
kindByField:
6868
Secret:
69-
- field: [ type ]
70-
values: [ 'helm.sh/release', 'helm.sh/release.v1' ]
69+
- field: [type]
70+
values: ['helm.sh/release', 'helm.sh/release.v1']

go.mod

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ require (
88
github.com/charmbracelet/bubbletea v1.1.1
99
github.com/ghodss/yaml v1.0.0
1010
github.com/google/uuid v1.6.0
11+
github.com/minio/minio-go/v7 v7.0.73
1112
github.com/olekukonko/tablewriter v0.0.5
1213
github.com/onsi/ginkgo/v2 v2.20.2
1314
github.com/onsi/gomega v1.34.2
@@ -41,16 +42,19 @@ require (
4142
github.com/charmbracelet/x/ansi v0.2.3 // indirect
4243
github.com/charmbracelet/x/term v0.2.0 // indirect
4344
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
45+
github.com/dustin/go-humanize v1.0.1 // indirect
4446
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
4547
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
4648
github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f // indirect
4749
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
4850
github.com/go-errors/errors v1.5.1 // indirect
51+
github.com/go-ini/ini v1.67.0 // indirect
4952
github.com/go-logr/logr v1.4.2 // indirect
5053
github.com/go-openapi/jsonpointer v0.21.0 // indirect
5154
github.com/go-openapi/jsonreference v0.21.0 // indirect
5255
github.com/go-openapi/swag v0.23.0 // indirect
5356
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
57+
github.com/goccy/go-json v0.10.3 // indirect
5458
github.com/gogo/protobuf v1.3.2 // indirect
5559
github.com/golang/protobuf v1.5.4 // indirect
5660
github.com/google/btree v1.1.2 // indirect
@@ -66,12 +70,15 @@ require (
6670
github.com/inconshreveable/mousetrap v1.1.0 // indirect
6771
github.com/josharian/intern v1.0.0 // indirect
6872
github.com/json-iterator/go v1.1.12 // indirect
73+
github.com/klauspost/compress v1.17.9 // indirect
74+
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
6975
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
7076
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
7177
github.com/mailru/easyjson v0.7.7 // indirect
7278
github.com/mattn/go-isatty v0.0.20 // indirect
7379
github.com/mattn/go-localereader v0.0.1 // indirect
7480
github.com/mattn/go-runewidth v0.0.16 // indirect
81+
github.com/minio/md5-simd v1.1.2 // indirect
7582
github.com/mitchellh/copystructure v1.2.0 // indirect
7683
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
7784
github.com/mitchellh/reflectwalk v1.0.2 // indirect
@@ -88,19 +95,20 @@ require (
8895
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
8996
github.com/pkg/errors v0.9.1 // indirect
9097
github.com/rivo/uniseg v0.4.7 // indirect
98+
github.com/rs/xid v1.5.0 // indirect
9199
github.com/russross/blackfriday/v2 v2.1.0 // indirect
92100
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
93101
github.com/stretchr/objx v0.5.2 // indirect
94102
github.com/x448/float16 v0.8.4 // indirect
95103
github.com/xlab/treeprint v1.2.0 // indirect
96104
go.starlark.net v0.0.0-20231013162135-47c85baa7a64 // indirect
97-
golang.org/x/crypto v0.26.0 // indirect
98-
golang.org/x/net v0.28.0 // indirect
99-
golang.org/x/oauth2 v0.21.0 // indirect
105+
golang.org/x/crypto v0.27.0 // indirect
106+
golang.org/x/net v0.29.0 // indirect
107+
golang.org/x/oauth2 v0.23.0 // indirect
100108
golang.org/x/sync v0.8.0 // indirect
101109
golang.org/x/sys v0.25.0 // indirect
102-
golang.org/x/text v0.17.0 // indirect
103-
golang.org/x/time v0.5.0 // indirect
110+
golang.org/x/text v0.18.0 // indirect
111+
golang.org/x/time v0.6.0 // indirect
104112
golang.org/x/tools v0.24.0 // indirect
105113
google.golang.org/protobuf v1.34.2 // indirect
106114
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect

go.sum

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
3939
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4040
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
4141
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
42+
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
43+
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
4244
github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g=
4345
github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
4446
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=
@@ -51,6 +53,8 @@ github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
5153
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
5254
github.com/go-errors/errors v1.5.1 h1:ZwEMSLRCapFLflTpT7NKaAc7ukJ8ZPEjzlxt8rPN8bk=
5355
github.com/go-errors/errors v1.5.1/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
56+
github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=
57+
github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
5458
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
5559
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
5660
github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ=
@@ -61,6 +65,8 @@ github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+Gr
6165
github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ=
6266
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
6367
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
68+
github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA=
69+
github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
6470
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
6571
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
6672
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
@@ -97,6 +103,11 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr
97103
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
98104
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
99105
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
106+
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
107+
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
108+
github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
109+
github.com/klauspost/cpuid/v2 v2.2.8 h1:+StwCXwm9PdpiEkPyzBXIy+M9KUb4ODm0Zarf1kS5BM=
110+
github.com/klauspost/cpuid/v2 v2.2.8/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
100111
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
101112
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
102113
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
@@ -117,6 +128,10 @@ github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+Ei
117128
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
118129
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
119130
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
131+
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
132+
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
133+
github.com/minio/minio-go/v7 v7.0.73 h1:qr2vi96Qm7kZ4v7LLebjte+MQh621fFWnv93p12htEo=
134+
github.com/minio/minio-go/v7 v7.0.73/go.mod h1:qydcVzV8Hqtj1VtEocfxbmVFa2siu6HGa+LDEPogjD8=
120135
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
121136
github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s=
122137
github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0=
@@ -162,6 +177,8 @@ github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
162177
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
163178
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
164179
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
180+
github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc=
181+
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
165182
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
166183
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
167184
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
@@ -198,18 +215,18 @@ go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc=
198215
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
199216
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
200217
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
201-
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
202-
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
218+
golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
219+
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
203220
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
204221
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
205222
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
206223
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
207224
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
208225
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
209-
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
210-
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
211-
golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs=
212-
golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
226+
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
227+
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
228+
golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs=
229+
golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
213230
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
214231
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
215232
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -220,17 +237,18 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w
220237
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
221238
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
222239
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
240+
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
223241
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
224242
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
225243
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
226244
golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
227245
golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
228246
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
229247
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
230-
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
231-
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
232-
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
233-
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
248+
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
249+
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
250+
golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U=
251+
golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
234252
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
235253
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
236254
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=

pkg/export/archive.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func (e *exporter) pruneArchives() error {
2323

2424
pattern := regexp.MustCompile(fmt.Sprintf(`^%s-?.*-\d{4}-\d{2}-\d{2}-\d{6}\.tar\.gz$`, filepath.Base(e.config.Target)))
2525

26-
deleteOlderThan := time.Now().AddDate(0, 0, -e.config.ArchiveRetentionDays)
26+
deleteOlderThan := e.config.MaxArchiveAge()
2727
entries, err := os.ReadDir(dir)
2828
if err != nil {
2929
return err

pkg/export/export.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package export
22

33
import (
4+
"context"
45
"os"
56
"sort"
67
"strconv"
@@ -38,10 +39,10 @@ func NewExporter(config *types.Config) (Exporter, error) {
3839

3940
// Exporter interface
4041
type Exporter interface {
41-
Export() error
42+
Export(context.Context) error
4243
}
4344

44-
func (e *exporter) Export() error {
45+
func (e *exporter) Export(ctx context.Context) error {
4546
e.start = time.Now()
4647

4748
defer e.printStats()
@@ -85,11 +86,11 @@ func (e *exporter) Export() error {
8586
var s *worker.Stats
8687
if prog.Async() {
8788
go func() {
88-
s, exportErr = worker.RunExport(workers, resources)
89+
s, exportErr = worker.RunExport(ctx, workers, resources)
8990
e.stats.Add(s)
9091
}()
9192
} else {
92-
s, exportErr = worker.RunExport(workers, resources)
93+
s, exportErr = worker.RunExport(ctx, workers, resources)
9394
e.stats.Add(s)
9495
}
9596

@@ -118,6 +119,13 @@ func (e *exporter) Export() error {
118119
return err
119120
}
120121
}
122+
123+
if e.config.S3Config != nil {
124+
err = e.uploadS3(ctx)
125+
if err != nil {
126+
return err
127+
}
128+
}
121129
}
122130
return nil
123131
}
@@ -166,6 +174,9 @@ func (e *exporter) writeIntro() {
166174
if e.config.ArchiveRetentionDays > 0 {
167175
e.l.Printf(" delete archives older than %d days 🚮\n", e.config.ArchiveRetentionDays)
168176
}
177+
if e.config.S3Config != nil {
178+
e.l.Printf(" upload to S3 🪣 %s/%s\n", e.config.S3Config.Endpoint, e.config.S3Config.Bucket)
179+
}
169180
}
170181
e.config.Logger().Printf("\nExporting ...\n")
171182
}

0 commit comments

Comments
 (0)