From 2b85630271900eaf10f65e678a6eebe1ec0c907e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=99=93=E4=BC=9F?= Date: Mon, 9 Oct 2023 10:18:31 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E4=BD=BF=E7=94=A8=20log=20?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2=20fmt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- access_requests/access_requests.go | 10 +++++----- .../instance_level_ci_variables.go | 6 +++--- job_artifacts/job_artifacts.go | 11 ++++++----- jobs/jobs.go | 6 +++--- pipelines/pipelines.go | 6 +++--- projects/projects.go | 6 +++--- 6 files changed, 23 insertions(+), 22 deletions(-) diff --git a/access_requests/access_requests.go b/access_requests/access_requests.go index dc16353..9c208a2 100644 --- a/access_requests/access_requests.go +++ b/access_requests/access_requests.go @@ -1,11 +1,11 @@ package access_requests import ( - "fmt" "github.com/urfave/cli/v2" "github.com/xanzy/go-gitlab" "github.com/xuxiaowei-com-cn/gitlab-go/constant" "github.com/xuxiaowei-com-cn/gitlab-go/flag" + "log" ) // AccessRequests 群组和项目访问请求 API https://docs.gitlab.cn/jh/api/access_requests.html @@ -33,13 +33,13 @@ func AccessRequests() *cli.Command { opt := &gitlab.ListAccessRequestsOptions{} 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 { return err } 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 @@ -62,13 +62,13 @@ func AccessRequests() *cli.Command { opt := &gitlab.ListAccessRequestsOptions{} 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 { return err } 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 diff --git a/instance_level_ci_variables/instance_level_ci_variables.go b/instance_level_ci_variables/instance_level_ci_variables.go index 17cad46..8f13f44 100644 --- a/instance_level_ci_variables/instance_level_ci_variables.go +++ b/instance_level_ci_variables/instance_level_ci_variables.go @@ -1,11 +1,11 @@ package instance_level_ci_variables import ( - "fmt" "github.com/urfave/cli/v2" "github.com/xanzy/go-gitlab" "github.com/xuxiaowei-com-cn/gitlab-go/constant" "github.com/xuxiaowei-com-cn/gitlab-go/flag" + "log" ) // 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{} 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 { return err } 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 diff --git a/job_artifacts/job_artifacts.go b/job_artifacts/job_artifacts.go index ee6f2ea..7e5c312 100644 --- a/job_artifacts/job_artifacts.go +++ b/job_artifacts/job_artifacts.go @@ -6,6 +6,7 @@ import ( "github.com/xanzy/go-gitlab" "github.com/xuxiaowei-com-cn/gitlab-go/constant" "github.com/xuxiaowei-com-cn/gitlab-go/flag" + "log" ) // JobsArtifacts 作业产物 API https://docs.gitlab.cn/jh/api/job_artifacts.html @@ -21,7 +22,7 @@ func JobsArtifacts() *cli.Command { Usage: "获取作业产物(未完成)", Flags: append(flag.Common(), flag.Id(true), flag.JobId(false)), Action: func(context *cli.Context) error { - fmt.Println("获取作业产物") + log.Printf("获取作业产物") return fmt.Errorf("未完成") }, @@ -53,9 +54,9 @@ func JobsArtifacts() *cli.Command { 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) - fmt.Printf("Response StatusCode: %d\n", response.Response.StatusCode) + log.Printf("Response StatusCode: %d\n", response.Response.StatusCode) if err != nil { return err } @@ -78,9 +79,9 @@ func JobsArtifacts() *cli.Command { return err } - fmt.Printf("Delete ProjectId: %s Artifacts\n", id) + log.Printf("Delete ProjectId: %s Artifacts\n", 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 { return err } diff --git a/jobs/jobs.go b/jobs/jobs.go index 3483892..90b154b 100644 --- a/jobs/jobs.go +++ b/jobs/jobs.go @@ -1,11 +1,11 @@ package jobs import ( - "fmt" "github.com/urfave/cli/v2" "github.com/xanzy/go-gitlab" "github.com/xuxiaowei-com-cn/gitlab-go/constant" "github.com/xuxiaowei-com-cn/gitlab-go/flag" + "log" ) // Jobs 作业 API https://docs.gitlab.cn/jh/api/jobs.html @@ -32,13 +32,13 @@ func Jobs() *cli.Command { opt := &gitlab.ListJobsOptions{} 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 { return err } 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 diff --git a/pipelines/pipelines.go b/pipelines/pipelines.go index 0c27588..439f594 100644 --- a/pipelines/pipelines.go +++ b/pipelines/pipelines.go @@ -1,11 +1,11 @@ package pipelines import ( - "fmt" "github.com/urfave/cli/v2" "github.com/xanzy/go-gitlab" "github.com/xuxiaowei-com-cn/gitlab-go/constant" "github.com/xuxiaowei-com-cn/gitlab-go/flag" + "log" ) // Pipelines 流水线 API https://docs.gitlab.cn/jh/api/pipelines.html @@ -35,13 +35,13 @@ func Pipelines() *cli.Command { Sort: &sort, } 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 { return err } 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 diff --git a/projects/projects.go b/projects/projects.go index bc02940..5e063d1 100644 --- a/projects/projects.go +++ b/projects/projects.go @@ -1,11 +1,11 @@ package projects import ( - "fmt" "github.com/urfave/cli/v2" "github.com/xanzy/go-gitlab" "github.com/xuxiaowei-com-cn/gitlab-go/constant" "github.com/xuxiaowei-com-cn/gitlab-go/flag" + "log" ) // Projects 项目 API https://docs.gitlab.cn/jh/api/projects.html @@ -34,13 +34,13 @@ func Projects() *cli.Command { Sort: &sort, } 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 { return err } 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