-
Notifications
You must be signed in to change notification settings - Fork 669
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
18 changed files
with
988 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package register | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
rconfig "github.com/flyteorg/flytectl/cmd/config/subcommand/register" | ||
cmdCore "github.com/flyteorg/flytectl/cmd/core" | ||
) | ||
|
||
const ( | ||
registerExampleShort = "Registers flytesnack example" | ||
registerExampleLong = ` | ||
Registers all latest flytesnacks example | ||
:: | ||
bin/flytectl register examples -d development -p flytesnacks | ||
Usage | ||
` | ||
githubOrg = "flyteorg" | ||
githubRepository = "flytesnacks" | ||
archive = true | ||
snackReleaseURL = "https://github.com/flyteorg/flytesnacks/releases/download/%s/flytesnacks-%s.tgz" | ||
flyteManifest = "https://github.com/flyteorg/flytesnacks/releases/download/%s/flyte_tests_manifest.json" | ||
) | ||
|
||
func registerExamplesFunc(ctx context.Context, args []string, cmdCtx cmdCore.CommandContext) error { | ||
flytesnacks, tag, err := getFlyteTestManifest() | ||
if err != nil { | ||
return err | ||
} | ||
rconfig.DefaultFilesConfig.Archive = archive | ||
for _, v := range flytesnacks { | ||
args := []string{ | ||
fmt.Sprintf(snackReleaseURL, tag, v.Name), | ||
} | ||
if err := Register(ctx, args, cmdCtx); err != nil { | ||
return fmt.Errorf("Example %v failed to register %v", v.Name, 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
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,45 @@ | ||
package sandbox | ||
|
||
import ( | ||
cmdcore "github.com/flyteorg/flytectl/cmd/core" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// Long descriptions are whitespace sensitive when generating docs using sphinx. | ||
const ( | ||
sandboxShort = `Used for testing flyte sandbox.` | ||
sandboxLong = ` | ||
Example Create sandbox cluster. | ||
:: | ||
bin/flytectl sandbox start | ||
Example Remove sandbox cluster. | ||
:: | ||
bin/flytectl sandbox teardown | ||
` | ||
) | ||
|
||
// CreateSandboxCommand will return sandbox command | ||
func CreateSandboxCommand() *cobra.Command { | ||
sandbox := &cobra.Command{ | ||
Use: "sandbox", | ||
Short: sandboxShort, | ||
Long: sandboxLong, | ||
} | ||
|
||
sandboxResourcesFuncs := map[string]cmdcore.CommandEntry{ | ||
"start": {CmdFunc: startSandboxCluster, Aliases: []string{}, ProjectDomainNotRequired: true, | ||
Short: startShort, | ||
Long: startLong}, | ||
"teardown": {CmdFunc: teardownSandboxCluster, Aliases: []string{}, ProjectDomainNotRequired: true, | ||
Short: teardownShort, | ||
Long: teardownLong}, | ||
} | ||
|
||
cmdcore.AddCommands(sandbox, sandboxResourcesFuncs) | ||
|
||
return sandbox | ||
} |
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,31 @@ | ||
package sandbox | ||
|
||
import ( | ||
"fmt" | ||
"sort" | ||
"testing" | ||
|
||
"gotest.tools/assert" | ||
) | ||
|
||
func TestCreateSandboxCommand(t *testing.T) { | ||
sandboxCommand := CreateSandboxCommand() | ||
assert.Equal(t, sandboxCommand.Use, "sandbox") | ||
assert.Equal(t, sandboxCommand.Short, "Used for testing flyte sandbox.") | ||
fmt.Println(sandboxCommand.Commands()) | ||
assert.Equal(t, len(sandboxCommand.Commands()), 2) | ||
cmdNouns := sandboxCommand.Commands() | ||
// Sort by Use value. | ||
sort.Slice(cmdNouns, func(i, j int) bool { | ||
return cmdNouns[i].Use < cmdNouns[j].Use | ||
}) | ||
|
||
assert.Equal(t, cmdNouns[0].Use, "start") | ||
assert.Equal(t, cmdNouns[0].Short, startShort) | ||
assert.Equal(t, cmdNouns[0].Long, startLong) | ||
|
||
assert.Equal(t, cmdNouns[1].Use, "teardown") | ||
assert.Equal(t, cmdNouns[1].Short, teardownShort) | ||
assert.Equal(t, cmdNouns[1].Long, teardownLong) | ||
|
||
} |
Oops, something went wrong.