@@ -95,30 +95,11 @@ type Plan struct {
9595 Sections map [string ]LayerSection `yaml:",inline"`
9696}
9797
98- // Section retrieves a section from the plan.
99- func (p * Plan ) Section (field string , out interface {}) error {
100- if _ , found := layerExtensions [field ]; ! found {
101- return fmt .Errorf ("cannot find registered extension for field %q" , field )
102- }
103-
104- outVal := reflect .ValueOf (out )
105- if outVal .Kind () != reflect .Ptr || outVal .IsNil () {
106- return fmt .Errorf ("cannot read non pointer to section type %q" , outVal .Kind ())
107- }
108-
109- section , exists := p .Sections [field ]
110- if ! exists {
111- return fmt .Errorf ("internal error: section %q is nil" , field )
112- }
113-
114- sectionVal := reflect .ValueOf (section )
115- sectionType := sectionVal .Type ()
116- outValPtrType := outVal .Elem ().Type ()
117- if ! sectionType .AssignableTo (outValPtrType ) {
118- return fmt .Errorf ("cannot assign value of type %s to out argument of type %s" , sectionType , outValPtrType )
119- }
120- outVal .Elem ().Set (sectionVal )
121- return nil
98+ // Section retrieves a section from the plan. If Section is called
99+ // before the plan is loaded, or with an unregistered field, this method
100+ // will return nil.
101+ func (p * Plan ) Section (field string ) LayerSection {
102+ return p .Sections [field ]
122103}
123104
124105// MarshalYAML implements an override for top level omitempty tags handling.
0 commit comments