@@ -14,6 +14,7 @@ import (
1414 vpc "github.com/nebius/gosdk/proto/nebius/vpc/v1"
1515)
1616
17+ //nolint:gocyclo,funlen // Complex instance creation with resource management
1718func (c * NebiusClient ) CreateInstance (ctx context.Context , attrs v1.CreateInstanceAttrs ) (* v1.Instance , error ) {
1819 // Track created resources for automatic cleanup on failure
1920 var networkID , subnetID , bootDiskID , instanceID string
@@ -198,7 +199,7 @@ func (c *NebiusClient) GetInstance(ctx context.Context, instanceID v1.CloudProvi
198199// This is used by both GetInstance and ListInstances for consistent conversion
199200// projectToRegion is an optional map of project ID to region for determining instance location
200201//
201- //nolint:gocognit // Complex function converting Nebius instance to v1.Instance with many field mappings
202+ //nolint:gocognit,gocyclo,funlen // Complex function converting Nebius instance to v1.Instance with many field mappings
202203func (c * NebiusClient ) convertNebiusInstanceToV1 (ctx context.Context , instance * compute.Instance , projectToRegion map [string ]string ) (* v1.Instance , error ) {
203204 if instance .Metadata == nil || instance .Spec == nil {
204205 return nil , fmt .Errorf ("invalid instance response from Nebius API" )
@@ -369,9 +370,9 @@ func (c *NebiusClient) waitForInstanceRunning(ctx context.Context, instanceID v1
369370 return nil , fmt .Errorf ("timeout waiting for instance to reach RUNNING state after %v" , timeout )
370371 }
371372
372- // Check if context is cancelled
373+ // Check if context is canceled
373374 if ctx .Err () != nil {
374- return nil , fmt .Errorf ("context cancelled while waiting for instance: %w" , ctx .Err ())
375+ return nil , fmt .Errorf ("context canceled while waiting for instance: %w" , ctx .Err ())
375376 }
376377
377378 // Get current instance state
@@ -429,9 +430,9 @@ func (c *NebiusClient) waitForInstanceState(ctx context.Context, instanceID v1.C
429430 return fmt .Errorf ("timeout waiting for instance to reach %s state after %v" , targetState , timeout )
430431 }
431432
432- // Check if context is cancelled
433+ // Check if context is canceled
433434 if ctx .Err () != nil {
434- return fmt .Errorf ("context cancelled while waiting for instance: %w" , ctx .Err ())
435+ return fmt .Errorf ("context canceled while waiting for instance: %w" , ctx .Err ())
435436 }
436437
437438 // Get current instance state
@@ -492,9 +493,9 @@ func (c *NebiusClient) waitForInstanceDeleted(ctx context.Context, instanceID v1
492493 return fmt .Errorf ("timeout waiting for instance to be deleted after %v" , timeout )
493494 }
494495
495- // Check if context is cancelled
496+ // Check if context is canceled
496497 if ctx .Err () != nil {
497- return fmt .Errorf ("context cancelled while waiting for instance deletion: %w" , ctx .Err ())
498+ return fmt .Errorf ("context canceled while waiting for instance deletion: %w" , ctx .Err ())
498499 }
499500
500501 // Try to get the instance
@@ -549,6 +550,8 @@ func stripCIDR(ipWithCIDR string) string {
549550}
550551
551552// extractImageFamily extracts the image family from attached disk spec
553+ //
554+ //nolint:unparam // Reserved for future image metadata extraction
552555func extractImageFamily (bootDisk * compute.AttachedDiskSpec ) string {
553556 if bootDisk == nil {
554557 return ""
@@ -658,7 +661,7 @@ func (c *NebiusClient) deleteInstanceIfExists(ctx context.Context, instanceID v1
658661 return nil
659662}
660663
661- //nolint:gocognit // Complex function listing instances across multiple projects with filtering
664+ //nolint:gocognit,gocyclo,funlen // Complex function listing instances across multiple projects with filtering
662665func (c * NebiusClient ) ListInstances (ctx context.Context , args v1.ListInstancesArgs ) ([]v1.Instance , error ) {
663666 c .logger .Info (ctx , "listing nebius instances" ,
664667 v1 .LogField ("primaryProjectID" , c .projectID ),
@@ -827,6 +830,7 @@ func matchesTagFilters(instanceTags map[string]string, tagFilters map[string][]s
827830 return true
828831}
829832
833+ //nolint:dupl // StopInstance and StartInstance have similar structure but different operations
830834func (c * NebiusClient ) StopInstance (ctx context.Context , instanceID v1.CloudProviderInstanceID ) error {
831835 c .logger .Info (ctx , "initiating instance stop operation" ,
832836 v1 .LogField ("instanceID" , instanceID ))
@@ -864,6 +868,7 @@ func (c *NebiusClient) StopInstance(ctx context.Context, instanceID v1.CloudProv
864868 return nil
865869}
866870
871+ //nolint:dupl // StartInstance and StopInstance have similar structure but different operations
867872func (c * NebiusClient ) StartInstance (ctx context.Context , instanceID v1.CloudProviderInstanceID ) error {
868873 c .logger .Info (ctx , "initiating instance start operation" ,
869874 v1 .LogField ("instanceID" , instanceID ))
@@ -901,27 +906,27 @@ func (c *NebiusClient) StartInstance(ctx context.Context, instanceID v1.CloudPro
901906 return nil
902907}
903908
904- func (c * NebiusClient ) RebootInstance (ctx context.Context , instanceID v1.CloudProviderInstanceID ) error {
909+ func (c * NebiusClient ) RebootInstance (_ context.Context , _ v1.CloudProviderInstanceID ) error {
905910 return fmt .Errorf ("nebius reboot instance implementation pending: %w" , v1 .ErrNotImplemented )
906911}
907912
908- func (c * NebiusClient ) ChangeInstanceType (ctx context.Context , instanceID v1.CloudProviderInstanceID , newInstanceType string ) error {
913+ func (c * NebiusClient ) ChangeInstanceType (_ context.Context , _ v1.CloudProviderInstanceID , _ string ) error {
909914 return fmt .Errorf ("nebius change instance type implementation pending: %w" , v1 .ErrNotImplemented )
910915}
911916
912- func (c * NebiusClient ) UpdateInstanceTags (ctx context.Context , args v1.UpdateInstanceTagsArgs ) error {
917+ func (c * NebiusClient ) UpdateInstanceTags (_ context.Context , _ v1.UpdateInstanceTagsArgs ) error {
913918 return fmt .Errorf ("nebius update instance tags implementation pending: %w" , v1 .ErrNotImplemented )
914919}
915920
916- func (c * NebiusClient ) ResizeInstanceVolume (ctx context.Context , args v1.ResizeInstanceVolumeArgs ) error {
921+ func (c * NebiusClient ) ResizeInstanceVolume (_ context.Context , _ v1.ResizeInstanceVolumeArgs ) error {
917922 return fmt .Errorf ("nebius resize instance volume implementation pending: %w" , v1 .ErrNotImplemented )
918923}
919924
920- func (c * NebiusClient ) AddFirewallRulesToInstance (ctx context.Context , args v1.AddFirewallRulesToInstanceArgs ) error {
925+ func (c * NebiusClient ) AddFirewallRulesToInstance (_ context.Context , _ v1.AddFirewallRulesToInstanceArgs ) error {
921926 return fmt .Errorf ("nebius firewall rules management not yet implemented: %w" , v1 .ErrNotImplemented )
922927}
923928
924- func (c * NebiusClient ) RevokeSecurityGroupRules (ctx context.Context , args v1.RevokeSecurityGroupRuleArgs ) error {
929+ func (c * NebiusClient ) RevokeSecurityGroupRules (_ context.Context , _ v1.RevokeSecurityGroupRuleArgs ) error {
925930 return fmt .Errorf ("nebius security group rules management not yet implemented: %w" , v1 .ErrNotImplemented )
926931}
927932
@@ -1219,7 +1224,7 @@ func (c *NebiusClient) buildDiskCreateRequest(ctx context.Context, diskName stri
12191224
12201225// getWorkingPublicImageID gets a working public image ID based on the requested image type
12211226//
1222- //nolint:gocognit // Complex function trying multiple image resolution strategies
1227+ //nolint:gocognit,gocyclo // Complex function trying multiple image resolution strategies
12231228func (c * NebiusClient ) getWorkingPublicImageID (ctx context.Context , requestedImage string ) (string , error ) {
12241229 // Get available public images from the correct region
12251230 publicImagesParent := c .getPublicImagesParent ()
@@ -1255,6 +1260,7 @@ func (c *NebiusClient) getWorkingPublicImageID(ctx context.Context, requestedIma
12551260 // Look for Ubuntu matches
12561261 if strings .Contains (requestedLower , "ubuntu" ) && strings .Contains (imageName , "ubuntu" ) {
12571262 // Prefer specific version matches
1263+ //nolint:gocritic // if-else chain is clearer than switch for version matching logic
12581264 if strings .Contains (requestedLower , "24.04" ) || strings .Contains (requestedLower , "24" ) {
12591265 if strings .Contains (imageName , "ubuntu24.04" ) {
12601266 bestMatch = image
@@ -1316,7 +1322,7 @@ func (c *NebiusClient) getPublicImagesParent() string {
13161322// nebius-eu-north1-l40s-4gpu-96vcpu-768gb
13171323// nebius-eu-north1-cpu-4vcpu-16gb
13181324//
1319- //nolint:gocognit // Complex function with multiple fallback strategies for parsing instance types
1325+ //nolint:gocognit,gocyclo,funlen // Complex function with multiple fallback strategies for parsing instance types
13201326func (c * NebiusClient ) parseInstanceType (ctx context.Context , instanceTypeID string ) (platform string , preset string , err error ) {
13211327 c .logger .Info (ctx , "parsing instance type" ,
13221328 v1 .LogField ("instanceTypeID" , instanceTypeID ),
@@ -1420,7 +1426,6 @@ func (c *NebiusClient) parseInstanceType(ctx context.Context, instanceTypeID str
14201426 // Match platform by GPU type
14211427 if (gpuType == "cpu" && strings .Contains (platformNameLower , "cpu" )) ||
14221428 (gpuType != "cpu" && strings .Contains (platformNameLower , gpuType )) {
1423-
14241429 // Log ALL available presets for this platform for debugging
14251430 availablePresets := make ([]string , 0 , len (p .Spec .Presets ))
14261431 for _ , preset := range p .Spec .Presets {
@@ -1533,6 +1538,8 @@ func (c *NebiusClient) parseInstanceType(ctx context.Context, instanceTypeID str
15331538// resolveImageFamily resolves an ImageID to an image family name
15341539// If ImageID is already a family name, use it directly
15351540// Otherwise, try to get the image and extract its family
1541+ //
1542+ //nolint:gocyclo,unparam // Complex image family resolution with fallback logic
15361543func (c * NebiusClient ) resolveImageFamily (ctx context.Context , imageID string ) (string , error ) {
15371544 // Common Nebius image families - if ImageID matches one of these, use it directly
15381545 commonFamilies := []string {
@@ -1690,7 +1697,6 @@ func (c *NebiusClient) cleanupOrphanedBootDisks(ctx context.Context, testID stri
16901697 (disk .Metadata .Labels != nil &&
16911698 (disk .Metadata .Labels ["test-id" ] == testID ||
16921699 disk .Metadata .Labels ["created-by" ] == "brev-cloud-sdk" )) {
1693-
16941700 // Delete this orphaned disk
16951701 err := c .deleteBootDisk (ctx , disk .Metadata .Id )
16961702 if err != nil {
0 commit comments