func (ai *TCRAPIClient) GetAllNamespaceByName(secret map[string]configs.Secret,
	region string, tcrName string) ([]string, string, error) {
	var nsList []string
	var tcrID string
	secretID, secretKey, err := GetTcrSecret(secret)
	if err != nil {
		log.Errorf("GetTcrSecret error: ", err)
		return nsList, tcrID, err
	}
	filterValues := []string{tcrName}
	resp, err := ai.DescribeInstances(secretID, secretKey, region, 0, 100, "RegistryName", filterValues)
	if err != nil {
		log.Errorf("DescribeInstances error, ", err)
		return nsList, tcrID, err
	}
	tcrID = *resp.Response.Registries[0].RegistryId
	offset := int64(1)
	count := 0
	limit := int64(100)
	for {
		resp, err := ai.DescribeNamespaces(secretID, secretKey, region, offset, limit, tcrID)
		if err != nil {
			log.Errorf("DescribeNamespaces error, ", err)
			return nsList, tcrID, err
		}
		log.Debugf("tcr namespace offset %d limit %d resp is %s", offset, limit, resp.ToJsonString())
		namespaceCount := *resp.Response.TotalCount
		count += len(resp.Response.NamespaceList)
		for _, ns := range resp.Response.NamespaceList {
			nsList = append(nsList, *ns.Name)
		}
		if int64(count) >= namespaceCount {
			break
		} else {
			offset += 1
		}
	}
	return nsList, tcrID, nil
}
GetAllNamespaceByName get all ns from tcr name
package tcrapis
import (
	"errors"
	"net/http"
	"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
	"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
	tcr "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tcr/v20190924"
	"tkestack.io/image-transfer/configs"
	"tkestack.io/image-transfer/pkg/log"
)
type TCRAPIClient struct {
	httpClient *http.Client
	url        string
}
func NewTCRAPIClient() *TCRAPIClient {
	httpclient := http.Client{}
	ai := TCRAPIClient{httpClient: &httpclient}
	return &ai
}