github.com/chipaca/snappy@v0.0.0-20210104084008-1f06296fe8ad/gadget/export_test.go (about)

     1  // -*- Mode: Go; indent-tabs-mode: t -*-
     2  
     3  /*
     4   * Copyright (C) 2019-2020 Canonical Ltd
     5   *
     6   * This program is free software: you can redistribute it and/or modify
     7   * it under the terms of the GNU General Public License version 3 as
     8   * published by the Free Software Foundation.
     9   *
    10   * This program is distributed in the hope that it will be useful,
    11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13   * GNU General Public License for more details.
    14   *
    15   * You should have received a copy of the GNU General Public License
    16   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    17   *
    18   */
    19  
    20  package gadget
    21  
    22  type (
    23  	ValidationState          = validationState
    24  	MountedFilesystemUpdater = mountedFilesystemUpdater
    25  	RawStructureUpdater      = rawStructureUpdater
    26  )
    27  
    28  var (
    29  	ValidateStructureType   = validateStructureType
    30  	ValidateVolumeStructure = validateVolumeStructure
    31  	ValidateRole            = validateRole
    32  	ValidateVolume          = validateVolume
    33  
    34  	SetImplicitForVolumeStructure = setImplicitForVolumeStructure
    35  
    36  	RuleValidateVolumes         = ruleValidateVolumes
    37  	RuleValidateVolumeStructure = ruleValidateVolumeStructure
    38  	EnsureVolumeRuleConsistency = ensureVolumeRuleConsistency
    39  
    40  	ResolveVolume      = resolveVolume
    41  	CanUpdateStructure = canUpdateStructure
    42  	CanUpdateVolume    = canUpdateVolume
    43  
    44  	WriteFile = writeFileOrSymlink
    45  
    46  	RawContentBackupPath = rawContentBackupPath
    47  
    48  	UpdaterForStructure = updaterForStructure
    49  
    50  	Flatten = flatten
    51  
    52  	FilesystemInfo = filesystemInfo
    53  
    54  	NewRawStructureUpdater      = newRawStructureUpdater
    55  	NewMountedFilesystemUpdater = newMountedFilesystemUpdater
    56  
    57  	FindDeviceForStructureWithFallback = findDeviceForStructureWithFallback
    58  	FindMountPointForStructure         = findMountPointForStructure
    59  
    60  	ParseRelativeOffset = parseRelativeOffset
    61  )
    62  
    63  func MockEvalSymlinks(mock func(path string) (string, error)) (restore func()) {
    64  	oldEvalSymlinks := evalSymlinks
    65  	evalSymlinks = mock
    66  	return func() {
    67  		evalSymlinks = oldEvalSymlinks
    68  	}
    69  }
    70  
    71  func (m *MountedFilesystemWriter) WriteDirectory(volumeRoot, src, dst string, preserveInDst []string) error {
    72  	return m.writeDirectory(volumeRoot, src, dst, preserveInDst)
    73  }