@@ -275,8 +275,8 @@ const (
275275
276276// ObjectUploadOption configures UploadObjectParams.
277277type ObjectUploadOption struct {
278- Type ObjectUploadOptionType
279- Apply func (params * UploadObjectParams )
278+ optType ObjectUploadOptionType
279+ apply func (params * UploadObjectParams )
280280}
281281
282282// UploadObjectParams hold content-type and conditional write attribute metadata for upload operations that are
@@ -291,8 +291,8 @@ type UploadObjectParams struct {
291291// WithContentType sets the content type of the object upload operation.
292292func WithContentType (contentType string ) ObjectUploadOption {
293293 return ObjectUploadOption {
294- Type : ContentType ,
295- Apply : func (params * UploadObjectParams ) {
294+ optType : ContentType ,
295+ apply : func (params * UploadObjectParams ) {
296296 params .ContentType = contentType
297297 },
298298 }
@@ -302,8 +302,8 @@ func WithContentType(contentType string) ObjectUploadOption {
302302// When supported by providers this operation is usually atomic, however this is dependent on the provider.
303303func WithIfNotExists () ObjectUploadOption {
304304 return ObjectUploadOption {
305- Type : IfNotExists ,
306- Apply : func (params * UploadObjectParams ) {
305+ optType : IfNotExists ,
306+ apply : func (params * UploadObjectParams ) {
307307 params .IfNotExists = true
308308 },
309309 }
@@ -313,8 +313,8 @@ func WithIfNotExists() ObjectUploadOption {
313313// otherwise, the operation fails.
314314func WithIfMatch (ver * ObjectVersion ) ObjectUploadOption {
315315 return ObjectUploadOption {
316- Type : IfMatch ,
317- Apply : func (params * UploadObjectParams ) {
316+ optType : IfMatch ,
317+ apply : func (params * UploadObjectParams ) {
318318 params .Condition = ver
319319 },
320320 }
@@ -324,8 +324,8 @@ func WithIfMatch(ver *ObjectVersion) ObjectUploadOption {
324324// otherwise, the operation fails.
325325func WithIfNotMatch (ver * ObjectVersion ) ObjectUploadOption {
326326 return ObjectUploadOption {
327- Type : IfNotMatch ,
328- Apply : func (params * UploadObjectParams ) {
327+ optType : IfNotMatch ,
328+ apply : func (params * UploadObjectParams ) {
329329 params .Condition = ver
330330 params .IfNotMatch = true
331331 },
@@ -334,22 +334,21 @@ func WithIfNotMatch(ver *ObjectVersion) ObjectUploadOption {
334334
335335// ValidateUploadOptions ensures that only supported options are passed as options, and that options used simultaneously are valid.
336336func ValidateUploadOptions (supportedOptions []ObjectUploadOptionType , opts ... ObjectUploadOption ) error {
337-
338337 for _ , opt := range opts {
339- if ! slices .Contains (supportedOptions , opt .Type ) {
340- return fmt .Errorf ("%w: %d" , ErrUploadOptionNotSupported , opt .Type )
338+ if ! slices .Contains (supportedOptions , opt .optType ) {
339+ return fmt .Errorf ("%w: %d" , ErrUploadOptionNotSupported , opt .optType )
341340 }
342- if opt .Type == IfMatch || opt .Type == IfNotMatch {
341+ if opt .optType == IfMatch || opt .optType == IfNotMatch {
343342 candidate := & UploadObjectParams {}
344- opt .Apply (candidate )
343+ opt .apply (candidate )
345344 if candidate .Condition == nil {
346345 return fmt .Errorf ("%w: Condition nil" , ErrUploadOptionInvalid )
347346 }
348347 }
349- if opt .Type == IfNotExists {
348+ if opt .optType == IfNotExists {
350349 // If IfNotExists provided alongside IfMatch or IfNotMatch.
351350 if slices .ContainsFunc (opts , func (opt ObjectUploadOption ) bool {
352- return opt .Type == IfMatch || opt .Type == IfNotMatch
351+ return opt .optType == IfMatch || opt .optType == IfNotMatch
353352 }) {
354353 return fmt .Errorf ("%w: IfNotExists not valid with IfMatch or IfNotMatch" , ErrUploadOptionInvalid )
355354 }
@@ -362,7 +361,7 @@ func ValidateUploadOptions(supportedOptions []ObjectUploadOptionType, opts ...Ob
362361func ApplyObjectUploadOptions (opts ... ObjectUploadOption ) UploadObjectParams {
363362 out := UploadObjectParams {}
364363 for _ , opt := range opts {
365- opt .Apply (& out )
364+ opt .apply (& out )
366365 }
367366 return out
368367}
0 commit comments