Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.

Fix AzureUniqueID when VMSS is used #2126

Merged
merged 1 commit into from
Mar 2, 2022
Merged

Fix AzureUniqueID when VMSS is used #2126

merged 1 commit into from
Mar 2, 2022

Conversation

dloucasfx
Copy link
Contributor

The AzureUniqueID has been using the wrong strings function TrimLeft to find out the instanceID, instead we should stick to TrimPrefix

fmt.Println("using TrimLeft: ", strings.TrimLeft("PDAPI290_0", "PDAPI290_"))
fmt.Println("using TrimPrefix: ", strings.TrimPrefix("PDAPI290_0", "PDAPI290_"))

Result:

using TrimLeft:  
using TrimPrefix:  0

Little bit more description: TrimLeft removes the leading characters of a string that matches the cutset.
In other words, it iterates through the string one character at a time, from left to right and checks if the character exists in the cutset (regardless of order), once it fails to find a char in the cutset it returns the index which is used to slice the string.
Problem in the example I showed, when all character of the string exists in the cutset.

Signed-off-by: Dani Louca [email protected]

Copy link
Contributor

@mstumpfx mstumpfx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👁️ 👄 👁️
Good find.

@dloucasfx dloucasfx merged commit 408f641 into main Mar 2, 2022
@atoulme atoulme deleted the SWAT-4199 branch December 6, 2022 23:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants