Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Commit c71764f

Browse files
authored
Merge pull request #692 from jmank88/manifest_lock_doc
Document lock.go and manifest.go
2 parents 0531ad1 + 4e7f652 commit c71764f

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

lock.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@ import (
1515
"github.com/pkg/errors"
1616
)
1717

18+
// LockName is the lock file name used by dep.
1819
const LockName = "Gopkg.lock"
1920

21+
// Lock holds lock file data and implements gps.Lock.
2022
type Lock struct {
2123
SolveMeta SolveMeta
2224
P []gps.LockedProject
2325
}
2426

27+
// SolveMeta holds solver meta data.
2528
type SolveMeta struct {
2629
InputsDigest []byte
2730
AnalyzerName string
@@ -109,10 +112,12 @@ func fromRawLock(raw rawLock) (*Lock, error) {
109112
return l, nil
110113
}
111114

115+
// InputHash returns the hash of inputs which produced this lock data.
112116
func (l *Lock) InputHash() []byte {
113117
return l.SolveMeta.InputsDigest
114118
}
115119

120+
// Projects returns the list of LockedProjects contained in the lock data.
116121
func (l *Lock) Projects() []gps.LockedProject {
117122
return l.P
118123
}
@@ -146,11 +151,10 @@ func (l *Lock) toRaw() rawLock {
146151
raw.Projects[k] = ld
147152
}
148153

149-
// TODO sort output - #15
150-
151154
return raw
152155
}
153156

157+
// MarshalTOML serializes this lock into TOML via an intermediate raw form.
154158
func (l *Lock) MarshalTOML() ([]byte, error) {
155159
raw := l.toRaw()
156160
result, err := toml.Marshal(raw)
@@ -180,6 +184,7 @@ func LockFromSolution(in gps.Solution) *Lock {
180184
return l
181185
}
182186

187+
// SortedLockedProjects implements sort.Interface.
183188
type SortedLockedProjects []gps.LockedProject
184189

185190
func (s SortedLockedProjects) Len() int { return len(s) }

manifest.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ import (
1717
"github.com/pkg/errors"
1818
)
1919

20+
// ManifestName is the manifest file name used by dep.
2021
const ManifestName = "Gopkg.toml"
2122

23+
// Manifest holds manifest file data and implements gps.RootManifest.
2224
type Manifest struct {
2325
Constraints gps.ProjectConstraints
2426
Ovr gps.ProjectConstraints
@@ -226,6 +228,7 @@ func (s sortedRawProjects) Less(i, j int) bool {
226228
return l.Source < r.Source
227229
}
228230

231+
// MarshalTOML serializes this manifest into TOML via an intermediate raw form.
229232
func (m *Manifest) MarshalTOML() ([]byte, error) {
230233
raw := m.toRaw()
231234
result, err := toml.Marshal(raw)
@@ -262,19 +265,23 @@ func toRawProject(name gps.ProjectRoot, project gps.ProjectProperties) rawProjec
262265
return raw
263266
}
264267

268+
// DependencyConstraints returns a list of project-level constraints.
265269
func (m *Manifest) DependencyConstraints() gps.ProjectConstraints {
266270
return m.Constraints
267271
}
268272

273+
// TestDependencyConstraints remains unimplemented by returning nil for now.
269274
func (m *Manifest) TestDependencyConstraints() gps.ProjectConstraints {
270275
// TODO decide whether we're going to incorporate this or not
271276
return nil
272277
}
273278

279+
// Overrides returns a list of project-level override constraints.
274280
func (m *Manifest) Overrides() gps.ProjectConstraints {
275281
return m.Ovr
276282
}
277283

284+
// IgnoredPackages returns a set of import paths to ignore.
278285
func (m *Manifest) IgnoredPackages() map[string]bool {
279286
if len(m.Ignored) == 0 {
280287
return nil
@@ -288,6 +295,7 @@ func (m *Manifest) IgnoredPackages() map[string]bool {
288295
return mp
289296
}
290297

298+
// RequiredPackages returns a set of import paths to require.
291299
func (m *Manifest) RequiredPackages() map[string]bool {
292300
if len(m.Required) == 0 {
293301
return nil

0 commit comments

Comments
 (0)