Skip to content
This repository was archived by the owner on Jan 21, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ define define_binary_target
$(eval $(call binary_target_template,$(1),$(2)))
endef

$(call define_binary_target,infrakit,github.com/docker/infrakit/cmd/cli)
$(call define_binary_target,infrakit,github.com/docker/infrakit/cmd/infrakit)
$(call define_binary_target,infrakit-manager,github.com/docker/infrakit/cmd/manager)
$(call define_binary_target,infrakit-group-default,github.com/docker/infrakit/cmd/group)
$(call define_binary_target,infrakit-resource,github.com/docker/infrakit/cmd/resource)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion cmd/cli/event/event.go → cmd/infrakit/event/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"strings"

"github.com/docker/infrakit/cmd/cli/base"
"github.com/docker/infrakit/cmd/infrakit/base"
"github.com/docker/infrakit/pkg/discovery"
logutil "github.com/docker/infrakit/pkg/log"
metadata_template "github.com/docker/infrakit/pkg/plugin/metadata/template"
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/flavor/flavor.go → cmd/infrakit/flavor/flavor.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os"
"strings"

"github.com/docker/infrakit/cmd/cli/base"
"github.com/docker/infrakit/cmd/infrakit/base"
"github.com/docker/infrakit/pkg/cli"
"github.com/docker/infrakit/pkg/discovery"
logutil "github.com/docker/infrakit/pkg/log"
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/group/group.go → cmd/infrakit/group/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"sort"
"strings"

"github.com/docker/infrakit/cmd/cli/base"
"github.com/docker/infrakit/cmd/infrakit/base"
"github.com/docker/infrakit/pkg/cli"
"github.com/docker/infrakit/pkg/discovery"
logutil "github.com/docker/infrakit/pkg/log"
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/info/info.go → cmd/infrakit/info/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"fmt"

"github.com/docker/infrakit/cmd/cli/base"
"github.com/docker/infrakit/cmd/infrakit/base"
"github.com/docker/infrakit/pkg/cli"
"github.com/docker/infrakit/pkg/discovery"
"github.com/docker/infrakit/pkg/plugin"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"
"text/template"

"github.com/docker/infrakit/cmd/cli/base"
"github.com/docker/infrakit/cmd/infrakit/base"
"github.com/docker/infrakit/pkg/cli"
"github.com/docker/infrakit/pkg/discovery"
logutil "github.com/docker/infrakit/pkg/log"
Expand Down
26 changes: 13 additions & 13 deletions cmd/cli/main.go → cmd/infrakit/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"os"
"strings"

"github.com/docker/infrakit/cmd/cli/base"
"github.com/docker/infrakit/cmd/infrakit/base"
"github.com/docker/infrakit/pkg/cli"
cli_local "github.com/docker/infrakit/pkg/cli/local"
"github.com/docker/infrakit/pkg/discovery"
Expand All @@ -16,18 +16,18 @@ import (
logutil "github.com/docker/infrakit/pkg/log"
"github.com/spf13/cobra"

_ "github.com/docker/infrakit/cmd/cli/event"
_ "github.com/docker/infrakit/cmd/cli/flavor"
_ "github.com/docker/infrakit/cmd/cli/group"
_ "github.com/docker/infrakit/cmd/cli/info"
_ "github.com/docker/infrakit/cmd/cli/instance"
_ "github.com/docker/infrakit/cmd/cli/manager"
_ "github.com/docker/infrakit/cmd/cli/metadata"
_ "github.com/docker/infrakit/cmd/cli/playbook"
_ "github.com/docker/infrakit/cmd/cli/plugin"
_ "github.com/docker/infrakit/cmd/cli/resource"
_ "github.com/docker/infrakit/cmd/cli/template"
_ "github.com/docker/infrakit/cmd/cli/util"
_ "github.com/docker/infrakit/cmd/infrakit/event"
_ "github.com/docker/infrakit/cmd/infrakit/flavor"
_ "github.com/docker/infrakit/cmd/infrakit/group"
_ "github.com/docker/infrakit/cmd/infrakit/info"
_ "github.com/docker/infrakit/cmd/infrakit/instance"
_ "github.com/docker/infrakit/cmd/infrakit/manager"
_ "github.com/docker/infrakit/cmd/infrakit/metadata"
_ "github.com/docker/infrakit/cmd/infrakit/playbook"
_ "github.com/docker/infrakit/cmd/infrakit/plugin"
_ "github.com/docker/infrakit/cmd/infrakit/resource"
_ "github.com/docker/infrakit/cmd/infrakit/template"
_ "github.com/docker/infrakit/cmd/infrakit/util"
)

func init() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strconv"
"strings"

"github.com/docker/infrakit/cmd/cli/base"
"github.com/docker/infrakit/cmd/infrakit/base"
"github.com/docker/infrakit/pkg/cli"
"github.com/docker/infrakit/pkg/discovery"
logutil "github.com/docker/infrakit/pkg/log"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"os"
"strconv"

"github.com/docker/infrakit/cmd/cli/base"
"github.com/docker/infrakit/cmd/infrakit/base"
"github.com/docker/infrakit/pkg/discovery"
logutil "github.com/docker/infrakit/pkg/log"
"github.com/docker/infrakit/pkg/rpc/client"
Expand Down
22 changes: 13 additions & 9 deletions cmd/cli/playbook/playbook.go → cmd/infrakit/playbook/playbook.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"os/user"
"path/filepath"

"github.com/docker/infrakit/cmd/cli/base"
"github.com/docker/infrakit/cmd/infrakit/base"
"github.com/docker/infrakit/pkg/cli"
"github.com/docker/infrakit/pkg/cli/local"
"github.com/docker/infrakit/pkg/cli/remote"
Expand All @@ -28,18 +28,22 @@ func init() {
base.Register(Command)
}

func getHome() string {
if usr, err := user.Current(); err == nil {
return usr.HomeDir
}
return os.Getenv("HOME")
}

func defaultPlaybooksFile() string {
if playbooksFile := os.Getenv(PlaybooksFileEnvVar); playbooksFile != "" {
return playbooksFile
}
return filepath.Join(getHome(), ".infrakit/playbooks")

// if there's INFRAKIT_HOME defined
home := os.Getenv("INFRAKIT_HOME")
if home != "" {
return filepath.Join(home, "playbooks")
}

home = os.Getenv("HOME")
if usr, err := user.Current(); err == nil {
home = usr.HomeDir
}
return filepath.Join(home, ".infrakit/playbooks")
}

// Load loads the playbook
Expand Down
12 changes: 7 additions & 5 deletions cmd/cli/plugin/plugin.go → cmd/infrakit/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ import (
"syscall"
"time"

"github.com/docker/infrakit/cmd/cli/base"
"github.com/docker/infrakit/cmd/infrakit/base"
"github.com/docker/infrakit/pkg/discovery"
"github.com/docker/infrakit/pkg/launch"
"github.com/docker/infrakit/pkg/launch/os"
logutil "github.com/docker/infrakit/pkg/log"
"github.com/docker/infrakit/pkg/plugin"
"github.com/docker/infrakit/pkg/template"
"github.com/docker/infrakit/pkg/types"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -64,19 +63,22 @@ func Command(plugins func() discovery.Plugins) *cobra.Command {
executor := start.Flags().String("exec", "os", "Executor to use for starting up plugins: [os | docker-run]")
doWait := start.Flags().BoolP("wait", "w", false, "True to wait in the foreground; Ctrl-C to exit")

templateFlags, toJSON, _, processTemplate := base.TemplateProcessor(plugins)
start.Flags().AddFlagSet(templateFlags)

start.RunE = func(c *cobra.Command, args []string) error {

configTemplate, err := template.NewTemplate(*configURL, template.Options{})
buff, err := processTemplate(*configURL)
if err != nil {
return err
}

view, err := configTemplate.Render(nil)
view, err := toJSON([]byte(buff))
if err != nil {
return err
}

configs := types.AnyString(view)
configs := types.AnyBytes(view)

parsedRules := []launch.Rule{}
err = configs.Decode(&parsedRules)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"os"

"github.com/docker/infrakit/cmd/cli/base"
"github.com/docker/infrakit/cmd/infrakit/base"
"github.com/docker/infrakit/pkg/cli"
"github.com/docker/infrakit/pkg/discovery"
logutil "github.com/docker/infrakit/pkg/log"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os"
"strings"

"github.com/docker/infrakit/cmd/cli/base"
"github.com/docker/infrakit/cmd/infrakit/base"
"github.com/docker/infrakit/pkg/discovery"
logutil "github.com/docker/infrakit/pkg/log"
"github.com/ghodss/yaml"
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion cmd/cli/util/util.go → cmd/infrakit/util/util.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package util

import (
"github.com/docker/infrakit/cmd/cli/base"
"github.com/docker/infrakit/cmd/infrakit/base"
"github.com/docker/infrakit/pkg/discovery"
"github.com/docker/infrakit/pkg/log"
"github.com/spf13/cobra"
Expand Down
14 changes: 14 additions & 0 deletions cmd/manager/os.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,27 @@ func defaultLeaderFile() string {
if leaderFile := os.Getenv(LeaderFileEnvVar); leaderFile != "" {
return leaderFile
}

// if there's INFRAKIT_HOME defined
home := os.Getenv("INFRAKIT_HOME")
if home != "" {
return filepath.Join(home, "leader")
}

return filepath.Join(getHome(), ".infrakit/leader")
}

func defaultStoreDir() string {
if storeDir := os.Getenv(StoreDirEnvVar); storeDir != "" {
return storeDir
}

// if there's INFRAKIT_HOME defined
home := os.Getenv("INFRAKIT_HOME")
if home != "" {
return filepath.Join(home, "configs")
}

return filepath.Join(getHome(), ".infrakit/configs")
}

Expand Down
8 changes: 7 additions & 1 deletion pkg/discovery/local/dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ func Dir() string {
return pluginDir
}

home := os.Getenv("HOME")
// if there's INFRAKIT_HOME defined
home := os.Getenv("INFRAKIT_HOME")
if home != "" {
return filepath.Join(home, "plugins")
}

home = os.Getenv("HOME")
if usr, err := user.Current(); err == nil {
home = usr.HomeDir
}
Expand Down