-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Adrian Riobo <[email protected]>
- Loading branch information
1 parent
08c1840
commit bc1d016
Showing
34 changed files
with
1,142 additions
and
431 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,14 @@ | ||
package constants | ||
|
||
import "github.com/redhat-developer/mapt/pkg/provider/aws/action/mac" | ||
|
||
const ( | ||
ParamMACArch string = "arch" | ||
ParamMACArchDesc string = "mac architecture allowed values x86, m1, m2" | ||
ParamMACArchDefault string = mac.DefaultArch | ||
ParamMACOSVersion string = "version" | ||
ParamMACOSVersionDesc string = "macos operating system vestion 11, 12 on x86 and m1/m2; 13, 14 on all archs" | ||
ParamMACOSVersionDefault string = mac.DefaultOSVersion | ||
ParamMACFixedLocation string = "fixed-location" | ||
ParamMACFixedLocationDesc string = "if this flag is set the host will be created only on the region set by the AWS Env (AWS_DEFAULT_REGION)" | ||
) |
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,139 @@ | ||
package services | ||
|
||
import ( | ||
awsParams "github.com/redhat-developer/mapt/cmd/mapt/cmd/aws/constants" | ||
params "github.com/redhat-developer/mapt/cmd/mapt/cmd/constants" | ||
maptContext "github.com/redhat-developer/mapt/pkg/manager/context" | ||
macpool "github.com/redhat-developer/mapt/pkg/provider/aws/action/mac-pool" | ||
"github.com/redhat-developer/mapt/pkg/util/logging" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/pflag" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
const ( | ||
cmdMacPool = "mac-pool" | ||
cmdMacPoolDesc = "mac pool operations" | ||
|
||
cmdHousekeep = "house-keep" | ||
cmdHousekeepDesc = "house keeping for mac pool. Detroy old machines on over capacity and create new ones if capacity not meet" | ||
|
||
paramName = "name" | ||
paramNameDesc = "pool name it is a unique identifier for the pool. The name should be unique for the whole AWS account" | ||
paramOfferedCapacity = "offered-capacity" | ||
paramOfferedCapacityDesc = "offered capacity to accept new workloads (non locked machines in the pool) at any given time. This is limited by max pool size parameter" | ||
paramOfferedCapacityDefault = 1 | ||
paramMaxSize = "max-size" | ||
paramMaxSizeDesc = "max number of machines in the pool" | ||
paramMaxSizeDefault = 2 | ||
) | ||
|
||
func GetMacPoolCmd() *cobra.Command { | ||
c := &cobra.Command{ | ||
Use: cmdMacPool, | ||
Short: cmdMacPoolDesc, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if err := viper.BindPFlags(cmd.Flags()); err != nil { | ||
return err | ||
} | ||
return nil | ||
}, | ||
} | ||
c.AddCommand( | ||
getCreateMacPool(), | ||
getHouseKeepingMacPool()) | ||
return c | ||
} | ||
|
||
func getCreateMacPool() *cobra.Command { | ||
c := &cobra.Command{ | ||
Use: params.CreateCmdName, | ||
Short: params.CreateCmdName, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if err := viper.BindPFlags(cmd.Flags()); err != nil { | ||
return err | ||
} | ||
// Initialize context | ||
maptContext.Init( | ||
viper.GetString(params.ProjectName), | ||
viper.GetString(params.BackedURL), | ||
viper.GetString(params.ConnectionDetailsOutput), | ||
viper.GetStringMapString(params.Tags), | ||
viper.IsSet(params.Debug), | ||
viper.GetUint(params.DebugLevel), | ||
false) | ||
|
||
if err := macpool.Create( | ||
&macpool.RequestArgs{ | ||
Prefix: "main", | ||
PoolName: viper.GetString(paramName), | ||
Architecture: viper.GetString(awsParams.ParamMACArch), | ||
Version: viper.GetString(awsParams.ParamMACOSVersion), | ||
OfferedCapacity: viper.GetInt(paramOfferedCapacity), | ||
MaxSize: viper.GetInt(paramMaxSize), | ||
FixedLocation: viper.IsSet(awsParams.ParamMACFixedLocation)}); err != nil { | ||
logging.Error(err) | ||
} | ||
return nil | ||
}, | ||
} | ||
flagSet := pflag.NewFlagSet(params.CreateCmdName, pflag.ExitOnError) | ||
flagSet.StringP(params.ConnectionDetailsOutput, "", "", params.ConnectionDetailsOutputDesc) | ||
flagSet.StringToStringP(params.Tags, "", nil, params.TagsDesc) | ||
flagSet.StringP(paramName, "", "", paramNameDesc) | ||
flagSet.Int(paramOfferedCapacity, paramOfferedCapacityDefault, paramOfferedCapacityDesc) | ||
flagSet.Int(paramMaxSize, paramMaxSizeDefault, paramMaxSizeDesc) | ||
flagSet.StringP(awsParams.ParamMACArch, "", awsParams.ParamMACArchDefault, awsParams.ParamMACArchDesc) | ||
flagSet.StringP(awsParams.ParamMACOSVersion, "", awsParams.ParamMACOSVersion, awsParams.ParamMACOSVersionDefault) | ||
flagSet.Bool(awsParams.ParamMACFixedLocation, false, awsParams.ParamMACFixedLocationDesc) | ||
flagSet.AddFlagSet(params.GetGHActionsFlagset()) | ||
c.PersistentFlags().AddFlagSet(flagSet) | ||
return c | ||
} | ||
|
||
func getHouseKeepingMacPool() *cobra.Command { | ||
c := &cobra.Command{ | ||
Use: cmdHousekeep, | ||
Short: cmdHousekeepDesc, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if err := viper.BindPFlags(cmd.Flags()); err != nil { | ||
return err | ||
} | ||
// Initialize context | ||
maptContext.Init( | ||
viper.GetString(params.ProjectName), | ||
viper.GetString(params.BackedURL), | ||
viper.GetString(params.ConnectionDetailsOutput), | ||
viper.GetStringMapString(params.Tags), | ||
viper.IsSet(params.Debug), | ||
viper.GetUint(params.DebugLevel), | ||
viper.IsSet(params.Serverless)) | ||
|
||
if err := macpool.HouseKeeper( | ||
&macpool.RequestArgs{ | ||
Prefix: "main", | ||
PoolName: viper.GetString(paramName), | ||
Architecture: viper.GetString(awsParams.ParamMACArch), | ||
Version: viper.GetString(awsParams.ParamMACOSVersion), | ||
OfferedCapacity: viper.GetInt(paramOfferedCapacity), | ||
MaxSize: viper.GetInt(paramMaxSize), | ||
FixedLocation: viper.IsSet(awsParams.ParamMACFixedLocation)}); err != nil { | ||
logging.Error(err) | ||
} | ||
return nil | ||
}, | ||
} | ||
flagSet := pflag.NewFlagSet(params.CreateCmdName, pflag.ExitOnError) | ||
flagSet.StringP(params.ConnectionDetailsOutput, "", "", params.ConnectionDetailsOutputDesc) | ||
flagSet.StringToStringP(params.Tags, "", nil, params.TagsDesc) | ||
flagSet.StringP(paramName, "", "", paramNameDesc) | ||
flagSet.Int(paramOfferedCapacity, paramOfferedCapacityDefault, paramOfferedCapacityDesc) | ||
flagSet.Int(paramMaxSize, paramMaxSizeDefault, paramMaxSizeDesc) | ||
flagSet.StringP(awsParams.ParamMACArch, "", awsParams.ParamMACArchDefault, awsParams.ParamMACArchDesc) | ||
flagSet.StringP(awsParams.ParamMACOSVersion, "", awsParams.ParamMACOSVersion, awsParams.ParamMACOSVersionDefault) | ||
flagSet.Bool(awsParams.ParamMACFixedLocation, false, awsParams.ParamMACFixedLocationDesc) | ||
flagSet.Bool(params.Serverless, false, params.ServerlessDesc) | ||
flagSet.AddFlagSet(params.GetGHActionsFlagset()) | ||
c.PersistentFlags().AddFlagSet(flagSet) | ||
return c | ||
} |
2 changes: 1 addition & 1 deletion
2
cmd/mapt/cmd/aws/replica/replica.go → cmd/mapt/cmd/aws/services/replica.go
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package replica | ||
package services | ||
|
||
import ( | ||
params "github.com/redhat-developer/mapt/cmd/mapt/cmd/constants" | ||
|
Oops, something went wrong.