本文整理匯總了Golang中github.com/golang/glog.Fatalf函數的典型用法代碼示例。如果您正苦於以下問題:Golang Fatalf函數的具體用法?Golang Fatalf怎麽用?Golang Fatalf使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Fatalf函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: doGenCommitters
func doGenCommitters(client *github_api.Client) {
c, err := github.UsersWithCommit(client, org, project)
if err != nil {
glog.Fatalf("Unable to read committers from github: %v", err)
}
if err = writeWhitelist(*committers, "# auto-generated by "+os.Args[0]+" -gen-committers; manual additions should go in the whitelist", c); err != nil {
glog.Fatalf("Unable to write committers: %v", err)
}
glog.Info("Successfully updated committers file.")
users, err := loadWhitelist(*userWhitelist)
if err != nil {
glog.Fatalf("error loading whitelist; it will not be updated: %v", err)
}
existing := util.NewStringSet(c...)
newUsers := []string{}
for _, u := range users {
if existing.Has(u) {
glog.Infof("%v is a dup, or already a committer. Will remove from whitelist.", u)
continue
}
existing.Insert(u)
newUsers = append(newUsers, u)
}
if err = writeWhitelist(*userWhitelist, "# remove dups with "+os.Args[0]+" -gen-committers", newUsers); err != nil {
glog.Fatalf("Unable to write de-duped whitelist: %v", err)
}
glog.Info("Successfully de-duped whitelist.")
os.Exit(0)
}
示例2: main
func main() {
clientConfig := kubectl_util.DefaultClientConfig(flags)
flags.Parse(os.Args)
cfg := parseCfg(*config, *lbDefAlgorithm)
var kubeClient *unversioned.Client
var err error
defErrorPage := newStaticPageHandler(*errorPage, defaultErrorPage)
if defErrorPage == nil {
glog.Fatalf("Failed to load the default error page")
}
go registerHandlers(defErrorPage)
var tcpSvcs map[string]int
if *tcpServices != "" {
tcpSvcs = parseTCPServices(*tcpServices)
} else {
glog.Infof("No tcp/https services specified")
}
if *startSyslog {
cfg.startSyslog = true
_, err = newSyslogServer("/var/run/haproxy.log.socket")
if err != nil {
glog.Fatalf("Failed to start syslog server: %v", err)
}
}
if *cluster {
if kubeClient, err = unversioned.NewInCluster(); err != nil {
glog.Fatalf("Failed to create client: %v", err)
}
} else {
config, err := clientConfig.ClientConfig()
if err != nil {
glog.Fatalf("error connecting to the client: %v", err)
}
kubeClient, err = unversioned.New(config)
}
namespace, specified, err := clientConfig.Namespace()
if err != nil {
glog.Fatalf("unexpected error: %v", err)
}
if !specified {
namespace = api.NamespaceAll
}
// TODO: Handle multiple namespaces
lbc := newLoadBalancerController(cfg, kubeClient, namespace, tcpSvcs)
go lbc.epController.Run(util.NeverStop)
go lbc.svcController.Run(util.NeverStop)
if *dry {
dryRun(lbc)
} else {
lbc.cfg.reload()
util.Until(lbc.worker, time.Second, util.NeverStop)
}
}
示例3: fetch
func (t *CloudInitTarget) fetch(p *fi.Source, destPath string) {
// We could probably move this to fi.Source - it is likely to be the same for every provider
if p.URL != "" {
if p.Parent != nil {
glog.Fatalf("unexpected parent with SourceURL in FetchInstructions: %v", p)
}
t.AddDownloadCommand(Once, p.URL, destPath)
} else if p.ExtractFromArchive != "" {
if p.Parent == nil {
glog.Fatalf("unexpected ExtractFromArchive without parent in FetchInstructions: %v", p)
}
// TODO: Remove duplicate commands?
archivePath := "/tmp/" + utils.SanitizeString(p.Parent.Key())
t.fetch(p.Parent, archivePath)
extractDir := "/tmp/extracted_" + utils.SanitizeString(p.Parent.Key())
t.AddMkdirpCommand(extractDir, 0755)
t.AddCommand(Once, "tar", "zxf", archivePath, "-C", extractDir)
// Always because this shouldn't happen and we want an indication that it happened
t.AddCommand(Always, "cp", path.Join(extractDir, p.ExtractFromArchive), destPath)
} else {
glog.Fatalf("unknown FetchInstructions: %v", p)
}
}
示例4: run
// run is responsible for preparing environment for actual build.
// It accepts factoryFunc and an ordered array of SCMAuths.
func run(builderFactory factoryFunc, scmAuths []scmauth.SCMAuth) {
client, endpoint, err := dockerutil.NewHelper().GetClient()
if err != nil {
glog.Fatalf("Error obtaining docker client: %v", err)
}
buildStr := os.Getenv("BUILD")
build := api.Build{}
if err := latest.Codec.DecodeInto([]byte(buildStr), &build); err != nil {
glog.Fatalf("Unable to parse build: %v", err)
}
var (
authcfg docker.AuthConfiguration
authPresent bool
)
output := build.Spec.Output.To != nil && len(build.Spec.Output.To.Name) != 0
if output {
authcfg, authPresent = dockercfg.NewHelper().GetDockerAuth(
build.Spec.Output.To.Name,
dockercfg.PullAuthType,
)
}
if build.Spec.Source.SourceSecret != nil {
if err := setupSourceSecret(build.Spec.Source.SourceSecret.Name, scmAuths); err != nil {
glog.Fatalf("Cannot setup secret file for accessing private repository: %v", err)
}
}
b := builderFactory(client, endpoint, authcfg, authPresent, &build)
if err = b.Build(); err != nil {
glog.Fatalf("Build error: %v", err)
}
if !output {
glog.Warning("Build does not have an Output defined, no output image was pushed to a registry.")
}
}
示例5: RunServiceAccountTokensController
// RunServiceAccountTokensController starts the service account token controller
func (c *MasterConfig) RunServiceAccountTokensController() {
if len(c.Options.ServiceAccountConfig.PrivateKeyFile) == 0 {
glog.Infof("Skipped starting Service Account Token Manager, no private key specified")
return
}
privateKey, err := serviceaccount.ReadPrivateKey(c.Options.ServiceAccountConfig.PrivateKeyFile)
if err != nil {
glog.Fatalf("Error reading signing key for Service Account Token Manager: %v", err)
}
rootCA := []byte{}
if len(c.Options.ServiceAccountConfig.MasterCA) > 0 {
rootCA, err = ioutil.ReadFile(c.Options.ServiceAccountConfig.MasterCA)
if err != nil {
glog.Fatalf("Error reading master ca file for Service Account Token Manager: %s: %v", c.Options.ServiceAccountConfig.MasterCA, err)
}
if _, err := kcrypto.CertsFromPEM(rootCA); err != nil {
glog.Fatalf("Error parsing master ca file for Service Account Token Manager: %s: %v", c.Options.ServiceAccountConfig.MasterCA, err)
}
}
options := sacontroller.TokensControllerOptions{
TokenGenerator: serviceaccount.JWTTokenGenerator(privateKey),
RootCA: rootCA,
}
sacontroller.NewTokensController(clientadapter.FromUnversionedClient(c.KubeClient()), options).Run()
}
示例6: RunDNSServer
// RunDNSServer starts the DNS server
func (c *MasterConfig) RunDNSServer() {
config, err := dns.NewServerDefaults()
if err != nil {
glog.Fatalf("Could not start DNS: %v", err)
}
config.DnsAddr = c.Options.DNSConfig.BindAddress
config.NoRec = true // do not want to deploy an open resolver
_, port, err := net.SplitHostPort(c.Options.DNSConfig.BindAddress)
if err != nil {
glog.Fatalf("Could not start DNS: %v", err)
}
if port != "53" {
glog.Warningf("Binding DNS on port %v instead of 53 (you may need to run as root and update your config), using %s which will not resolve from all locations", port, c.Options.DNSConfig.BindAddress)
}
if ok, err := cmdutil.TryListen(c.Options.DNSConfig.BindAddress); !ok {
glog.Warningf("Could not start DNS: %v", err)
return
}
go func() {
err := dns.ListenAndServe(config, c.DNSServerClient(), c.EtcdHelper.Client.(*etcdclient.Client))
glog.Fatalf("Could not start DNS: %v", err)
}()
cmdutil.WaitForSuccessfulDial(false, "tcp", c.Options.DNSConfig.BindAddress, 100*time.Millisecond, 100*time.Millisecond, 100)
glog.Infof("DNS listening at %s", c.Options.DNSConfig.BindAddress)
}
示例7: Less
func (r *RuntimeSort) Less(i, j int) bool {
iObj := r.objs[i]
jObj := r.objs[j]
parser := jsonpath.New("sorting")
parser.Parse(r.field)
iValues, err := parser.FindResults(reflect.ValueOf(iObj).Elem().Interface())
if err != nil {
glog.Fatalf("Failed to get i values for %#v using %s (%#v)", iObj, r.field, err)
}
jValues, err := parser.FindResults(reflect.ValueOf(jObj).Elem().Interface())
if err != nil {
glog.Fatalf("Failed to get j values for %#v using %s (%v)", jObj, r.field, err)
}
iField := iValues[0][0]
jField := jValues[0][0]
less, err := isLess(iField, jField)
if err != nil {
glog.Fatalf("Field %s in %v is an unsortable type: %s, err: %v", r.field, iObj, iField.Kind().String(), err)
}
return less
}
示例8: Fatalf
func Fatalf(ctx context.Context, format string, args ...interface{}) {
if ctx == nil || !hasTraceKey(ctx) {
glog.Fatalf(format, args)
return
}
glog.Fatalf(prependFormat(format), prependParam(args, ctx)...)
}
示例9: run
// run is responsible for preparing environment for actual build.
// It accepts factoryFunc and an ordered array of SCMAuths.
func run(builderFactory factoryFunc, scmAuths []scmauth.SCMAuth) {
client, endpoint, err := dockerutil.NewHelper().GetClient()
if err != nil {
glog.Fatalf("Error obtaining docker client: %v", err)
}
buildStr := os.Getenv("BUILD")
glog.V(4).Infof("$BUILD env var is %s \n", buildStr)
build := api.Build{}
if err := latest.Codec.DecodeInto([]byte(buildStr), &build); err != nil {
glog.Fatalf("Unable to parse build: %v", err)
}
if build.Spec.Source.SourceSecret != nil {
if err := setupSourceSecret(build.Spec.Source.SourceSecret.Name, scmAuths); err != nil {
glog.Fatalf("Cannot setup secret file for accessing private repository: %v", err)
}
}
b := builderFactory(client, endpoint, &build)
if err = b.Build(); err != nil {
glog.Fatalf("Build error: %v", err)
}
if build.Spec.Output.To == nil || len(build.Spec.Output.To.Name) == 0 {
glog.Warning("Build does not have an Output defined, no output image was pushed to a registry.")
}
}
示例10: InstallAPIs
// InstallAPIs will install the APIs for the restStorageProviders if they are enabled.
func (m *Master) InstallAPIs(apiResourceConfigSource genericapiserver.APIResourceConfigSource, restOptionsGetter generic.RESTOptionsGetter, restStorageProviders ...RESTStorageProvider) {
apiGroupsInfo := []genericapiserver.APIGroupInfo{}
for _, restStorageBuilder := range restStorageProviders {
groupName := restStorageBuilder.GroupName()
if !apiResourceConfigSource.AnyResourcesForGroupEnabled(groupName) {
glog.V(1).Infof("Skipping disabled API group %q.", groupName)
continue
}
apiGroupInfo, enabled := restStorageBuilder.NewRESTStorage(apiResourceConfigSource, restOptionsGetter)
if !enabled {
glog.Warningf("Problem initializing API group %q, skipping.", groupName)
continue
}
glog.V(1).Infof("Enabling API group %q.", groupName)
if postHookProvider, ok := restStorageBuilder.(genericapiserver.PostStartHookProvider); ok {
name, hook, err := postHookProvider.PostStartHook()
if err != nil {
glog.Fatalf("Error building PostStartHook: %v", err)
}
if err := m.GenericAPIServer.AddPostStartHook(name, hook); err != nil {
glog.Fatalf("Error registering PostStartHook %q: %v", name, err)
}
}
apiGroupsInfo = append(apiGroupsInfo, apiGroupInfo)
}
for i := range apiGroupsInfo {
if err := m.GenericAPIServer.InstallAPIGroup(&apiGroupsInfo[i]); err != nil {
glog.Fatalf("Error in registering group versions: %v", err)
}
}
}
示例11: Less
func (r *RuntimeSort) Less(i, j int) bool {
iObj := r.objs[i]
jObj := r.objs[j]
parser := jsonpath.New("sorting")
parser.Parse(r.field)
iValues, err := parser.FindResults(reflect.ValueOf(iObj).Elem().Interface())
if err != nil {
glog.Fatalf("Failed to get i values for %#v using %s (%#v)", iObj, r.field, err)
}
jValues, err := parser.FindResults(reflect.ValueOf(jObj).Elem().Interface())
if err != nil {
glog.Fatalf("Failed to get j values for %#v using %s (%v)", jObj, r.field, err)
}
iField := iValues[0][0]
jField := jValues[0][0]
switch iField.Kind() {
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
return iField.Int() < jField.Int()
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
return iField.Uint() < jField.Uint()
case reflect.Float32, reflect.Float64:
return iField.Float() < jField.Float()
case reflect.String:
return iField.String() < jField.String()
default:
glog.Fatalf("Field %s in %v is an unsortable type: %s", r.field, iObj, iField.Kind().String())
}
// default to preserving order
return i < j
}
示例12: multisnapshotCmd
func multisnapshotCmd(mysqld *mysqlctl.Mysqld, subFlags *flag.FlagSet, args []string) {
concurrency := subFlags.Int("concurrency", 8, "how many compression jobs to run simultaneously")
spec := subFlags.String("spec", "-", "shard specification")
tablesString := subFlags.String("tables", "", "dump only this comma separated list of tables")
skipSlaveRestart := subFlags.Bool("skip-slave-restart", false, "after the snapshot is done, do not restart slave replication")
maximumFilesize := subFlags.Uint64("maximum-file-size", 128*1024*1024, "the maximum size for an uncompressed data file")
subFlags.Parse(args)
if subFlags.NArg() != 2 {
log.Fatalf("action multisnapshot requires <db name> <key name>")
}
shards, err := key.ParseShardingSpec(*spec)
if err != nil {
log.Fatalf("multisnapshot failed: %v", err)
}
var tables []string
if *tablesString != "" {
tables = strings.Split(*tablesString, ",")
}
filenames, err := mysqld.CreateMultiSnapshot(shards, subFlags.Arg(0), subFlags.Arg(1), tabletAddr, false, *concurrency, tables, *skipSlaveRestart, *maximumFilesize, nil)
if err != nil {
log.Fatalf("multisnapshot failed: %v", err)
} else {
log.Infof("manifest locations: %v", filenames)
}
}
示例13: InitPlugin
// InitPlugin creates an instance of the named interface.
func InitPlugin(name string, client client.Interface, configFilePath string) Interface {
var (
config *os.File
err error
)
if name == "" {
glog.Info("No admission plugin specified.")
return nil
}
if configFilePath != "" {
config, err = os.Open(configFilePath)
if err != nil {
glog.Fatalf("Couldn't open admission plugin configuration %s: %#v",
configFilePath, err)
}
defer config.Close()
}
plugin, err := GetPlugin(name, client, config)
if err != nil {
glog.Fatalf("Couldn't init admission plugin %q: %v", name, err)
}
if plugin == nil {
glog.Fatalf("Unknown admission plugin: %s", name)
}
return plugin
}
示例14: main
func main() {
flag.Parse()
// create the client
client, err := vtctlclient.New(*server, *dialTimeout)
if err != nil {
log.Fatalf("Cannot dial to server %v: %v", *server, err)
}
defer client.Close()
// run the command
c, errFunc := client.ExecuteVtctlCommand(flag.Args(), *actionTimeout, *lockWaitTimeout)
if err = errFunc(); err != nil {
log.Fatalf("Cannot execute remote command: %v", err)
}
// stream the result
for e := range c {
switch e.Level {
case logutil.LOGGER_INFO:
log.Info(e.String())
case logutil.LOGGER_WARNING:
log.Warning(e.String())
case logutil.LOGGER_ERROR:
log.Error(e.String())
case logutil.LOGGER_CONSOLE:
fmt.Print(e.Value)
}
}
// then display the overall error
if err = errFunc(); err != nil {
log.Fatalf("Remote error: %v", err)
}
}
示例15: CopyTablets
// CopyTablets will create the tablets in the destination topo
func CopyTablets(fromTS, toTS topo.Server) {
cells, err := fromTS.GetKnownCells()
if err != nil {
log.Fatalf("fromTS.GetKnownCells failed: %v", err)
}
wg := sync.WaitGroup{}
rec := concurrency.AllErrorRecorder{}
for _, cell := range cells {
wg.Add(1)
go func(cell string) {
defer wg.Done()
tabletAliases, err := fromTS.GetTabletsByCell(cell)
if err != nil {
rec.RecordError(err)
} else {
for _, tabletAlias := range tabletAliases {
wg.Add(1)
go func(tabletAlias topo.TabletAlias) {
defer wg.Done()
// read the source tablet
ti, err := fromTS.GetTablet(tabletAlias)
if err != nil {
rec.RecordError(err)
return
}
// try to create the destination
err = toTS.CreateTablet(ti.Tablet)
if err == topo.ErrNodeExists {
// update the destination tablet
log.Warningf("tablet %v already exists, updating it", tabletAlias)
err = toTS.UpdateTabletFields(ti.Alias(), func(t *topo.Tablet) error {
*t = *ti.Tablet
return nil
})
}
if err != nil {
rec.RecordError(err)
return
}
// create the replication paths
// for masters only here
if ti.Type == topo.TYPE_MASTER {
if err = toTS.CreateReplicationPath(ti.Keyspace, ti.Shard, ti.Alias().String()); err != nil && err != topo.ErrNodeExists {
rec.RecordError(err)
}
}
}(tabletAlias)
}
}
}(cell)
}
wg.Wait()
if rec.HasErrors() {
log.Fatalf("copyTablets failed: %v", rec.Error())
}
}