Skip to content

Commit

Permalink
refactor(snap): Update command and metadata sourcing (#266)
Browse files Browse the repository at this point in the history
- Inline CLIs flags
- Remove unused packages
- Remove external metadata sourcing

Signed-off-by: Mengyi Wang <[email protected]>
  • Loading branch information
MonicaisHer authored Mar 16, 2023
1 parent d829a2c commit 965f04e
Showing 1 changed file with 17 additions and 32 deletions.
49 changes: 17 additions & 32 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: edgex-device-snmp
base: core20
license: Apache-2.0
adopt-info: metadata
summary: EdgeX SNMP Device Service
description: Refer to https://snapcraft.io/https://snapcraft.io/edgex-device-snmp
adopt-info: device-snmp

architectures:
- build-on: amd64
Expand Down Expand Up @@ -32,13 +34,10 @@ plugs:
apps:
device-snmp:
adapter: full
command: bin/device-snmp $CONFIG_PRO_ARG $CONF_ARG $REGISTRY_ARG
command: bin/device-snmp --configDir $SNAP_DATA/config/device-snmp/res --configProvider --registry
command-chain:
- bin/source-env-file.sh
environment:
CONFIG_PRO_ARG: "--cp=consul.http://localhost:8500"
CONF_ARG: "--configDir=$SNAP_DATA/config/device-snmp/res"
REGISTRY_ARG: "--registry"
DEVICE_PROFILESDIR: $SNAP_DATA/config/device-snmp/res/profiles
DEVICE_DEVICESDIR: $SNAP_DATA/config/device-snmp/res/devices
SECRETSTORE_TOKENFILE: $SNAP_DATA/device-snmp/secrets-token.json
Expand All @@ -57,19 +56,27 @@ parts:
install -DT ./helper-go $SNAPCRAFT_PART_INSTALL/bin/helper-go
device-snmp:
after: [metadata]
source: .
plugin: make
build-packages: [git, zip, pkg-config]
build-packages:
- git
build-snaps:
- go/1.20/stable
override-build: |
cd $SNAPCRAFT_PART_SRC
# the version is needed for the build
cat ./VERSION
if git describe ; then
VERSION=$(git describe --tags --abbrev=0 | sed 's/v//')
else
VERSION="0.0.0"
fi
# set the version of the snap
snapcraftctl set-version $VERSION
# write version to file for the build
echo $VERSION > VERSION
make tidy
make build
install -DT "./cmd/device-snmp" "$SNAPCRAFT_PART_INSTALL/bin/device-snmp"
Expand All @@ -91,25 +98,3 @@ parts:
organize:
source-env-file.sh: bin/source-env-file.sh

metadata:
plugin: nil
source: https://github.com/canonical/edgex-snap-metadata.git
source-branch: appstream
source-depth: 1
override-build: |
# install the icon at the default internal path
install -DT edgex-snap-icon.png \
$SNAPCRAFT_PART_INSTALL/meta/gui/icon.png
# change to this project's repo to get the version
cd $SNAPCRAFT_PROJECT_DIR
if git describe ; then
VERSION=$(git describe --tags --abbrev=0 | sed 's/v//')
else
VERSION="0.0.0"
fi
# write version to file for the build
echo $VERSION > ./VERSION
# set the version of this snap
snapcraftctl set-version $VERSION
parse-info: [edgex-device-snmp.metainfo.xml]

0 comments on commit 965f04e

Please sign in to comment.