terraform/internal/moduleref/record.go

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

49 lines
1.1 KiB
Go
Raw Permalink Normal View History

2024-10-21 13:54:45 -04:00
// Copyright IBM Corp. 2014, 2026
// SPDX-License-Identifier: BUSL-1.1
package moduleref
2024-11-18 13:41:53 -05:00
import (
"github.com/hashicorp/go-version"
"github.com/hashicorp/terraform/internal/addrs"
)
const FormatVersion = "1.0"
// ModuleRecord is the implementation of a module entry defined in the module
// manifest that is declared by configuration.
type Record struct {
2024-11-18 13:41:53 -05:00
Key string
Source addrs.ModuleSource
Version *version.Version
VersionConstraints version.Constraints
Children Records
}
// ModuleRecordManifest is the view implementation of module entries declared
// in configuration
type Manifest struct {
2024-11-18 13:41:53 -05:00
FormatVersion string
Records Records
}
2024-11-18 13:41:53 -05:00
func (m *Manifest) addModuleEntry(entry *Record) {
m.Records = append(m.Records, entry)
}
func (r *Record) addChild(child *Record) {
r.Children = append(r.Children, child)
}
type Records []*Record
func (r Records) Len() int {
return len(r)
}
func (r Records) Less(i, j int) bool {
return r[i].Key < r[j].Key
}
func (r Records) Swap(i, j int) {
r[i], r[j] = r[j], r[i]
}