MCPcopy Create free account
hub / github.com/cloudquery/cloudquery / Validate

Method Validate

plugins/destination/file/client/spec/spec.go:93–120  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

91}
92
93func (s *Spec) Validate() error {
94 if len(s.Path) == 0 {
95 return errors.New("`path` must be set")
96 }
97
98 if s.NoRotate {
99 if strings.Contains(s.Path, varUUID) {
100 return fmt.Errorf("`path` should not contain %s when `no_rotate` = true", varUUID)
101 }
102
103 if (s.BatchSize != nil && *s.BatchSize > 0) || (s.BatchSizeBytes != nil && *s.BatchSizeBytes > 0) || (s.BatchTimeout != nil && s.BatchTimeout.Duration() > 0) {
104 return errors.New("`no_rotate` cannot be used with non-zero `batch_size`, `batch_size_bytes` or `batch_timeout_ms`")
105 }
106 }
107
108 if !strings.Contains(s.Path, varUUID) && s.batchingEnabled() {
109 return fmt.Errorf("`path` should contain %s when using a non-zero `batch_size`, `batch_size_bytes` or `batch_timeout_ms`", varUUID)
110 }
111
112 // required for s.FileSpec.Validate call
113 err := s.FileSpec.UnmarshalSpec()
114 if err != nil {
115 return err
116 }
117 s.FileSpec.SetDefaults()
118
119 return s.FileSpec.Validate()
120}
121
122func (s *Spec) ReplacePathVariables(table string, fileIdentifier string, t time.Time) string {
123 name := strings.ReplaceAll(s.Path, varTable, table)

Callers 2

NewFunction · 0.45
TestSpec_ValidateFunction · 0.45

Calls 4

batchingEnabledMethod · 0.95
ErrorfMethod · 0.80
UnmarshalSpecMethod · 0.45
SetDefaultsMethod · 0.45

Tested by 1

TestSpec_ValidateFunction · 0.36