This repository has been archived by the owner on Mar 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2412 from ibuildthecloud/main
Add local environment
- Loading branch information
Showing
33 changed files
with
1,821 additions
and
27 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
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,29 @@ | ||
package cli | ||
|
||
import ( | ||
cli "github.com/acorn-io/runtime/pkg/cli/builder" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func NewLocal(c CommandContext) *cobra.Command { | ||
cmd := cli.Command(&Local{}, cobra.Command{ | ||
SilenceUsage: true, | ||
Short: "Manage local development acorn runtime", | ||
Hidden: true, | ||
}) | ||
cmd.AddCommand(NewLocalServer(c)) | ||
cmd.AddCommand(NewLocalCreate(c)) | ||
cmd.AddCommand(NewLocalLogs(c)) | ||
cmd.AddCommand(NewLocalRm(c)) | ||
cmd.AddCommand(NewLocalStart(c)) | ||
cmd.AddCommand(NewLocalStop(c)) | ||
cmd.AddCommand(NewLocalReset(c)) | ||
return cmd | ||
} | ||
|
||
type Local struct { | ||
} | ||
|
||
func (a *Local) Run(cmd *cobra.Command, args []string) error { | ||
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,35 @@ | ||
package cli | ||
|
||
import ( | ||
"fmt" | ||
|
||
cli "github.com/acorn-io/runtime/pkg/cli/builder" | ||
"github.com/acorn-io/runtime/pkg/local" | ||
"github.com/acorn-io/runtime/pkg/system" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func NewLocalCreate(c CommandContext) *cobra.Command { | ||
cmd := cli.Command(&Create{}, cobra.Command{ | ||
SilenceUsage: true, | ||
Short: "Create local development server", | ||
}) | ||
return cmd | ||
} | ||
|
||
type Create struct { | ||
Upgrade bool `usage:"Upgrade if runtime already exists"` | ||
} | ||
|
||
func (a *Create) Run(cmd *cobra.Command, args []string) error { | ||
c, err := local.NewContainer(cmd.Context()) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if _, err := c.Create(cmd.Context(), a.Upgrade); err != nil { | ||
return err | ||
} | ||
fmt.Println("running", system.DefaultImage()) | ||
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,30 @@ | ||
package cli | ||
|
||
import ( | ||
cli "github.com/acorn-io/runtime/pkg/cli/builder" | ||
"github.com/acorn-io/runtime/pkg/local" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func NewLocalLogs(c CommandContext) *cobra.Command { | ||
cmd := cli.Command(&LocalLogs{}, cobra.Command{ | ||
Use: "logs [flags]", | ||
Aliases: []string{"log"}, | ||
SilenceUsage: true, | ||
Short: "Show logs of local development server", | ||
}) | ||
return cmd | ||
} | ||
|
||
type LocalLogs struct { | ||
local.LogOptions | ||
} | ||
|
||
func (a *LocalLogs) Run(cmd *cobra.Command, args []string) error { | ||
c, err := local.NewContainer(cmd.Context()) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return c.Logs(cmd.Context(), a.LogOptions) | ||
} |
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,34 @@ | ||
package cli | ||
|
||
import ( | ||
"fmt" | ||
|
||
cli "github.com/acorn-io/runtime/pkg/cli/builder" | ||
"github.com/acorn-io/runtime/pkg/local" | ||
"github.com/acorn-io/runtime/pkg/system" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func NewLocalReset(c CommandContext) *cobra.Command { | ||
cmd := cli.Command(&Reset{}, cobra.Command{ | ||
SilenceUsage: true, | ||
Short: "Reset local development server, deleting all data", | ||
}) | ||
return cmd | ||
} | ||
|
||
type Reset struct { | ||
} | ||
|
||
func (a *Reset) Run(cmd *cobra.Command, args []string) error { | ||
c, err := local.NewContainer(cmd.Context()) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if err := c.Reset(cmd.Context()); err != nil { | ||
return err | ||
} | ||
fmt.Println("running", system.DefaultImage()) | ||
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,36 @@ | ||
package cli | ||
|
||
import ( | ||
"fmt" | ||
|
||
cli "github.com/acorn-io/runtime/pkg/cli/builder" | ||
"github.com/acorn-io/runtime/pkg/local" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func NewLocalRm(c CommandContext) *cobra.Command { | ||
cmd := cli.Command(&LocalRm{}, cobra.Command{ | ||
Use: "rm [flags]", | ||
Aliases: []string{"delete"}, | ||
SilenceUsage: true, | ||
Short: "Delete local development server", | ||
}) | ||
return cmd | ||
} | ||
|
||
type LocalRm struct { | ||
State bool `usage:"Include associated state (acorns and acorn data)"` | ||
} | ||
|
||
func (a *LocalRm) Run(cmd *cobra.Command, args []string) error { | ||
c, err := local.NewContainer(cmd.Context()) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if err := c.Delete(cmd.Context(), a.State); err != nil { | ||
return err | ||
} | ||
fmt.Println("removed") | ||
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,22 @@ | ||
package cli | ||
|
||
import ( | ||
cli "github.com/acorn-io/runtime/pkg/cli/builder" | ||
"github.com/acorn-io/runtime/pkg/local" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func NewLocalServer(c CommandContext) *cobra.Command { | ||
cmd := cli.Command(&Server{}, cobra.Command{ | ||
SilenceUsage: true, | ||
Short: "Run local development server", | ||
}) | ||
return cmd | ||
} | ||
|
||
type Server struct { | ||
} | ||
|
||
func (a *Server) Run(cmd *cobra.Command, args []string) error { | ||
return local.ServerRun(cmd.Context()) | ||
} |
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,40 @@ | ||
package cli | ||
|
||
import ( | ||
"fmt" | ||
|
||
cli "github.com/acorn-io/runtime/pkg/cli/builder" | ||
"github.com/acorn-io/runtime/pkg/local" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func NewLocalStart(c CommandContext) *cobra.Command { | ||
cmd := cli.Command(&LocalStart{}, cobra.Command{ | ||
Use: "start [flags]", | ||
Aliases: []string{"delete"}, | ||
SilenceUsage: true, | ||
Short: "Start local development server", | ||
}) | ||
return cmd | ||
} | ||
|
||
type LocalStart struct { | ||
} | ||
|
||
func (a *LocalStart) Run(cmd *cobra.Command, args []string) error { | ||
c, err := local.NewContainer(cmd.Context()) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if _, err := c.Create(cmd.Context(), false); err != nil { | ||
return err | ||
} | ||
|
||
if err := c.Start(cmd.Context()); err != nil { | ||
return err | ||
} | ||
|
||
fmt.Println("started") | ||
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,35 @@ | ||
package cli | ||
|
||
import ( | ||
"fmt" | ||
|
||
cli "github.com/acorn-io/runtime/pkg/cli/builder" | ||
"github.com/acorn-io/runtime/pkg/local" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func NewLocalStop(c CommandContext) *cobra.Command { | ||
cmd := cli.Command(&LocalStop{}, cobra.Command{ | ||
Use: "stop [flags]", | ||
Aliases: []string{"delete"}, | ||
SilenceUsage: true, | ||
Short: "Stop local development server", | ||
}) | ||
return cmd | ||
} | ||
|
||
type LocalStop struct { | ||
} | ||
|
||
func (a *LocalStop) Run(cmd *cobra.Command, args []string) error { | ||
c, err := local.NewContainer(cmd.Context()) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if err := c.Stop(cmd.Context()); err != nil { | ||
return err | ||
} | ||
fmt.Println("stopped") | ||
return nil | ||
} |
Oops, something went wrong.