func fetchAndStoreResourceURL(ctx context.Context, url string) error {
	data, err := armclient.DoRequest(ctx, "GET", url)
	if err != nil {
		panic(err)
	}
	var resourceResponse armclient.SubResourcesResponse
	err = json.Unmarshal([]byte(data), &resourceResponse)
	if err != nil {
		return err
	}
	resourcesToStore := make([]storage.Resource, 0, len(resourceResponse.Resources))
	for _, r := range resourceResponse.Resources {
		resourcesToStore = append(resourcesToStore, storage.Resource{
			ID:   r.ID,
			Name: r.Name,
		})
	}
	if len(resourcesToStore) == 0 {
		return nil
	}
	err = storage.PutResourceBatch(url, resourcesToStore)
	if err != nil {
		return err
	}

	if resourceResponse.NextLink != "" {
		// Next links are fully formed, including 'https://management.azure.com/'
		// we don't want this so we strip that out
		return fetchAndStoreResourceURL(ctx, strings.Replace(resourceResponse.NextLink, "https://management.azure.com", "", 1))
	}
	return nil
}
// fetchAndStoreURL takes a link to a page of '/resources'
// and stores the resulting batch into a bucket in boltdb
fetchAndStoreURL takes a link to a page of '/resources'
and stores the resulting batch into a bucket in boltdb
// fetchAndStoreURL takes a link to a page of ' / resources ' // and stores the resulting batch into a bucket in boltdb
func fetchAndStoreResourceURL(ctx context.Context, url string) error {
	data, err := armclient.DoRequest(ctx, "GET", url)
	if err != nil {
		panic(err)
	}
	var resourceResponse armclient.SubResourcesResponse
	err = json.Unmarshal([]byte(data), &resourceResponse)
	if err != nil {
		return err
	}
	resourcesToStore := make([]storage.Resource, 0, len(resourceResponse.Resources))
	for _, r := range resourceResponse.Resources {
		resourcesToStore = append(resourcesToStore, storage.Resource{
			ID:   r.ID,
			Name: r.Name,
		})
	}
	if len(resourcesToStore) == 0 {
		return nil
	}
	err = storage.PutResourceBatch(url, resourcesToStore)
	if err != nil {
		return err
	}
	if resourceResponse.NextLink != "" {
		return fetchAndStoreResourceURL(ctx, strings.Replace(resourceResponse.NextLink, "https://management.azure.com", "", 1))
	}
	return nil
}
func fetchAndStoreResourceURL ( ctx context . Context , url string ) error { data , err := armclient . DoRequest ( ctx , " " , url ) if err != nil { panic ( err ) } var resourceResponse armclient . SubResourcesResponse err = json . Unmarshal ( [ ] byte ( data ) , & resourceResponse ) if err != nil { return err } resourcesToStore := make ( [ ] storage . Resource , 0 , len ( resourceResponse . Resources ) ) for _ , r := range resourceResponse . Resources { resourcesToStore = append ( resourcesToStore , storage . Resource { ID : r . ID , Name : r . Name , } ) } if len ( resourcesToStore ) == 0 { return nil } err = storage . PutResourceBatch ( url , resourcesToStore ) if err != nil { return err } if resourceResponse . NextLink != " " { return fetchAndStoreResourceURL ( ctx , strings . Replace ( resourceResponse . NextLink , " " , " " , 1 ) ) } return nil }
fetchAndStoreURL takes a link to a page of '/resources'
and stores the resulting batch into a bucket in boltdb
fetchAndStoreURL takes a link to a page of ' / resources ' and stores the resulting batch into a bucket in boltdb
// Next links are fully formed, including 'https://management.azure.com/' // we don't want this so we strip that out