Skip to content

Commit

Permalink
Merge pull request #27 from crassirostris/event-exporter-location
Browse files Browse the repository at this point in the history
[event-exporter] Propagate location from the configuration parameters
  • Loading branch information
Mik Vyatskov authored Aug 16, 2017
2 parents d6827d1 + 60af934 commit 081bc13
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions event-exporter/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ BINARY_NAME = event-exporter

PREFIX = gcr.io/google-containers
IMAGE_NAME = event-exporter
TAG = v0.1.5
TAG = v0.1.6

build:
${ENVVAR} godep go build -a -o ${BINARY_NAME}

test:
${ENVVAR} godep go test ./...

container: build
container:
docker build --pull -t ${PREFIX}/${IMAGE_NAME}:${TAG} .

push: container
Expand Down
7 changes: 3 additions & 4 deletions event-exporter/sinks/stackdriver/sink_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type sdSinkConfig struct {
Resource *sd.MonitoredResource
}

func newGceSdSinkConfig() (*sdSinkConfig, error) {
func newGceSdSinkConfig(location string) (*sdSinkConfig, error) {
if !metadata.OnGCE() {
return nil, errors.New("not running on GCE, which is not supported for Stackdriver sink")
}
Expand All @@ -65,9 +65,8 @@ func newGceSdSinkConfig() (*sdSinkConfig, error) {
Type: "gke_cluster",
Labels: map[string]string{
"cluster_name": clusterName,
// TODO: Replace with the actual zone of the cluster
"location": "",
"project_id": projectID,
"location": location,
"project_id": projectID,
},
}

Expand Down
4 changes: 3 additions & 1 deletion event-exporter/sinks/stackdriver/sink_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type sdSinkFactory struct {
flushDelay *time.Duration
maxBufferSize *int
maxConcurrency *int
location *string
}

// NewSdSinkFactory creates a new Stackdriver sink factory
Expand All @@ -49,6 +50,7 @@ func NewSdSinkFactory() sinks.SinkFactory {
"in the request to Stackdriver"),
maxConcurrency: fs.Int("max-concurrency", defaultMaxConcurrency, "Maximum number of "+
"concurrent requests to Stackdriver"),
location: fs.String("location", "", "GCE location of the cluster"),
}
}

Expand Down Expand Up @@ -81,7 +83,7 @@ func (f *sdSinkFactory) CreateNew(opts []string) (sinks.Sink, error) {
}

func (f *sdSinkFactory) createSinkConfig() (*sdSinkConfig, error) {
config, err := newGceSdSinkConfig()
config, err := newGceSdSinkConfig(*f.location)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 081bc13

Please sign in to comment.