Skip to content

Commit

Permalink
feat(snap): Remove device-virtual (#4041)
Browse files Browse the repository at this point in the history
Signed-off-by: Mengyi Wang <[email protected]>
  • Loading branch information
MonicaisHer authored Jun 3, 2022
1 parent 9735311 commit fed831e
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 117 deletions.
4 changes: 2 additions & 2 deletions snap/local/build-helpers/bin/minimal-snap-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ SNAPCRAFT_YAML="$CURRDIR/snap/snapcraft.yaml"
$CURRDIR/yq e -P -i 'del(.apps.consul,.apps.redis,.apps.postgres,.apps.kong-daemon,.apps.vault,.apps.vault-cli)' "$SNAPCRAFT_YAML"

# remove second chunk of apps
$CURRDIR/yq e -P -i 'del(.apps.device-virtual,.apps.app-service-configurable)' "$SNAPCRAFT_YAML"
$CURRDIR/yq e -P -i 'del(.apps.app-service-configurable)' "$SNAPCRAFT_YAML"

# remove third chunk of apps
$CURRDIR/yq e -P -i 'del(.apps.redis-cli,.apps.consul-cli)' "$SNAPCRAFT_YAML"
Expand All @@ -34,6 +34,6 @@ $CURRDIR/yq e -P -i 'del(.apps.redis-cli,.apps.consul-cli)' "$SNAPCRAFT_YAML"
$CURRDIR/yq e -P -i 'del(.apps.kong,.apps.psql,.apps.psql-any,.apps.createdb,.apps.kuiper,.apps.kuiper-cli)' "$SNAPCRAFT_YAML"

# remove unwanted parts
$CURRDIR/yq e -P -i 'del(.parts.snapcraft-preload,.parts.postgres,.parts.consul,.parts.redis,.parts.kong,.parts.vault,.parts.device-virtual-go,.parts.kuiper,.parts.app-service-config)' "$SNAPCRAFT_YAML"
$CURRDIR/yq e -P -i 'del(.parts.snapcraft-preload,.parts.postgres,.parts.consul,.parts.redis,.parts.kong,.parts.vault,.parts.kuiper,.parts.app-service-config)' "$SNAPCRAFT_YAML"


4 changes: 2 additions & 2 deletions snap/local/hooks/cmd/configure/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func getSecretStoreServices() []string {
// (excludes all non-EdgeX runtime dependencies, and security-*-setup jobs).
func getEdgeXRefServices() []string {
return []string{"core-data", "core-metadata", "core-command",
"device-virtual", "support-notifications",
"support-notifications",
"support-scheduler", "sys-mgmt-agent"}
}

Expand All @@ -93,7 +93,7 @@ func getCoreDefaultServices() []string {
// - kuiper isn't included because it's not yet possible
// to provide kuiper configuration via content interface
func getOptServices() []string {
return []string{"support-notifications", "support-scheduler", "device-virtual"}
return []string{"support-notifications", "support-scheduler"}
}

func isDisableAllowed(s string) error {
Expand Down
1 change: 0 additions & 1 deletion snap/local/hooks/cmd/configure/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ func processAppOptions() {
"support-notifications",
"support-scheduler",
"app-service-configurable",
"device-virtual",
"security-secretstore-setup",
"security-bootstrapper", // local executable
"security-proxy-setup",
Expand Down
57 changes: 2 additions & 55 deletions snap/local/hooks/cmd/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func getServicesWithConfig() []string {
"security-file-token-provider", "security-proxy-setup",
"security-secretstore-setup", "core-command", "core-data",
"core-metadata", "support-notifications", "support-scheduler",
"sys-mgmt-agent", "device-virtual", "app-service-configurable"}
"sys-mgmt-agent", "app-service-configurable"}
}

// TODO: re-factor to get this list from snapd using snapctl
Expand All @@ -104,7 +104,7 @@ func getAllServices() []string {
"security-proxy-setup", "security-bootstrapper-redis",
"security-consul-bootstrapper", "core-command",
"core-data", "core-metadata", "support-notifications",
"support-scheduler", "sys-mgmt-agent", "device-virtual",
"support-scheduler", "sys-mgmt-agent",
"kuiper", "app-service-configurable"}
}

Expand Down Expand Up @@ -146,49 +146,6 @@ func installConfFiles() error {
return nil
}

// installDevices installs device-virtual's static device files to $SNAP_DATA
func installDevices() error {
var err error

destDir := hooks.SnapDataConf + "/device-virtual/res/devices"
destPath := destDir + "/devices.toml"
srcPath := hooks.SnapConf + "/device-virtual/res/devices/devices.toml"

if err = os.MkdirAll(destDir, 0755); err != nil {
return err
}

if err = hooks.CopyFile(srcPath, destPath); err != nil {
return err
}

return nil
}

// installDevProfiles installs device-virtual's device profiles to $SNAP_DATA
func installDevProfiles() error {
var err error
profiles := []string{"bool", "float", "int", "uint", "binary"}

srcDir := hooks.SnapConf + "/device-virtual/res/profiles"
destDir := hooks.SnapDataConf + "/device-virtual/res/profiles"
if err = os.MkdirAll(destDir, 0755); err != nil {
return err
}

for _, v := range profiles {
fileName := "/device.virtual." + v + ".yaml"
srcPath := srcDir + fileName
destPath := destDir + fileName

if err = hooks.CopyFile(srcPath, destPath); err != nil {
return err
}
}

return nil
}

// installKuiper execs a shell script to install Kuiper's file into $SNAP_DATA
func installKuiper() error {
// install files using edgex-ekuiper install hook
Expand Down Expand Up @@ -383,16 +340,6 @@ func main() {
os.Exit(1)
}

if err = installDevices(); err != nil {
hooks.Error(fmt.Sprintf("edgexfoundry:install: %v", err))
os.Exit(1)
}

if err = installDevProfiles(); err != nil {
hooks.Error(fmt.Sprintf("edgexfoundry:install: %v", err))
os.Exit(1)
}

if err = installKuiper(); err != nil {
hooks.Error(fmt.Sprintf("edgexfoundry:install: %v", err))
os.Exit(1)
Expand Down
57 changes: 0 additions & 57 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -342,25 +342,6 @@ apps:
SECRETSTORE_TOKENFILE: $SNAP_DATA/secrets/sys-mgmt-agent/secrets-token.json
daemon: simple
plugs: [network, network-bind]
device-virtual:
adapter: full
after:
- security-bootstrapper-redis
# This generates the consul role for this service before the service starts
- security-consul-bootstrapper
- security-proxy-setup
- core-data
- core-metadata
command: bin/device-virtual -confdir $SNAP_DATA/config/device-virtual/res -cp -r
command-chain:
- bin/security-secret-store-env-var.sh
- bin/service-config-overrides.sh
daemon: simple
environment:
DEVICE_DEVICESDIR: $SNAP_DATA/config/device-virtual/res/devices
DEVICE_PROFILESDIR: $SNAP_DATA/config/device-virtual/res/profiles
SECRETSTORE_TOKENFILE: $SNAP_DATA/secrets/device-virtual/secrets-token.json
plugs: [network, network-bind]
app-service-configurable:
adapter: full
after:
Expand Down Expand Up @@ -783,44 +764,6 @@ parts:
vault: bin/vault

# DEVICE SERVICES parts
#
# NOTE - it would be nice to also just use stage-snaps to include
# device-virtual, however we currently don't publish an independent
# snap of device-virtual. Maybe we should, as this would simplify
# this snap.
device-virtual-go:
source: https://github.com/edgexfoundry/device-virtual-go.git
source-depth: 1
# Set source-branch to tag so that depth of 1 is relative to that tag.
# This is equivalent to "git clone --depth 1 --branch <tag> <url>"
source-branch: v2.2.0
plugin: make
after: [go-build-helper]
override-build: |
# get the short tag without commit count and hash when there are untagged commits
# drop the v prefix
echo VERSION=$(git describe --tags --abbrev=0 | sed 's/v//') > ./VERSION
make build
install -DT "./cmd/device-virtual" "$SNAPCRAFT_PART_INSTALL/bin/device-virtual"
install -DT "./cmd/res/configuration.toml" \
"$SNAPCRAFT_PART_INSTALL/config/device-virtual/res/configuration.toml"
install -DT "./cmd/res/devices/devices.toml" \
"$SNAPCRAFT_PART_INSTALL/config/device-virtual/res/devices/devices.toml"
mkdir -p $SNAPCRAFT_PART_INSTALL/config/device-virtual/res/profiles
for profileType in bool float int uint binary; do
install -T "./cmd/res/profiles/device.virtual.$profileType.yaml" \
"$SNAPCRAFT_PART_INSTALL/config/device-virtual/res/profiles/device.virtual.$profileType.yaml"
done
install -DT "./Attribution.txt" \
"$SNAPCRAFT_PART_INSTALL/usr/share/doc/device-virtual/Attribution.txt"
install -DT "./LICENSE" \
"$SNAPCRAFT_PART_INSTALL/usr/share/doc/device-virtual/LICENSE"
# TODO: vet all the correct files are available...
app-service-configurable:
plugin: nil
Expand Down

0 comments on commit fed831e

Please sign in to comment.