Skip to content
Snippets Groups Projects
Commit 9bf121bd authored by Manuel Kieweg's avatar Manuel Kieweg
Browse files

merge

parent b636a139
No related branches found
No related tags found
2 merge requests!123Refactor container deployment,!90Develop
FROM golang:1.15-alpine AS builder
ARG GITLAB_USER
ARG GITLAB_TOKEN
WORKDIR /src/gosdn
COPY . .
RUN apk add git
RUN git config --global url."https://$GITLAB_USER:$GITLAB_TOKEN@code.fbi.h-da.de".insteadOf "https://code.fbi.h-da.de"
RUN go mod download
RUN CGO_ENABLED=0 GOOS=linux go build ./cmd/gosdn
FROM alpine:latest
EXPOSE 8443
EXPOSE 55055
COPY --from=builder /src/gosdn/gosdn .
COPY --from=builder /src/gosdn/configs ./configs
ENTRYPOINT [ "./gosdn" ]
CMD [""]
FROM golang:1.15-alpine AS builder
ARG GITLAB_USER
ARG GITLAB_TOKEN
WORKDIR /src/gosdn
COPY . .
RUN apk add git
RUN git config --global url."https://$GITLAB_USER:$GITLAB_TOKEN@code.fbi.h-da.de".insteadOf "https://code.fbi.h-da.de"
RUN go mod download
RUN CGO_ENABLED=0 GOOS=linux go build -race ./cmd/gosdn
FROM alpine:latest
EXPOSE 8443
EXPOSE 55055
COPY --from=builder /src/gosdn/gosdn .
COPY --from=builder /src/gosdn/configs ./configs
ENTRYPOINT [ "./gosdn" ]
CMD [""]
...@@ -47,7 +47,6 @@ func initialize() error { ...@@ -47,7 +47,6 @@ func initialize() error {
} }
// TODO: Start grpc listener here // TODO: Start grpc listener here
return httpAPI() return httpAPI()
} }
...@@ -76,9 +75,11 @@ func createPrincipalNetworkDomain(sbi SouthboundInterface) error { ...@@ -76,9 +75,11 @@ func createPrincipalNetworkDomain(sbi SouthboundInterface) error {
// Run calls initialize to start the controller // Run calls initialize to start the controller
func Run(ctx context.Context) error { func Run(ctx context.Context) error {
var initError error var initError error
coreLock.Lock()
coreOnce.Do(func() { coreOnce.Do(func() {
initError = initialize() initError = initialize()
}) })
coreLock.Unlock()
if initError != nil { if initError != nil {
log.WithFields(log.Fields{}).Error(initError) log.WithFields(log.Fields{}).Error(initError)
return initError return initError
......
...@@ -31,7 +31,7 @@ func registerHttpHandler() { ...@@ -31,7 +31,7 @@ func registerHttpHandler() {
} }
// deprecated // deprecated
func httpAPI() (err error) { func httpAPI() error {
registerHttpHandler() registerHttpHandler()
c.httpServer = &http.Server{Addr: ":8080"} c.httpServer = &http.Server{Addr: ":8080"}
go func() { go func() {
......
...@@ -36,6 +36,10 @@ func testSetupHTTP() { ...@@ -36,6 +36,10 @@ func testSetupHTTP() {
if err := c.pndc.add(pnd); err != nil { if err := c.pndc.add(pnd); err != nil {
log.Fatal(err) log.Fatal(err)
} }
if err := httpAPI(); err != nil {
log.Fatal(err)
return
}
} }
func Test_httpApi(t *testing.T) { func Test_httpApi(t *testing.T) {
...@@ -137,10 +141,6 @@ func Test_httpApi(t *testing.T) { ...@@ -137,10 +141,6 @@ func Test_httpApi(t *testing.T) {
wantErr: false, wantErr: false,
}, },
} }
if err := httpAPI(); err != nil {
t.Errorf("httpApi() error = %v", err)
return
}
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
got, err := http.Get(tt.request) got, err := http.Get(tt.request)
......
...@@ -45,6 +45,12 @@ var gnmiAddress = "141.100.70.171:6030" ...@@ -45,6 +45,12 @@ var gnmiAddress = "141.100.70.171:6030"
// TODO: Move somewhere more sensible // TODO: Move somewhere more sensible
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
log.SetReportCaller(true) log.SetReportCaller(true)
if os.Getenv("GOSDN_LOG") == "nolog" {
log.SetLevel(log.PanicLevel)
}
gnmiMessages = map[string]pb.Message{ gnmiMessages = map[string]pb.Message{
"../test/proto/cap-resp-arista-ceos": &gpb.CapabilityResponse{}, "../test/proto/cap-resp-arista-ceos": &gpb.CapabilityResponse{},
"../test/proto/req-full-node": &gpb.GetRequest{}, "../test/proto/req-full-node": &gpb.GetRequest{},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment