(feat) describe-regions

This commit is contained in:
Julian Sommer
2026-01-14 03:48:43 +00:00
parent 0c164a4807
commit 35db549d7e
4 changed files with 43 additions and 0 deletions
+22
View File
@@ -10,6 +10,7 @@ import (
gateway_ec2_image "github.com/mulgadc/hive/hive/gateway/ec2/image"
gateway_ec2_instance "github.com/mulgadc/hive/hive/gateway/ec2/instance"
gateway_ec2_key "github.com/mulgadc/hive/hive/gateway/ec2/key"
gateway_ec2_regions "github.com/mulgadc/hive/hive/gateway/ec2/regions"
"github.com/mulgadc/hive/hive/utils"
)
@@ -276,6 +277,27 @@ func (gw *GatewayConfig) EC2_Request(ctx *fiber.Ctx) error {
payload := utils.GenerateXMLPayload("DescribeImagesResponse", output)
xmlOutput, err = utils.MarshalToXML(payload)
if err != nil {
return errors.New("failed to marshal response to XML")
}
case "DescribeRegions":
var input = &ec2.DescribeRegionsInput{}
err = awsec2query.QueryParamsToStruct(queryArgs, input)
if err != nil {
return err
}
output, err := gateway_ec2_regions.DescribeRegions(input, gw.Region)
if err != nil {
return err
}
// Convert to XML
payload := utils.GenerateXMLPayload("DescribeRegionsResponse", output)
xmlOutput, err = utils.MarshalToXML(payload)
if err != nil {
return errors.New("failed to marshal response to XML")
}
@@ -0,0 +1,19 @@
package gateway_ec2_regions
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"
)
// uses the loaded config file to get the region.
func DescribeRegions(input *ec2.DescribeRegionsInput, region string) (output *ec2.DescribeRegionsOutput, err error) {
output = &ec2.DescribeRegionsOutput{
Regions: []*ec2.Region{
{
RegionName: aws.String(region),
},
}}
return output, nil
}
+1
View File
@@ -23,6 +23,7 @@ type GatewayConfig struct {
NATSConn *nats.Conn // Shared NATS connection for service communication
Config string // Shared AWS Gateway config for S3 auth
ExpectedNodes int // Number of expected hive nodes for multi-node operations
Region string // Region this gateway is running in
}
var supportedServices = map[string]bool{
+1
View File
@@ -91,6 +91,7 @@ func launchService(config *config.ClusterConfig) (err error) {
DisableLogging: false,
NATSConn: natsConn,
Config: nodeConfig.AWSGW.Config,
Region: nodeConfig.Region,
}
app := gw.SetupRoutes()