-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
315 additions
and
8 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
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,64 @@ | ||
package cmd | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"github.com/nullstone-io/deployment-sdk/app" | ||
"github.com/nullstone-io/deployment-sdk/logging" | ||
"github.com/nullstone-io/deployment-sdk/outputs" | ||
"github.com/urfave/cli/v2" | ||
"gopkg.in/nullstone-io/go-api-client.v0" | ||
"gopkg.in/nullstone-io/nullstone.v0/admin" | ||
"os" | ||
) | ||
|
||
var Run = func(appProviders app.Providers, providers admin.Providers) *cli.Command { | ||
return &cli.Command{ | ||
Name: "run", | ||
Description: "Starts a new container/serverless for the given Nullstone job/task. ", | ||
Usage: "Starts a new job/task", | ||
UsageText: "nullstone run [--stack=<stack-name>] --app=<app-name> --env=<env-name> [options] [command]", | ||
Flags: []cli.Flag{ | ||
StackFlag, | ||
AppFlag, | ||
EnvFlag, | ||
ContainerFlag, | ||
}, | ||
Action: func(c *cli.Context) error { | ||
var cmd []string | ||
if c.Args().Present() { | ||
cmd = c.Args().Slice() | ||
} | ||
|
||
return AppWorkspaceAction(c, func(ctx context.Context, cfg api.Config, appDetails app.Details) error { | ||
client := api.Client{Config: cfg} | ||
user, err := client.CurrentUser().Get(ctx) | ||
if err != nil { | ||
return fmt.Errorf("unable to fetch the current user") | ||
} | ||
if user == nil { | ||
return fmt.Errorf("unable to load the current user info") | ||
} | ||
|
||
source := outputs.ApiRetrieverSource{Config: cfg} | ||
|
||
logStreamer, err := appProviders.FindLogStreamer(ctx, logging.StandardOsWriters{}, source, appDetails) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
remoter, err := providers.FindRemoter(ctx, logging.StandardOsWriters{}, source, appDetails) | ||
if err != nil { | ||
return err | ||
} | ||
options := admin.RunOptions{ | ||
Container: c.String("container"), | ||
Username: user.Name, | ||
LogStreamer: logStreamer, | ||
LogEmitter: app.NewWriterLogEmitter(os.Stdout), | ||
} | ||
return remoter.Run(ctx, options, 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
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
Oops, something went wrong.