-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bd84f60
commit 432c8ce
Showing
239 changed files
with
28,992 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
BSD 3-Clause License | ||
|
||
Copyright © 2020, Intel Corporation | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions | ||
are met: | ||
|
||
1. Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | ||
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | ||
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Copyright © 2020 Intel Corporation. All rights reserved. | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
||
.PHONY: clean \ | ||
build \ | ||
docker-rm \ | ||
clean-docker \ | ||
run-portainer \ | ||
run \ | ||
down \ | ||
build-image \ | ||
|
||
DOCKERS= \ | ||
docker-build-image \ | ||
as-vending \ | ||
as-controller-board-status \ | ||
ds-card-reader \ | ||
ds-controller-board \ | ||
ds-inference-mock \ | ||
ms-authentication \ | ||
ms-inventory \ | ||
ms-ledger | ||
|
||
.PHONY: $(DOCKERS) | ||
|
||
docker-rm: | ||
-docker rm $$(docker ps -aq) | ||
|
||
clean-docker: docker-rm | ||
docker volume prune -f && \ | ||
docker network prune -f | ||
|
||
run-portainer: | ||
docker-compose -f docker-compose.portainer.yml up -d | ||
|
||
run: | ||
docker-compose -f docker-compose.yml up -d | ||
|
||
run-physical: | ||
docker-compose -f docker-compose.yml -f docker-compose.physical.card-reader.yml -f docker-compose.physical.controller-board.yml up -d | ||
|
||
run-physical-card-reader: | ||
docker-compose -f docker-compose.yml -f docker-compose.physical.card-reader.yml up -d | ||
|
||
run-physical-controller-board: | ||
docker-compose -f docker-compose.yml -f docker-compose.physical.controller-board.yml up -d | ||
|
||
down: | ||
-docker-compose -f docker-compose.yml stop -t 1 | ||
-docker-compose -f docker-compose.yml down | ||
|
||
clean: down docker-rm | ||
docker rmi -f $$(docker images | grep '<none>' | awk '{print $$3}') && \ | ||
docker rmi -f $$(docker images | grep automated-checkout | awk '{print $$3}') && \ | ||
docker volume prune -f && \ | ||
docker network prune -f | ||
|
||
$(DOCKERS): | ||
cd $@; \ | ||
make build | ||
|
||
build : $(DOCKERS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
# Automated Checkout | ||
|
||
For complete documentation on the Automated Checkout Reference Design, please visit **[this repository's GitHub Pages site](https://intel-iot-devkit.github.io/automated-checkout/index.html)**. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, build with `go test -c` | ||
*.test | ||
main | ||
as-controller-board-status | ||
test.txt | ||
go.sum | ||
.vscode/* | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# created during testing | ||
functions/test.log | ||
functions/test_*.log | ||
logs/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Copyright © 2020 Intel Corporation. All rights reserved. | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
||
run: | ||
# timeout for analysis, e.g. 30s, 5m, default is 1m | ||
timeout: 5m | ||
linters-settings: | ||
misspell: | ||
locale: US | ||
linters: | ||
enable: | ||
- bodyclose | ||
- errcheck | ||
- goconst | ||
- golint | ||
- govet | ||
- gosimple | ||
- ineffassign | ||
- misspell | ||
- staticcheck | ||
- structcheck | ||
- typecheck | ||
- unused | ||
- unconvert | ||
- unparam | ||
- varcheck | ||
disable-all: true | ||
fast: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Copyright © 2020 Intel Corporation. All rights reserved. | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
||
FROM automated-checkout/build:latest AS builder | ||
|
||
LABEL license='SPDX-License-Identifier: BSD-3-Clause' \ | ||
copyright='Copyright (c) 2020: Intel' | ||
|
||
RUN mkdir as-controller-board-status | ||
WORKDIR /usr/local/bin/as-controller-board-status/ | ||
COPY . . | ||
|
||
# Compile the code | ||
RUN make gobuild | ||
|
||
# Next image - Copy built Go binary into new workspace | ||
FROM alpine | ||
|
||
LABEL license='SPDX-License-Identifier: BSD-3-Clause' \ | ||
copyright='Copyright (c) 2020: Intel' | ||
|
||
RUN apk --no-cache add zeromq | ||
COPY --from=builder /usr/local/bin/as-controller-board-status/res/docker/configuration.toml /res/docker/configuration.toml | ||
COPY --from=builder /usr/local/bin/as-controller-board-status/main /as-controller-board-status | ||
|
||
CMD [ "/as-controller-board-status","--profile=docker","--confdir=/res", "-r"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
BSD 3-Clause License | ||
|
||
Copyright © 2020, Intel Corporation | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions | ||
are met: | ||
|
||
1. Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | ||
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | ||
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Copyright © 2020 Intel Corporation. All rights reserved. | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
||
.PHONY: build gobuild run gorun stop test lint | ||
|
||
MICROSERVICE=automated-checkout/as-controller-board-status | ||
|
||
build: | ||
docker build --rm \ | ||
--build-arg http_proxy \ | ||
--build-arg https_proxy \ | ||
-f Dockerfile \ | ||
-t $(MICROSERVICE):dev \ | ||
. | ||
|
||
gobuild: | ||
CGO_ENABLED=1 GOOS=linux go build -ldflags='-s -w' -a -installsuffix cgo main.go | ||
|
||
run: | ||
docker run \ | ||
--rm \ | ||
-p 48094:48094 \ | ||
$(MICROSERVICE):dev | ||
|
||
gorun: | ||
./main | ||
|
||
stop: | ||
docker rm -f $(MICROSERVICE):dev | ||
|
||
test: | ||
go test -test.v -cover ./... | ||
|
||
testHTML: | ||
go test -test.v -coverprofile=test_coverage.out ./... && \ | ||
go tool cover -html=test_coverage.out | ||
|
||
GOLANGCI_VERSION := $(shell golangci-lint --version 2>/dev/null) | ||
|
||
lint: | ||
ifdef GOLANGCI_VERSION | ||
golangci-lint run | ||
else | ||
@echo "golangci-lint not found. Please refer to the README documentation for proper installation" | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright © 2020 Intel Corporation. All rights reserved. | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
package functions | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"net/http" | ||
|
||
utilities "github.com/intel-iot-devkit/automated-checkout-utilities" | ||
) | ||
|
||
const ( | ||
// RESTPost is a const used for REST commands using the specified method. | ||
RESTPost = "POST" | ||
// RESTPut is a const used for REST commands using the specified method. | ||
RESTPut = "PUT" | ||
// RESTGet is a const used for REST commands using the specified method. | ||
RESTGet = "GET" | ||
// ApplicationJSONContentType is a const holding the common HTTP | ||
// Content-Type header value, "application/json" | ||
ApplicationJSONContentType = "application/json" | ||
) | ||
|
||
// RESTCommandJSON submits a REST API call a specified restURL using the | ||
// specified restMethod, and will serialize the inputInterface into JSON | ||
// and submit it as part of the outbound REST request. | ||
func (edgexconfig *ControllerBoardStatusAppSettings) RESTCommandJSON(restURL string, restMethod string, inputInterface interface{}) (err error) { | ||
// Serialize the inputInterface | ||
inputInterfaceJSON, err := utilities.GetAsJSON(inputInterface) | ||
if err != nil { | ||
return fmt.Errorf("Failed to serialize the input interface as JSON: %v", err.Error()) | ||
} | ||
|
||
// Build out the request | ||
req, err := http.NewRequest(restMethod, restURL, bytes.NewBuffer([]byte(inputInterfaceJSON))) | ||
if err != nil { | ||
return fmt.Errorf("Failed to build the REST %v request for the URL %v due to error: %v", restMethod, restURL, err.Error()) | ||
} | ||
client := &http.Client{ | ||
Timeout: edgexconfig.RESTCommandTimeout, | ||
} | ||
|
||
resp, err := client.Do(req) | ||
if err != nil { | ||
return fmt.Errorf("Failed to submit REST %v request due to error: %v", restMethod, err.Error()) | ||
} | ||
defer resp.Body.Close() | ||
|
||
if resp.StatusCode != http.StatusOK { | ||
// Convert the response body into a string so that it can be returned as part of the error | ||
buf := new(bytes.Buffer) | ||
_, err := buf.ReadFrom(resp.Body) | ||
if err != nil { | ||
return fmt.Errorf("Did not receive an HTTP 200 status OK response from %v, instead got a response code of %v, and the response body could not be serialized", restURL, resp.StatusCode) | ||
} | ||
return fmt.Errorf("Did not receive an HTTP 200 status OK response from %v, instead got a response code of %v, and the response body was: %v", restURL, resp.StatusCode, buf.String()) | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.