Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: SCM git client #1048

Merged
merged 3 commits into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/pkg/plugin/githubactions/golang/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package golang

import (
"github.com/devstream-io/devstream/internal/pkg/plugininstaller/github"
githubCommon "github.com/devstream-io/devstream/pkg/util/github"
githubCommon "github.com/devstream-io/devstream/pkg/util/scm/github"
)

var workflows = []*githubCommon.Workflow{
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/plugin/githubactions/nodejs/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package nodejs

import (
"github.com/devstream-io/devstream/internal/pkg/plugininstaller/github"
githubCommon "github.com/devstream-io/devstream/pkg/util/github"
githubCommon "github.com/devstream-io/devstream/pkg/util/scm/github"
)

var workflows = []*githubCommon.Workflow{
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/plugin/githubactions/python/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package python

import (
"github.com/devstream-io/devstream/internal/pkg/plugininstaller/github"
githubCommon "github.com/devstream-io/devstream/pkg/util/github"
githubCommon "github.com/devstream-io/devstream/pkg/util/scm/github"
)

var workflows = []*githubCommon.Workflow{
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/plugin/gitlabci/golang/golang.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package golang
import (
"github.com/devstream-io/devstream/internal/pkg/plugininstaller"
"github.com/devstream-io/devstream/internal/pkg/plugininstaller/ci"
"github.com/devstream-io/devstream/pkg/util/gitlab"
"github.com/devstream-io/devstream/pkg/util/scm/gitlab"
)

func setCIContent(options plugininstaller.RawOptions) (plugininstaller.RawOptions, error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/plugin/gitlabci/java/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (

"github.com/mitchellh/mapstructure"

"github.com/devstream-io/devstream/pkg/util/git"
"github.com/devstream-io/devstream/pkg/util/log"
"github.com/devstream-io/devstream/pkg/util/scm/git"
)

func Create(options map[string]interface{}) (map[string]interface{}, error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/plugin/gitlabci/java/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (

"github.com/mitchellh/mapstructure"

"github.com/devstream-io/devstream/pkg/util/git"
"github.com/devstream-io/devstream/pkg/util/log"
"github.com/devstream-io/devstream/pkg/util/scm/git"
)

func Delete(options map[string]interface{}) (bool, error) {
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/plugin/gitlabci/java/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

"github.com/spf13/viper"

"github.com/devstream-io/devstream/pkg/util/git"
"github.com/devstream-io/devstream/pkg/util/gitlab"
"github.com/devstream-io/devstream/pkg/util/scm/git"
"github.com/devstream-io/devstream/pkg/util/scm/gitlab"
)

type RegistryType string
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/plugin/gitlabci/java/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (

"github.com/mitchellh/mapstructure"

"github.com/devstream-io/devstream/pkg/util/git"
"github.com/devstream-io/devstream/pkg/util/log"
"github.com/devstream-io/devstream/pkg/util/scm/git"
)

func Update(options map[string]interface{}) (map[string]interface{}, error) {
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/plugin/jiragithub/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (

"github.com/mitchellh/mapstructure"

"github.com/devstream-io/devstream/pkg/util/git"
"github.com/devstream-io/devstream/pkg/util/github"
"github.com/devstream-io/devstream/pkg/util/log"
"github.com/devstream-io/devstream/pkg/util/scm/git"
"github.com/devstream-io/devstream/pkg/util/scm/github"
)

// Create sets up jira-github-integ workflows.
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/plugin/jiragithub/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (

"github.com/mitchellh/mapstructure"

"github.com/devstream-io/devstream/pkg/util/git"
"github.com/devstream-io/devstream/pkg/util/github"
"github.com/devstream-io/devstream/pkg/util/log"
"github.com/devstream-io/devstream/pkg/util/scm/git"
"github.com/devstream-io/devstream/pkg/util/scm/github"
)

// Delete remove jira-github-integ workflows.
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/plugin/jiragithub/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package jiragithub
import (
"github.com/spf13/viper"

"github.com/devstream-io/devstream/pkg/util/github"
"github.com/devstream-io/devstream/pkg/util/scm/github"
)

func setRepoSecrets(gitHubClient *github.Client) error {
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/plugin/jiragithub/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (

"github.com/mitchellh/mapstructure"

"github.com/devstream-io/devstream/pkg/util/git"
"github.com/devstream-io/devstream/pkg/util/github"
"github.com/devstream-io/devstream/pkg/util/log"
"github.com/devstream-io/devstream/pkg/util/scm/git"
"github.com/devstream-io/devstream/pkg/util/scm/github"
)

// Read get jira-github-integ workflows.
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/plugin/jiragithub/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package jiragithub
import (
"github.com/mitchellh/mapstructure"

github "github.com/devstream-io/devstream/pkg/util/github"
github "github.com/devstream-io/devstream/pkg/util/scm/github"
"github.com/devstream-io/devstream/pkg/util/template"
)

Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/plugin/jiragithub/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (

"github.com/mitchellh/mapstructure"

"github.com/devstream-io/devstream/pkg/util/git"
"github.com/devstream-io/devstream/pkg/util/github"
"github.com/devstream-io/devstream/pkg/util/log"
"github.com/devstream-io/devstream/pkg/util/scm/git"
"github.com/devstream-io/devstream/pkg/util/scm/github"
)

// Update remove and set up jira-github-integ workflows.
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/plugin/jiragithub/workflow.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package jiragithub

import (
github "github.com/devstream-io/devstream/pkg/util/github"
"github.com/devstream-io/devstream/pkg/util/scm/github"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/plugin/trellogithub/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (

"github.com/spf13/viper"

"github.com/devstream-io/devstream/pkg/util/git"
"github.com/devstream-io/devstream/pkg/util/github"
"github.com/devstream-io/devstream/pkg/util/scm/git"
"github.com/devstream-io/devstream/pkg/util/scm/github"
)

// VerifyWorkflows get the workflows with names "wf1.yml", "wf2.yml", then:
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/plugin/trellogithub/read.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package trellogithub

import (
"github.com/devstream-io/devstream/pkg/util/github"
"github.com/devstream-io/devstream/pkg/util/log"
"github.com/devstream-io/devstream/pkg/util/scm/github"
)

func Read(options map[string]interface{}) (map[string]interface{}, error) {
Expand Down
5 changes: 2 additions & 3 deletions internal/pkg/plugin/trellogithub/trellogithub.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import (
"fmt"

mapset "github.com/deckarep/golang-set/v2"

"github.com/mitchellh/mapstructure"

"github.com/devstream-io/devstream/pkg/util/git"
"github.com/devstream-io/devstream/pkg/util/github"
"github.com/devstream-io/devstream/pkg/util/log"
"github.com/devstream-io/devstream/pkg/util/mapz"
"github.com/devstream-io/devstream/pkg/util/scm/git"
"github.com/devstream-io/devstream/pkg/util/scm/github"
)

type TrelloGithub struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/plugin/trellogithub/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package trellogithub

import (
"github.com/devstream-io/devstream/internal/pkg/plugin/trellogithub/trello"
"github.com/devstream-io/devstream/pkg/util/github"
"github.com/devstream-io/devstream/pkg/util/scm/github"
)

const (
Expand Down
8 changes: 5 additions & 3 deletions internal/pkg/plugininstaller/ci/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package ci
import (
"errors"

"github.com/devstream-io/devstream/pkg/util/scm"
"github.com/devstream-io/devstream/pkg/util/scm/git"

"github.com/devstream-io/devstream/internal/pkg/plugininstaller"
"github.com/devstream-io/devstream/pkg/util/git"
)

func PushCIFiles(options plugininstaller.RawOptions) error {
Expand All @@ -18,7 +20,7 @@ func PushCIFiles(options plugininstaller.RawOptions) error {
return err
}
//3. init git client
gitClient, err := opts.ProjectRepo.NewClient()
gitClient, err := scm.NewClient(opts.ProjectRepo.BuildRepoInfo())
if err != nil {
return err
}
Expand All @@ -45,7 +47,7 @@ func DeleteCIFiles(options plugininstaller.RawOptions) error {
return errors.New("can't get valid ci files, please check your config")
}
//2. init git client
gitClient, err := opts.ProjectRepo.NewClient()
gitClient, err := scm.NewClient(opts.ProjectRepo.BuildRepoInfo())
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/plugininstaller/ci/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/devstream-io/devstream/internal/pkg/plugininstaller"
"github.com/devstream-io/devstream/internal/pkg/plugininstaller/common"
"github.com/devstream-io/devstream/pkg/util/file"
"github.com/devstream-io/devstream/pkg/util/git"
"github.com/devstream-io/devstream/pkg/util/scm/git"
"github.com/devstream-io/devstream/pkg/util/template"
"github.com/devstream-io/devstream/pkg/util/types"
)
Expand Down
3 changes: 2 additions & 1 deletion internal/pkg/plugininstaller/ci/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ci
import (
"github.com/devstream-io/devstream/internal/pkg/plugininstaller"
"github.com/devstream-io/devstream/internal/pkg/statemanager"
"github.com/devstream-io/devstream/pkg/util/scm"
)

func GetCIFileStatus(options plugininstaller.RawOptions) (statemanager.ResourceState, error) {
Expand All @@ -11,7 +12,7 @@ func GetCIFileStatus(options plugininstaller.RawOptions) (statemanager.ResourceS
return nil, err
}
fileLocation := getCIFilePath(opts.CIConfig.Type)
client, err := opts.ProjectRepo.NewClient()
client, err := scm.NewClient(opts.ProjectRepo.BuildRepoInfo())
if err != nil {
return nil, err
}
Expand Down
Loading