From 625832bf46f9ba47e23883613eaa7f42222d2227 Mon Sep 17 00:00:00 2001 From: qwerty287 Date: Sat, 20 Jan 2024 13:12:07 +0100 Subject: [PATCH 1/5] Clean up models --- agent/logger.go | 4 +- pipeline/backend/docker/convert_test.go | 2 +- pipeline/backend/types/auth.go | 1 - pipeline/backend/types/secret.go | 1 - pipeline/frontend/yaml/compiler/compiler.go | 1 - pipeline/frontend/yaml/compiler/convert.go | 1 - server/api/registry.go | 8 --- server/forge/bitbucket/convert.go | 1 - server/forge/bitbucket/convert_test.go | 1 - server/forge/github/convert_test.go | 2 - server/forge/github/parse.go | 2 - server/forge/gitlab/convert.go | 1 - server/model/agent.go | 16 ++--- server/model/environ.go | 2 - server/model/feed.go | 1 - server/model/pipeline.go | 3 - server/model/registry.go | 4 -- server/pipeline/restart.go | 2 - server/pipeline/stepbuilder/stepBuilder.go | 1 - server/store/datastore/feed.go | 1 - .../migration/029_clean_registry_pipeline.go | 57 +++++++++++++++++ server/store/datastore/migration/migration.go | 1 + server/store/datastore/pipeline.go | 1 - server/store/datastore/registry_test.go | 4 -- woodpecker-go/woodpecker/types.go | 63 ++++++++++--------- 25 files changed, 101 insertions(+), 80 deletions(-) create mode 100644 server/store/datastore/migration/029_clean_registry_pipeline.go diff --git a/agent/logger.go b/agent/logger.go index 99541ede0d..80f5112acc 100644 --- a/agent/logger.go +++ b/agent/logger.go @@ -37,9 +37,7 @@ func (r *Runner) createLogger(logger zerolog.Logger, uploads *sync.WaitGroup, wo var secrets []string for _, secret := range workflow.Config.Secrets { - if secret.Mask { - secrets = append(secrets, secret.Value) - } + secrets = append(secrets, secret.Value) } loglogger.Debug().Msg("log stream opened") diff --git a/pipeline/backend/docker/convert_test.go b/pipeline/backend/docker/convert_test.go index e3540e7146..435d669b4b 100644 --- a/pipeline/backend/docker/convert_test.go +++ b/pipeline/backend/docker/convert_test.go @@ -151,7 +151,7 @@ func TestToConfigFull(t *testing.T) { OnFailure: true, OnSuccess: true, Failure: "fail", - AuthConfig: backend.Auth{Username: "user", Password: "123456", Email: "user@example.com"}, + AuthConfig: backend.Auth{Username: "user", Password: "123456"}, NetworkMode: "bridge", Ports: []backend.Port{{Number: 21}, {Number: 22}}, }) diff --git a/pipeline/backend/types/auth.go b/pipeline/backend/types/auth.go index 3df98c0203..6c336a3572 100644 --- a/pipeline/backend/types/auth.go +++ b/pipeline/backend/types/auth.go @@ -18,5 +18,4 @@ package types type Auth struct { Username string `json:"username,omitempty"` Password string `json:"password,omitempty"` - Email string `json:"email,omitempty"` } diff --git a/pipeline/backend/types/secret.go b/pipeline/backend/types/secret.go index c7d1a2b021..7a7b2ecb1f 100644 --- a/pipeline/backend/types/secret.go +++ b/pipeline/backend/types/secret.go @@ -18,5 +18,4 @@ package types type Secret struct { Name string `json:"name,omitempty"` Value string `json:"value,omitempty"` - Mask bool `json:"mask,omitempty"` } diff --git a/pipeline/frontend/yaml/compiler/compiler.go b/pipeline/frontend/yaml/compiler/compiler.go index 3e82fcaaa1..229f399d6b 100644 --- a/pipeline/frontend/yaml/compiler/compiler.go +++ b/pipeline/frontend/yaml/compiler/compiler.go @@ -129,7 +129,6 @@ func (c *Compiler) Compile(conf *yaml_types.Workflow) (*backend_types.Config, er config.Secrets = append(config.Secrets, &backend_types.Secret{ Name: sec.Name, Value: sec.Value, - Mask: true, }) } diff --git a/pipeline/frontend/yaml/compiler/convert.go b/pipeline/frontend/yaml/compiler/convert.go index c5b3739f4b..670051f382 100644 --- a/pipeline/frontend/yaml/compiler/convert.go +++ b/pipeline/frontend/yaml/compiler/convert.go @@ -111,7 +111,6 @@ func (c *Compiler) createProcess(container *yaml_types.Container, stepType backe if utils.MatchHostname(container.Image, registry.Hostname) { authConfig.Username = registry.Username authConfig.Password = registry.Password - authConfig.Email = registry.Email break } } diff --git a/server/api/registry.go b/server/api/registry.go index 1818d4989b..27b1c9e047 100644 --- a/server/api/registry.go +++ b/server/api/registry.go @@ -70,8 +70,6 @@ func PostRegistry(c *gin.Context) { Address: in.Address, Username: in.Username, Password: in.Password, - Token: in.Token, - Email: in.Email, } if err := registry.Validate(); err != nil { c.String(http.StatusBadRequest, "Error inserting registry. %s", err) @@ -119,12 +117,6 @@ func PatchRegistry(c *gin.Context) { if in.Password != "" { registry.Password = in.Password } - if in.Token != "" { - registry.Token = in.Token - } - if in.Email != "" { - registry.Email = in.Email - } if err := registry.Validate(); err != nil { c.String(http.StatusUnprocessableEntity, "Error updating registry. %s", err) diff --git a/server/forge/bitbucket/convert.go b/server/forge/bitbucket/convert.go index 700b3c32c8..9410696fba 100644 --- a/server/forge/bitbucket/convert.go +++ b/server/forge/bitbucket/convert.go @@ -176,7 +176,6 @@ func convertPullHook(from *internal.PullRequestHook) *model.Pipeline { from.PullRequest.Source.Branch.Name, from.PullRequest.Dest.Branch.Name, ), - CloneURL: fmt.Sprintf("https://bitbucket.org/%s", from.PullRequest.Source.Repo.FullName), ForgeURL: from.PullRequest.Links.HTML.Href, Branch: from.PullRequest.Dest.Branch.Name, Message: from.PullRequest.Desc, diff --git a/server/forge/bitbucket/convert_test.go b/server/forge/bitbucket/convert_test.go index 88a9ef7cc5..2ce3e27f61 100644 --- a/server/forge/bitbucket/convert_test.go +++ b/server/forge/bitbucket/convert_test.go @@ -142,7 +142,6 @@ func Test_helper(t *testing.T) { g.Assert(pipeline.ForgeURL).Equal(hook.PullRequest.Links.HTML.Href) g.Assert(pipeline.Ref).Equal("refs/heads/main") g.Assert(pipeline.Refspec).Equal("change:main") - g.Assert(pipeline.CloneURL).Equal("https://bitbucket.org/baz/bar") g.Assert(pipeline.Message).Equal(hook.PullRequest.Desc) g.Assert(pipeline.Timestamp).Equal(hook.PullRequest.Updated.Unix()) }) diff --git a/server/forge/github/convert_test.go b/server/forge/github/convert_test.go index 8ebe43fa81..d6461f4440 100644 --- a/server/forge/github/convert_test.go +++ b/server/forge/github/convert_test.go @@ -212,7 +212,6 @@ func Test_helper(t *testing.T) { g.Assert(pipeline.Branch).Equal(*from.PullRequest.Base.Ref) g.Assert(pipeline.Ref).Equal("refs/pull/42/merge") g.Assert(pipeline.Refspec).Equal("changes:main") - g.Assert(pipeline.CloneURL).Equal("https://github.com/octocat/hello-world-fork") g.Assert(pipeline.Commit).Equal(*from.PullRequest.Head.SHA) g.Assert(pipeline.Message).Equal(*from.PullRequest.Title) g.Assert(pipeline.Title).Equal(*from.PullRequest.Title) @@ -264,7 +263,6 @@ func Test_helper(t *testing.T) { g.Assert(pipeline.Author).Equal(*from.Sender.Login) g.Assert(pipeline.Avatar).Equal(*from.Sender.AvatarURL) g.Assert(pipeline.Email).Equal(*from.HeadCommit.Author.Email) - g.Assert(pipeline.CloneURL).Equal(*from.Repo.CloneURL) }) g.It("should convert a tag from webhook", func() { diff --git a/server/forge/github/parse.go b/server/forge/github/parse.go index 79089f35e8..fa354a1dbf 100644 --- a/server/forge/github/parse.go +++ b/server/forge/github/parse.go @@ -90,7 +90,6 @@ func parsePushHook(hook *github.PushEvent) (*model.Repo, *model.Pipeline) { Email: hook.GetHeadCommit().GetAuthor().GetEmail(), Avatar: hook.GetSender().GetAvatarURL(), Author: hook.GetSender().GetLogin(), - CloneURL: hook.GetRepo().GetCloneURL(), Sender: hook.GetSender().GetLogin(), ChangedFiles: getChangedFilesFromCommits(hook.Commits), } @@ -164,7 +163,6 @@ func parsePullHook(hook *github.PullRequestEvent, merge bool) (*github.PullReque Avatar: hook.GetPullRequest().GetUser().GetAvatarURL(), Title: hook.GetPullRequest().GetTitle(), Sender: hook.GetSender().GetLogin(), - CloneURL: hook.GetPullRequest().GetHead().GetRepo().GetCloneURL(), Refspec: fmt.Sprintf(refSpec, hook.GetPullRequest().GetHead().GetRef(), hook.GetPullRequest().GetBase().GetRef(), diff --git a/server/forge/gitlab/convert.go b/server/forge/gitlab/convert.go index d376e26229..2180c447ba 100644 --- a/server/forge/gitlab/convert.go +++ b/server/forge/gitlab/convert.go @@ -120,7 +120,6 @@ func convertMergeRequestHook(hook *gitlab.MergeEvent, req *http.Request) (int, * pipeline.Message = lastCommit.Message pipeline.Commit = lastCommit.ID - pipeline.CloneURL = obj.Source.HTTPURL pipeline.Ref = fmt.Sprintf(mergeRefs, obj.IID) pipeline.Branch = obj.SourceBranch diff --git a/server/model/agent.go b/server/model/agent.go index 65278c21b4..26b72f4abc 100644 --- a/server/model/agent.go +++ b/server/model/agent.go @@ -18,15 +18,15 @@ type Agent struct { ID int64 `json:"id" xorm:"pk autoincr 'id'"` Created int64 `json:"created" xorm:"created"` Updated int64 `json:"updated" xorm:"updated"` - Name string `json:"name"` + Name string `json:"name" xorm:"name"` OwnerID int64 `json:"owner_id" xorm:"'owner_id'"` - Token string `json:"token"` - LastContact int64 `json:"last_contact"` - Platform string `json:"platform" xorm:"VARCHAR(100)"` - Backend string `json:"backend" xorm:"VARCHAR(100)"` - Capacity int32 `json:"capacity"` - Version string `json:"version"` - NoSchedule bool `json:"no_schedule"` + Token string `json:"token" xorm:"token"` + LastContact int64 `json:"last_contact" xorm:"last_contact"` + Platform string `json:"platform" xorm:"VARCHAR(100) 'platform'"` + Backend string `json:"backend" xorm:"VARCHAR(100) 'backend'"` + Capacity int32 `json:"capacity" xorm:"capacity"` + Version string `json:"version" xorm:"version"` + NoSchedule bool `json:"no_schedule" xorm:"no_schedule"` } // @name Agent // TableName return database table name for xorm diff --git a/server/model/environ.go b/server/model/environ.go index 939ed6b9b4..4c70db4c61 100644 --- a/server/model/environ.go +++ b/server/model/environ.go @@ -36,7 +36,6 @@ type EnvironStore interface { // Environ represents an environment variable. type Environ struct { - ID int64 `json:"id"` Name string `json:"name"` Value string `json:"value,omitempty"` } @@ -56,7 +55,6 @@ func (e *Environ) Validate() error { // Copy makes a copy of the environment variable without the value. func (e *Environ) Copy() *Environ { return &Environ{ - ID: e.ID, Name: e.Name, } } diff --git a/server/model/feed.go b/server/model/feed.go index d330c2f854..0ff5296a07 100644 --- a/server/model/feed.go +++ b/server/model/feed.go @@ -29,7 +29,6 @@ type Feed struct { Branch string `json:"branch,omitempty" xorm:"feed_pipeline_branch"` Ref string `json:"ref,omitempty" xorm:"feed_pipeline_ref"` Refspec string `json:"refspec,omitempty" xorm:"feed_pipeline_refspec"` - Remote string `json:"remote,omitempty" xorm:"feed_pipeline_clone_url"` Title string `json:"title,omitempty" xorm:"feed_pipeline_title"` Message string `json:"message,omitempty" xorm:"feed_pipeline_message"` Author string `json:"author,omitempty" xorm:"feed_pipeline_author"` diff --git a/server/model/pipeline.go b/server/model/pipeline.go index f5af0c80a9..e1eaabc99f 100644 --- a/server/model/pipeline.go +++ b/server/model/pipeline.go @@ -24,12 +24,10 @@ type Pipeline struct { RepoID int64 `json:"-" xorm:"UNIQUE(s) INDEX 'pipeline_repo_id'"` Number int64 `json:"number" xorm:"UNIQUE(s) 'pipeline_number'"` Author string `json:"author" xorm:"INDEX 'pipeline_author'"` - ConfigID int64 `json:"-" xorm:"pipeline_config_id"` Parent int64 `json:"parent" xorm:"pipeline_parent"` Event WebhookEvent `json:"event" xorm:"pipeline_event"` Status StatusValue `json:"status" xorm:"INDEX 'pipeline_status'"` Errors []*errors.PipelineError `json:"errors" xorm:"json 'pipeline_errors'"` - Enqueued int64 `json:"enqueued_at" xorm:"pipeline_enqueued"` Created int64 `json:"created_at" xorm:"pipeline_created"` Updated int64 `json:"updated_at" xorm:"updated NOT NULL DEFAULT 0 'updated'"` Started int64 `json:"started_at" xorm:"pipeline_started"` @@ -39,7 +37,6 @@ type Pipeline struct { Branch string `json:"branch" xorm:"pipeline_branch"` Ref string `json:"ref" xorm:"pipeline_ref"` Refspec string `json:"refspec" xorm:"pipeline_refspec"` - CloneURL string `json:"clone_url" xorm:"pipeline_clone_url"` Title string `json:"title" xorm:"pipeline_title"` Message string `json:"message" xorm:"TEXT 'pipeline_message'"` Timestamp int64 `json:"timestamp" xorm:"pipeline_timestamp"` diff --git a/server/model/registry.go b/server/model/registry.go index 875cd2d9c0..0c270756e1 100644 --- a/server/model/registry.go +++ b/server/model/registry.go @@ -57,8 +57,6 @@ type Registry struct { Address string `json:"address" xorm:"UNIQUE(s) INDEX 'registry_addr'"` Username string `json:"username" xorm:"varchar(2000) 'registry_username'"` Password string `json:"password" xorm:"TEXT 'registry_password'"` - Token string `json:"token" xorm:"TEXT 'registry_token'"` - Email string `json:"email" xorm:"varchar(500) 'registry_email'"` } // @name Registry // Validate validates the registry information. @@ -83,7 +81,5 @@ func (r *Registry) Copy() *Registry { RepoID: r.RepoID, Address: r.Address, Username: r.Username, - Email: r.Email, - Token: r.Token, } } diff --git a/server/pipeline/restart.go b/server/pipeline/restart.go index 89fb8193cd..73933ceeb3 100644 --- a/server/pipeline/restart.go +++ b/server/pipeline/restart.go @@ -18,7 +18,6 @@ import ( "context" "errors" "fmt" - "time" "github.com/rs/zerolog/log" @@ -130,7 +129,6 @@ func createNewOutOfOld(old *model.Pipeline) *model.Pipeline { newPipeline.Status = model.StatusPending newPipeline.Started = 0 newPipeline.Finished = 0 - newPipeline.Enqueued = time.Now().UTC().Unix() newPipeline.Errors = nil return &newPipeline } diff --git a/server/pipeline/stepbuilder/stepBuilder.go b/server/pipeline/stepbuilder/stepBuilder.go index 88c40363dd..674f381403 100644 --- a/server/pipeline/stepbuilder/stepBuilder.go +++ b/server/pipeline/stepbuilder/stepBuilder.go @@ -256,7 +256,6 @@ func (b *StepBuilder) toInternalRepresentation(parsed *yaml_types.Workflow, envi Hostname: reg.Address, Username: reg.Username, Password: reg.Password, - Email: reg.Email, }) } diff --git a/server/store/datastore/feed.go b/server/store/datastore/feed.go index 5ce768d9fc..9268093862 100644 --- a/server/store/datastore/feed.go +++ b/server/store/datastore/feed.go @@ -32,7 +32,6 @@ pipelines.pipeline_commit as feed_pipeline_commit, pipelines.pipeline_branch as feed_pipeline_branch, pipelines.pipeline_ref as feed_pipeline_ref, pipelines.pipeline_refspec as feed_pipeline_refspec, -pipelines.pipeline_clone_url as feed_pipeline_clone_url, pipelines.pipeline_title as feed_pipeline_title, pipelines.pipeline_message as feed_pipeline_message, pipelines.pipeline_author as feed_pipeline_author, diff --git a/server/store/datastore/migration/029_clean_registry_pipeline.go b/server/store/datastore/migration/029_clean_registry_pipeline.go new file mode 100644 index 0000000000..c83fb6c9f8 --- /dev/null +++ b/server/store/datastore/migration/029_clean_registry_pipeline.go @@ -0,0 +1,57 @@ +// Copyright 2024 Woodpecker Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package migration + +import ( + "src.techknowlogick.com/xormigrate" + "xorm.io/xorm" +) + +type oldRegistry029 struct { + ID int64 `json:"id" xorm:"pk autoincr 'registry_id'"` + Token string `json:"token" xorm:"TEXT 'registry_token'"` + Email string `json:"email" xorm:"varchar(500) 'registry_email'"` +} + +func (oldRegistry029) TableName() string { + return "registry" +} + +type oldPipeline029 struct { + ID int64 `json:"id" xorm:"pk autoincr 'pipeline_id'"` + ConfigID int64 `json:"-" xorm:"pipeline_config_id"` + Enqueued int64 `json:"enqueued_at" xorm:"pipeline_enqueued"` + CloneURL string `json:"clone_url" xorm:"pipeline_clone_url"` +} // @name Pipeline + +// TableName return database table name for xorm +func (oldPipeline029) TableName() string { + return "pipelines" +} + +var cleanRegistryPipeline = xormigrate.Migration{ + ID: "clean-registry-pipeline", + MigrateSession: func(sess *xorm.Session) (err error) { + if err := sess.Sync(new(oldRegistry029), new(oldPipeline029)); err != nil { + return err + } + + if err := dropTableColumns(sess, "pipelines", "pipeline_clone_url", "pipeline_config_id"); err != nil { + return err + } + + return dropTableColumns(sess, "secrets", "registry_email", "registry_token") + }, +} diff --git a/server/store/datastore/migration/migration.go b/server/store/datastore/migration/migration.go index 0da773bcfe..ceb001c5c3 100644 --- a/server/store/datastore/migration/migration.go +++ b/server/store/datastore/migration/migration.go @@ -58,6 +58,7 @@ var migrationTasks = []*xormigrate.Migration{ &removePluginOnlyOptionFromSecretsTable, &convertToNewPipelineErrorFormat, &renameLinkToURL, + &cleanRegistryPipeline, } var allBeans = []any{ diff --git a/server/store/datastore/pipeline.go b/server/store/datastore/pipeline.go index 1e65184853..a3f436d5e4 100644 --- a/server/store/datastore/pipeline.go +++ b/server/store/datastore/pipeline.go @@ -114,7 +114,6 @@ func (s storage) CreatePipeline(pipeline *model.Pipeline, stepList ...*model.Ste pipeline.Number = number + 1 pipeline.Created = time.Now().UTC().Unix() - pipeline.Enqueued = pipeline.Created // only Insert set auto created ID back to object if _, err := sess.Insert(pipeline); err != nil { return err diff --git a/server/store/datastore/registry_test.go b/server/store/datastore/registry_test.go index a4e9e07ffa..35c7bfc14f 100644 --- a/server/store/datastore/registry_test.go +++ b/server/store/datastore/registry_test.go @@ -32,8 +32,6 @@ func TestRegistryFind(t *testing.T) { Address: "index.docker.io", Username: "foo", Password: "bar", - Email: "foo@bar.com", - Token: "12345", }) assert.NoError(t, err) @@ -43,8 +41,6 @@ func TestRegistryFind(t *testing.T) { assert.Equal(t, "index.docker.io", registry.Address) assert.Equal(t, "foo", registry.Username) assert.Equal(t, "bar", registry.Password) - assert.Equal(t, "foo@bar.com", registry.Email) - assert.Equal(t, "12345", registry.Token) } func TestRegistryList(t *testing.T) { diff --git a/woodpecker-go/woodpecker/types.go b/woodpecker-go/woodpecker/types.go index ba2cff1b75..1c495362a1 100644 --- a/woodpecker-go/woodpecker/types.go +++ b/woodpecker-go/woodpecker/types.go @@ -69,34 +69,35 @@ type ( // Pipeline defines a pipeline object. Pipeline struct { - ID int64 `json:"id"` - Number int64 `json:"number"` - Parent int64 `json:"parent"` - Event string `json:"event"` - Status string `json:"status"` - Errors PipelineError `json:"errors"` - Enqueued int64 `json:"enqueued_at"` - Created int64 `json:"created_at"` - Updated int64 `json:"updated_at"` - Started int64 `json:"started_at"` - Finished int64 `json:"finished_at"` - Deploy string `json:"deploy_to"` - Commit string `json:"commit"` - Branch string `json:"branch"` - Ref string `json:"ref"` - Refspec string `json:"refspec"` - CloneURL string `json:"clone_url"` - Title string `json:"title"` - Message string `json:"message"` - Timestamp int64 `json:"timestamp"` - Sender string `json:"sender"` - Author string `json:"author"` - Avatar string `json:"author_avatar"` - Email string `json:"author_email"` - ForgeURL string `json:"forge_url"` - Reviewer string `json:"reviewed_by"` - Reviewed int64 `json:"reviewed_at"` - Workflows []*Workflow `json:"workflows,omitempty"` + ID int64 `json:"id"` + Number int64 `json:"number"` + Parent int64 `json:"parent"` + Event string `json:"event"` + Status string `json:"status"` + Errors PipelineError `json:"errors"` + // Deprecated TODO remove in 3.x + Enqueued int64 `json:"enqueued_at"` + Created int64 `json:"created_at"` + Updated int64 `json:"updated_at"` + Started int64 `json:"started_at"` + Finished int64 `json:"finished_at"` + Deploy string `json:"deploy_to"` + Commit string `json:"commit"` + Branch string `json:"branch"` + Ref string `json:"ref"` + Refspec string `json:"refspec"` + CloneURL string `json:"clone_url"` + Title string `json:"title"` + Message string `json:"message"` + Timestamp int64 `json:"timestamp"` + Sender string `json:"sender"` + Author string `json:"author"` + Avatar string `json:"author_avatar"` + Email string `json:"author_email"` + ForgeURL string `json:"forge_url"` + Reviewer string `json:"reviewed_by"` + Reviewed int64 `json:"reviewed_at"` + Workflows []*Workflow `json:"workflows,omitempty"` } // Workflow represents a workflow in the pipeline. @@ -134,8 +135,10 @@ type ( Address string `json:"address"` Username string `json:"username"` Password string `json:"password,omitempty"` - Email string `json:"email"` - Token string `json:"token"` + // Deprecated + Email string `json:"email"` // TODO remove in 3.x + // Deprecated + Token string `json:"token"` // TODO remove in 3.x } // Secret represents a secret variable, such as a password or token. From 3f8931571a32949ad8b8ee29f296a29706541f00 Mon Sep 17 00:00:00 2001 From: qwerty287 Date: Sun, 21 Jan 2024 08:25:36 +0100 Subject: [PATCH 2/5] gen swagger --- cmd/server/docs/docs.go | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/cmd/server/docs/docs.go b/cmd/server/docs/docs.go index 6c7823a86d..3380e29fc5 100644 --- a/cmd/server/docs/docs.go +++ b/cmd/server/docs/docs.go @@ -3784,9 +3784,6 @@ const docTemplate = `{ "refspec": { "type": "string" }, - "remote": { - "type": "string" - }, "repo_id": { "type": "integer" }, @@ -3913,9 +3910,6 @@ const docTemplate = `{ "type": "string" } }, - "clone_url": { - "type": "string" - }, "commit": { "type": "string" }, @@ -3925,9 +3919,6 @@ const docTemplate = `{ "deploy_to": { "type": "string" }, - "enqueued_at": { - "type": "integer" - }, "errors": { "type": "array", "items": { @@ -4037,18 +4028,12 @@ const docTemplate = `{ "address": { "type": "string" }, - "email": { - "type": "string" - }, "id": { "type": "integer" }, "password": { "type": "string" }, - "token": { - "type": "string" - }, "username": { "type": "string" } From 62530afc2e01f6b0806c65a81c23bc6d11c51735 Mon Sep 17 00:00:00 2001 From: qwerty287 Date: Sun, 21 Jan 2024 08:59:39 +0100 Subject: [PATCH 3/5] Fix migration --- .../store/datastore/migration/029_clean_registry_pipeline.go | 4 ++-- web/src/lib/api/types/pipeline.ts | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/server/store/datastore/migration/029_clean_registry_pipeline.go b/server/store/datastore/migration/029_clean_registry_pipeline.go index c83fb6c9f8..7742aa0ea8 100644 --- a/server/store/datastore/migration/029_clean_registry_pipeline.go +++ b/server/store/datastore/migration/029_clean_registry_pipeline.go @@ -48,10 +48,10 @@ var cleanRegistryPipeline = xormigrate.Migration{ return err } - if err := dropTableColumns(sess, "pipelines", "pipeline_clone_url", "pipeline_config_id"); err != nil { + if err := dropTableColumns(sess, "pipelines", "pipeline_clone_url", "pipeline_config_id", "pipeline_enqueued"); err != nil { return err } - return dropTableColumns(sess, "secrets", "registry_email", "registry_token") + return dropTableColumns(sess, "registry", "registry_email", "registry_token") }, } diff --git a/web/src/lib/api/types/pipeline.ts b/web/src/lib/api/types/pipeline.ts index aafb7611fe..32fcceb034 100644 --- a/web/src/lib/api/types/pipeline.ts +++ b/web/src/lib/api/types/pipeline.ts @@ -30,9 +30,6 @@ export type Pipeline = { // When the pipeline was updated last time in database. updated_at: number; - // When the pipeline was enqueued. - enqueued_at: number; - // When the pipeline began execution. started_at: number; From 6a9f3413afbc1dab52d78b11c73b6a914a915fef Mon Sep 17 00:00:00 2001 From: qwerty287 Date: Sun, 21 Jan 2024 09:08:51 +0100 Subject: [PATCH 4/5] Regen swagger --- cmd/server/docs/docs.go | 239 +--------------------------------------- 1 file changed, 2 insertions(+), 237 deletions(-) diff --git a/cmd/server/docs/docs.go b/cmd/server/docs/docs.go index 3380e29fc5..92135d0be5 100644 --- a/cmd/server/docs/docs.go +++ b/cmd/server/docs/docs.go @@ -3892,108 +3892,14 @@ const docTemplate = `{ "Pipeline": { "type": "object", "properties": { - "author": { - "type": "string" - }, - "author_avatar": { - "type": "string" - }, - "author_email": { - "type": "string" - }, - "branch": { - "type": "string" - }, - "changed_files": { - "type": "array", - "items": { - "type": "string" - } - }, - "commit": { - "type": "string" - }, - "created_at": { - "type": "integer" - }, - "deploy_to": { + "clone_url": { "type": "string" }, - "errors": { - "type": "array", - "items": { - "$ref": "#/definitions/errors.PipelineError" - } - }, - "event": { - "$ref": "#/definitions/WebhookEvent" - }, - "finished_at": { + "enqueued_at": { "type": "integer" }, - "forge_url": { - "type": "string" - }, "id": { "type": "integer" - }, - "message": { - "type": "string" - }, - "number": { - "type": "integer" - }, - "parent": { - "type": "integer" - }, - "pr_labels": { - "type": "array", - "items": { - "type": "string" - } - }, - "ref": { - "type": "string" - }, - "refspec": { - "type": "string" - }, - "reviewed_at": { - "type": "integer" - }, - "reviewed_by": { - "type": "string" - }, - "sender": { - "description": "uses reported user for webhooks and name of cron for cron pipelines", - "type": "string" - }, - "started_at": { - "type": "integer" - }, - "status": { - "$ref": "#/definitions/StatusValue" - }, - "timestamp": { - "type": "integer" - }, - "title": { - "type": "string" - }, - "updated_at": { - "type": "integer" - }, - "variables": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "workflows": { - "type": "array", - "items": { - "$ref": "#/definitions/model.Workflow" - } } } }, @@ -4248,64 +4154,6 @@ const docTemplate = `{ "StatusCreated" ] }, - "Step": { - "type": "object", - "properties": { - "end_time": { - "type": "integer" - }, - "error": { - "type": "string" - }, - "exit_code": { - "type": "integer" - }, - "id": { - "type": "integer" - }, - "name": { - "type": "string" - }, - "pid": { - "type": "integer" - }, - "pipeline_id": { - "type": "integer" - }, - "ppid": { - "type": "integer" - }, - "start_time": { - "type": "integer" - }, - "state": { - "$ref": "#/definitions/StatusValue" - }, - "type": { - "$ref": "#/definitions/StepType" - }, - "uuid": { - "type": "string" - } - } - }, - "StepType": { - "type": "string", - "enum": [ - "clone", - "service", - "plugin", - "commands", - "cache" - ], - "x-enum-varnames": [ - "StepTypeClone", - "StepTypeService", - "StepTypePlugin", - "StepTypeCommands", - "StepTypeCache" - ] - }, "Task": { "type": "object", "properties": { @@ -4396,89 +4244,6 @@ const docTemplate = `{ "EventCron", "EventManual" ] - }, - "errors.PipelineError": { - "type": "object", - "properties": { - "data": {}, - "is_warning": { - "type": "boolean" - }, - "message": { - "type": "string" - }, - "type": { - "$ref": "#/definitions/errors.PipelineErrorType" - } - } - }, - "errors.PipelineErrorType": { - "type": "string", - "enum": [ - "linter", - "deprecation", - "compiler", - "generic" - ], - "x-enum-comments": { - "PipelineErrorTypeCompiler": "some error with the config semantics", - "PipelineErrorTypeDeprecation": "using some deprecated feature", - "PipelineErrorTypeGeneric": "some generic error", - "PipelineErrorTypeLinter": "some error with the config syntax" - }, - "x-enum-varnames": [ - "PipelineErrorTypeLinter", - "PipelineErrorTypeDeprecation", - "PipelineErrorTypeCompiler", - "PipelineErrorTypeGeneric" - ] - }, - "model.Workflow": { - "type": "object", - "properties": { - "agent_id": { - "type": "integer" - }, - "children": { - "type": "array", - "items": { - "$ref": "#/definitions/Step" - } - }, - "end_time": { - "type": "integer" - }, - "environ": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "error": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "name": { - "type": "string" - }, - "pid": { - "type": "integer" - }, - "pipeline_id": { - "type": "integer" - }, - "platform": { - "type": "string" - }, - "start_time": { - "type": "integer" - }, - "state": { - "$ref": "#/definitions/StatusValue" - } - } } } }` From 90450d6292727ee9baa8f5c4971917f544e08f9a Mon Sep 17 00:00:00 2001 From: qwerty287 Date: Sun, 21 Jan 2024 09:09:52 +0100 Subject: [PATCH 5/5] fix docs --- cmd/server/docs/docs.go | 239 +++++++++++++++++- .../migration/029_clean_registry_pipeline.go | 2 +- 2 files changed, 238 insertions(+), 3 deletions(-) diff --git a/cmd/server/docs/docs.go b/cmd/server/docs/docs.go index 92135d0be5..3380e29fc5 100644 --- a/cmd/server/docs/docs.go +++ b/cmd/server/docs/docs.go @@ -3892,14 +3892,108 @@ const docTemplate = `{ "Pipeline": { "type": "object", "properties": { - "clone_url": { + "author": { + "type": "string" + }, + "author_avatar": { + "type": "string" + }, + "author_email": { + "type": "string" + }, + "branch": { "type": "string" }, - "enqueued_at": { + "changed_files": { + "type": "array", + "items": { + "type": "string" + } + }, + "commit": { + "type": "string" + }, + "created_at": { "type": "integer" }, + "deploy_to": { + "type": "string" + }, + "errors": { + "type": "array", + "items": { + "$ref": "#/definitions/errors.PipelineError" + } + }, + "event": { + "$ref": "#/definitions/WebhookEvent" + }, + "finished_at": { + "type": "integer" + }, + "forge_url": { + "type": "string" + }, "id": { "type": "integer" + }, + "message": { + "type": "string" + }, + "number": { + "type": "integer" + }, + "parent": { + "type": "integer" + }, + "pr_labels": { + "type": "array", + "items": { + "type": "string" + } + }, + "ref": { + "type": "string" + }, + "refspec": { + "type": "string" + }, + "reviewed_at": { + "type": "integer" + }, + "reviewed_by": { + "type": "string" + }, + "sender": { + "description": "uses reported user for webhooks and name of cron for cron pipelines", + "type": "string" + }, + "started_at": { + "type": "integer" + }, + "status": { + "$ref": "#/definitions/StatusValue" + }, + "timestamp": { + "type": "integer" + }, + "title": { + "type": "string" + }, + "updated_at": { + "type": "integer" + }, + "variables": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "workflows": { + "type": "array", + "items": { + "$ref": "#/definitions/model.Workflow" + } } } }, @@ -4154,6 +4248,64 @@ const docTemplate = `{ "StatusCreated" ] }, + "Step": { + "type": "object", + "properties": { + "end_time": { + "type": "integer" + }, + "error": { + "type": "string" + }, + "exit_code": { + "type": "integer" + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "pid": { + "type": "integer" + }, + "pipeline_id": { + "type": "integer" + }, + "ppid": { + "type": "integer" + }, + "start_time": { + "type": "integer" + }, + "state": { + "$ref": "#/definitions/StatusValue" + }, + "type": { + "$ref": "#/definitions/StepType" + }, + "uuid": { + "type": "string" + } + } + }, + "StepType": { + "type": "string", + "enum": [ + "clone", + "service", + "plugin", + "commands", + "cache" + ], + "x-enum-varnames": [ + "StepTypeClone", + "StepTypeService", + "StepTypePlugin", + "StepTypeCommands", + "StepTypeCache" + ] + }, "Task": { "type": "object", "properties": { @@ -4244,6 +4396,89 @@ const docTemplate = `{ "EventCron", "EventManual" ] + }, + "errors.PipelineError": { + "type": "object", + "properties": { + "data": {}, + "is_warning": { + "type": "boolean" + }, + "message": { + "type": "string" + }, + "type": { + "$ref": "#/definitions/errors.PipelineErrorType" + } + } + }, + "errors.PipelineErrorType": { + "type": "string", + "enum": [ + "linter", + "deprecation", + "compiler", + "generic" + ], + "x-enum-comments": { + "PipelineErrorTypeCompiler": "some error with the config semantics", + "PipelineErrorTypeDeprecation": "using some deprecated feature", + "PipelineErrorTypeGeneric": "some generic error", + "PipelineErrorTypeLinter": "some error with the config syntax" + }, + "x-enum-varnames": [ + "PipelineErrorTypeLinter", + "PipelineErrorTypeDeprecation", + "PipelineErrorTypeCompiler", + "PipelineErrorTypeGeneric" + ] + }, + "model.Workflow": { + "type": "object", + "properties": { + "agent_id": { + "type": "integer" + }, + "children": { + "type": "array", + "items": { + "$ref": "#/definitions/Step" + } + }, + "end_time": { + "type": "integer" + }, + "environ": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "error": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "pid": { + "type": "integer" + }, + "pipeline_id": { + "type": "integer" + }, + "platform": { + "type": "string" + }, + "start_time": { + "type": "integer" + }, + "state": { + "$ref": "#/definitions/StatusValue" + } + } } } }` diff --git a/server/store/datastore/migration/029_clean_registry_pipeline.go b/server/store/datastore/migration/029_clean_registry_pipeline.go index 7742aa0ea8..8534369a41 100644 --- a/server/store/datastore/migration/029_clean_registry_pipeline.go +++ b/server/store/datastore/migration/029_clean_registry_pipeline.go @@ -34,7 +34,7 @@ type oldPipeline029 struct { ConfigID int64 `json:"-" xorm:"pipeline_config_id"` Enqueued int64 `json:"enqueued_at" xorm:"pipeline_enqueued"` CloneURL string `json:"clone_url" xorm:"pipeline_clone_url"` -} // @name Pipeline +} // TableName return database table name for xorm func (oldPipeline029) TableName() string {