✨ 使用 log 替换 fmt
This commit is contained in:
parent
596d9c01e0
commit
2b85630271
|
@ -1,11 +1,11 @@
|
||||||
package access_requests
|
package access_requests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
"github.com/xanzy/go-gitlab"
|
"github.com/xanzy/go-gitlab"
|
||||||
"github.com/xuxiaowei-com-cn/gitlab-go/constant"
|
"github.com/xuxiaowei-com-cn/gitlab-go/constant"
|
||||||
"github.com/xuxiaowei-com-cn/gitlab-go/flag"
|
"github.com/xuxiaowei-com-cn/gitlab-go/flag"
|
||||||
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AccessRequests 群组和项目访问请求 API https://docs.gitlab.cn/jh/api/access_requests.html
|
// AccessRequests 群组和项目访问请求 API https://docs.gitlab.cn/jh/api/access_requests.html
|
||||||
|
@ -33,13 +33,13 @@ func AccessRequests() *cli.Command {
|
||||||
|
|
||||||
opt := &gitlab.ListAccessRequestsOptions{}
|
opt := &gitlab.ListAccessRequestsOptions{}
|
||||||
accessRequests, response, err := gitClient.AccessRequests.ListGroupAccessRequests(id, opt)
|
accessRequests, response, err := gitClient.AccessRequests.ListGroupAccessRequests(id, opt)
|
||||||
fmt.Printf("Response StatusCode: %d\n", response.Response.StatusCode)
|
log.Printf("Response StatusCode: %d\n", response.Response.StatusCode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for index, accessRequest := range accessRequests {
|
for index, accessRequest := range accessRequests {
|
||||||
fmt.Printf("Index: %d,\t ID: %d,\t Username: %s,\t Name: %s,\t State: %s,\t CreatedAt: %s,\t RequestedAt: %s,\t AccessLevel: %d\n", index, accessRequest.ID, accessRequest.Username, accessRequest.Name, accessRequest.State, accessRequest.CreatedAt, accessRequest.RequestedAt, accessRequest.AccessLevel)
|
log.Printf("Index: %d,\t ID: %d,\t Username: %s,\t Name: %s,\t State: %s,\t CreatedAt: %s,\t RequestedAt: %s,\t AccessLevel: %d\n", index, accessRequest.ID, accessRequest.Username, accessRequest.Name, accessRequest.State, accessRequest.CreatedAt, accessRequest.RequestedAt, accessRequest.AccessLevel)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -62,13 +62,13 @@ func AccessRequests() *cli.Command {
|
||||||
|
|
||||||
opt := &gitlab.ListAccessRequestsOptions{}
|
opt := &gitlab.ListAccessRequestsOptions{}
|
||||||
accessRequests, response, err := gitClient.AccessRequests.ListProjectAccessRequests(id, opt)
|
accessRequests, response, err := gitClient.AccessRequests.ListProjectAccessRequests(id, opt)
|
||||||
fmt.Printf("Response StatusCode: %d\n", response.Response.StatusCode)
|
log.Printf("Response StatusCode: %d\n", response.Response.StatusCode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for index, accessRequest := range accessRequests {
|
for index, accessRequest := range accessRequests {
|
||||||
fmt.Printf("Index: %d,\t ID: %d,\t Username: %s,\t Name: %s,\t State: %s,\t CreatedAt: %s,\t RequestedAt: %s,\t AccessLevel: %d\n", index, accessRequest.ID, accessRequest.Username, accessRequest.Name, accessRequest.State, accessRequest.CreatedAt, accessRequest.RequestedAt, accessRequest.AccessLevel)
|
log.Printf("Index: %d,\t ID: %d,\t Username: %s,\t Name: %s,\t State: %s,\t CreatedAt: %s,\t RequestedAt: %s,\t AccessLevel: %d\n", index, accessRequest.ID, accessRequest.Username, accessRequest.Name, accessRequest.State, accessRequest.CreatedAt, accessRequest.RequestedAt, accessRequest.AccessLevel)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package instance_level_ci_variables
|
package instance_level_ci_variables
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
"github.com/xanzy/go-gitlab"
|
"github.com/xanzy/go-gitlab"
|
||||||
"github.com/xuxiaowei-com-cn/gitlab-go/constant"
|
"github.com/xuxiaowei-com-cn/gitlab-go/constant"
|
||||||
"github.com/xuxiaowei-com-cn/gitlab-go/flag"
|
"github.com/xuxiaowei-com-cn/gitlab-go/flag"
|
||||||
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// InstanceLevelCiVariables 实例级 CI/CD 变量 API https://docs.gitlab.cn/jh/api/instance_level_ci_variables.html
|
// InstanceLevelCiVariables 实例级 CI/CD 变量 API https://docs.gitlab.cn/jh/api/instance_level_ci_variables.html
|
||||||
|
@ -31,13 +31,13 @@ func InstanceLevelCiVariables() *cli.Command {
|
||||||
|
|
||||||
opt := &gitlab.ListInstanceVariablesOptions{}
|
opt := &gitlab.ListInstanceVariablesOptions{}
|
||||||
variables, response, err := gitClient.InstanceVariables.ListVariables(opt)
|
variables, response, err := gitClient.InstanceVariables.ListVariables(opt)
|
||||||
fmt.Printf("Response StatusCode: %d\n", response.Response.StatusCode)
|
log.Printf("Response StatusCode: %d\n", response.Response.StatusCode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for index, variable := range variables {
|
for index, variable := range variables {
|
||||||
fmt.Printf("Index: %d,\t Key: %s,\t Value: %s,\t VariableType: %s,\t Protected: %t,\t Masked: %t,\t Raw: %t\n", index, variable.Key, variable.Value, variable.VariableType, variable.Protected, variable.Masked, variable.Raw)
|
log.Printf("Index: %d,\t Key: %s,\t Value: %s,\t VariableType: %s,\t Protected: %t,\t Masked: %t,\t Raw: %t\n", index, variable.Key, variable.Value, variable.VariableType, variable.Protected, variable.Masked, variable.Raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"github.com/xanzy/go-gitlab"
|
"github.com/xanzy/go-gitlab"
|
||||||
"github.com/xuxiaowei-com-cn/gitlab-go/constant"
|
"github.com/xuxiaowei-com-cn/gitlab-go/constant"
|
||||||
"github.com/xuxiaowei-com-cn/gitlab-go/flag"
|
"github.com/xuxiaowei-com-cn/gitlab-go/flag"
|
||||||
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// JobsArtifacts 作业产物 API https://docs.gitlab.cn/jh/api/job_artifacts.html
|
// JobsArtifacts 作业产物 API https://docs.gitlab.cn/jh/api/job_artifacts.html
|
||||||
|
@ -21,7 +22,7 @@ func JobsArtifacts() *cli.Command {
|
||||||
Usage: "获取作业产物(未完成)",
|
Usage: "获取作业产物(未完成)",
|
||||||
Flags: append(flag.Common(), flag.Id(true), flag.JobId(false)),
|
Flags: append(flag.Common(), flag.Id(true), flag.JobId(false)),
|
||||||
Action: func(context *cli.Context) error {
|
Action: func(context *cli.Context) error {
|
||||||
fmt.Println("获取作业产物")
|
log.Printf("获取作业产物")
|
||||||
|
|
||||||
return fmt.Errorf("未完成")
|
return fmt.Errorf("未完成")
|
||||||
},
|
},
|
||||||
|
@ -53,9 +54,9 @@ func JobsArtifacts() *cli.Command {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("Delete ProjectId: %s, JobId: %d Artifacts\n", id, jobId)
|
log.Printf("Delete ProjectId: %s, JobId: %d Artifacts\n", id, jobId)
|
||||||
response, err := gitClient.Jobs.DeleteArtifacts(id, jobId)
|
response, err := gitClient.Jobs.DeleteArtifacts(id, jobId)
|
||||||
fmt.Printf("Response StatusCode: %d\n", response.Response.StatusCode)
|
log.Printf("Response StatusCode: %d\n", response.Response.StatusCode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -78,9 +79,9 @@ func JobsArtifacts() *cli.Command {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("Delete ProjectId: %s Artifacts\n", id)
|
log.Printf("Delete ProjectId: %s Artifacts\n", id)
|
||||||
response, err := gitClient.Jobs.DeleteProjectArtifacts(id)
|
response, err := gitClient.Jobs.DeleteProjectArtifacts(id)
|
||||||
fmt.Printf("Response StatusCode: %d\n", response.Response.StatusCode)
|
log.Printf("Response StatusCode: %d\n", response.Response.StatusCode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package jobs
|
package jobs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
"github.com/xanzy/go-gitlab"
|
"github.com/xanzy/go-gitlab"
|
||||||
"github.com/xuxiaowei-com-cn/gitlab-go/constant"
|
"github.com/xuxiaowei-com-cn/gitlab-go/constant"
|
||||||
"github.com/xuxiaowei-com-cn/gitlab-go/flag"
|
"github.com/xuxiaowei-com-cn/gitlab-go/flag"
|
||||||
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Jobs 作业 API https://docs.gitlab.cn/jh/api/jobs.html
|
// Jobs 作业 API https://docs.gitlab.cn/jh/api/jobs.html
|
||||||
|
@ -32,13 +32,13 @@ func Jobs() *cli.Command {
|
||||||
|
|
||||||
opt := &gitlab.ListJobsOptions{}
|
opt := &gitlab.ListJobsOptions{}
|
||||||
jobs, response, err := gitClient.Jobs.ListProjectJobs(id, opt)
|
jobs, response, err := gitClient.Jobs.ListProjectJobs(id, opt)
|
||||||
fmt.Printf("Response StatusCode: %d\n", response.Response.StatusCode)
|
log.Printf("Response StatusCode: %d\n", response.Response.StatusCode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for index, job := range jobs {
|
for index, job := range jobs {
|
||||||
fmt.Printf("Index: %d,\t ID: %d,\t Name: %s,\t ProjectID: %d,\t Status: %s,\t CreatedAt: %s\n", index, job.ID, job.Name, job.Project.ID, job.Status, job.CreatedAt)
|
log.Printf("Index: %d,\t ID: %d,\t Name: %s,\t ProjectID: %d,\t Status: %s,\t CreatedAt: %s\n", index, job.ID, job.Name, job.Project.ID, job.Status, job.CreatedAt)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package pipelines
|
package pipelines
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
"github.com/xanzy/go-gitlab"
|
"github.com/xanzy/go-gitlab"
|
||||||
"github.com/xuxiaowei-com-cn/gitlab-go/constant"
|
"github.com/xuxiaowei-com-cn/gitlab-go/constant"
|
||||||
"github.com/xuxiaowei-com-cn/gitlab-go/flag"
|
"github.com/xuxiaowei-com-cn/gitlab-go/flag"
|
||||||
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Pipelines 流水线 API https://docs.gitlab.cn/jh/api/pipelines.html
|
// Pipelines 流水线 API https://docs.gitlab.cn/jh/api/pipelines.html
|
||||||
|
@ -35,13 +35,13 @@ func Pipelines() *cli.Command {
|
||||||
Sort: &sort,
|
Sort: &sort,
|
||||||
}
|
}
|
||||||
PipelineInfos, response, err := gitClient.Pipelines.ListProjectPipelines(id, opt)
|
PipelineInfos, response, err := gitClient.Pipelines.ListProjectPipelines(id, opt)
|
||||||
fmt.Printf("Response StatusCode: %d\n", response.Response.StatusCode)
|
log.Printf("Response StatusCode: %d\n", response.Response.StatusCode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for index, pipelineInfo := range PipelineInfos {
|
for index, pipelineInfo := range PipelineInfos {
|
||||||
fmt.Printf("Index: %d,\t ID: %d,\t IID: %d,\t ProjectID: %d,\t Status: %s,\t CreatedAt: %s\n", index, pipelineInfo.ID, pipelineInfo.IID, pipelineInfo.ProjectID, pipelineInfo.Status, pipelineInfo.CreatedAt)
|
log.Printf("Index: %d,\t ID: %d,\t IID: %d,\t ProjectID: %d,\t Status: %s,\t CreatedAt: %s\n", index, pipelineInfo.ID, pipelineInfo.IID, pipelineInfo.ProjectID, pipelineInfo.Status, pipelineInfo.CreatedAt)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package projects
|
package projects
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
"github.com/xanzy/go-gitlab"
|
"github.com/xanzy/go-gitlab"
|
||||||
"github.com/xuxiaowei-com-cn/gitlab-go/constant"
|
"github.com/xuxiaowei-com-cn/gitlab-go/constant"
|
||||||
"github.com/xuxiaowei-com-cn/gitlab-go/flag"
|
"github.com/xuxiaowei-com-cn/gitlab-go/flag"
|
||||||
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Projects 项目 API https://docs.gitlab.cn/jh/api/projects.html
|
// Projects 项目 API https://docs.gitlab.cn/jh/api/projects.html
|
||||||
|
@ -34,13 +34,13 @@ func Projects() *cli.Command {
|
||||||
Sort: &sort,
|
Sort: &sort,
|
||||||
}
|
}
|
||||||
projects, response, err := gitClient.Projects.ListProjects(opt)
|
projects, response, err := gitClient.Projects.ListProjects(opt)
|
||||||
fmt.Printf("Response StatusCode: %d\n", response.Response.StatusCode)
|
log.Printf("Response StatusCode: %d\n", response.Response.StatusCode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for index, project := range projects {
|
for index, project := range projects {
|
||||||
fmt.Printf("Index: %d,\t ID: %d,\t Path: %s,\t Name: %s\n", index, project.ID, project.Path, project.Name)
|
log.Printf("Index: %d,\t ID: %d,\t Path: %s,\t Name: %s\n", index, project.ID, project.Path, project.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue