Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

Commit

Permalink
Add logo
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
  • Loading branch information
alexellis committed Sep 12, 2019
1 parent 1783498 commit eb82b47
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 64 deletions.
130 changes: 66 additions & 64 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,70 +18,6 @@ import (
yaml "gopkg.in/yaml.v2"
)

// Vars are variables parsed from flags
type Vars struct {
YamlFile string
Verbose bool
}

const (
// OrchestrationK8s uses Kubernetes
OrchestrationK8s = "kubernetes"

// OrchestrationSwarm uses Docker Swarm
OrchestrationSwarm = "swarm"
)

func taskGivesStdout(tool string) error {
task := execute.ExecTask{Command: tool}
res, err := task.Execute()
if err != nil {
return fmt.Errorf("could not run: '%s', error: %s", tool, err)
}
if len(res.Stdout) == 0 {
return fmt.Errorf("error executing '%s', no output was given - tool is available in PATH", task.Command)
}
return nil
}

func validateTools(tools []string) error {

for _, tool := range tools {
err := taskGivesStdout(tool)
if err != nil {
return err
}
}

return nil

}

func validatePlan(plan types.Plan) error {
for _, secret := range plan.Secrets {
if featureEnabled(plan.Features, secret.Filters) {
err := filesExists(secret.Files)
if err != nil {
return err
}
}
}
return nil
}

func filesExists(files []types.FileSecret) error {
if len(files) > 0 {
for _, file := range files {
if len(file.ValueCommand) == 0 {
if _, err := os.Stat(file.ExpandValueFrom()); err != nil {
return err
}
}
}
}
return nil
}

func main() {
var printVersion bool
vars := Vars{}
Expand All @@ -91,6 +27,8 @@ func main() {

flag.Parse()

fmt.Println(version.Logo)

if printVersion {
fmt.Printf(
`ofc-bootstrap
Expand Down Expand Up @@ -164,6 +102,70 @@ func main() {
fmt.Fprintf(os.Stdout, "Plan completed in %f seconds\n", done.Seconds())
}

// Vars are variables parsed from flags
type Vars struct {
YamlFile string
Verbose bool
}

const (
// OrchestrationK8s uses Kubernetes
OrchestrationK8s = "kubernetes"

// OrchestrationSwarm uses Docker Swarm
OrchestrationSwarm = "swarm"
)

func taskGivesStdout(tool string) error {
task := execute.ExecTask{Command: tool}
res, err := task.Execute()
if err != nil {
return fmt.Errorf("could not run: '%s', error: %s", tool, err)
}
if len(res.Stdout) == 0 {
return fmt.Errorf("error executing '%s', no output was given - tool is available in PATH", task.Command)
}
return nil
}

func validateTools(tools []string) error {

for _, tool := range tools {
err := taskGivesStdout(tool)
if err != nil {
return err
}
}

return nil

}

func validatePlan(plan types.Plan) error {
for _, secret := range plan.Secrets {
if featureEnabled(plan.Features, secret.Filters) {
err := filesExists(secret.Files)
if err != nil {
return err
}
}
}
return nil
}

func filesExists(files []types.FileSecret) error {
if len(files) > 0 {
for _, file := range files {
if len(file.ValueCommand) == 0 {
if _, err := os.Stat(file.ExpandValueFrom()); err != nil {
return err
}
}
}
}
return nil
}

func process(plan types.Plan) error {

if plan.OpenFaaSCloudVersion == "" {
Expand Down
7 changes: 7 additions & 0 deletions version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,10 @@ func GetVersion() string {
}
return Version
}

const Logo = ` ___ _____ ____
/ _ \| ___/ ___|
| | | | |_ | |
| |_| | _|| |___
\___/|_| \____|
`

0 comments on commit eb82b47

Please sign in to comment.