diff --git a/spinifex/gateway/ecr/registry_image.go b/spinifex/gateway/ecr/registry_image.go index d7b747499..2b533ec42 100644 --- a/spinifex/gateway/ecr/registry_image.go +++ b/spinifex/gateway/ecr/registry_image.go @@ -134,7 +134,7 @@ func (reg *Registry) GetManifest(account, repo, ref string, acceptedTypes []stri } return nil, "", "", err } - if len(acceptedTypes) > 0 && !mediaTypeAccepted(acceptedTypes, meta.MediaType) { + if len(acceptedTypes) > 0 && !slices.Contains(acceptedTypes, meta.MediaType) { return nil, "", "", ErrImageNotFound } out, err := scoped.Store.GetObject(&s3.GetObjectInput{ @@ -326,8 +326,3 @@ func (reg *Registry) referencedDigests(account string) (map[string]bool, error) } return referenced, nil } - -// mediaTypeAccepted reports whether mediaType is in the accepted set. -func mediaTypeAccepted(accepted []string, mediaType string) bool { - return slices.Contains(accepted, mediaType) -} diff --git a/spinifex/handlers/ec2/vpc/external_ipam.go b/spinifex/handlers/ec2/vpc/external_ipam.go index 6935a2cff..10c1380a4 100644 --- a/spinifex/handlers/ec2/vpc/external_ipam.go +++ b/spinifex/handlers/ec2/vpc/external_ipam.go @@ -103,7 +103,7 @@ func (m *ExternalIPAM) AllocateIP(region, az, purpose, allocID, eniID, instanceI if pool == nil { return "", "", fmt.Errorf("InsufficientAddressCapacity: no external pool available for region=%q az=%q", region, az) } - ip, err := m.allocateFromPool(pool.Name, purpose, allocID, eniID, instanceID) + ip, err := m.AllocateFromPool(pool.Name, purpose, allocID, eniID, instanceID) if err != nil { return "", "", err } @@ -112,10 +112,6 @@ func (m *ExternalIPAM) AllocateIP(region, az, purpose, allocID, eniID, instanceI // AllocateFromPool allocates an IP from a specific named pool. func (m *ExternalIPAM) AllocateFromPool(poolName, purpose, allocID, eniID, instanceID string) (string, error) { - return m.allocateFromPool(poolName, purpose, allocID, eniID, instanceID) -} - -func (m *ExternalIPAM) allocateFromPool(poolName, purpose, allocID, eniID, instanceID string) (string, error) { alloc, err := m.allocatorFor(poolName) if err != nil { return "", err diff --git a/spinifex/handlers/eks/access_entry.go b/spinifex/handlers/eks/access_entry.go index 894de52fe..6250fec1b 100644 --- a/spinifex/handlers/eks/access_entry.go +++ b/spinifex/handlers/eks/access_entry.go @@ -230,15 +230,11 @@ func associatedPolicyToAWS(p AssociatedAccessPolicy) *eks.AssociatedAccessPolicy } } -// defaultKubernetesUsername mirrors AWS behaviour: username defaults to principalARN when omitted. -func defaultKubernetesUsername(principalARN string) string { - return principalARN -} - // newAccessEntryRecord builds a record; defaults username to principalARN when unset. func newAccessEntryRecord(region, accountID, cluster, principalARN, username string, groups []string, entryType string, tags map[string]string, now time.Time) *AccessEntryRecord { + // AWS defaults the Kubernetes username to the principal ARN when omitted. if username == "" { - username = defaultKubernetesUsername(principalARN) + username = principalARN } return &AccessEntryRecord{ ARN: AccessEntryARN(region, accountID, cluster, principalARN), diff --git a/spinifex/handlers/elbv2/service_impl_lb_network.go b/spinifex/handlers/elbv2/service_impl_lb_network.go index 00445809f..64fe4727e 100644 --- a/spinifex/handlers/elbv2/service_impl_lb_network.go +++ b/spinifex/handlers/elbv2/service_impl_lb_network.go @@ -108,7 +108,7 @@ func (s *ELBv2ServiceImpl) SetSubnets(input *elbv2.SetSubnetsInput, accountID st return nil, errors.New(awserrors.ErrorMissingParameter) } - desired := desiredSubnetSet(input) + desired := flattenSubnetIDs(input.Subnets, input.SubnetMappings) if len(desired) == 0 { return nil, errors.New(awserrors.ErrorMissingParameter) } @@ -237,11 +237,6 @@ func (s *ELBv2ServiceImpl) SetSubnets(input *elbv2.SetSubnetsInput, accountID st return s.setSubnetsOutput(lb), nil } -// desiredSubnetSet flattens Subnets and SubnetMappings into a deduplicated, ordered list. -func desiredSubnetSet(input *elbv2.SetSubnetsInput) []string { - return flattenSubnetIDs(input.Subnets, input.SubnetMappings) -} - // flattenSubnetIDs deduplicates the explicit Subnets list and the SubnetMappings // list into one ordered subnet-ID slice. LBC supplies ALB subnets via // SubnetMappings, so both sources must be honoured wherever subnets are read. diff --git a/spinifex/instancetypes/definitions.go b/spinifex/instancetypes/definitions.go index 2f3567877..e7d336716 100644 --- a/spinifex/instancetypes/definitions.go +++ b/spinifex/instancetypes/definitions.go @@ -332,7 +332,7 @@ var instanceFamilyDefs = []instanceFamilyDef{ // System (internal-only, not exposed via DescribeInstanceTypes) {name: "sys", sizes: systemSizes, currentGen: true}, - // GPU Accelerated — not emitted by generateForGeneration; used by generateGPUTypes. + // GPU Accelerated — not emitted by generateForGeneration; used by GenerateGPUTypes. {name: "g4dn", sizes: g4dnSizes, currentGen: true}, {name: "g4ad", sizes: g4adSizes, currentGen: true}, {name: "g5", sizes: g5Sizes, currentGen: true}, diff --git a/spinifex/instancetypes/generate.go b/spinifex/instancetypes/generate.go index 00b39d156..02686aa8d 100644 --- a/spinifex/instancetypes/generate.go +++ b/spinifex/instancetypes/generate.go @@ -113,12 +113,7 @@ func generateSystemTypes(arch string) map[string]*ec2.InstanceTypeInfo { } // GenerateGPUTypes returns InstanceTypeInfo entries for each GPU model with GpuInfo populated. -// Exported for use by the daemon's hot-reload path. func GenerateGPUTypes(models []GPUModel, arch string) map[string]*ec2.InstanceTypeInfo { - return generateGPUTypes(models, arch) -} - -func generateGPUTypes(models []GPUModel, arch string) map[string]*ec2.InstanceTypeInfo { types := make(map[string]*ec2.InstanceTypeInfo) seen := make(map[string]bool) @@ -262,7 +257,7 @@ func DetectAndGenerate(cpu CPUInfo, arch string, gpuModels []GPUModel) map[strin // Merge in GPU instance types if the host has recognized GPUs. if len(gpuModels) > 0 { - maps.Copy(types, generateGPUTypes(gpuModels, arch)) + maps.Copy(types, GenerateGPUTypes(gpuModels, arch)) } if len(types) == 0 { diff --git a/spinifex/instancetypes/generate_test.go b/spinifex/instancetypes/generate_test.go index 8bcd22ed6..fe30deee2 100644 --- a/spinifex/instancetypes/generate_test.go +++ b/spinifex/instancetypes/generate_test.go @@ -423,7 +423,7 @@ func TestGPUModelForVendorDevice_Unknown(t *testing.T) { } func TestGenerateGPUTypes_NVIDIAa10g(t *testing.T) { - types := generateGPUTypes([]GPUModel{NVIDIAa10g}, "x86_64") + types := GenerateGPUTypes([]GPUModel{NVIDIAa10g}, "x86_64") // g5 has 5 single-GPU sizes: xlarge, 2xlarge, 4xlarge, 8xlarge, 16xlarge assert.Len(t, types, 5) @@ -448,17 +448,17 @@ func TestGenerateGPUTypes_NVIDIAa10g(t *testing.T) { func TestGenerateGPUTypes_DeduplicatesSameFamily(t *testing.T) { // Two GPUs of the same model (same family) should produce only one set of types. - types := generateGPUTypes([]GPUModel{NVIDIAa10g, NVIDIAa10g}, "x86_64") + types := GenerateGPUTypes([]GPUModel{NVIDIAa10g, NVIDIAa10g}, "x86_64") assert.Len(t, types, 5, "duplicate GPU model should not double the type count") } func TestGenerateGPUTypes_EmptyModels(t *testing.T) { - types := generateGPUTypes(nil, "x86_64") + types := GenerateGPUTypes(nil, "x86_64") assert.Empty(t, types) } func TestIsGPUType(t *testing.T) { - gpuTypes := generateGPUTypes([]GPUModel{NVIDIAa10g}, "x86_64") + gpuTypes := GenerateGPUTypes([]GPUModel{NVIDIAa10g}, "x86_64") for name, info := range gpuTypes { assert.True(t, IsGPUType(info), "%s should be a GPU type", name) }