Skip to content

Commit

Permalink
move nix-expressions to assets
Browse files Browse the repository at this point in the history
  • Loading branch information
adamtulinius committed Mar 27, 2018
1 parent 79caff8 commit 376704a
Show file tree
Hide file tree
Showing 3 changed files with 297 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Run `go-bindata -pkg assets -o assets/assets.go data/` after updating files from data/
260 changes: 260 additions & 0 deletions assets/assets.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 36 additions & 2 deletions morph.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ package main

import (
"fmt"
"git-platform.dbc.dk/platform/morph/assets"
filter "git-platform.dbc.dk/platform/morph/filter"
nix "git-platform.dbc.dk/platform/morph/nix"
"gopkg.in/alecthomas/kingpin.v2"
"io/ioutil"
"os"
"path/filepath"
)

var (
Expand All @@ -17,15 +20,46 @@ var (
deploySkip = deploy.Flag("skip", "Skip first n hosts").Default("0").Int()
deployLimit = deploy.Flag("limit", "Select at most n hosts").Int()
deployDryRun = deploy.Flag("dry-run", "Don't perform any actions").Default("False").Bool()

tempDir, tempDirErr = ioutil.TempDir("", "morph-")
)

func init() {
kingpin.MustParse(app.Parse(os.Args[1:]))
if tempDirErr != nil {
panic(tempDirErr)
}
}

func main() {
// setup assets

tempDir, err := ioutil.TempDir("", "morph-")
if err != nil {panic(err)}
defer os.RemoveAll(tempDir)

evalMachinesData, err := assets.Asset("data/eval-machines.nix")
if err != nil {
if err != nil {panic(err)}
}

optionsData, err := assets.Asset("data/options.nix")
if err != nil {
if err != nil {panic(err)}
}

evalMachinesPath := filepath.Join(tempDir, "eval-machines.nix")
optionsPath := filepath.Join(tempDir, "options.nix")
ioutil.WriteFile(evalMachinesPath, evalMachinesData, 0644)
ioutil.WriteFile(optionsPath, optionsData, 0644)

fmt.Println(tempDir)

// assets done


fmt.Println((*deployment).Name())
hosts, err := nix.GetMachines("/home/atu/go/src/git-platform.dbc.dk/platform/morph/data/eval-machines.nix", *deployment)
hosts, err := nix.GetMachines(evalMachinesPath, *deployment)
if err != nil {
panic(err)
}
Expand All @@ -40,7 +74,7 @@ func main() {
filteredHosts := filter.FilterHosts(matchingHosts, *deploySkip, *deployEvery, *deployLimit)
fmt.Println(filteredHosts)

resultPath, err := nix.BuildMachines("/home/atu/go/src/git-platform.dbc.dk/platform/morph/data/eval-machines.nix", *deployment, filteredHosts)
resultPath, err := nix.BuildMachines(evalMachinesPath, *deployment, filteredHosts)
if err != nil {
panic(err)
}
Expand Down

0 comments on commit 376704a

Please sign in to comment.