File: registry.go

package info (click to toggle)
golang-github-denverdino-aliyungo 0.0~git20180921.13fa8aa-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,824 kB
  • sloc: xml: 1,359; makefile: 3
file content (40 lines) | stat: -rw-r--r-- 1,133 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package cs

import (
	"net/http"
)

const (
	CRDefaultEndpoint = "https://cr.cn-hangzhou.aliyuncs.com"
	CRAPIVersion      = "2016-06-07"
)

func NewCRClientWithSecurityToken(region, accessKeyId, accessKeySecret, securityToken string) *Client {
	return &Client{
		AccessKeyId:     accessKeyId,
		AccessKeySecret: accessKeySecret,
		SecurityToken:   securityToken,
		endpoint:        "https://cr." + region + ".aliyuncs.com",
		Version:         CRAPIVersion,
		httpClient:      &http.Client{},
	}
}

type CRAuthorizationToken struct {
	Data struct {
		AuthorizationToken string `json:"authorizationToken"`
		TempUserName       string `json:"tempUserName"`
		ExpireDate         int64  `json:"expireDate"`
	} `json:"data"`
	RequestId string `json:"requestId"`
}

func (client *Client) GetCRAuthorizationToken() (crtoken CRAuthorizationToken, err error) {
	err = client.Invoke("", http.MethodGet, "/tokens", nil, nil, &crtoken)
	return
}

func (client *Client) GetCRRepoInfo(repoNamespace, repoName string) (str string, err error) {
	err = client.Invoke("", http.MethodGet, "/repos/"+repoNamespace+"/"+repoName, nil, nil, &str)
	return
}