Skip to content

Commit

Permalink
doc: make the default options displayed next to the option type on go…
Browse files Browse the repository at this point in the history
…doc (#372)

**Typed** constants/variables are displayed next to the declaration of
their type.

Resolves #304

Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
  • Loading branch information
Wwwsylvia authored Dec 5, 2022
1 parent 7dcd097 commit ff05195
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 26 deletions.
17 changes: 8 additions & 9 deletions copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,14 @@ import (
// defaultConcurrency is the default value of CopyGraphOptions.Concurrency.
const defaultConcurrency = 3 // This value is consistent with dockerd and containerd.

var (
// DefaultCopyOptions provides the default CopyOptions.
DefaultCopyOptions = CopyOptions{
CopyGraphOptions: DefaultCopyGraphOptions,
}
// DefaultCopyGraphOptions provides the default CopyGraphOptions.
DefaultCopyGraphOptions CopyGraphOptions
)

// errSkipDesc signals copyNode() to stop processing a descriptor.
var errSkipDesc = errors.New("skip descriptor")

// DefaultCopyOptions provides the default CopyOptions.
var DefaultCopyOptions CopyOptions = CopyOptions{
CopyGraphOptions: DefaultCopyGraphOptions,
}

// CopyOptions contains parameters for oras.Copy.
type CopyOptions struct {
CopyGraphOptions
Expand Down Expand Up @@ -86,6 +82,9 @@ func (opts *CopyOptions) WithTargetPlatform(p *ocispec.Platform) {
// CopyGraphOptions.MaxMetadataBytes.
const defaultCopyMaxMetadataBytes int64 = 4 * 1024 * 1024 // 4 MiB

// DefaultCopyGraphOptions provides the default CopyGraphOptions.
var DefaultCopyGraphOptions CopyGraphOptions

// CopyGraphOptions contains parameters for oras.CopyGraph.
type CopyGraphOptions struct {
// Concurrency limits the maximum number of concurrent copy tasks.
Expand Down
19 changes: 9 additions & 10 deletions extendedcopy.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,21 @@ import (
"oras.land/oras-go/v2/registry"
)

var (
// DefaultExtendedCopyOptions provides the default ExtendedCopyOptions.
DefaultExtendedCopyOptions = ExtendedCopyOptions{
ExtendedCopyGraphOptions: DefaultExtendedCopyGraphOptions,
}
// DefaultExtendedCopyGraphOptions provides the default ExtendedCopyGraphOptions.
DefaultExtendedCopyGraphOptions = ExtendedCopyGraphOptions{
CopyGraphOptions: DefaultCopyGraphOptions,
}
)
// DefaultExtendedCopyOptions provides the default ExtendedCopyOptions.
var DefaultExtendedCopyOptions ExtendedCopyOptions = ExtendedCopyOptions{
ExtendedCopyGraphOptions: DefaultExtendedCopyGraphOptions,
}

// ExtendedCopyOptions contains parameters for oras.ExtendedCopy.
type ExtendedCopyOptions struct {
ExtendedCopyGraphOptions
}

// DefaultExtendedCopyGraphOptions provides the default ExtendedCopyGraphOptions.
var DefaultExtendedCopyGraphOptions ExtendedCopyGraphOptions = ExtendedCopyGraphOptions{
CopyGraphOptions: DefaultCopyGraphOptions,
}

// ExtendedCopyGraphOptions contains parameters for oras.ExtendedCopyGraph.
type ExtendedCopyGraphOptions struct {
CopyGraphOptions
Expand Down
12 changes: 5 additions & 7 deletions pack.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,11 @@ const (
MediaTypeUnknownArtifact = "application/vnd.unknown.artifact.v1"
)

var (
// ErrInvalidDateTimeFormat is returned by Pack() when
// AnnotationArtifactCreated or AnnotationCreated is provided, but its value
// is not in RFC 3339 format.
// Reference: https://www.rfc-editor.org/rfc/rfc3339#section-5.6
ErrInvalidDateTimeFormat = errors.New("invalid date and time format")
)
// ErrInvalidDateTimeFormat is returned by Pack() when
// AnnotationArtifactCreated or AnnotationCreated is provided, but its value
// is not in RFC 3339 format.
// Reference: https://www.rfc-editor.org/rfc/rfc3339#section-5.6
var ErrInvalidDateTimeFormat = errors.New("invalid date and time format")

// PackOptions contains parameters for oras.Pack.
type PackOptions struct {
Expand Down

0 comments on commit ff05195

Please sign in to comment.