package configkit // Metadata provides detached presence, origin, and history queries for a load. // Its zero value contains no paths. type Metadata struct { fields map[string]FieldInfo history map[string][]Change } // Lookup returns information for an effective path. Unknown and invalid paths // return false. func (m Metadata) Lookup(path Path) (FieldInfo, bool) { if !path.valid() { return FieldInfo{}, false } info, ok := m.fields[path.String()] if !ok { return FieldInfo{}, false } return cloneFieldInfo(info), true } // IsExplicit reports whether a surviving input contribution explicitly defined // path. func (m Metadata) IsExplicit(path Path) bool { info, ok := m.Lookup(path) return ok && info.Explicit } // History returns detached definition and resolution records for path. Unknown and // invalid paths return nil. func (m Metadata) History(path Path) []Change { if !path.valid() { return nil } history, ok := m.history[path.String()] if !ok { return nil } cloned := make([]Change, len(history)) for i, change := range history { cloned[i] = cloneChange(change) } return cloned }