Skip to content

Commit

Permalink
Add provider to node
Browse files Browse the repository at this point in the history
  • Loading branch information
nomeguy committed Oct 10, 2023
1 parent 2785fb8 commit 299c417
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 10 deletions.
15 changes: 8 additions & 7 deletions object/site.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ import (
)

type Node struct {
Name string `json:"name"`
Version string `json:"version"`
Diff string `json:"diff"`
Pid int `json:"pid"`
Status string `json:"status"`
Message string `json:"message"`
Name string `json:"name"`
Version string `json:"version"`
Diff string `json:"diff"`
Pid int `json:"pid"`
Status string `json:"status"`
Message string `json:"message"`
Provider string `json:"provider"`
}

type Site struct {
Expand Down Expand Up @@ -255,7 +256,7 @@ func (site *Site) checkNodes() error {
diff = site.Nodes[0].Diff
}

pid, err := run.CreateRepo(site.Name, !ok, diff)
pid, err := run.CreateRepo(site.Name, !ok, diff, node.Provider)
if err != nil {
return err
}
Expand Down
4 changes: 4 additions & 0 deletions run/cdn.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ func updateHtml(domainUrl string, buildDir string) {
}

func gitUploadCdn(providerName string, siteName string) error {
if providerName == "" {
return nil
}

fmt.Printf("gitUploadCdn(): [%s]\n", siteName)

path := GetRepoPath(siteName)
Expand Down
2 changes: 1 addition & 1 deletion run/git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestGitGetDiff(t *testing.T) {
//diff := GitDiff("F:/github_repos/casdoor")
//println(diff)

pid, err := CreateRepo("casdoor_test", true, "")
pid, err := CreateRepo("casdoor_test", true, "", "")
if err != nil {
panic(err)
}
Expand Down
12 changes: 11 additions & 1 deletion run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func isTargetRepo(siteName string) bool {
return strings.HasPrefix(siteName, "cc_") || strings.Count(siteName, "_") == 2
}

func CreateRepo(siteName string, needStart bool, diff string) (int, error) {
func CreateRepo(siteName string, needStart bool, diff string, providerName string) (int, error) {
path := GetRepoPath(siteName)
if !util.FileExist(path) {
originalName := getOriginalName(siteName)
Expand Down Expand Up @@ -67,6 +67,11 @@ func CreateRepo(siteName string, needStart bool, diff string) (int, error) {
if err != nil {
return 0, err
}

err = gitUploadCdn(providerName, siteName)
if err != nil {
return 0, err
}
}

err = updateBatFile(siteName)
Expand Down Expand Up @@ -113,6 +118,11 @@ func CreateRepo(siteName string, needStart bool, diff string) (int, error) {
if err != nil {
return 0, err
}

err = gitUploadCdn(providerName, siteName)
if err != nil {
return 0, err
}
}

if affected {
Expand Down
15 changes: 14 additions & 1 deletion web/src/NodeTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class NodeTable extends React.Component {
title: "Version",
dataIndex: "version",
key: "version",
width: "300px",
width: "160px",
render: (text, record, index) => {
if (text === "") {
return null;
Expand Down Expand Up @@ -174,6 +174,19 @@ class NodeTable extends React.Component {
dataIndex: "message",
key: "message",
},
{
title: "Provider",
dataIndex: "provider",
key: "provider",
width: "250px",
render: (text, record, index) => {
return (
<Input value={text} onChange={e => {
this.updateField(table, index, "provider", e.target.value);
}} />
);
},
},
{
title: "Action",
key: "action",
Expand Down

0 comments on commit 299c417

Please sign in to comment.