// SetupRootfs assumes the base layer is correct in the cache, and sets up the
// base to the output.
//
// If the layer is a build only layer, this code simply initializes the
// filesystem in roots to the built tag's filesystem.
SetupRootfs assumes the base layer is correct in the cache, and sets up the
base to the output.

If the layer is a build only layer, this code simply initializes the
filesystem in roots to the built tag's filesystem.
// SetupRootfs assumes the base layer is correct in the cache and sets up the // base to the output . // // If the layer is a build only layer this code simply initializes the // filesystem in roots to the built tag ' s filesystem .
func SetupRootfs(o BaseLayerOpts) error {
	err := o.Storage.Delete(o.Name)
	if err != nil && !os.IsNotExist(errors.Unwrap(err)) {
		return err
	}
	if o.Layer.From.Type == types.BuiltLayer {
		return o.Storage.Restore(o.Layer.From.Tag, o.Name)
	}
	if err := o.Storage.Create(o.Name); err != nil {
		return err
	}
	switch o.Layer.From.Type {
	case types.TarLayer:
		err := o.Storage.SetupEmptyRootfs(o.Name)
		if err != nil {
			return err
		}
		return setupTarRootfs(o)
	case types.OCILayer:
		fallthrough
	case types.DockerLayer:
		return setupContainersImageRootfs(o)
	default:
		return errors.Errorf("unknown layer type: %v", o.Layer.From.Type)
	}
}
func SetupRootfs ( o BaseLayerOpts ) error { err := o . Storage . Delete ( o . Name ) if err != nil && ! os . IsNotExist ( errors . Unwrap ( err ) ) { return err } if o . Layer . From . Type == types . BuiltLayer { return o . Storage . Restore ( o . Layer . From . Tag , o . Name ) } if err := o . Storage . Create ( o . Name ) ; err != nil { return err } switch o . Layer . From . Type { case types . TarLayer : err := o . Storage . SetupEmptyRootfs ( o . Name ) if err != nil { return err } return setupTarRootfs ( o ) case types . OCILayer : fallthrough case types . DockerLayer : return setupContainersImageRootfs ( o ) default : return errors . Errorf ( " " , o . Layer . From . Type ) } }
SetupRootfs assumes the base layer is correct in the cache, and sets up the
base to the output.
SetupRootfs assumes the base layer is correct in the cache and sets up the base to the output .
// For built type images, we already have the base fs content // and umoci metadata. So let's just use that. // For everything else, we create a new snapshot and extract whatever // we can on top of it.