@@ -10,6 +10,7 @@ import (
1010 "sort"
1111 "strings"
1212 "text/template"
13+ "time"
1314
1415 "github.com/Masterminds/sprig"
1516 "github.com/bakito/kubexporter/pkg/log"
@@ -97,27 +98,28 @@ func NewConfig(configFlags *genericclioptions.ConfigFlags, printFlags *genericcl
9798
9899// Config export config
99100type Config struct {
100- Excluded Excluded `json:"excluded" yaml:"excluded"`
101- Included Included `json:"included" yaml:"included"`
102- ConsiderOwnerReferences bool `json:"considerOwnerReferences" yaml:"considerOwnerReferences"`
103- Masked * Masked `json:"masked" yaml:"masked"`
104- Encrypted * Encrypted `json:"encrypted" yaml:"masked"`
105- SortSlices KindFields `json:"sortSlices" yaml:"sortSlices"`
106- FileNameTemplate string `json:"fileNameTemplate" yaml:"fileNameTemplate"`
107- ListFileNameTemplate string `json:"listFileNameTemplate" yaml:"listFileNameTemplate"`
108- AsLists bool `json:"asLists" yaml:"asLists"`
109- QueryPageSize int `json:"queryPageSize" yaml:"queryPageSize"`
110- Target string `json:"target" yaml:"target"`
111- ClearTarget bool `json:"clearTarget" yaml:"clearTarget"`
112- Summary bool `json:"summary" yaml:"summary"`
113- Progress Progress `json:"progress" yaml:"progress"`
114- Namespace string `json:"namespace" yaml:"namespace"`
115- Worker int `json:"worker" yaml:"worker"`
116- Archive bool `json:"archive" yaml:"archive"`
117- ArchiveRetentionDays int `json:"archiveRetentionDays" yaml:"archiveRetentionDays"`
118- ArchiveTarget string `json:"archiveTarget" yaml:"archiveTarget"`
119- Quiet bool `json:"quiet" yaml:"quiet"`
120- Verbose bool `json:"verbose" yaml:"verbose"`
101+ Excluded Excluded `json:"excluded" yaml:"excluded"`
102+ Included Included `json:"included" yaml:"included"`
103+ CreatedWithin time.Duration `json:"createdWithin" yaml:"createdWithin"`
104+ ConsiderOwnerReferences bool `json:"considerOwnerReferences" yaml:"considerOwnerReferences"`
105+ Masked * Masked `json:"masked" yaml:"masked"`
106+ Encrypted * Encrypted `json:"encrypted" yaml:"masked"`
107+ SortSlices KindFields `json:"sortSlices" yaml:"sortSlices"`
108+ FileNameTemplate string `json:"fileNameTemplate" yaml:"fileNameTemplate"`
109+ ListFileNameTemplate string `json:"listFileNameTemplate" yaml:"listFileNameTemplate"`
110+ AsLists bool `json:"asLists" yaml:"asLists"`
111+ QueryPageSize int `json:"queryPageSize" yaml:"queryPageSize"`
112+ Target string `json:"target" yaml:"target"`
113+ ClearTarget bool `json:"clearTarget" yaml:"clearTarget"`
114+ Summary bool `json:"summary" yaml:"summary"`
115+ Progress Progress `json:"progress" yaml:"progress"`
116+ Namespace string `json:"namespace" yaml:"namespace"`
117+ Worker int `json:"worker" yaml:"worker"`
118+ Archive bool `json:"archive" yaml:"archive"`
119+ ArchiveRetentionDays int `json:"archiveRetentionDays" yaml:"archiveRetentionDays"`
120+ ArchiveTarget string `json:"archiveTarget" yaml:"archiveTarget"`
121+ Quiet bool `json:"quiet" yaml:"quiet"`
122+ Verbose bool `json:"verbose" yaml:"verbose"`
121123
122124 excludedSet set
123125 includedSet set
@@ -337,6 +339,9 @@ func (c *Config) IsInstanceExcluded(res *GroupResource, us unstructured.Unstruct
337339 if c .isExcludedByOwnerReference (us ) {
338340 return true
339341 }
342+ if c .CreatedWithin > 0 && us .GetCreationTimestamp ().Time .Before (time .Now ().Add (- c .CreatedWithin )) {
343+ return true
344+ }
340345 if fvs , ok := c .Excluded .KindsByField [res .GroupKind ()]; ok {
341346 for _ , fv := range fvs {
342347 for _ , v := range fv .Values {
0 commit comments