# Registry (/docs/go-sdk/registry)

> For AI agents: the complete documentation index is at https://www.daytona.com/llms.txt.

## Registries [#registries]

```go
type Registries struct {
	// contains filtered or unexported fields
}
```

Registries manages the project's container-registry credentials, which
image pulls and builds use to reach private registries. Passwords are
write-only: the API never returns them, and the SDK keeps no copy of one it
sends. Obtain it from Client.Registries.

#### Registries.Delete [#registriesdelete]

```go
func (r *Registries) Delete(ctx context.Context, host string) error
```

Delete deletes the credential for host. ErrNotFound is preserved.

#### Registries.Get [#registriesget]

```go
func (r *Registries) Get(ctx context.Context, host string) (*Registry, error)
```

Get fetches one registry credential's metadata by host, never its password.
ErrNotFound means no credential exists for the host, except on Daytona
Cloud, which does not serve this read yet: until it does, Get returns
ErrNotFound even for a credential that exists; use List or ListAll there.

#### Registries.GoString [#registriesgostring]

```go
func (r *Registries) GoString() string
```

GoString returns a credential-free diagnostic name.

#### Registries.List [#registrieslist]

```go
func (r *Registries) List(ctx context.Context, opts *ListRegistriesOptions) (*Page[Registry], error)
```

List returns exactly one page of registry credential metadata, never
passwords. Invalid pagination returns ErrBadRequest.

#### Registries.ListAll [#registrieslistall]

```go
func (r *Registries) ListAll(ctx context.Context, opts *ListRegistriesOptions) iter.Seq2[Registry, error]
```

ListAll lazily traverses registry credential pages, stopping on
cancellation, an error, a repeated cursor, or when the consumer breaks.

#### Registries.Set [#registriesset]

```go
func (r *Registries) Set(ctx context.Context, host string, opts *SetRegistryOptions) (*Registry, error)
```

Set creates or replaces the credential for host with exactly the given
options, in one request, and returns its metadata. Nil opts or invalid
input (an empty Kind included) returns ErrBadRequest before any request.

**Example**:

```go
client, err := daytona.New()
if err != nil {
	log.Fatal(err)
}
defer func() {
	if closeErr := client.Close(); closeErr != nil {
		log.Print(closeErr)
	}
}()

ctx := context.Background()
registry, err := client.Registries().Set(ctx, "ghcr.io", &daytona.SetRegistryOptions{
	Username: "octo",
	Password: os.Getenv("GHCR_TOKEN"),
	Kind:     daytona.RegistryKindGHCR,
})
if err != nil {
	log.Fatal(err)
}
log.Print(registry.Host, registry.Kind, registry.Username) // Never contains the password.
```

#### Registries.String [#registriesstring]

```go
func (r *Registries) String() string
```

String returns a credential-free diagnostic name.

## ListRegistriesOptions [#listregistriesoptions]

```go
type ListRegistriesOptions struct {
	// Cursor is the opaque continuation cursor.
	Cursor string
	// Limit is 1–200; zero uses the server default.
	Limit int
}
```

ListRegistriesOptions selects one page of registry credential metadata.

## SetRegistryOptions [#setregistryoptions]

```go
type SetRegistryOptions struct {
	// Username is the registry username, or the IAM role ARN for ecr_role (required).
	Username string
	// Kind is the authentication kind (required): RegistryKindBasic for a
	// plain username and password.
	Kind RegistryKind
	// Password is write-only and never returned. It is required for every kind
	// but ecr_role.
	Password string
	// Description is the description; nil leaves the credential without one.
	Description *string
}
```

SetRegistryOptions states a whole registry credential: the API replaces the
stored one, so Set sends exactly these fields in one request.

#### SetRegistryOptions.GoString [#setregistryoptionsgostring]

```go
func (o SetRegistryOptions) GoString() string
```

GoString prints the options with the same redaction as String.
The %#v format uses the redacted form, not Go syntax.

#### SetRegistryOptions.LogValue [#setregistryoptionslogvalue]

```go
func (o SetRegistryOptions) LogValue() slog.Value
```

LogValue gives log/slog the options with a non-empty Password redacted.

#### SetRegistryOptions.MarshalJSON [#setregistryoptionsmarshaljson]

```go
func (o SetRegistryOptions) MarshalJSON() ([]byte, error)
```

MarshalJSON encodes the options with a non-empty Password redacted; the
request body Set sends is built separately.

#### SetRegistryOptions.String [#setregistryoptionsstring]

```go
func (o SetRegistryOptions) String() string
```

String prints the options with a non-empty Password redacted.
