Example #1
0
func detectNamespace(data map[string][]byte, parent *database.Layer) (namespace *database.Namespace, err error) {
	namespace = detectors.DetectNamespace(data)

	// Attempt to detect the OS from the parent layer.
	if namespace == nil && parent != nil {
		namespace = parent.Namespace
		if err != nil {
			return
		}
	}

	return
}
Example #2
0
func detectNamespace(name string, data map[string][]byte, parent *database.Layer) (namespace *database.Namespace) {
	// Use registered detectors to get the Namespace.
	namespace = detectors.DetectNamespace(data)
	if namespace != nil {
		log.Debugf("layer %s: detected namespace %q", name, namespace.Name)
		return
	}

	// Use the parent's Namespace.
	if parent != nil {
		namespace = parent.Namespace
		if namespace != nil {
			log.Debugf("layer %s: detected namespace %q (from parent)", name, namespace.Name)
			return
		}
	}

	return
}