forked from kubev2v/forklift
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sanitize datastore identifiers from ESXi providers
when we get datastores from the ESXi SDK, their identifier may be in the form of '10.11.12.13:/vol/virtv2v/function' which leads to invalid endpoints in the inventory so we sanitize such identifiers Signed-off-by: Arik Hadas <[email protected]>
- Loading branch information
Showing
4 changed files
with
34 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package vsphere | ||
|
||
import ( | ||
"crypto/md5" | ||
"encoding/hex" | ||
"net/url" | ||
) | ||
|
||
func sanitize(datastoreId string) (sanitizedId string, changed bool) { | ||
sanitizedId = url.PathEscape(datastoreId) | ||
if sanitizedId != datastoreId { | ||
sum := md5.Sum([]byte(datastoreId)) | ||
sanitizedId = hex.EncodeToString(sum[:]) | ||
changed = true | ||
} | ||
return | ||
} |