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

Method Validate

plugins/destination/gcs/client/spec/spec.go:99–125  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

97}
98
99func (s *Spec) Validate() error {
100 if len(s.Bucket) == 0 {
101 return errors.New("`bucket` is required")
102 }
103 if len(s.Path) == 0 {
104 return errors.New("`path` is required")
105 }
106
107 if s.NoRotate && ((s.BatchSize != nil && *s.BatchSize > 0) || (s.BatchSizeBytes != nil && *s.BatchSizeBytes > 0) || (s.BatchTimeout != nil && s.BatchTimeout.Duration() > 0)) {
108 return errors.New("`no_rotate` cannot be used with non-zero `batch_size`, `batch_size_bytes` or `batch_timeout_ms`")
109 }
110
111 if len(s.ServiceAccountKeyJSON) > 0 {
112 if err := isValidJson(s.ServiceAccountKeyJSON); err != nil {
113 return fmt.Errorf("invalid json for service_account_key_json: %w", err)
114 }
115 }
116
117 // required for s.FileSpec.Validate call
118 err := s.FileSpec.UnmarshalSpec()
119 if err != nil {
120 return err
121 }
122 s.FileSpec.SetDefaults()
123
124 return s.FileSpec.Validate()
125}
126
127func (s *Spec) PathContainsUUID() bool {
128 return strings.Contains(s.Path, varUUID)

Callers 1

NewFunction · 0.45

Calls 4

ErrorfMethod · 0.80
isValidJsonFunction · 0.70
UnmarshalSpecMethod · 0.45
SetDefaultsMethod · 0.45

Tested by

no test coverage detected