func()

in internal/backint/configuration/configuration.go [161:195]


func (p *Parameters) validateParameters() error {
	if p.Config.GetBucket() == "" {
		return errors.New("bucket must be provided")
	}
	if strings.Contains(p.Config.GetBucket(), "/") || strings.HasPrefix(p.Config.GetBucket(), "gs:") {
		return fmt.Errorf("bucket (%s) must not contain any '/' or be prefixed with 'gs:', only include the name of the bucket in the parameter", p.Config.GetBucket())
	}
	if p.Config.GetRecoveryBucket() != "" && (strings.Contains(p.Config.GetRecoveryBucket(), "/") || strings.HasPrefix(p.Config.GetRecoveryBucket(), "gs:")) {
		return fmt.Errorf("recovery_bucket (%s) must not contain any '/' or be prefixed with 'gs:', only include the name of the bucket in the parameter", p.Config.GetRecoveryBucket())
	}
	if p.Config.GetEncryptionKey() != "" && p.Config.GetKmsKey() != "" {
		return errors.New("only one of encryption_key or kms_key can be provided")
	}
	if p.Config.GetFunction() == bpb.Function_BACKUP && (p.Config.GetParallelStreams() > 1 || p.Config.GetXmlMultipartUpload()) {
		if p.Config.GetCompress() {
			return errors.New("compressed parallel backups are not supported - 'parallel_streams' must be set to 1 in order to compress data")
		}
		if p.Config.GetEncryptionKey() != "" || p.Config.GetKmsKey() != "" {
			return errors.New("encrypted parallel backups are not supported - 'parallel_streams' must be set to 1 in order to encrypt data")
		}
	}
	if p.Config.GetFunction() == bpb.Function_RESTORE && p.Config.GetParallelRecoveryStreams() > 1 {
		if p.Config.GetCompress() {
			return errors.New("compressed parallel restores are not supported - 'parallel_recovery_streams' must be set to 0 or 1 in order to compress data")
		}
	}
	if p.Config.GetObjectRetentionMode() != "" && p.Config.GetObjectRetentionMode() != "Unlocked" && p.Config.GetObjectRetentionMode() != "Locked" {
		return errors.New("object_retention_mode must be either 'Unlocked' or 'Locked'")
	}
	if (p.Config.GetObjectRetentionTime() != "" && p.Config.GetObjectRetentionMode() == "") || (p.Config.GetObjectRetentionTime() == "" && p.Config.GetObjectRetentionMode() != "") {
		return errors.New("object_retention_time and object_retention_mode must be set together")
	}

	return nil
}