bucket

package
v1.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package bucket provides utilities for managing buckets.

Index

Constants

View Source
const (
	PermKeyRole  = "role"
	PermKeyUsers = "users"
)

Variables

This section is empty.

Functions

func PatchCORS

func PatchCORS(base *storage.CORSConfig, addChunks []string, removeChunks []string) (*storage.CORSConfig, error)

PatchCORS applies additive (--cors) and subtractive (--delete-cors) updates to an existing CORS configuration. Semantics for add:

  • origins/response-headers: union (trimmed, deduped, sorted)
  • max-age: set only if explicitly provided

Removals:

  • origins/response-headers: set-difference
  • specifying max-age here is rejected
  • if origins are targeted and removal leaves zero origins, the CORS configuration is cleared (function returns nil, changed=true)

func PatchCustomHostnames

func PatchCustomHostnames(base []string, clear bool, add []string, remove []string) ([]string, error)

PatchCustomHostnames applies add/clear/delete operations to a slice of BucketCustomHostname entries. It follows the common "patch" pattern:

  • If clear is true, the result is an empty list regardless of input.
  • Entries in add are parsed and replace any existing ones with the same host.
  • Entries in remove identify hostnames to be removed.

func PatchLifecyclePolicies

func PatchLifecyclePolicies(
	base []*storage.BucketLifecyclePolicy,
	clear bool,
	addChunks []string,
	deleteChunks []string,
) ([]*storage.BucketLifecyclePolicy, error)

PatchLifecyclePolicies applies a sequence of operations to a set of bucket lifecycle policies. Operations are applied in the following order:

  • Clear: optionally start from an empty set, discarding all existing policies.
  • Add: merge new or updated policies into the working set. Policies are keyed by prefix; providing the same prefix again replaces the previous entry.
  • Delete: remove policies by prefix from the working set.

The result is a deterministic, prefix-sorted slice.

func PatchPermissions

func PatchPermissions(base []*storage.BucketPermission, add, remove []string) ([]*storage.BucketPermission, error)

PatchPermissions applies additive and subtractive permission specs on top of an existing slice of BucketPermission objects. The input slices `add` and `remove` are raw flag values (e.g. "reader=user1,user2"), which are parsed and merged deterministically. Behavior:

  • `add`: users are added to the given role (duplicates deduped).
  • `remove`: users are removed from the given role.
  • `remove` with no users removes the whole role.
  • Empty/whitespace users are rejected.

The result is normalized so that roles and user names are sorted and duplicate-free.

Returns an error if role names are invalid, if empty users appear in `add`, or if parsing of the specs fails.

Types

type LifecycleSpec

type LifecycleSpec struct {
	Prefix          string
	ExpireAfterDays *int32
	IsLive          bool
}

type PermissionSpec

type PermissionSpec struct {
	Role  string
	Users []string
}

PermissionSpec represents a parsed permission entry. Each spec binds a role to a (possibly empty) list of users.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL