func()

in controllers/blobstore/chain/crete_s3_blobstore.go [66:118]


func (c *CreateS3BlobStore) specToS3Blobstore(
	ctx context.Context,
	spec *nexusApi.NexusBlobStoreSpec,
	namespace string,
) (*blobstore.S3, error) {
	specCopy := spec.DeepCopy()

	s3 := &blobstore.S3{
		Name: specCopy.Name,
		BucketConfiguration: blobstore.S3BucketConfiguration{
			Bucket: blobstore.S3Bucket{
				Region:     specCopy.S3.Bucket.Region,
				Name:       specCopy.S3.Bucket.Name,
				Prefix:     specCopy.S3.Bucket.Prefix,
				Expiration: specCopy.S3.Bucket.Expiration,
			},
		},
	}

	if specCopy.SoftQuota != nil {
		s3.SoftQuota = &blobstore.SoftQuota{
			Limit: specCopy.SoftQuota.Limit,
			Type:  specCopy.SoftQuota.Type,
		}
	}

	if specCopy.S3.Encryption != nil {
		s3.BucketConfiguration.Encryption = &blobstore.S3Encryption{
			Key:  specCopy.S3.Encryption.Key,
			Type: specCopy.S3.Encryption.Type,
		}
	}

	if specCopy.S3.AdvancedBucketConnection != nil {
		s3.BucketConfiguration.AdvancedBucketConnection = &blobstore.S3AdvancedBucketConnection{
			Endpoint:              specCopy.S3.AdvancedBucketConnection.Endpoint,
			SignerType:            specCopy.S3.AdvancedBucketConnection.SignerType,
			ForcePathStyle:        &specCopy.S3.AdvancedBucketConnection.ForcePathStyle,
			MaxConnectionPoolSize: &specCopy.S3.AdvancedBucketConnection.MaxConnectionPoolSize,
		}
	}

	if specCopy.S3.BucketSecurity != nil {
		bucketSecurity, err := c.s3BucketSecurityToS3Blobstore(ctx, specCopy.S3.BucketSecurity, namespace)
		if err != nil {
			return nil, err
		}

		s3.BucketConfiguration.BucketSecurity = bucketSecurity
	}

	return s3, nil
}