Skip to content

Commit

Permalink
Merge pull request #120 from go-atomci/feat-initialize-migration
Browse files Browse the repository at this point in the history
Feat initialize migration
  • Loading branch information
colynn authored Apr 29, 2022
2 parents 7cceefc + 330e43a commit 1fb237a
Show file tree
Hide file tree
Showing 12 changed files with 292 additions and 262 deletions.
3 changes: 2 additions & 1 deletion cmd/atomci/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ import (

func main() {
models.InitDB()
initialize.Init()
migrations.Migrate()
// TODO: resource items migrate later
initialize.Init()

cronjob.RunPublishJobServer()
beego.Info("Beego version:", beego.VERSION)
Expand Down
5 changes: 0 additions & 5 deletions internal/dao/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ func CreateGroupRole(req *models.GroupRoleReq) (*models.GroupRole, error) {
return nil, err
}

log.Log.Debug("req operations length: %v", len(req.Operations))
err := GenerateCasbinrules(req.Role, req.Operations)
if err != nil {
log.Log.Error("generate casbin rules error: %s", err.Error())
Expand Down Expand Up @@ -161,10 +160,6 @@ func AddRoleOperation(req *models.GroupRoleOperationReq) error {
if _, err := GetOrmer().Raw(sql).Exec(); err != nil {
return err
}

if err := GenerateCasbinrules(req.Role, req.Operations); err != nil {
return err
}
}
return nil
}
Expand Down
15 changes: 0 additions & 15 deletions internal/initialize/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,4 @@ func Init() {
os.Exit(2)
}
}

/*
TODO: Below resources just run once
*/
if err := Component(); err != nil {
os.Exit(2)
}

// init compile envs
initCompileEnvs()

// init task tmpls
if err := initTaskTemplates(); err != nil {
os.Exit(2)
}
}
82 changes: 0 additions & 82 deletions internal/initialize/init_compile_envs.go

This file was deleted.

73 changes: 0 additions & 73 deletions internal/initialize/init_component.go

This file was deleted.

83 changes: 0 additions & 83 deletions internal/initialize/init_task_tmpl.go

This file was deleted.

19 changes: 18 additions & 1 deletion internal/migrations/migration20220101.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
/*
Copyright 2021 The AtomCI Group 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 migrations

import (
"fmt"
"time"

"github.com/astaxie/beego/orm"
"github.com/go-atomci/atomci/internal/middleware/log"
"time"
)

type Migration20220101 struct {
Expand Down
19 changes: 18 additions & 1 deletion internal/migrations/migration20220309.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
/*
Copyright 2021 The AtomCI Group 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 migrations

import (
"github.com/astaxie/beego/orm"
"strings"
"time"

"github.com/astaxie/beego/orm"
)

type Migration20220309 struct {
Expand Down
19 changes: 18 additions & 1 deletion internal/migrations/migration20220324.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
/*
Copyright 2021 The AtomCI Group 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 migrations

import (
"time"

"github.com/astaxie/beego/orm"
"github.com/go-atomci/atomci/internal/core/settings"
"time"
)

type Migration20220324 struct {
Expand Down
16 changes: 16 additions & 0 deletions internal/migrations/migration20220414.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
Copyright 2021 The AtomCI Group 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 migrations

import (
Expand Down
Loading

0 comments on commit 1fb237a

Please sign in to comment.