update docs

Signed-off-by: runzexia <runzexia@yunify.com>
This commit is contained in:
runzexia
2019-06-05 15:47:38 +08:00
parent fd530f4c1e
commit 1b3e80519d
5 changed files with 87 additions and 59 deletions

View File

@@ -30,46 +30,45 @@ type JenkinsCredential struct {
Type string `json:"type" description:"type of credential,such as ssh/kubeconfig"`
DisplayName string `json:"display_name,omitempty" description:"credential's display name'"`
Fingerprint *struct {
FileName string `json:"file_name,omitempty"`
Hash string `json:"hash,omitempty"`
FileName string `json:"file_name,omitempty" description:"credential's display name and description"`
Hash string `json:"hash,omitempty" description:"credential's hash'"`
Usage []*struct {
Name string `json:"name,omitempty"`
Name string `json:"name,omitempty" description:"jenkins pipeline full name"`
Ranges struct {
Ranges []*struct {
Start int `json:"start,omitempty"`
End int `json:"end,omitempty"`
Start int `json:"start,omitempty" description:"start build number"`
End int `json:"end,omitempty" description:"end build number"`
} `json:"ranges,omitempty"`
} `json:"ranges,omitempty"`
} `json:"usage,omitempty"`
} `json:"fingerprint,omitempty" description:""`
Description string `json:"description,omitempty"`
Domain string `json:"domain,omitempty"`
CreateTime *time.Time `json:"create_time,omitempty"`
Creator string `json:"creator,omitempty"`
UsernamePasswordCredential *UsernamePasswordCredential `json:"username_password,omitempty"`
SshCredential *SshCredential `json:"ssh,omitempty"`
SecretTextCredential *SecretTextCredential `json:"secret_text,omitempty"`
KubeconfigCredential *KubeconfigCredential `json:"kubeconfig,omitempty"`
} `json:"ranges,omitempty" description:"all build num using credential"`
} `json:"usage,omitempty" description:"all usage of credential"`
} `json:"fingerprint,omitempty" description:"usage of credential"`
Description string `json:"description,omitempty" description:"credential's description'"`
Domain string `json:"domain,omitempty" description:"credential's domain, default '_''"`
CreateTime *time.Time `json:"create_time,omitempty" description:"credential's create_time'"`
Creator string `json:"creator,omitempty" description:"creator's username"`
UsernamePasswordCredential *UsernamePasswordCredential `json:"username_password,omitempty" description:"username password credential struct"`
SshCredential *SshCredential `json:"ssh,omitempty" description:"ssh credential struct"`
SecretTextCredential *SecretTextCredential `json:"secret_text,omitempty" description:"secret_text credential struct"`
KubeconfigCredential *KubeconfigCredential `json:"kubeconfig,omitempty" description:"kubeconfig credential struct"`
}
type UsernamePasswordCredential struct {
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
Username string `json:"username,omitempty" description:"username of username_password credential"`
Password string `json:"password,omitempty" description:"password of username_password credential"`
}
type SshCredential struct {
Username string `json:"username,omitempty"`
Passphrase string `json:"passphrase,omitempty"`
PrivateKey string `json:"private_key,omitempty" mapstructure:"private_key"`
Username string `json:"username,omitempty" description:"username of ssh credential"`
Passphrase string `json:"passphrase,omitempty" description:"passphrase of ssh credential, password of ssh credential"`
PrivateKey string `json:"private_key,omitempty" mapstructure:"private_key" description:"private key of ssh credential"`
}
type SecretTextCredential struct {
Secret string `json:"secret,omitempty"`
Description string `json:"description,omitempty"`
Secret string `json:"secret,omitempty" description:"secret content of credential"`
}
type KubeconfigCredential struct {
Content string `json:"content,omitempty"`
Content string `json:"content,omitempty" description:"content of kubeconfig"`
}
const (

View File

@@ -205,7 +205,7 @@ func UpdateProjectCredential(projectId, credentialId string, credentialRequest *
credentialId, err := jenkinsClient.UpdateSecretTextCredentialInFolder(credentialRequest.Domain,
credentialId,
credentialRequest.SecretTextCredential.Secret,
credentialRequest.SecretTextCredential.Description,
credentialRequest.Description,
projectId)
if err != nil {
glog.Errorf("%+v", err)
@@ -421,17 +421,17 @@ func formatCredentialResponse(
response.DisplayName = jenkinsCredentialResponse.DisplayName
if jenkinsCredentialResponse.Fingerprint != nil && jenkinsCredentialResponse.Fingerprint.Hash != "" {
response.Fingerprint = &struct {
FileName string `json:"file_name,omitempty"`
Hash string `json:"hash,omitempty"`
FileName string `json:"file_name,omitempty" description:"credential's display name and description"`
Hash string `json:"hash,omitempty" description:"credential's hash'"`
Usage []*struct {
Name string `json:"name,omitempty"`
Name string `json:"name,omitempty" description:"jenkins pipeline full name"`
Ranges struct {
Ranges []*struct {
Start int `json:"start,omitempty"`
End int `json:"end,omitempty"`
Start int `json:"start,omitempty" description:"start build number"`
End int `json:"end,omitempty" description:"end build number"`
} `json:"ranges,omitempty"`
} `json:"ranges,omitempty"`
} `json:"usage,omitempty"`
} `json:"ranges,omitempty" description:"all build num using credential"`
} `json:"usage,omitempty" description:"all usage of credential"`
}{}
response.Fingerprint.FileName = jenkinsCredentialResponse.Fingerprint.FileName
response.Fingerprint.Hash = jenkinsCredentialResponse.Fingerprint.Hash