Skip to content

Commit

Permalink
Merge pull request #1 from bosch-io/init-contrib
Browse files Browse the repository at this point in the history
Eclipse Kanto Software Update initial contribution
  • Loading branch information
konstantina-gramatova authored Feb 11, 2022
2 parents b4108ab + 9e80d03 commit 203788a
Show file tree
Hide file tree
Showing 55 changed files with 7,293 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.go text eol=lf
45 changes: 45 additions & 0 deletions .github/workflows/validation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Validation

on:
pull_request:
branches:
- main
paths-ignore:
- "**/*.md"
push:
branches:
- main
paths-ignore:
- "**/*.md"

jobs:
validation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '1.17.2'
- name: Setup
run: |
go mod download
go install golang.org/x/lint/golint@latest
go get -t ./...
- name: Format
run: |
unformatted_code=$(gofmt -l .)
if [ -n "$unformatted_code" ]; then
echo "Improperly formatted code:"
echo "$unformatted_code"
exit 1
fi
- name: Lint
run: |
golint -set_exit_status ./...
- name: Vet
run: |
go vet ./...
- name: Test
run: |
go test ./... -coverprofile coverage.out -covermode count
go tool cover -func coverage.out
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**/log/
.idea/
.vscode/
69 changes: 69 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# How to Contribute to Eclipse Kanto - Software Update

First of all, thanks for considering to contribute to Eclipse Kanto - Software Update. We really
appreciate the time and effort you want to spend helping to improve things around here.

In order to get you started as fast as possible we need to go through some organizational issues first, though.

## Eclipse Contributor Agreement

Before your contribution can be accepted by the project team contributors must
electronically sign the Eclipse Contributor Agreement (ECA).

* http://www.eclipse.org/legal/ECA.php

Commits that are provided by non-committers must have a Signed-off-by field in
the footer indicating that the author is aware of the terms by which the
contribution has been provided to the project. The non-committer must
additionally have an Eclipse Foundation account and must have a signed Eclipse
Contributor Agreement (ECA) on file.

For more information, please see the Eclipse Committer Handbook:
https://www.eclipse.org/projects/handbook/#resources-commit

## Code Style Guide

