Skip to content

Commit

Permalink
Added README and moved the Config struct
Browse files Browse the repository at this point in the history
  • Loading branch information
thrawn01 committed Mar 22, 2016
1 parent 67d7f10 commit 41b6fbe
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
7 changes: 1 addition & 6 deletions Dockerfile
@@ -1,19 +1,14 @@
# Start from a Debian image with the latest version of Go installed
# and a workspace (GOPATH) configured at /go.
FROM golang

# Copy the local package files to the container's workspace.
ADD . /go/src/github.com/thrawn01/configmap-microservice-demo

# Build the outyet command inside the container.
# (You may fetch or manage dependencies here,
# either manually or with a tool like "godep".)
RUN go get github.com/julienschmidt/httprouter
RUN go get gopkg.in/fsnotify.v1
RUN go get gopkg.in/yaml.v2
RUN go install github.com/thrawn01/configmap-microservice-demo

# Run the outyet command by default when the container starts.
# Run the command by default when the container starts.
ENTRYPOINT /go/bin/configmap-microservice-demo

# Document that the service listens on port 8080.
Expand Down
9 changes: 9 additions & 0 deletions README.md
@@ -0,0 +1,9 @@
## How to write configmap enabled golang microservices

This repo holds code demonstrating how to build a golang service that
reconfigures on the fly when ConfigMap data updates.

The blog post explaining this code is available
[here](http://thrawn01.org/blog/blog/2016/03/22/howto-write-configmap-enabled-golang-microservices/)


2 changes: 1 addition & 1 deletion kubernetes-configmap.yaml
Expand Up @@ -5,4 +5,4 @@ metadata:
namespace: default
data:
configmap-microservice-demo.yaml: |
message: Hello Grandma
message: Hello World
10 changes: 10 additions & 0 deletions main.go
Expand Up @@ -20,6 +20,16 @@ func check(err error) {
}
}

/*
This is the struct that holds our application's configuration
*/
type Config struct {
Message string `yaml:"message"`
}

/*
Simple Yaml Config file loader
*/
func loadConfig(configFile string) *Config {
conf := &Config{}
configData, err := ioutil.ReadFile(configFile)
Expand Down
7 changes: 0 additions & 7 deletions manager.go
Expand Up @@ -2,13 +2,6 @@ package main

import "sync"

/*
This is the struct that holds our application's configuration
*/
type Config struct {
Message string `yaml:"message"`
}

/*
Simple interface that allows us to switch out both implementations of the Manager
*/
Expand Down

0 comments on commit 41b6fbe

Please sign in to comment.