-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: "dependencies" support in Application spec
Signed-off-by: aavarghese <[email protected]>
- Loading branch information
1 parent
7266b6c
commit 2445e0f
Showing
25 changed files
with
349 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//go:build full || deploy | ||
|
||
package subcommands | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
|
||
"lunchpail.io/cmd/subcommands/dependson" | ||
) | ||
|
||
func newDependsOnCmd() *cobra.Command { | ||
return &cobra.Command{ | ||
Use: "dependson", | ||
Short: "Commands for installing dependencies", | ||
Long: "Commands for installing dependencies", | ||
} | ||
} | ||
|
||
func init() { | ||
cmd := newDependsOnCmd() | ||
rootCmd.AddCommand(cmd) | ||
cmd.AddCommand(dependson.Minio()) | ||
cmd.AddCommand(dependson.Python()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package dependson | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"lunchpail.io/cmd/options" | ||
"lunchpail.io/pkg/runtime/dependson" | ||
) | ||
|
||
func Minio() *cobra.Command { | ||
var opts dependson.DependsOnOptions | ||
cmd := &cobra.Command{ | ||
Use: "minio", | ||
Short: "Install minio", | ||
Long: "Install minio", | ||
Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs), | ||
} | ||
|
||
logOpts := options.AddLogOptions(cmd) | ||
|
||
cmd.RunE = func(cmd *cobra.Command, args []string) error { | ||
opts.Verbose = logOpts.Verbose | ||
opts.Debug = logOpts.Debug | ||
return dependson.InstallMinio(context.Background(), args[0], opts) | ||
} | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package dependson | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"lunchpail.io/cmd/options" | ||
"lunchpail.io/pkg/runtime/dependson" | ||
) | ||
|
||
func Python() *cobra.Command { | ||
var opts dependson.DependsOnOptions | ||
cmd := &cobra.Command{ | ||
Use: "python", | ||
Short: "Install conda/python environment", | ||
Long: "Install conda/python environment", | ||
Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs), | ||
} | ||
|
||
logOpts := options.AddLogOptions(cmd) | ||
|
||
cmd.RunE = func(cmd *cobra.Command, args []string) error { | ||
opts.Verbose = logOpts.Verbose | ||
opts.Debug = logOpts.Debug | ||
return dependson.InstallPython(context.Background(), args[0], opts) | ||
} | ||
|
||
return cmd | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package dependson | ||
|
||
type DependsOnOptions struct { | ||
// Verbose output | ||
Verbose bool | ||
|
||
// Debug output | ||
Debug bool | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package dependson | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"os/exec" | ||
) | ||
|
||
func installMinio(version string, verbose bool) error { | ||
if version == "latest" { | ||
if verbose { | ||
fmt.Fprintf(os.Stderr, "Installing the latest minio release\n") | ||
} | ||
return brewInstall("minio/stable/minio", verbose) | ||
} else { | ||
return nil //Todo | ||
} | ||
} | ||
|
||
func installPython(version string, verbose bool) error { | ||
return brewInstall("python", verbose) | ||
} | ||
|
||
func brewInstall(pkg string, verbose bool) error { | ||
cmd := exec.Command("brew", "install", pkg) | ||
if verbose { | ||
cmd.Stdout = os.Stdout | ||
} | ||
cmd.Stderr = os.Stderr | ||
return cmd.Run() | ||
} | ||
|
||
func setenv() error { | ||
// nothing to do | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package dependson | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"os/exec" | ||
) | ||
|
||
func InstallMinio(ctx context.Context, version string, opts DependsOnOptions) error { | ||
if err := setenv(); err != nil { | ||
return err | ||
} | ||
|
||
if _, err := exec.LookPath("minio"); err != nil { | ||
if errors.Is(err, exec.ErrNotFound) { | ||
//Todo: use context? | ||
return installMinio(version, opts.Verbose) | ||
} else if err != nil { | ||
return err | ||
} | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package dependson | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"os/exec" | ||
) | ||
|
||
func InstallPython(ctx context.Context, version string, opts DependsOnOptions) error { | ||
if err := setenv(); err != nil { | ||
return err | ||
} | ||
|
||
if _, err := exec.LookPath("python"); err != nil { | ||
if errors.Is(err, exec.ErrNotFound) { | ||
//Todo: use context? | ||
return installPython(version, opts.Verbose) | ||
} else if err != nil { | ||
return err | ||
} | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# test7-python | ||
|
||
This is a variant of python-basic, but using `dependson` Application support |
Oops, something went wrong.