Пример #1
0
func checkInProduction() bool {
	if !metadata.OnGCE() {
		return false
	}
	proj, _ := metadata.ProjectID()
	inst, _ := metadata.InstanceName()
	log.Printf("Running on GCE: %v / %v", proj, inst)
	return proj == "camlistore-website" && inst == "camweb"
}
Пример #2
0
func initGCP() {
	initGCPOnce.Do(func() {
		onGCE = metadata.OnGCE()
		if onGCE {
			// These will fail on instances if the metadata service is
			// down or the client is compiled with an API version that
			// has been removed. Since these are not vital, let's ignore
			// them and make their fields in the dockeLogEntry ,omitempty
			projectID, _ = metadata.ProjectID()
			zone, _ = metadata.Zone()
			instanceName, _ = metadata.InstanceName()
			instanceID, _ = metadata.InstanceID()
		}
	})
}
Пример #3
0
func (c *googleAPIClient) instanceInfo() (project, zone, instance string, err error) {
	project, err = metadata.ProjectID()
	if err != nil {
		return
	}
	zone, err = metadata.Zone()
	if err != nil {
		return
	}
	name, err := metadata.InstanceName()
	if err != nil {
		return
	}
	instancePath := path.Join("projects", project, "zones", zone, "instances", name)
	instance = strings.TrimRight(c.config.InstanceBase, "/") + "/" + instancePath
	return
}
Пример #4
0
func init() {
	if onGCE {
		// These will fail on instances if the metadata service is
		// down or the client is compiled with an API version that
		// has been removed. Since these are not vital, let's ignore
		// them and make their fields in the dockeLogEntry ,omitempty
		projectID, _ = metadata.ProjectID()
		zone, _ = metadata.Zone()
		instanceName, _ = metadata.InstanceName()
		instanceID, _ = metadata.InstanceID()
	}

	if err := logger.RegisterLogDriver(name, New); err != nil {
		logrus.Fatal(err)
	}

	if err := logger.RegisterLogOptValidator(name, ValidateLogOpts); err != nil {
		logrus.Fatal(err)
	}
}