Beispiel #1
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()
		}
	})
}
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
}
Beispiel #3
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)
	}
}