forked from hyperledger-cacti/cacti
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: jagpreetsinghsasan <[email protected]>
- Loading branch information
1 parent
74751af
commit 2e30533
Showing
22 changed files
with
1,658 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package configure | ||
|
||
type BevelConfig struct { | ||
LedgerType string `json:"LedgerType"` | ||
GitUrl string `json:"GitUrl"` | ||
GitUserName string `json:"GitUserName"` | ||
GitToken string `json:"GitToken"` | ||
GitUserEmail string `json:"GitUserEmail"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package configure | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/go-git/go-git/v5" | ||
"github.com/go-git/go-git/v5/plumbing/transport/http" | ||
"github.com/hyperledger/cacti/examples/bevel/utils" | ||
"go.uber.org/zap" | ||
) | ||
|
||
const ( | ||
BevelRemoteUrl = "https://github.com/hyperledger/bevel.git" | ||
BevelRemoteName = "BevelRemoteForCacti" | ||
BevelBranchName = "cactibevelexample" | ||
) | ||
|
||
func DownloadBevelRepo(gitUrl string, gitUsername string, gitToken string, logger *zap.Logger){ | ||
logger.Info("Deleting any previous instances of repository present on the ./repo path") | ||
errRemoveRepo := os.RemoveAll("./repo") | ||
if errRemoveRepo != nil { | ||
logger.Error(fmt.Sprint(errRemoveRepo)) | ||
} | ||
|
||
|
||
logger.Info("Cloning the bevel repository") | ||
_, err := git.PlainClone("repo", false, &git.CloneOptions{ | ||
URL: gitUrl, | ||
Auth: &http.BasicAuth{ | ||
Username: gitUsername, | ||
Password: gitToken, | ||
}, | ||
Progress: os.Stdout, | ||
}) | ||
|
||
if err != nil { | ||
logger.Error(fmt.Sprint(err)) | ||
} | ||
} | ||
|
||
func CreateBranchFromBevelRemote(logger *zap.Logger) { | ||
utils.ExecuteCmd([]string{"git", "-C", "./repo/", "remote", "add", "bevel", BevelRemoteUrl}, false, logger) | ||
utils.ExecuteCmd([]string{"git", "-C", "./repo/", "fetch", "bevel", "tag", "v1.0.0.0", "--no-tags"}, false, logger) | ||
utils.ExecuteCmd([]string{"git", "-C", "./repo/", "checkout", "-b", BevelBranchName, "v1.0.0.0"}, false, logger) | ||
utils.ExecuteCmd([]string{"git", "-C", "./repo/", "push", "--set-upstream", "origin", "cactibevelexample", "--force"}, true, logger) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package configure | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"os" | ||
"go.uber.org/zap" | ||
) | ||
|
||
func ReadBevelConfig(bevelConfigFileAbsPath string, logger *zap.Logger) BevelConfig{ | ||
logger.Info("Reading file contents from: " + bevelConfigFileAbsPath) | ||
|
||
file, err := os.Open(bevelConfigFileAbsPath) | ||
if err != nil { | ||
logger.Error(fmt.Sprint(err)) | ||
} | ||
defer file.Close() | ||
|
||
var bevelConfig BevelConfig | ||
decoder := json.NewDecoder(file) | ||
err = decoder.Decode(&bevelConfig) | ||
if err != nil { | ||
logger.Error(fmt.Sprint(err)) | ||
} | ||
|
||
return bevelConfig | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.