-
Notifications
You must be signed in to change notification settings - Fork 920
Description
Bug Report
I never get any results from NewListPager when trying to list task runs via TaskRunsClient
. I've tried using versions 1.0.0-1.3.0-beta.2 and it doesn't seem to make a difference. The example doesn't seem to work either (after replacing "<subscription-id>"
, "myResourceGroup"
, and "myRegistry"
). Here's a minimal example that shows the problem (alternatively you could replace the values and run the link above).
package main
import (
"context"
"fmt"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistry"
)
var (
subscriptionID = "<subscription-id>"
resourceGroup = "<resource-group>"
registryName = "<registry>"
)
func main() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatal("Couldn't create credential\n")
}
containerRegistryClientFactory, err := armcontainerregistry.NewClientFactory(subscriptionID, cred, nil)
if err != nil {
log.Fatal(err)
}
taskRunsClient := containerRegistryClientFactory.NewTaskRunsClient()
taskRunsPager := taskRunsClient.NewListPager(resourceGroup, registryName, nil)
for taskRunsPager.More() {
fmt.Println("More")
page, err := taskRunsPager.NextPage(context.Background())
if err != nil {
log.Fatal(err)
}
j, err := page.MarshalJSON()
fmt.Println(string(j))
for _, taskRun := range page.Value {
fmt.Println("TaskRun")
fmt.Printf("%s: %s\n", *taskRun.Name, *taskRun.Properties.RunResult.Name)
}
}
}
This yields
More
{"value":[]}
even though this registry definitely has task runs in it's history. This is confirmed by using the azure-cli
: az acr task list-runs -r <registry> --subscription <subscription-id>
If there were an error I'd expect to hit one of the error conditions.
We can tell that it's at least connecting to the registry because changing the the registry
name to a name that doesn't exist yields an error.
module path:
sdk/resourcemanager/containerregistry/armcontainerregistry
go version:
go version go1.22.7 linux/amd64