本文整理匯總了Golang中github.com/eris-ltd/eris-cli/Godeps/_workspace/src/github.com/Sirupsen/logrus.Warn函數的典型用法代碼示例。如果您正苦於以下問題:Golang Warn函數的具體用法?Golang Warn怎麽用?Golang Warn使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Warn函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GetTheImages
func GetTheImages() error {
if os.Getenv("ERIS_PULL_APPROVE") == "true" {
if err := pullDefaultImages(); err != nil {
return err
}
log.Warn("Pulling of default images successful")
} else {
var input string
log.Warn(`WARNING: Approximately 1 gigabyte of docker images are about to be pulled onto your host machine
Please ensure that you have sufficient bandwidth to handle the download
On a remote host in the cloud, this should only take a few minutes but can sometimes take 10 or more.
These times can double or triple on local host machines
If you already have these images, they will be updated`)
log.WithField("ERIS_PULL_APPROVE", "true").Warn("To avoid this warning on all future pulls, set as an environment variable")
fmt.Print("Do you wish to continue? (y/n): ")
if _, err := fmt.Scanln(&input); err != nil {
return fmt.Errorf("Error reading from stdin: %v\n", err)
}
if input == "Y" || input == "y" || input == "YES" || input == "Yes" || input == "yes" {
if err := pullDefaultImages(); err != nil {
return err
}
log.Warn("Pulling of default images successful")
}
}
return nil
}
示例2: createContainer
// ----------------------------------------------------------------------------
// --------------------- Container Core ------------------------------------
// ----------------------------------------------------------------------------
func createContainer(opts docker.CreateContainerOptions) (*docker.Container, error) {
dockerContainer, err := util.DockerClient.CreateContainer(opts)
if err != nil {
if err == docker.ErrNoSuchImage {
if os.Getenv("ERIS_PULL_APPROVE") != "true" {
var input string
log.WithField("image", opts.Config.Image).Warn("The docker image not found locally")
fmt.Print("Would you like the marmots to pull it from the repository? (y/n): ")
fmt.Scanln(&input)
if input == "Y" || input == "y" || input == "YES" || input == "Yes" || input == "yes" {
log.Debug("User assented to pull")
} else {
log.Debug("User refused to pull")
return nil, fmt.Errorf("Cannot start a container based on an image you will not let me pull.\n")
}
} else {
log.WithField("image", opts.Config.Image).Warn("The Docker image is not found locally")
log.Warn("The marmots are approved to pull it from the repository on your behalf")
log.Warn("This could take a few minutes")
}
if err := pullImage(opts.Config.Image, nil); err != nil {
return nil, err
}
dockerContainer, err = util.DockerClient.CreateContainer(opts)
if err != nil {
return nil, err
}
} else {
return nil, err
}
}
return dockerContainer, nil
}
示例3: createErisMachine
func createErisMachine(driver string) error {
log.Warn("Creating the Eris Docker Machine")
log.Warn("This will take some time, please feel free to go feed your marmot")
log.WithField("driver", driver).Debug()
cmd := "docker-machine"
args := []string{"create", "--driver", driver, "eris"}
if err := exec.Command(cmd, args...).Run(); err != nil {
log.Debugf("There was an error creating the Eris Docker Machine: %v", err)
return mustInstallError()
}
log.Debug("Eris Docker Machine created")
return startErisMachine()
}
示例4: ListAll
//XXX chains and services only
func ListAll(do *definitions.Do, typ string) (err error) {
quiet := do.Quiet
var result string
if do.All == true { //overrides all the functionality used for flags/tests to stdout a nice table
resK, err := ListKnown(typ)
if err != nil {
return err
}
do.Result = resK //for testing but not rly needed
knowns := strings.Split(resK, "\n")
typs := fmt.Sprintf("The known %s on your host kind marmot:", typ)
log.WithField("=>", knowns[0]).Warn(typs)
knowns = append(knowns[:0], knowns[1:]...)
for _, known := range knowns {
log.WithField("=>", known).Warn()
}
result, err = PrintTableReport(typ, true, true) //when latter bool is true, former one will be ignored...
if err != nil {
return err
}
contType := fmt.Sprintf("Active %s containers:", typ)
log.Warn(contType)
log.Warn(result)
} else {
var resK, resR, resE string
if do.Known {
if resK, err = ListKnown(typ); err != nil {
return err
}
do.Result = resK
}
if do.Running {
if resR, err = ListRunningOrExisting(quiet, false, typ); err != nil {
return err
}
do.Result = resR
}
if do.Existing {
if resE, err = ListRunningOrExisting(quiet, true, typ); err != nil {
return err
}
do.Result = resE
}
}
return nil
}
示例5: ImportChain
func ImportChain(do *definitions.Do) error {
fileName := filepath.Join(ChainsPath, do.Name)
if filepath.Ext(fileName) == "" {
fileName = fileName + ".toml"
}
s := strings.Split(do.Path, ":")
if s[0] == "ipfs" {
var err error
if log.GetLevel() > 0 {
err = ipfs.GetFromIPFS(s[1], fileName, "", os.Stdout)
} else {
err = ipfs.GetFromIPFS(s[1], fileName, "", bytes.NewBuffer([]byte{}))
}
if err != nil {
return err
}
return nil
}
if strings.Contains(s[0], "github") {
log.Warn("https://twitter.com/ryaneshea/status/595957712040628224")
return nil
}
return fmt.Errorf("I do not know how to get that file. Sorry.")
}
示例6: TestKillRmService
func TestKillRmService(t *testing.T) {
testStartService(t, servName, false)
do := def.NowDo()
do.Name = servName
do.Rm = false
do.RmD = false
do.Operations.Args = []string{servName}
log.WithField("=>", servName).Debug("Stopping service (from tests)")
if e := KillService(do); e != nil {
log.Error(e)
tests.IfExit(e)
}
testExistAndRun(t, servName, 1, true, false)
testNumbersExistAndRun(t, servName, 1, 0)
if os.Getenv("TEST_IN_CIRCLE") == "true" {
log.Warn("Testing in Circle where we don't have rm privileges. Skipping test")
return
}
do = def.NowDo()
do.Name = servName
do.Operations.Args = []string{servName}
do.File = false
do.RmD = true
log.WithField("=>", servName).Debug("Removing service (from tests)")
if e := RmService(do); e != nil {
log.Error(e)
tests.IfExit(e)
}
testExistAndRun(t, servName, 1, false, false)
testNumbersExistAndRun(t, servName, 0, 0)
}
示例7: FilesPut
func FilesPut(cmd *cobra.Command, args []string) {
IfExit(ArgCheck(1, "eq", cmd, args))
do.Name = args[0]
err := files.PutFiles(do)
IfExit(err)
log.Warn(do.Result)
}
示例8: ImportAction
func ImportAction(do *definitions.Do) error {
if do.Name == "" {
do.Name = strings.Join(do.Operations.Args, "_")
}
fileName := filepath.Join(ActionsPath, strings.Join(do.Operations.Args, " "))
if filepath.Ext(fileName) == "" {
fileName = fileName + ".toml"
}
s := strings.Split(do.Path, ":")
if s[0] == "ipfs" {
var err error
//unset 1 as default ContainerNumber, let it take flag?
ipfsService, err := loaders.LoadServiceDefinition("ipfs", false, 1)
if err != nil {
return err
}
ipfsService.Operations.ContainerType = definitions.TypeService
err = perform.DockerRunService(ipfsService.Service, ipfsService.Operations)
if err != nil {
return err
}
if log.GetLevel() > 0 {
err = ipfs.GetFromIPFS(s[1], fileName, "", os.Stdout)
} else {
err = ipfs.GetFromIPFS(s[1], fileName, "", bytes.NewBuffer([]byte{}))
}
if err != nil {
return err
}
return nil
}
if strings.Contains(s[0], "github") {
log.Warn("https://twitter.com/ryaneshea/status/595957712040628224")
return nil
}
log.Warn("Failed to get that file. Sorry")
return nil
}
示例9: ListDatas
// pulled out for simplicity; neither known or running
func ListDatas(do *definitions.Do) error {
var result string
var err error
if do.Quiet {
result = strings.Join(util.DataContainerNames(), "\n")
do.Result = result
log.Warn(result)
} else {
result, err = PrintTableReport("data", true, true)
if err != nil {
return err
}
log.Warn("Active data containers:")
log.Warn(result)
}
return nil
}
示例10: FilesList
func FilesList(cmd *cobra.Command, args []string) {
if len(args) != 1 {
cmd.Help()
return
}
do.Name = args[0]
err := files.ListFiles(do)
IfExit(err)
log.Warn(do.Result)
}
示例11: CatChain
func CatChain(do *definitions.Do) error {
cat, err := ioutil.ReadFile(filepath.Join(ChainsPath, do.Name+".toml"))
if err != nil {
return err
}
// Let's actually WRITE this to the GlobalConfig.Writer...
log.Warn(string(cat))
return nil
}
示例12: TestPutFiles
func TestPutFiles(t *testing.T) {
do := definitions.NowDo()
do.Name = file
log.WithField("=>", do.Name).Info("Putting file (from tests)")
hash := "QmcJdniiSKMp5az3fJvkbJTANd7bFtDoUkov3a8pkByWkv"
// Fake IPFS server.
os.Setenv("ERIS_IPFS_HOST", "http://0.0.0.0")
ipfs := tests.NewServer("0.0.0.0:8080")
log.Warn("Server turned on.")
ipfs.SetResponse(tests.ServerResponse{
Code: http.StatusOK,
Header: map[string][]string{
"Ipfs-Hash": {hash},
},
})
log.Warn("Waiting on server response.")
defer ipfs.Close()
if err := PutFiles(do); err != nil {
fatal(t, err)
}
if expected := "/ipfs/"; ipfs.Path() != expected {
fatal(t, fmt.Errorf("Called the wrong endpoint; expected %v, got %v\n", expected, ipfs.Path()))
}
if expected := "POST"; ipfs.Method() != expected {
fatal(t, fmt.Errorf("Used the wrong HTTP method; expected %v, got %v\n", expected, ipfs.Method()))
}
if ipfs.Body() != content {
fatal(t, fmt.Errorf("Put the bad file; expected %q, got %q\n", content, ipfs.Body()))
}
if hash != do.Result {
fatal(t, fmt.Errorf("Hash mismatch; expected %q, got %q\n", hash, do.Result))
}
log.WithField("result", do.Result).Debug("Finished putting a file")
}
示例13: checkThenInitErisRoot
func checkThenInitErisRoot(force bool) (bool, error) {
var newDir bool
if force { //for testing only
log.Warn("Force initializing eris root directory")
if err := common.InitErisDir(); err != nil {
return true, fmt.Errorf("Error:\tcould not initialize the eris root directory.\n%s\n", err)
}
return true, nil
}
if !util.DoesDirExist(common.ErisRoot) {
log.Warn("Eris root directory does not exist. The marmots will initialize this directory for you")
if err := common.InitErisDir(); err != nil {
return true, fmt.Errorf("Error:\tcould not initialize the eris root directory.\n%s\n", err)
}
newDir = true
} else { // ErisRoot exists, prompt for overwrite
newDir = false
}
return newDir, nil
}
示例14: removeErisImages
func removeErisImages(prompt bool) error {
opts := docker.ListImagesOptions{
All: true,
Filters: nil,
Digests: false,
}
allTheImages, err := DockerClient.ListImages(opts)
if err != nil {
return err
}
//get all repo tags & IDs
// [zr] this could probably be cleaner
repoTags := make(map[int][]string)
imageIDs := make(map[int]string)
for i, image := range allTheImages {
repoTags[i] = image.RepoTags
imageIDs[i] = image.ID
}
erisImages := []string{}
erisImageIDs := []string{}
//searches through repo tags for eris images & "maps" to ID
for i, repoTag := range repoTags {
for _, rt := range repoTag {
r, err := regexp.Compile(`eris`)
if err != nil {
log.Errorf("Regexp error: %v", err)
}
if r.MatchString(rt) == true {
erisImages = append(erisImages, rt)
erisImageIDs = append(erisImageIDs, imageIDs[i])
}
}
}
if !prompt || canWeRemove(erisImages, "images") {
for i, imageID := range erisImageIDs {
log.WithFields(log.Fields{
"=>": erisImages[i],
"id": imageID,
}).Debug("Removing image")
if err := DockerClient.RemoveImage(imageID); err != nil {
return err
}
}
} else {
log.Warn("Permission to remove images not given, continuing with clean")
}
return nil
}
示例15: ListActions
func ListActions(cmd *cobra.Command, args []string) {
// TODO: add scoping for when projects done.
do.Known = true
do.Running = false
do.Existing = false
if err := util.ListAll(do, "actions"); err != nil {
return
}
for _, s := range strings.Split(do.Result, "\n") {
log.Warn(strings.Replace(s, "_", " ", -1))
}
}