* Keep the code well-formatted through: `gofmt`
* Keep the code error-free through: `go vet` and `golint`
* Avoid common mistakes and pitfalls following: [Go Code Review Comments](https://github.com/golang/go/wiki/CodeReviewComments)

## Making Your Changes

* Fork the repository on GitHub.
* Create a new branch for your changes.
* Make your changes following the code style guide (see Code Style Guide section above).
* When you create new files make sure you include a proper license header at the top of the file (see License Header section below).
* Make sure you include test cases for non-trivial features.
* Make sure test cases provide sufficient code coverage (see GitHub actions for minimal accepted coverage).
* Make sure the test suite passes after your changes.
* Commit your changes into that branch.
* Use descriptive and meaningful commit messages. Start the first line of the commit message with the issue number and titile e.g. `[#9865] Add token based authentication`.
* Squash multiple commits that are related to each other semantically into a single one.
* Make sure you use the `-s` flag when committing as explained above.
* Push your changes to your branch in your forked repository.

## License Header

Please make sure any file you newly create contains a proper license header like this:

Adjusted for Go files:
```go
// Copyright (c) <year> Contributors to the Eclipse Foundation
//
// See the NOTICE file(s) distributed with this work for additional
// information regarding copyright ownership.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0
//
// SPDX-License-Identifier: EPL-2.0
```

## Submitting the Changes

Submit a pull request via the normal GitHub UI.

## After Submitting

* Do not use your branch for any other development, otherwise further changes that you make will be visible in the PR.
97 changes: 97 additions & 0 deletions NOTICE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Notices for Eclipse Kanto - Software Update

This content is produced and maintained by the Eclipse Kanto project.

* Project home: https://eclipse.org/kanto

## Trademarks

Eclipse Kanto, and the Eclipse Kanto Logo are trademarks of the Eclipse Foundation.
Eclipse, and the Eclipse Logo are registered trademarks of the Eclipse Foundation.

## Copyright

All content is the property of the respective authors or their employers.
For more information regarding authorship of content, please consult the
listed source code repository logs.

## Declared Project Licenses

This program and the accompanying materials are made available under the terms
of the Eclipse Public License v2.0 which is available at
https://www.eclipse.org/legal/epl-2.0/

SPDX-License-Identifier: EPL-2.0

## Source Code

The project maintains all source code repositories in the following GitHub organization:

* https://github.com/eclipse-kanto

## Third-party Content

This project makes use of the follow third party projects.

eclipse/ditto-clients-golang (0.0.0-20211126080925-0676267c80ac)

* License: Eclipse Public License v2.0
* Project: https://github.com/eclipse/ditto-clients-golang
* Source: https://github.com/eclipse/ditto-clients-golang/tree/0676267c80ac5f68495127b66a95535075bd4bd6

eclipse/paho.mqtt.golang (1.3.5)

* License: Eclipse Public License v2.0
* Project: https://github.com/eclipse/paho.mqtt.golang
* Source: https://github.com/eclipse/paho.mqtt.golang/releases/tag/v1.3.5

fsnotify/fsnotify (1.5.1)

* License: BSD 3-Clause "New" or "Revised" License
* Project: https://github.com/fsnotify/fsnotify
* Source: https://github.com/fsnotify/fsnotify/releases/tag/v1.5.1

google/uuid (1.3.0)

* License: BSD 3-Clause "New" or "Revised"
* Project: https://github.com/google/uuid
* Source: https://github.com/google/uuid/releases/tag/v1.3.0

gorilla/websocket (1.4.2)

* License: BSD 2-Clause "Simplified" License
* Project: https://github.com/gorilla/websocket
* Source: https://github.com/gorilla/websocket/releases/tag/v1.4.2

natefinch/lumberjack (2.0.0)

* License: MIT License
* Project: https://gopkg.in/natefinch/lumberjack
* Source: https://github.com/natefinch/lumberjack/releases/tag/v2.0.0

golang/go (1.17.2)

* License: BSD 3-Clause "New" or "Revised" License
* Project: https://github.com/golang/go
* Source: https://github.com/golang/go/releases/tag/go1.17.2

golang.org/x/net (0.0.0-20211123203042-d83791d6bcd9)

* License: BSD 3-Clause "New" or "Revised" License
* Project: https://pkg.go.dev/golang.org/x/net
* Source: https://github.com/golang/net/tree/d83791d6bcd9ec2bdaacd08f4da4718370382c74

golang.org/x/sys (0.0.0-20211124211545-fe61309f8881)

* License: BSD 3-Clause "New" or "Revised" License
* Project: https://pkg.go.dev/golang.org/x/sys
* Source: https://github.com/golang/sys/tree/fe61309f888157de161a48facf03d9412635cffe

## Cryptography

Content may contain encryption software. The country in which you are currently
may have restrictions on the import, possession, and use, and/or re-export to
another country, of encryption software. BEFORE using any encryption software,
please check the country's laws, regulations and policies concerning the import,
possession, or use, and re-export of encryption software, to see if this is
permitted.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
![Kanto logo](https://github.com/eclipse-kanto/kanto/raw/master/logo/kanto.svg)

# Eclipse Kanto - Software Update

Software update on a device via script enables updates of any kind of software, predefined in your script. You can monitor the install and download process and resume it on start up.

This functionality is provided by the Eclipse Kanto as a software-update native application. It allows you to install on a device any kind of software you define in your software updatable module.

Use the following operations to manage your script-based software updatable module:
* Download operation – download software module and store it for feature use
* Install operation – download or update software module and then install it
* Operation progress – download and install operations support progress
* Artifact validation:
* validate downloaded artifacts with provided hash
* download operation will stop, if the artifact file size exceeds the expected size
* Resume on startup:
* resume module execution on startup
* resume partially downloaded files on startup
* Command line interface – CLI client providing access to all core configurations

## Community

* [GitHub Issues](https://github.com/eclipse-kanto/software-update/issues)
* [Mailing List](https://accounts.eclipse.org/mailing-list/kanto-dev)
54 changes: 54 additions & 0 deletions cmd/software-update/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright (c) 2021 Contributors to the Eclipse Foundation
//
// See the NOTICE file(s) distributed with this work for additional
// information regarding copyright ownership.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0
//
// SPDX-License-Identifier: EPL-2.0

package main

import (
"fmt"
"os"
"os/signal"

feature "github.com/eclipse-kanto/software-update/internal"
"github.com/eclipse-kanto/software-update/internal/logger"
)

var version = "N/A"

func main() {
// Initialize flags.
suConfig, logConfig, err := feature.InitFlags(version)
if err != nil {
fmt.Println(err)
os.Exit(1)
}

// Initialize logs.
loggerOut := logger.SetupLogger(logConfig)
defer loggerOut.Close()

// Create new Script-Based software updatable
su, err := feature.NewScriptBasedSU(suConfig)
if err != nil {
logger.Errorf("failed to create script-based software updatable: %v", err)
os.Exit(1)
}
su.Connect()

// Disconnect client on exit
defer func() {
su.Disconnect()
logger.Infof("Disconnected from MQTT broker: %s", suConfig.Broker)
}()

chWaitCtrlC := make(chan os.Signal, 1)
signal.Notify(chWaitCtrlC, os.Interrupt)
<-chWaitCtrlC
}
17 changes: 17 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module github.com/eclipse-kanto/software-update

go 1.17

require (
github.com/eclipse/ditto-clients-golang v0.0.0-20211126080925-0676267c80ac
github.com/eclipse/paho.mqtt.golang v1.3.5
github.com/fsnotify/fsnotify v1.5.1
github.com/google/uuid v1.3.0
gopkg.in/natefinch/lumberjack.v2 v2.0.0
)

require (
github.com/gorilla/websocket v1.4.2 // indirect
golang.org/x/net v0.0.0-20211123203042-d83791d6bcd9 // indirect
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881 // indirect
)
54 changes: 54 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
github.com/BurntSushi/toml v0.4.1 h1:GaI7EiDXDRfa8VshkTj7Fym7ha+y8/XxIgD2okUIjLw=
github.com/BurntSushi/toml v0.4.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/eclipse/ditto-clients-golang v0.0.0-20211126080925-0676267c80ac h1:+Tl05cZOU8RXl95RP2iZ6LFM5CXxTVhz4ux0LtPUYR4=
github.com/eclipse/ditto-clients-golang v0.0.0-20211126080925-0676267c80ac/go.mod h1:hAXWyOdJLxUQTK4nCc3xAHgEU5iQa5a5DzFeS8ErR60=
github.com/eclipse/paho.mqtt.golang v1.2.0/go.mod h1:H9keYFcgq3Qr5OUJm/JZI/i6U7joQ8SYLhZwfeOo6Ts=
github.com/eclipse/paho.mqtt.golang v1.3.5 h1:sWtmgNxYM9P2sP+xEItMozsR3w0cqZFlqnNN1bdl41Y=
github.com/eclipse/paho.mqtt.golang v1.3.5/go.mod h1:eTzb4gxwwyWpqBUHGQZ4ABAV7+Jgm1PklsYT/eo8Hcc=
github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI=
github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU=
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200425230154-ff2c4b7c35a0/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20211123203042-d83791d6bcd9 h1:0qxwC5n+ttVOINCBeRHO0nq9X7uy8SDsPoi5OaCdIEI=
golang.org/x/net v0.0.0-20211123203042-d83791d6bcd9/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881 h1:TyHqChC80pFkXWraUUf6RuB5IqFdQieMLwwCJokV2pc=
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8=
gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
Loading

0 comments on commit 203788a

Please sign in to comment.