Skip to content

Commit ff05195

Browse files
authored
doc: make the default options displayed next to the option type on godoc (#372)
**Typed** constants/variables are displayed next to the declaration of their type. Resolves #304 Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
1 parent 7dcd097 commit ff05195

File tree

3 files changed

+22
-26
lines changed

3 files changed

+22
-26
lines changed

copy.go

+8-9
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,14 @@ import (
3636
// defaultConcurrency is the default value of CopyGraphOptions.Concurrency.
3737
const defaultConcurrency = 3 // This value is consistent with dockerd and containerd.
3838

39-
var (
40-
// DefaultCopyOptions provides the default CopyOptions.
41-
DefaultCopyOptions = CopyOptions{
42-
CopyGraphOptions: DefaultCopyGraphOptions,
43-
}
44-
// DefaultCopyGraphOptions provides the default CopyGraphOptions.
45-
DefaultCopyGraphOptions CopyGraphOptions
46-
)
47-
4839
// errSkipDesc signals copyNode() to stop processing a descriptor.
4940
var errSkipDesc = errors.New("skip descriptor")
5041

42+
// DefaultCopyOptions provides the default CopyOptions.
43+
var DefaultCopyOptions CopyOptions = CopyOptions{
44+
CopyGraphOptions: DefaultCopyGraphOptions,
45+
}
46+
5147
// CopyOptions contains parameters for oras.Copy.
5248
type CopyOptions struct {
5349
CopyGraphOptions
@@ -86,6 +82,9 @@ func (opts *CopyOptions) WithTargetPlatform(p *ocispec.Platform) {
8682
// CopyGraphOptions.MaxMetadataBytes.
8783
const defaultCopyMaxMetadataBytes int64 = 4 * 1024 * 1024 // 4 MiB
8884

85+
// DefaultCopyGraphOptions provides the default CopyGraphOptions.
86+
var DefaultCopyGraphOptions CopyGraphOptions
87+
8988
// CopyGraphOptions contains parameters for oras.CopyGraph.
9089
type CopyGraphOptions struct {
9190
// Concurrency limits the maximum number of concurrent copy tasks.

extendedcopy.go

+9-10
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,21 @@ import (
2929
"oras.land/oras-go/v2/registry"
3030
)
3131

32-
var (
33-
// DefaultExtendedCopyOptions provides the default ExtendedCopyOptions.
34-
DefaultExtendedCopyOptions = ExtendedCopyOptions{
35-
ExtendedCopyGraphOptions: DefaultExtendedCopyGraphOptions,
36-
}
37-
// DefaultExtendedCopyGraphOptions provides the default ExtendedCopyGraphOptions.
38-
DefaultExtendedCopyGraphOptions = ExtendedCopyGraphOptions{
39-
CopyGraphOptions: DefaultCopyGraphOptions,
40-
}
41-
)
32+
// DefaultExtendedCopyOptions provides the default ExtendedCopyOptions.
33+
var DefaultExtendedCopyOptions ExtendedCopyOptions = ExtendedCopyOptions{
34+
ExtendedCopyGraphOptions: DefaultExtendedCopyGraphOptions,
35+
}
4236

4337
// ExtendedCopyOptions contains parameters for oras.ExtendedCopy.
4438
type ExtendedCopyOptions struct {
4539
ExtendedCopyGraphOptions
4640
}
4741

42+
// DefaultExtendedCopyGraphOptions provides the default ExtendedCopyGraphOptions.
43+
var DefaultExtendedCopyGraphOptions ExtendedCopyGraphOptions = ExtendedCopyGraphOptions{
44+
CopyGraphOptions: DefaultCopyGraphOptions,
45+
}
46+
4847
// ExtendedCopyGraphOptions contains parameters for oras.ExtendedCopyGraph.
4948
type ExtendedCopyGraphOptions struct {
5049
CopyGraphOptions

pack.go

+5-7
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,11 @@ const (
3838
MediaTypeUnknownArtifact = "application/vnd.unknown.artifact.v1"
3939
)
4040

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

4947
// PackOptions contains parameters for oras.Pack.
5048
type PackOptions struct {

0 commit comments

Comments
 (0)