| 
									
										
										
										
											2021-04-19 03:41:13 +08:00
										 |  |  | // Copyright (c) 2015-2021 MinIO, Inc.
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // This file is part of MinIO Object Storage stack
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // This program is free software: you can redistribute it and/or modify
 | 
					
						
							|  |  |  | // it under the terms of the GNU Affero General Public License as published by
 | 
					
						
							|  |  |  | // the Free Software Foundation, either version 3 of the License, or
 | 
					
						
							|  |  |  | // (at your option) any later version.
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // This program is distributed in the hope that it will be useful
 | 
					
						
							|  |  |  | // but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					
						
							|  |  |  | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					
						
							|  |  |  | // GNU Affero General Public License for more details.
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // You should have received a copy of the GNU Affero General Public License
 | 
					
						
							|  |  |  | // along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
					
						
							| 
									
										
										
										
											2016-04-30 05:24:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-19 07:23:42 +08:00
										 |  |  | package cmd | 
					
						
							| 
									
										
										
										
											2016-04-30 05:24:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-20 03:40:27 +08:00
										 |  |  | import ( | 
					
						
							| 
									
										
										
										
											2018-03-15 03:01:47 +08:00
										 |  |  | 	"context" | 
					
						
							| 
									
										
										
										
											2017-09-20 03:40:27 +08:00
										 |  |  | 	"io" | 
					
						
							| 
									
										
										
										
											2018-09-21 10:22:09 +08:00
										 |  |  | 	"net/http" | 
					
						
							| 
									
										
										
										
											2020-07-09 08:36:56 +08:00
										 |  |  | 	"time" | 
					
						
							| 
									
										
										
										
											2017-09-20 03:40:27 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-20 08:53:08 +08:00
										 |  |  | 	"github.com/minio/madmin-go/v3" | 
					
						
							| 
									
										
										
										
											2020-07-15 00:38:05 +08:00
										 |  |  | 	"github.com/minio/minio-go/v7/pkg/encrypt" | 
					
						
							|  |  |  | 	"github.com/minio/minio-go/v7/pkg/tags" | 
					
						
							| 
									
										
										
										
											2022-08-30 07:57:16 +08:00
										 |  |  | 	"github.com/minio/minio/internal/hash" | 
					
						
							| 
									
										
										
										
											2021-11-02 23:11:50 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	"github.com/minio/minio/internal/bucket/replication" | 
					
						
							|  |  |  | 	xioutil "github.com/minio/minio/internal/ioutil" | 
					
						
							| 
									
										
										
										
											2017-09-20 03:40:27 +08:00
										 |  |  | ) | 
					
						
							| 
									
										
										
										
											2016-04-30 05:24:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-09 03:08:18 +08:00
										 |  |  | //go:generate msgp -file $GOFILE -io=false -tests=false -unexported=false
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //msgp:ignore ObjectOptions TransitionOptions DeleteBucketOptions
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-18 04:01:22 +08:00
										 |  |  | // CheckPreconditionFn returns true if precondition check failed.
 | 
					
						
							|  |  |  | type CheckPreconditionFn func(o ObjectInfo) bool | 
					
						
							| 
									
										
										
										
											2019-03-07 04:38:41 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-10 22:57:56 +08:00
										 |  |  | // EvalMetadataFn validates input objInfo and GetObjectInfo error and returns an updated metadata and replication decision if any
 | 
					
						
							|  |  |  | type EvalMetadataFn func(o *ObjectInfo, gerr error) (ReplicateDecision, error) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // EvalRetentionBypassFn validates input objInfo and GetObjectInfo error and returns an error if retention bypass is not allowed.
 | 
					
						
							|  |  |  | type EvalRetentionBypassFn func(o ObjectInfo, gerr error) error | 
					
						
							| 
									
										
										
										
											2021-10-30 23:22:04 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-21 05:18:09 +08:00
										 |  |  | // GetObjectInfoFn is the signature of GetObjectInfo function.
 | 
					
						
							| 
									
										
										
										
											2020-06-13 11:04:01 +08:00
										 |  |  | type GetObjectInfoFn func(ctx context.Context, bucket, object string, opts ObjectOptions) (ObjectInfo, error) | 
					
						
							| 
									
										
										
										
											2019-11-21 05:18:09 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-02 18:51:33 +08:00
										 |  |  | // WalkVersionsSortOrder represents the sort order in which versions of an
 | 
					
						
							|  |  |  | // object should be returned by ObjectLayer.Walk method
 | 
					
						
							|  |  |  | type WalkVersionsSortOrder uint8 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const ( | 
					
						
							|  |  |  | 	// WalkVersionsSortAsc - Sort in ascending order of ModTime
 | 
					
						
							|  |  |  | 	WalkVersionsSortAsc WalkVersionsSortOrder = iota | 
					
						
							|  |  |  | 	// WalkVersionsSortDesc - Sort in descending order of ModTime
 | 
					
						
							|  |  |  | 	WalkVersionsSortDesc | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-13 11:04:01 +08:00
										 |  |  | // ObjectOptions represents object options for ObjectLayer object operations
 | 
					
						
							| 
									
										
										
										
											2018-09-11 00:42:43 +08:00
										 |  |  | type ObjectOptions struct { | 
					
						
							| 
									
										
										
										
											2020-11-13 04:12:09 +08:00
										 |  |  | 	ServerSideEncryption encrypt.ServerSide | 
					
						
							|  |  |  | 	VersionSuspended     bool      // indicates if the bucket was previously versioned but is currently suspended.
 | 
					
						
							|  |  |  | 	Versioned            bool      // indicates if the bucket is versioned
 | 
					
						
							|  |  |  | 	VersionID            string    // Specifies the versionID which needs to be overwritten or read
 | 
					
						
							|  |  |  | 	MTime                time.Time // Is only set in POST/PUT operations
 | 
					
						
							|  |  |  | 	Expires              time.Time // Is only used in POST/PUT operations
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-22 05:45:06 +08:00
										 |  |  | 	DeleteMarker            bool // Is only set in DELETE operations for delete marker replication
 | 
					
						
							|  |  |  | 	CheckDMReplicationReady bool // Is delete marker ready to be replicated - set only during HEAD
 | 
					
						
							| 
									
										
										
										
											2023-07-22 22:19:43 +08:00
										 |  |  | 	Tagging                 bool // Is only in GET/HEAD operations to return tagging metadata along with regular metadata and body.
 | 
					
						
							| 
									
										
										
										
											2022-10-22 05:45:06 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-23 06:28:56 +08:00
										 |  |  | 	UserDefined         map[string]string   // only set in case of POST/PUT operations
 | 
					
						
							| 
									
										
										
										
											2024-01-06 02:43:06 +08:00
										 |  |  | 	ObjectAttributes    map[string]struct{} // Attribute tags defined by the users for the GetObjectAttributes request
 | 
					
						
							|  |  |  | 	MaxParts            int                 // used in GetObjectAttributes. Signals how many parts we should return
 | 
					
						
							|  |  |  | 	PartNumberMarker    int                 // used in GetObjectAttributes. Signals the part number after which results should be returned
 | 
					
						
							| 
									
										
										
										
											2023-05-23 06:28:56 +08:00
										 |  |  | 	PartNumber          int                 // only useful in case of GetObject/HeadObject
 | 
					
						
							|  |  |  | 	CheckPrecondFn      CheckPreconditionFn // only set during GetObject/HeadObject/CopyObjectPart preconditional valuation
 | 
					
						
							|  |  |  | 	EvalMetadataFn      EvalMetadataFn      // only set for retention settings, meant to be used only when updating metadata in-place.
 | 
					
						
							|  |  |  | 	DeleteReplication   ReplicationState    // Represents internal replication state needed for Delete replication
 | 
					
						
							|  |  |  | 	Transition          TransitionOptions | 
					
						
							|  |  |  | 	Expiration          ExpirationOptions | 
					
						
							|  |  |  | 	LifecycleAuditEvent lcAuditEvent | 
					
						
							| 
									
										
										
										
											2021-09-19 04:31:35 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-30 07:57:16 +08:00
										 |  |  | 	WantChecksum *hash.Checksum // x-amz-checksum-XXX checksum sent to PutObject/ CompleteMultipartUpload.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-25 23:08:54 +08:00
										 |  |  | 	WantServerSideChecksumType hash.ChecksumType // if set, we compute a server-side checksum of this type
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-17 10:35:24 +08:00
										 |  |  | 	NoDecryption                        bool      // indicates if the stream must be decrypted.
 | 
					
						
							|  |  |  | 	PreserveETag                        string    // preserves this etag during a PUT call.
 | 
					
						
							| 
									
										
										
										
											2021-09-19 04:31:35 +08:00
										 |  |  | 	NoLock                              bool      // indicates to lower layers if the caller is expecting to hold locks.
 | 
					
						
							|  |  |  | 	ProxyRequest                        bool      // only set for GET/HEAD in active-active replication scenario
 | 
					
						
							| 
									
										
										
										
											2024-04-20 17:05:54 +08:00
										 |  |  | 	ProxyHeaderSet                      bool      // only set for GET/HEAD in active-active replication scenario
 | 
					
						
							| 
									
										
										
										
											2021-09-19 04:31:35 +08:00
										 |  |  | 	ReplicationRequest                  bool      // true only if replication request
 | 
					
						
							|  |  |  | 	ReplicationSourceTaggingTimestamp   time.Time // set if MinIOSourceTaggingTimestamp received
 | 
					
						
							|  |  |  | 	ReplicationSourceLegalholdTimestamp time.Time // set if MinIOSourceObjectLegalholdTimestamp received
 | 
					
						
							|  |  |  | 	ReplicationSourceRetentionTimestamp time.Time // set if MinIOSourceObjectRetentionTimestamp received
 | 
					
						
							| 
									
										
										
										
											2022-02-24 03:59:13 +08:00
										 |  |  | 	DeletePrefix                        bool      // set true to enforce a prefix deletion, only application for DeleteObject API,
 | 
					
						
							| 
									
										
										
										
											2023-08-10 07:30:22 +08:00
										 |  |  | 	DeletePrefixObject                  bool      // set true when object's erasure set is resolvable by object name (using getHashedSetIndex)
 | 
					
						
							| 
									
										
										
										
											2022-02-24 03:59:13 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	Speedtest bool // object call specifically meant for SpeedTest code, set to 'true' when invoked by SpeedtestHandler.
 | 
					
						
							| 
									
										
										
										
											2021-06-16 09:43:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-25 10:07:27 +08:00
										 |  |  | 	// Use the maximum parity (N/2), used when saving server configuration files
 | 
					
						
							| 
									
										
										
										
											2021-03-10 02:19:47 +08:00
										 |  |  | 	MaxParity bool | 
					
						
							| 
									
										
										
										
											2022-01-11 01:07:49 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-31 23:13:23 +08:00
										 |  |  | 	// Provides a per object encryption function, allowing metadata encryption.
 | 
					
						
							|  |  |  | 	EncryptFn objectMetaEncryptFn | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-17 10:35:24 +08:00
										 |  |  | 	// SkipDecommissioned set to 'true' if the call requires skipping the pool being decommissioned.
 | 
					
						
							|  |  |  | 	// mainly set for certain WRITE operations.
 | 
					
						
							|  |  |  | 	SkipDecommissioned bool | 
					
						
							| 
									
										
										
										
											2022-10-26 03:36:57 +08:00
										 |  |  | 	// SkipRebalancing should be set to 'true' if the call should skip pools
 | 
					
						
							|  |  |  | 	// participating in a rebalance operation. Typically set for 'write' operations.
 | 
					
						
							|  |  |  | 	SkipRebalancing bool | 
					
						
							| 
									
										
										
										
											2022-05-07 10:05:28 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-09 10:05:14 +08:00
										 |  |  | 	SrcPoolIdx int // set by PutObject/CompleteMultipart operations due to rebalance; used to prevent rebalance src, dst pools to be the same
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 06:03:30 +08:00
										 |  |  | 	DataMovement bool // indicates an going decommisionning or rebalacing
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-08 13:06:44 +08:00
										 |  |  | 	PrefixEnabledFn func(prefix string) bool // function which returns true if versioning is enabled on prefix
 | 
					
						
							| 
									
										
										
										
											2022-07-12 08:30:56 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// IndexCB will return any index created but the compression.
 | 
					
						
							|  |  |  | 	// Object must have been read at this point.
 | 
					
						
							|  |  |  | 	IndexCB func() []byte | 
					
						
							| 
									
										
										
										
											2022-12-22 08:24:07 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-02 13:11:03 +08:00
										 |  |  | 	// InclFreeVersions indicates that free versions need to be included
 | 
					
						
							|  |  |  | 	// when looking up a version by fi.VersionID
 | 
					
						
							| 
									
										
										
										
											2022-12-22 08:24:07 +08:00
										 |  |  | 	InclFreeVersions bool | 
					
						
							| 
									
										
										
										
											2024-03-02 13:11:03 +08:00
										 |  |  | 	// SkipFreeVersion skips adding a free version when a tiered version is
 | 
					
						
							|  |  |  | 	// being 'replaced'
 | 
					
						
							|  |  |  | 	// Note: Used only when a tiered object is being expired.
 | 
					
						
							|  |  |  | 	SkipFreeVersion bool | 
					
						
							| 
									
										
										
										
											2023-06-17 22:30:53 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-10 22:57:56 +08:00
										 |  |  | 	MetadataChg           bool                  // is true if it is a metadata update operation.
 | 
					
						
							|  |  |  | 	EvalRetentionBypassFn EvalRetentionBypassFn // only set for enforcing retention bypass on DeleteObject.
 | 
					
						
							| 
									
										
										
										
											2023-11-23 05:46:17 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	FastGetObjInfo bool // Only for S3 Head/Get Object calls for now
 | 
					
						
							| 
									
										
										
										
											2024-03-06 19:43:16 +08:00
										 |  |  | 	NoAuditLog     bool // Only set for decom, rebalance, to avoid double audits.
 | 
					
						
							| 
									
										
										
										
											2018-09-11 00:42:43 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-28 09:20:04 +08:00
										 |  |  | // WalkOptions provides filtering, marker and other Walk() specific options.
 | 
					
						
							|  |  |  | type WalkOptions struct { | 
					
						
							| 
									
										
										
										
											2023-12-02 18:51:33 +08:00
										 |  |  | 	Filter       func(info FileInfo) bool // return WalkFilter returns 'true/false'
 | 
					
						
							|  |  |  | 	Marker       string                   // set to skip until this object
 | 
					
						
							|  |  |  | 	LatestOnly   bool                     // returns only latest versions for all matching objects
 | 
					
						
							|  |  |  | 	AskDisks     string                   // dictates how many disks are being listed
 | 
					
						
							|  |  |  | 	VersionsSort WalkVersionsSortOrder    // sort order for versions of the same object; default: Ascending order in ModTime
 | 
					
						
							| 
									
										
										
										
											2024-08-23 05:57:20 +08:00
										 |  |  | 	Limit        int                      // maximum number of items, 0 means no limit
 | 
					
						
							| 
									
										
										
										
											2023-11-28 09:20:04 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-28 08:06:47 +08:00
										 |  |  | // ExpirationOptions represents object options for object expiration at objectLayer.
 | 
					
						
							|  |  |  | type ExpirationOptions struct { | 
					
						
							|  |  |  | 	Expire bool | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-20 01:30:42 +08:00
										 |  |  | // TransitionOptions represents object options for transition ObjectLayer operation
 | 
					
						
							|  |  |  | type TransitionOptions struct { | 
					
						
							|  |  |  | 	Status         string | 
					
						
							|  |  |  | 	Tier           string | 
					
						
							|  |  |  | 	ETag           string | 
					
						
							|  |  |  | 	RestoreRequest *RestoreObjectRequest | 
					
						
							|  |  |  | 	RestoreExpiry  time.Time | 
					
						
							|  |  |  | 	ExpireRestored bool | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-26 08:51:32 +08:00
										 |  |  | // MakeBucketOptions represents bucket options for ObjectLayer bucket operations
 | 
					
						
							|  |  |  | type MakeBucketOptions struct { | 
					
						
							| 
									
										
										
										
											2020-06-13 11:04:01 +08:00
										 |  |  | 	LockEnabled       bool | 
					
						
							|  |  |  | 	VersioningEnabled bool | 
					
						
							| 
									
										
										
										
											2022-07-26 08:51:32 +08:00
										 |  |  | 	ForceCreate       bool      // Create buckets even if they are already created.
 | 
					
						
							|  |  |  | 	CreatedAt         time.Time // only for site replication
 | 
					
						
							| 
									
										
										
										
											2023-01-04 00:16:39 +08:00
										 |  |  | 	NoLock            bool      // does not lock the make bucket call if set to 'true'
 | 
					
						
							| 
									
										
										
										
											2020-06-13 11:04:01 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-07 01:24:40 +08:00
										 |  |  | // DeleteBucketOptions provides options for DeleteBucket calls.
 | 
					
						
							|  |  |  | type DeleteBucketOptions struct { | 
					
						
							| 
									
										
										
										
											2023-01-04 00:16:39 +08:00
										 |  |  | 	NoLock     bool             // does not lock the delete bucket call if set to 'true'
 | 
					
						
							|  |  |  | 	NoRecreate bool             // do not recreate bucket on delete failures
 | 
					
						
							| 
									
										
										
										
											2022-07-26 08:51:32 +08:00
										 |  |  | 	Force      bool             // Force deletion
 | 
					
						
							|  |  |  | 	SRDeleteOp SRBucketDeleteOp // only when site replication is enabled
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // BucketOptions provides options for ListBuckets and GetBucketInfo call.
 | 
					
						
							|  |  |  | type BucketOptions struct { | 
					
						
							| 
									
										
										
										
											2024-06-22 06:22:24 +08:00
										 |  |  | 	Deleted    bool // true only when site replication is enabled
 | 
					
						
							|  |  |  | 	Cached     bool // true only when we are requesting a cached response instead of hitting the disk for example ListBuckets() call.
 | 
					
						
							|  |  |  | 	NoMetadata bool | 
					
						
							| 
									
										
										
										
											2021-10-07 01:24:40 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-19 04:31:35 +08:00
										 |  |  | // SetReplicaStatus sets replica status and timestamp for delete operations in ObjectOptions
 | 
					
						
							|  |  |  | func (o *ObjectOptions) SetReplicaStatus(st replication.StatusType) { | 
					
						
							|  |  |  | 	o.DeleteReplication.ReplicaStatus = st | 
					
						
							|  |  |  | 	o.DeleteReplication.ReplicaTimeStamp = UTCNow() | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // DeleteMarkerReplicationStatus - returns replication status of delete marker from DeleteReplication state in ObjectOptions
 | 
					
						
							|  |  |  | func (o *ObjectOptions) DeleteMarkerReplicationStatus() replication.StatusType { | 
					
						
							|  |  |  | 	return o.DeleteReplication.CompositeReplicationStatus() | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // VersionPurgeStatus - returns version purge status from DeleteReplication state in ObjectOptions
 | 
					
						
							|  |  |  | func (o *ObjectOptions) VersionPurgeStatus() VersionPurgeStatusType { | 
					
						
							|  |  |  | 	return o.DeleteReplication.CompositeVersionPurgeStatus() | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // SetDeleteReplicationState sets the delete replication options.
 | 
					
						
							|  |  |  | func (o *ObjectOptions) SetDeleteReplicationState(dsc ReplicateDecision, vID string) { | 
					
						
							|  |  |  | 	o.DeleteReplication = ReplicationState{ | 
					
						
							|  |  |  | 		ReplicateDecisionStr: dsc.String(), | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2025-03-30 08:56:02 +08:00
										 |  |  | 	switch o.VersionID { | 
					
						
							|  |  |  | 	case "": | 
					
						
							| 
									
										
										
										
											2021-09-19 04:31:35 +08:00
										 |  |  | 		o.DeleteReplication.ReplicationStatusInternal = dsc.PendingStatus() | 
					
						
							|  |  |  | 		o.DeleteReplication.Targets = replicationStatusesMap(o.DeleteReplication.ReplicationStatusInternal) | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 		o.DeleteReplication.VersionPurgeStatusInternal = dsc.PendingStatus() | 
					
						
							|  |  |  | 		o.DeleteReplication.PurgeTargets = versionPurgeStatusesMap(o.DeleteReplication.VersionPurgeStatusInternal) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // PutReplicationState gets ReplicationState for PUT operation from ObjectOptions
 | 
					
						
							|  |  |  | func (o *ObjectOptions) PutReplicationState() (r ReplicationState) { | 
					
						
							|  |  |  | 	rstatus, ok := o.UserDefined[ReservedMetadataPrefixLower+ReplicationStatus] | 
					
						
							|  |  |  | 	if !ok { | 
					
						
							|  |  |  | 		return | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	r.ReplicationStatusInternal = rstatus | 
					
						
							|  |  |  | 	r.Targets = replicationStatusesMap(rstatus) | 
					
						
							|  |  |  | 	return | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-10 22:57:56 +08:00
										 |  |  | // SetEvalMetadataFn sets the metadata evaluation function
 | 
					
						
							|  |  |  | func (o *ObjectOptions) SetEvalMetadataFn(f EvalMetadataFn) { | 
					
						
							|  |  |  | 	o.EvalMetadataFn = f | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // SetEvalRetentionBypassFn sets the retention bypass function
 | 
					
						
							|  |  |  | func (o *ObjectOptions) SetEvalRetentionBypassFn(f EvalRetentionBypassFn) { | 
					
						
							|  |  |  | 	o.EvalRetentionBypassFn = f | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-30 05:24:10 +08:00
										 |  |  | // ObjectLayer implements primitives for object API layer.
 | 
					
						
							|  |  |  | type ObjectLayer interface { | 
					
						
							| 
									
										
										
										
											2019-11-14 04:17:45 +08:00
										 |  |  | 	// Locking operations on object.
 | 
					
						
							| 
									
										
										
										
											2020-11-05 00:25:42 +08:00
										 |  |  | 	NewNSLock(bucket string, objects ...string) RWLocker | 
					
						
							| 
									
										
										
										
											2019-11-14 04:17:45 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-27 05:13:10 +08:00
										 |  |  | 	// Storage operations.
 | 
					
						
							| 
									
										
										
										
											2018-03-15 03:01:47 +08:00
										 |  |  | 	Shutdown(context.Context) error | 
					
						
							| 
									
										
										
										
											2023-02-24 11:33:31 +08:00
										 |  |  | 	NSScanner(ctx context.Context, updates chan<- DataUsageInfo, wantCycle uint32, scanMode madmin.HealScanMode) error | 
					
						
							| 
									
										
										
										
											2021-03-05 06:36:23 +08:00
										 |  |  | 	BackendInfo() madmin.BackendInfo | 
					
						
							| 
									
										
										
										
											2024-05-04 04:08:20 +08:00
										 |  |  | 	Legacy() bool // Only returns true for deployments which use CRCMOD as its object distribution algorithm.
 | 
					
						
							| 
									
										
										
										
											2023-12-22 08:56:43 +08:00
										 |  |  | 	StorageInfo(ctx context.Context, metrics bool) StorageInfo | 
					
						
							|  |  |  | 	LocalStorageInfo(ctx context.Context, metrics bool) StorageInfo | 
					
						
							| 
									
										
										
										
											2016-05-27 05:13:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-30 05:24:10 +08:00
										 |  |  | 	// Bucket operations.
 | 
					
						
							| 
									
										
										
										
											2022-12-23 23:46:00 +08:00
										 |  |  | 	MakeBucket(ctx context.Context, bucket string, opts MakeBucketOptions) error | 
					
						
							| 
									
										
										
										
											2022-07-26 08:51:32 +08:00
										 |  |  | 	GetBucketInfo(ctx context.Context, bucket string, opts BucketOptions) (bucketInfo BucketInfo, err error) | 
					
						
							|  |  |  | 	ListBuckets(ctx context.Context, opts BucketOptions) (buckets []BucketInfo, err error) | 
					
						
							| 
									
										
										
										
											2021-10-07 01:24:40 +08:00
										 |  |  | 	DeleteBucket(ctx context.Context, bucket string, opts DeleteBucketOptions) error | 
					
						
							| 
									
										
										
										
											2018-03-15 03:01:47 +08:00
										 |  |  | 	ListObjects(ctx context.Context, bucket, prefix, marker, delimiter string, maxKeys int) (result ListObjectsInfo, err error) | 
					
						
							|  |  |  | 	ListObjectsV2(ctx context.Context, bucket, prefix, continuationToken, delimiter string, maxKeys int, fetchOwner bool, startAfter string) (result ListObjectsV2Info, err error) | 
					
						
							| 
									
										
										
										
											2020-06-13 11:04:01 +08:00
										 |  |  | 	ListObjectVersions(ctx context.Context, bucket, prefix, marker, versionMarker, delimiter string, maxKeys int) (result ListObjectVersionsInfo, err error) | 
					
						
							|  |  |  | 	// Walk lists all objects including versions, delete markers.
 | 
					
						
							| 
									
										
										
										
											2024-05-07 04:27:52 +08:00
										 |  |  | 	Walk(ctx context.Context, bucket, prefix string, results chan<- itemOrErr[ObjectInfo], opts WalkOptions) error | 
					
						
							| 
									
										
										
										
											2016-04-30 05:24:10 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Object operations.
 | 
					
						
							| 
									
										
										
										
											2018-09-11 00:42:43 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-21 10:22:09 +08:00
										 |  |  | 	// GetObjectNInfo returns a GetObjectReader that satisfies the
 | 
					
						
							| 
									
										
										
										
											2023-04-18 03:16:37 +08:00
										 |  |  | 	// ReadCloser interface. The Close method runs any cleanup
 | 
					
						
							|  |  |  | 	// functions, so it must always be called after reading till EOF
 | 
					
						
							| 
									
										
										
										
											2018-09-21 10:22:09 +08:00
										 |  |  | 	//
 | 
					
						
							|  |  |  | 	// IMPORTANTLY, when implementations return err != nil, this
 | 
					
						
							|  |  |  | 	// function MUST NOT return a non-nil ReadCloser.
 | 
					
						
							| 
									
										
										
										
											2023-04-18 03:16:37 +08:00
										 |  |  | 	GetObjectNInfo(ctx context.Context, bucket, object string, rs *HTTPRangeSpec, h http.Header, opts ObjectOptions) (reader *GetObjectReader, err error) | 
					
						
							| 
									
										
										
										
											2018-09-11 00:42:43 +08:00
										 |  |  | 	GetObjectInfo(ctx context.Context, bucket, object string, opts ObjectOptions) (objInfo ObjectInfo, err error) | 
					
						
							| 
									
										
										
										
											2019-02-09 13:31:06 +08:00
										 |  |  | 	PutObject(ctx context.Context, bucket, object string, data *PutObjReader, opts ObjectOptions) (objInfo ObjectInfo, err error) | 
					
						
							| 
									
										
										
										
											2018-09-11 00:42:43 +08:00
										 |  |  | 	CopyObject(ctx context.Context, srcBucket, srcObject, destBucket, destObject string, srcInfo ObjectInfo, srcOpts, dstOpts ObjectOptions) (objInfo ObjectInfo, err error) | 
					
						
							| 
									
										
										
										
											2020-06-13 11:04:01 +08:00
										 |  |  | 	DeleteObject(ctx context.Context, bucket, object string, opts ObjectOptions) (ObjectInfo, error) | 
					
						
							|  |  |  | 	DeleteObjects(ctx context.Context, bucket string, objects []ObjectToDelete, opts ObjectOptions) ([]DeletedObject, []error) | 
					
						
							| 
									
										
										
										
											2021-04-20 01:30:42 +08:00
										 |  |  | 	TransitionObject(ctx context.Context, bucket, object string, opts ObjectOptions) error | 
					
						
							|  |  |  | 	RestoreTransitionedObject(ctx context.Context, bucket, object string, opts ObjectOptions) error | 
					
						
							| 
									
										
										
										
											2016-04-30 05:24:10 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Multipart operations.
 | 
					
						
							| 
									
										
										
										
											2018-03-15 03:01:47 +08:00
										 |  |  | 	ListMultipartUploads(ctx context.Context, bucket, prefix, keyMarker, uploadIDMarker, delimiter string, maxUploads int) (result ListMultipartsInfo, err error) | 
					
						
							| 
									
										
										
										
											2022-08-30 07:57:16 +08:00
										 |  |  | 	NewMultipartUpload(ctx context.Context, bucket, object string, opts ObjectOptions) (result *NewMultipartUploadResult, err error) | 
					
						
							| 
									
										
										
										
											2018-03-15 03:01:47 +08:00
										 |  |  | 	CopyObjectPart(ctx context.Context, srcBucket, srcObject, destBucket, destObject string, uploadID string, partID int, | 
					
						
							| 
									
										
										
										
											2018-09-11 00:42:43 +08:00
										 |  |  | 		startOffset int64, length int64, srcInfo ObjectInfo, srcOpts, dstOpts ObjectOptions) (info PartInfo, err error) | 
					
						
							| 
									
										
										
										
											2018-11-15 09:36:41 +08:00
										 |  |  | 	PutObjectPart(ctx context.Context, bucket, object, uploadID string, partID int, data *PutObjReader, opts ObjectOptions) (info PartInfo, err error) | 
					
						
							| 
									
										
										
										
											2020-05-29 03:36:20 +08:00
										 |  |  | 	GetMultipartInfo(ctx context.Context, bucket, object, uploadID string, opts ObjectOptions) (info MultipartInfo, err error) | 
					
						
							| 
									
										
										
										
											2019-01-06 06:16:43 +08:00
										 |  |  | 	ListObjectParts(ctx context.Context, bucket, object, uploadID string, partNumberMarker int, maxParts int, opts ObjectOptions) (result ListPartsInfo, err error) | 
					
						
							| 
									
										
										
										
											2020-09-15 06:57:13 +08:00
										 |  |  | 	AbortMultipartUpload(ctx context.Context, bucket, object, uploadID string, opts ObjectOptions) error | 
					
						
							| 
									
										
										
										
											2018-11-15 09:36:41 +08:00
										 |  |  | 	CompleteMultipartUpload(ctx context.Context, bucket, object, uploadID string, uploadedParts []CompletePart, opts ObjectOptions) (objInfo ObjectInfo, err error) | 
					
						
							| 
									
										
										
										
											2016-10-15 10:57:40 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-06-19 00:11:04 +08:00
										 |  |  | 	GetDisks(poolIdx, setIdx int) ([]StorageAPI, error) // return the disks belonging to pool and set.
 | 
					
						
							|  |  |  | 	SetDriveCounts() []int                              // list of erasure stripe size for each pool in order.
 | 
					
						
							| 
									
										
										
										
											2021-01-23 04:09:24 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Healing operations.
 | 
					
						
							|  |  |  | 	HealFormat(ctx context.Context, dryRun bool) (madmin.HealResultItem, error) | 
					
						
							|  |  |  | 	HealBucket(ctx context.Context, bucket string, opts madmin.HealOpts) (madmin.HealResultItem, error) | 
					
						
							|  |  |  | 	HealObject(ctx context.Context, bucket, object, versionID string, opts madmin.HealOpts) (madmin.HealResultItem, error) | 
					
						
							|  |  |  | 	HealObjects(ctx context.Context, bucket, prefix string, opts madmin.HealOpts, fn HealObjectFn) error | 
					
						
							| 
									
										
										
										
											2022-11-29 02:20:55 +08:00
										 |  |  | 	CheckAbandonedParts(ctx context.Context, bucket, object string, opts madmin.HealOpts) error | 
					
						
							| 
									
										
										
										
											2021-01-23 04:09:24 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-21 09:31:22 +08:00
										 |  |  | 	// Returns health of the backend
 | 
					
						
							|  |  |  | 	Health(ctx context.Context, opts HealthOptions) HealthResult | 
					
						
							| 
									
										
										
										
											2020-01-21 00:45:59 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-05 04:32:31 +08:00
										 |  |  | 	// Metadata operations
 | 
					
						
							|  |  |  | 	PutObjectMetadata(context.Context, string, string, ObjectOptions) (ObjectInfo, error) | 
					
						
							| 
									
										
										
										
											2023-03-16 22:48:05 +08:00
										 |  |  | 	DecomTieredObject(context.Context, string, string, FileInfo, ObjectOptions) error | 
					
						
							| 
									
										
										
										
											2021-04-05 04:32:31 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-21 00:45:59 +08:00
										 |  |  | 	// ObjectTagging operations
 | 
					
						
							| 
									
										
										
										
											2021-02-02 05:52:51 +08:00
										 |  |  | 	PutObjectTags(context.Context, string, string, string, ObjectOptions) (ObjectInfo, error) | 
					
						
							| 
									
										
										
										
											2020-06-13 11:04:01 +08:00
										 |  |  | 	GetObjectTags(context.Context, string, string, ObjectOptions) (*tags.Tags, error) | 
					
						
							| 
									
										
										
										
											2021-02-02 05:52:51 +08:00
										 |  |  | 	DeleteObjectTags(context.Context, string, string, ObjectOptions) (ObjectInfo, error) | 
					
						
							| 
									
										
										
										
											2016-04-30 05:24:10 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2021-02-27 01:52:02 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | // GetObject - TODO(aead): This function just acts as an adapter for GetObject tests and benchmarks
 | 
					
						
							|  |  |  | // since the GetObject method of the ObjectLayer interface has been removed. Once, the
 | 
					
						
							|  |  |  | // tests are adjusted to use GetObjectNInfo this function can be removed.
 | 
					
						
							|  |  |  | func GetObject(ctx context.Context, api ObjectLayer, bucket, object string, startOffset int64, length int64, writer io.Writer, etag string, opts ObjectOptions) (err error) { | 
					
						
							|  |  |  | 	var header http.Header | 
					
						
							|  |  |  | 	if etag != "" { | 
					
						
							|  |  |  | 		header.Set("ETag", etag) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	Range := &HTTPRangeSpec{Start: startOffset, End: startOffset + length} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-18 03:16:37 +08:00
										 |  |  | 	reader, err := api.GetObjectNInfo(ctx, bucket, object, Range, header, opts) | 
					
						
							| 
									
										
										
										
											2021-02-27 01:52:02 +08:00
										 |  |  | 	if err != nil { | 
					
						
							|  |  |  | 		return err | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	defer reader.Close() | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-02 23:11:50 +08:00
										 |  |  | 	_, err = xioutil.Copy(writer, reader) | 
					
						
							| 
									
										
										
										
											2021-02-27 01:52:02 +08:00
										 |  |  | 	return err | 
					
						
							|  |  |  | } |