github.com/mponton/terratest@v0.44.0/modules/azure/resourceid.go (about)

     1  package azure
     2  
     3  import "github.com/mponton/terratest/modules/collections"
     4  
     5  // GetNameFromResourceID gets the Name from an Azure Resource ID.
     6  func GetNameFromResourceID(resourceID string) string {
     7  	id, err := GetNameFromResourceIDE(resourceID)
     8  	if err != nil {
     9  		return ""
    10  	}
    11  	return id
    12  }
    13  
    14  // GetNameFromResourceIDE gets the Name from an Azure Resource ID.
    15  // This function would fail the test if there is an error.
    16  func GetNameFromResourceIDE(resourceID string) (string, error) {
    17  	id, err := collections.GetSliceLastValueE(resourceID, "/")
    18  	if err != nil {
    19  		return "", err
    20  	}
    21  	return id, nil
    22  }