()
| 97 | } |
| 98 | |
| 99 | func (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 | |
| 127 | func (s *Spec) PathContainsUUID() bool { |
| 128 | return strings.Contains(s.Path, varUUID) |
no test coverage detected