github.com/pojntfx/hydrapp/hydrapp@v0.0.0-20240516002902-d08759d6ca9f/pkg/config/parse.go (about)

     1  package config
     2  
     3  import (
     4  	"io"
     5  
     6  	"github.com/pojntfx/hydrapp/hydrapp/pkg/renderers"
     7  	"github.com/pojntfx/hydrapp/hydrapp/pkg/renderers/rpm"
     8  	"gopkg.in/yaml.v3"
     9  )
    10  
    11  type Root struct {
    12  	App      App                 `yaml:"app"`
    13  	Go       Go                  `yaml:"go"`
    14  	Releases []renderers.Release `yaml:"releases"`
    15  	DEB      []DEB               `yaml:"deb"`
    16  	DMG      DMG                 `yaml:"dmg"`
    17  	Flatpak  []Flatpak           `yaml:"flatpak"`
    18  	MSI      []MSI               `yaml:"msi"`
    19  	RPM      []RPM               `yaml:"rpm"`
    20  	APK      APK                 `yaml:"apk"`
    21  	Binaries Binaries            `yaml:"binaries"`
    22  	Docs     Docs                `yaml:"docs"`
    23  }
    24  
    25  type App struct {
    26  	ID          string `yaml:"id"`
    27  	Name        string `yaml:"name"`
    28  	Summary     string `yaml:"summary"`
    29  	Description string `yaml:"description"`
    30  	License     string `yaml:"license"`
    31  	Homepage    string `yaml:"homepage"`
    32  	Git         string `yaml:"git"`
    33  	BaseURL     string `yaml:"baseurl"`
    34  }
    35  
    36  type Go struct {
    37  	Main     string `yaml:"main"`
    38  	Flags    string `yaml:"flags"`
    39  	Generate string `yaml:"generate"`
    40  	Tests    string `yaml:"tests"`
    41  	Image    string `yaml:"img"`
    42  }
    43  
    44  type DEB struct {
    45  	Path            string        `yaml:"path"`
    46  	OS              string        `yaml:"os"`
    47  	Distro          string        `yaml:"distro"`
    48  	Mirrorsite      string        `yaml:"mirrorsite"`
    49  	Components      []string      `yaml:"components"`
    50  	Debootstrapopts string        `yaml:"debootstrapopts"`
    51  	Architecture    string        `yaml:"architecture"`
    52  	Packages        []rpm.Package `yaml:"packages"`
    53  }
    54  
    55  type DMG struct {
    56  	Path     string   `yaml:"path"`
    57  	Packages []string `yaml:"packages"`
    58  }
    59  
    60  type Flatpak struct {
    61  	Path         string `yaml:"path"`
    62  	Architecture string `yaml:"architecture"`
    63  }
    64  
    65  type MSI struct {
    66  	Path         string   `yaml:"path"`
    67  	Architecture string   `yaml:"architecture"`
    68  	Include      string   `yaml:"include"`
    69  	Packages     []string `yaml:"packages"`
    70  }
    71  
    72  type RPM struct {
    73  	Path         string        `yaml:"path"`
    74  	Trailer      string        `yaml:"trailer"`
    75  	Distro       string        `yaml:"distro"`
    76  	Architecture string        `yaml:"architecture"`
    77  	Packages     []rpm.Package `yaml:"packages"`
    78  }
    79  
    80  type APK struct {
    81  	Path string `yaml:"path"`
    82  }
    83  
    84  type Binaries struct {
    85  	Path     string   `yaml:"path"`
    86  	Exclude  string   `yaml:"exclude"`
    87  	Packages []string `yaml:"packages"`
    88  }
    89  
    90  type Docs struct {
    91  	Path string `yaml:"path"`
    92  }
    93  
    94  func Parse(r io.Reader) (*Root, error) {
    95  	var root Root
    96  	if err := yaml.NewDecoder(r).Decode(&root); err != nil {
    97  		return nil, err
    98  	}
    99  
   100  	return &root, nil
   101  }