Documentation ¶
Overview ¶
Copyright © 2022 John, Sing Dao, Siu <john.sd.siu@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Index ¶
- Constants
- type GitApi
- func (self *GitApi) Del() *GitApi
- func (self *GitApi) Do() *GitApi
- func (self *GitApi) EndpointRepos() *GitApi
- func (self *GitApi) EndpointReposSecrets() *GitApi
- func (self *GitApi) EndpointReposSecretsPubkey() *GitApi
- func (self *GitApi) EndpointReposTopics() *GitApi
- func (self *GitApi) EndpointUserRepos() *GitApi
- func (self *GitApi) Get() *GitApi
- func (self *GitApi) HeaderGithub() *GitApi
- func (self *GitApi) HeaderInit() *GitApi
- func (self *GitApi) Patch() *GitApi
- func (self *GitApi) Post() *GitApi
- func (self *GitApi) ProcessOutput() *GitApi
- func (self *GitApi) Put() *GitApi
- type GitApiInfo
- type GitApiReq
- type GitApiRes
- type NilType
- type RepoDescription
- type RepoEncryptedPair
- type RepoInfo
- type RepoInfoList
- type RepoPrivate
- type RepoPublicKey
- type RepoTopics
- type RepoVisibility
Constants ¶
const ( Vendor_Github = "github" Vendor_Gitea = "gitea" Vendor_Gogs = "gogs" )
GitApi supperted vendors
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GitApi ¶
type GitApi struct { Req GitApiReq `json:"In"` // Api http input Res GitApiRes `json:"Out"` // Api http output Name string `json:"Name"` // Name of connection User string `json:"User"` // Api username Vendor string `json:"Vendor"` // github/gitea SkipVerify bool `json:"skipverify"` // Api request skip cert verify (allow self-signed cert) Repo string `json:"Repo"` // Repository name Info GitApiInfo `json:"Info"` // Pointer to structure. Use NilType.Nil() for nil pointer }
GitApi
func GitApiNew ¶
func GitApiNew( name string, token string, entrypoint string, user string, vendor string, skipverify bool, repo string, info GitApiInfo) *GitApi
Setup a *GitApi
func (*GitApi) Do ¶
Execute http request using info in GitApi.Req. Then put response info in GitApi.Res.
GitApi.Info, if not nil, will be - auto marshal for send other than "GET" - auto unmarshal from http response body
func (*GitApi) EndpointRepos ¶
Initialize endpoint /repos/OWNER/REPO
Use current directory if GitApi.Repo is empty
func (*GitApi) EndpointReposSecrets ¶
Initialize endpoint /repos/OWNER/REPO/actions/secrets
func (*GitApi) EndpointReposSecretsPubkey ¶
Initialize endpoint /repos/OWNER/REPO/actions/secrets/public-key
func (*GitApi) EndpointReposTopics ¶
Initialize endpoint /repos/OWNER/REPO/topics
func (*GitApi) EndpointUserRepos ¶
Initialize endpoint /user/repos
func (*GitApi) HeaderGithub ¶ added in v1.2.0
Set github/gitea header
GitApi.Req.Token, if empty, authorization header will not be set.
func (*GitApi) HeaderInit ¶ added in v1.2.5
Setup empty API header
func (*GitApi) ProcessOutput ¶ added in v1.1.0
Print both Body and Err into string pointer
type GitApiInfo ¶
type GitApiInfo interface { // *RepoEncryptedPair | // *RepoPublicKey | // *RepoPrivate | // *RepoVisibility | // *RepoDescription | // *RepoTopics | // *RepoInfo | // *RepoInfoList | // *NilType StringP() *string String() string }
GitApi structures interface
type GitApiReq ¶ added in v1.3.0
type GitApiReq struct { Data string `json:"Data"` // Json marshaled Info Entrypoint string `json:"Entrypoint"` // Api base url Endpoint string `json:"Endpoint"` // Api endpoint Header *http.Header `json:"Header"` // Http request header Method string `json:"Method"` // Http request method Token string `json:"Token"` // Api auth token UrlVal *url.Values `json:"UrlVal"` // Api url values }
GitApi http input structure
func (*GitApiReq) UrlValInit ¶ added in v1.3.0
func (self *GitApiReq) UrlValInit()
Setup empty API url values
type GitApiRes ¶ added in v1.3.0
type GitApiRes struct { Body *[]byte `json:"Body"` Err string `json:"Err"` Header *http.Header `json:"Header"` // Http response header Url *url.URL `json:"Url"` // In.Uri + In.Endpoint Output *string `json:"Output"` // Api response body in string Status string `json:"Status"` // Http response status }
GitApi http output structure
type NilType ¶
type NilType struct {
Nil *byte // Dummy pointer
}
This is used as a dummy type for nil GitApiInfo parameter
type RepoDescription ¶
type RepoDescription struct {
Description string `json:"description"`
}
Github repository description structure
func (*RepoDescription) String ¶
func (self *RepoDescription) String() string
func (*RepoDescription) StringP ¶
func (self *RepoDescription) StringP() *string
type RepoEncryptedPair ¶
type RepoEncryptedPair struct { Encrypted_value string `json:"encrypted_value"` // Encrypted value Key_id string `json:"key_id"` // Public key id }
Github repository action secret structure
func (*RepoEncryptedPair) String ¶
func (self *RepoEncryptedPair) String() string
func (*RepoEncryptedPair) StringP ¶
func (self *RepoEncryptedPair) StringP() *string
type RepoInfoList ¶
type RepoInfoList []RepoInfo
Github repository(creation) info array
func (*RepoInfoList) String ¶
func (self *RepoInfoList) String() string
func (*RepoInfoList) StringP ¶
func (self *RepoInfoList) StringP() *string
type RepoPrivate ¶
type RepoPrivate struct {
Private bool `json:"private"`
}
Github repository private structure
func (*RepoPrivate) String ¶
func (self *RepoPrivate) String() string
func (*RepoPrivate) StringP ¶
func (self *RepoPrivate) StringP() *string
type RepoPublicKey ¶
Github repository public key structure
func (*RepoPublicKey) String ¶
func (self *RepoPublicKey) String() string
func (*RepoPublicKey) StringP ¶
func (self *RepoPublicKey) StringP() *string
type RepoTopics ¶
type RepoTopics struct { Topics *[]string `json:"topics"` // Github topics is "Topics" Names *[]string `json:"names"` // Gitea topics is "Names" }
Github repository topics structure
func (*RepoTopics) String ¶
func (self *RepoTopics) String() string
func (*RepoTopics) StringP ¶
func (self *RepoTopics) StringP() *string
type RepoVisibility ¶
type RepoVisibility struct {
Visibility string `json:"visibility"`
}
Github repository visibility structure
func (*RepoVisibility) String ¶
func (self *RepoVisibility) String() string
func (*RepoVisibility) StringP ¶
func (self *RepoVisibility) StringP() *string