-
Notifications
You must be signed in to change notification settings - Fork 8
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
486138a
commit 2bbc0f2
Showing
35 changed files
with
1,315 additions
and
532 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 ( | ||
MACArch string = "arch" | ||
MACArchDesc string = "MAC architecture allowed values x86, m1, m2" | ||
MACArchDefault string = mac.DefaultArch | ||
MACOSVersion string = "version" | ||
MACOSVersionDesc string = "MACos operating system vestion 11, 12 on x86 and m1/m2; 13, 14 on all archs" | ||
MACOSVersionDefault string = mac.DefaultOSVersion | ||
MACFixedLocation string = "fixed-location" | ||
MACFixedLocationDesc 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.MACArch), | ||
OSVersion: viper.GetString(awsParams.MACOSVersion), | ||
OfferedCapacity: viper.GetInt(paramOfferedCapacity), | ||
MaxSize: viper.GetInt(paramMaxSize)}); err != nil { | ||
// FixedLocation: viper.IsSet(awsParams.MACFixedLocation)}); 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.MACArch, "", awsParams.MACArchDefault, awsParams.MACArchDesc) | ||
flagSet.StringP(awsParams.MACOSVersion, "", awsParams.MACOSVersion, awsParams.MACOSVersionDefault) | ||
// flagSet.Bool(awsParams.MACFixedLocation, false, awsParams.MACFixedLocationDesc) | ||
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.MACArch), | ||
OSVersion: viper.GetString(awsParams.MACOSVersion), | ||
OfferedCapacity: viper.GetInt(paramOfferedCapacity), | ||
MaxSize: viper.GetInt(paramMaxSize)}); err != nil { | ||
// FixedLocation: viper.IsSet(awsParams.MACFixedLocation)}); 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.MACArch, "", awsParams.MACArchDefault, awsParams.MACArchDesc) | ||
flagSet.StringP(awsParams.MACOSVersion, "", awsParams.MACOSVersion, awsParams.MACOSVersionDefault) | ||
// flagSet.Bool(awsParams.MACFixedLocation, false, awsParams.MACFixedLocationDesc) | ||
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.