mirror of
https://github.com/luxfi/cli.git
synced 2026-10-30 17:01:20 +00:00
- Update github.com/luxfi/netrunner v1.15.3 → v1.15.4 - Update github.com/luxfi/node v1.22.77 → v1.22.80 - Remove local replace directive for netrunner - Use published package versions for reproducible builds
69 lines
1.9 KiB
Go
69 lines
1.9 KiB
Go
// Copyright (C) 2022-2025, Lux Industries, Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
// Package models contains data structures and types used throughout the CLI.
|
|
package models
|
|
|
|
import (
|
|
"maps"
|
|
"slices"
|
|
)
|
|
|
|
// RegionConfig contains cloud infrastructure configuration for a specific region.
|
|
type RegionConfig struct {
|
|
InstanceIDs []string
|
|
APIInstanceIDs []string
|
|
PublicIPs []string
|
|
KeyPair string
|
|
SecurityGroup string
|
|
CertFilePath string
|
|
ImageID string
|
|
Prefix string
|
|
CertName string
|
|
SecurityGroupName string
|
|
NumNodes int
|
|
InstanceType string
|
|
}
|
|
|
|
// CloudConfig maps region names to their configurations.
|
|
type CloudConfig map[string]RegionConfig
|
|
|
|
// GetRegions returns a slice of strings representing the regions of the RegionConfig.
|
|
func (ccm *CloudConfig) GetRegions() []string {
|
|
return slices.Collect(maps.Keys(*ccm))
|
|
}
|
|
|
|
// GetAllInstanceIDs returns all instance IDs
|
|
func (ccm *CloudConfig) GetAllInstanceIDs() []string {
|
|
instanceIDs := []string{}
|
|
for _, cloudConfig := range *ccm {
|
|
instanceIDs = append(instanceIDs, cloudConfig.InstanceIDs...)
|
|
}
|
|
return instanceIDs
|
|
}
|
|
|
|
// GetAllAPIInstanceIDs returns all API instance IDs
|
|
func (ccm *CloudConfig) GetAllAPIInstanceIDs() []string {
|
|
apiInstanceIDs := []string{}
|
|
for _, cloudConfig := range *ccm {
|
|
apiInstanceIDs = append(apiInstanceIDs, cloudConfig.APIInstanceIDs...)
|
|
}
|
|
return apiInstanceIDs
|
|
}
|
|
|
|
// GetInstanceIDsForRegion returns instance IDs for specific region
|
|
func (ccm *CloudConfig) GetInstanceIDsForRegion(region string) []string {
|
|
if regionConf, ok := (*ccm)[region]; ok {
|
|
return regionConf.InstanceIDs
|
|
}
|
|
return []string{}
|
|
}
|
|
|
|
// GetAPIInstanceIDsForRegion returns API instance IDs for specific region
|
|
func (ccm *CloudConfig) GetAPIInstanceIDsForRegion(region string) []string {
|
|
if regionConf, ok := (*ccm)[region]; ok {
|
|
return regionConf.APIInstanceIDs
|
|
}
|
|
return []string{}
|
|
}
|