You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I try to list immutable rules of a project with ListImmuRules method, it returns a 401 error.
I use the admin account and everything works on projects, repositories, artifacts and labels.
Here is my code :
package main
import (
"context""fmt""strings""github.com/goharbor/go-client/pkg/harbor""github.com/goharbor/go-client/pkg/sdk/v2.0/client/artifact""github.com/goharbor/go-client/pkg/sdk/v2.0/client/immutable""github.com/goharbor/go-client/pkg/sdk/v2.0/client/label""github.com/goharbor/go-client/pkg/sdk/v2.0/client/project""github.com/goharbor/go-client/pkg/sdk/v2.0/client/repository"
)
funcmain() {
// Create a new REST client for the Harbor APIcs, _:=harbor.NewClientSet(&harbor.ClientSetConfig{
URL: "https://registry-docker.staging.eul.sncf.fr/api/v2.0",
Password: "admin",
Username: "NQs2rE9UNMGLafJ8m7rAZF6Rnf3gR8NPDwL1IKpjbChj1EWKVM",
Insecure: false,
})
h:=cs.V2()
// Get all labelsscope:="g"labels, err:=h.Label.ListLabels(context.Background(), &label.ListLabelsParams{Scope: &scope})
iferr!=nil {
fmt.Println(err)
return
}
fmt.Println("Labels:", labels.GetPayload())
// Get all projectsprojects, err:=h.Project.ListProjects(context.Background(), &project.ListProjectsParams{})
iferr!=nil {
fmt.Println(err)
return
}
fmt.Println("Projects:", projects.GetPayload())
for_, project:=rangeprojects.GetPayload() {
// Get all repositories in the projectrepositories, err:=h.Repository.ListRepositories(context.Background(), &repository.ListRepositoriesParams{ProjectName: project.Name})
iferr!=nil {
fmt.Println(err)
return
}
fmt.Println("Repositories:", repositories.GetPayload())
for_, repository:=rangerepositories.GetPayload() {
// Get all artifacts in the repositoryartifacts, err:=h.Artifact.ListArtifacts(context.Background(), &artifact.ListArtifactsParams{ProjectName: project.Name, RepositoryName: strings.Join(strings.Split(repository.Name, "/")[1:], "/")})
iferr!=nil {
fmt.Println(err)
return
}
fmt.Println("Artifacts:", artifacts.GetPayload())
}
// Get all immutable rules in the projectimmutableRules, err:=h.Immutable.ListImmuRules(context.Background(), &immutable.ListImmuRulesParams{ProjectNameOrID: project.Name})
iferr!=nil {
fmt.Println(err)
return
}
fmt.Println("Immutable rules:", immutableRules.GetPayload())
}
}
Everything works until the ListImmuRules method : [GET /projects/{project_name_or_id}/immutabletagrules][401] listImmuRulesUnauthorized &{Errors:[0xc000224220]}
The text was updated successfully, but these errors were encountered:
Hi,
When I try to list immutable rules of a project with ListImmuRules method, it returns a 401 error.
I use the admin account and everything works on projects, repositories, artifacts and labels.
Here is my code :
Everything works until the ListImmuRules method :
[GET /projects/{project_name_or_id}/immutabletagrules][401] listImmuRulesUnauthorized &{Errors:[0xc000224220]}
The text was updated successfully, but these errors were encountered: