github.com/replicatedhq/ship@v0.55.0/pkg/lifecycle/daemon/ui.bindatafs.go (about)

     1  // Code generated by go-bindata.
     2  // sources:
     3  // DO NOT EDIT!
     4  
     5  package daemon
     6  
     7  import (
     8  	"fmt"
     9  	"io/ioutil"
    10  	"net/http"
    11  	"os"
    12  	"path/filepath"
    13  	"strings"
    14  )
    15  
    16  // bindataRead reads the given file from disk. It returns an error on failure.
    17  func bindataRead(path, name string) ([]byte, error) {
    18  	buf, err := ioutil.ReadFile(path)
    19  	if err != nil {
    20  		err = fmt.Errorf("Error reading asset %s at %s: %v", name, path, err)
    21  	}
    22  	return buf, err
    23  }
    24  
    25  type asset struct {
    26  	bytes []byte
    27  	info  os.FileInfo
    28  }
    29  
    30  // Asset loads and returns the asset for the given name.
    31  // It returns an error if the asset could not be found or
    32  // could not be loaded.
    33  func Asset(name string) ([]byte, error) {
    34  	cannonicalName := strings.Replace(name, "\\", "/", -1)
    35  	if f, ok := _bindata[cannonicalName]; ok {
    36  		a, err := f()
    37  		if err != nil {
    38  			return nil, fmt.Errorf("Asset %s can't read by error: %v", name, err)
    39  		}
    40  		return a.bytes, nil
    41  	}
    42  	return nil, fmt.Errorf("Asset %s not found", name)
    43  }
    44  
    45  // MustAsset is like Asset but panics when Asset would return an error.
    46  // It simplifies safe initialization of global variables.
    47  func MustAsset(name string) []byte {
    48  	a, err := Asset(name)
    49  	if err != nil {
    50  		panic("asset: Asset(" + name + "): " + err.Error())
    51  	}
    52  
    53  	return a
    54  }
    55  
    56  // AssetInfo loads and returns the asset info for the given name.
    57  // It returns an error if the asset could not be found or
    58  // could not be loaded.
    59  func AssetInfo(name string) (os.FileInfo, error) {
    60  	cannonicalName := strings.Replace(name, "\\", "/", -1)
    61  	if f, ok := _bindata[cannonicalName]; ok {
    62  		a, err := f()
    63  		if err != nil {
    64  			return nil, fmt.Errorf("AssetInfo %s can't read by error: %v", name, err)
    65  		}
    66  		return a.info, nil
    67  	}
    68  	return nil, fmt.Errorf("AssetInfo %s not found", name)
    69  }
    70  
    71  // AssetNames returns the names of the assets.
    72  func AssetNames() []string {
    73  	names := make([]string, 0, len(_bindata))
    74  	for name := range _bindata {
    75  		names = append(names, name)
    76  	}
    77  	return names
    78  }
    79  
    80  // _bindata is a table, holding each asset generator, mapped to its name.
    81  var _bindata = map[string]func() (*asset, error){}
    82  
    83  // AssetDir returns the file names below a certain
    84  // directory embedded in the file by go-bindata.
    85  // For example if you run go-bindata on data/... and data contains the
    86  // following hierarchy:
    87  //     data/
    88  //       foo.txt
    89  //       img/
    90  //         a.png
    91  //         b.png
    92  // then AssetDir("data") would return []string{"foo.txt", "img"}
    93  // AssetDir("data/img") would return []string{"a.png", "b.png"}
    94  // AssetDir("foo.txt") and AssetDir("notexist") would return an error
    95  // AssetDir("") will return []string{"data"}.
    96  func AssetDir(name string) ([]string, error) {
    97  	node := _bintree
    98  	if len(name) != 0 {
    99  		cannonicalName := strings.Replace(name, "\\", "/", -1)
   100  		pathList := strings.Split(cannonicalName, "/")
   101  		for _, p := range pathList {
   102  			node = node.Children[p]
   103  			if node == nil {
   104  				return nil, fmt.Errorf("Asset %s not found", name)
   105  			}
   106  		}
   107  	}
   108  	if node.Func != nil {
   109  		return nil, fmt.Errorf("Asset %s not found", name)
   110  	}
   111  	rv := make([]string, 0, len(node.Children))
   112  	for childName := range node.Children {
   113  		rv = append(rv, childName)
   114  	}
   115  	return rv, nil
   116  }
   117  
   118  type bintree struct {
   119  	Func     func() (*asset, error)
   120  	Children map[string]*bintree
   121  }
   122  
   123  var _bintree = &bintree{nil, map[string]*bintree{}}
   124  
   125  // RestoreAsset restores an asset under the given directory
   126  func RestoreAsset(dir, name string) error {
   127  	data, err := Asset(name)
   128  	if err != nil {
   129  		return err
   130  	}
   131  	info, err := AssetInfo(name)
   132  	if err != nil {
   133  		return err
   134  	}
   135  	err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755))
   136  	if err != nil {
   137  		return err
   138  	}
   139  	err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode())
   140  	if err != nil {
   141  		return err
   142  	}
   143  	err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
   144  	if err != nil {
   145  		return err
   146  	}
   147  	return nil
   148  }
   149  
   150  // RestoreAssets restores an asset under the given directory recursively
   151  func RestoreAssets(dir, name string) error {
   152  	children, err := AssetDir(name)
   153  	// File
   154  	if err != nil {
   155  		return RestoreAsset(dir, name)
   156  	}
   157  	// Dir
   158  	for _, child := range children {
   159  		err = RestoreAssets(dir, filepath.Join(name, child))
   160  		if err != nil {
   161  			return err
   162  		}
   163  	}
   164  	return nil
   165  }
   166  
   167  func _filePath(dir, name string) string {
   168  	cannonicalName := strings.Replace(name, "\\", "/", -1)
   169  	return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
   170  }
   171  
   172  func assetFS() http.FileSystem {
   173  	for k := range _bintree.Children {
   174  		return http.Dir(k)
   175  	}
   176  	panic("unreachable")
   177  }