-
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: ibmcloud be to use local setup rather than k8 kind cluster
Signed-off-by: aavarghese <[email protected]>
- Loading branch information
1 parent
e71352b
commit d8ecff7
Showing
13 changed files
with
291 additions
and
60 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,42 @@ | ||
package component | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/spf13/cobra" | ||
"lunchpail.io/cmd/options" | ||
"lunchpail.io/pkg/build" | ||
"lunchpail.io/pkg/runtime" | ||
) | ||
|
||
type RunLocallyOptions struct { | ||
Component string | ||
LLIR string | ||
build.LogOptions | ||
} | ||
|
||
func AddRunLocallyOptions(cmd *cobra.Command) *RunLocallyOptions { | ||
options := RunLocallyOptions{} | ||
cmd.Flags().StringVarP(&options.Component, "component", "", "", "") | ||
cmd.Flags().StringVar(&options.LLIR, "llir", "", "") | ||
cmd.MarkFlagRequired("component") | ||
cmd.MarkFlagRequired("llir") | ||
return &options | ||
} | ||
|
||
func RunLocally() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "run-locally", | ||
Short: "Commands for running a component locally", | ||
Long: "Commands for running a component locally", | ||
} | ||
|
||
runOpts := AddRunLocallyOptions(cmd) | ||
options.AddLogOptions(cmd) | ||
|
||
cmd.RunE = func(cmd *cobra.Command, args []string) error { | ||
return runtime.RunLocally(context.Background(), runOpts.Component, runOpts.LLIR, runOpts.LogOptions) | ||
} | ||
|
||
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
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,36 @@ | ||
package ibmcloud | ||
|
||
import ( | ||
"context" | ||
|
||
"lunchpail.io/pkg/ir/llir" | ||
) | ||
|
||
func (backend Backend) CreateImage(ctx context.Context, ir llir.LLIR, opts llir.Options, destroy bool) (string, error) { | ||
runname := ir.RunName() | ||
|
||
zone := opts.Zone //command line zone value | ||
if zone == "" { //random zone value using config | ||
randomZone, err := getRandomizedZone(backend.config, backend.vpcService) //Todo: spread among random zones with a subnet in each zone | ||
if err != nil { | ||
return "", err | ||
} | ||
zone = randomZone | ||
} | ||
instanceID, err := createResources(ctx, backend.vpcService, runname, ir, backend.config.ResourceGroup.GUID, backend.sshKeyType, backend.sshPublicKey, zone, opts.Profile, opts.ImageID, backend.namespace, opts) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
imageID, err := createImage(backend.vpcService, runname, backend.config.ResourceGroup.GUID, instanceID) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
if destroy { | ||
if err := stopOrDeleteVM(backend.vpcService, runname, backend.config.ResourceGroup.GUID, true); err != nil { | ||
return "", err | ||
} | ||
} | ||
return imageID, 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,12 @@ | ||
package kubernetes | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"lunchpail.io/pkg/ir/llir" | ||
) | ||
|
||
func (backend Backend) CreateImage(ctx context.Context, ir llir.LLIR, opts llir.Options, destroy bool) (string, error) { | ||
return "", fmt.Errorf("Unsupported operation: 'CreateImage'") | ||
} |
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,12 @@ | ||
package local | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"lunchpail.io/pkg/ir/llir" | ||
) | ||
|
||
func (backend Backend) CreateImage(ctx context.Context, ir llir.LLIR, opts llir.Options, destroy bool) (string, error) { | ||
return "", fmt.Errorf("Unsupported operation: 'CreateImage'") | ||
} |
Oops, something went wrong.