// LoadComponent imports components into a Component struct and adds it to the // Components map. func (openControl *OpenControl) LoadComponent(componentDir string) error { // Get file system assistance. fs := fs.OSUtil{} // Read the component file. fileName := filepath.Join(componentDir, "component.yaml") componentData, err := fs.OpenAndReadFile(fileName) if err != nil { return errors.New(constants.ErrComponentFileDNE) } // Parse the component. var component base.Component component, err = versions.ParseComponent(componentData, fileName) if err != nil { return err } // Ensure we have a key for the component. if component.GetKey() == "" { component.SetKey(getKey(componentDir)) } // If the component is new, make sure we load the justifications as well. if openControl.Components.CompareAndAdd(component) { openControl.Justifications.LoadMappings(component) } return nil }