Skip to content

Commit 3a90b0a

Browse files
authored
Merge pull request #104 from thin-edge/fix-self-update
fix: only use self sm-plugin for legacy updates
2 parents f697011 + f060dcd commit 3a90b0a

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

cli/self/cmd.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
package self
22

33
import (
4+
"os"
5+
"path/filepath"
6+
47
"github.com/spf13/cobra"
58
"github.com/thin-edge/tedge-container-plugin/pkg/cli"
69
)
710

11+
func CalledAsSMPlugin() bool {
12+
args := os.Args
13+
name := filepath.Base(args[0])
14+
return name == "self"
15+
}
16+
817
// NewSoftwareManagementSelfCommand returns a cobra command for `self` subcommands
918
func NewSoftwareManagementSelfCommand(cmdCli cli.Cli) *cobra.Command {
1019
cmd := &cobra.Command{

cli/self/list.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ func NewListCommand(cliContext cli.Cli) *cobra.Command {
2929
Args: cobra.ExactArgs(0),
3030
RunE: func(cmd *cobra.Command, args []string) error {
3131
slog.Info("Executing", "cmd", cmd.CalledAs(), "args", args)
32+
33+
if CalledAsSMPlugin() {
34+
slog.Info("Called as sm-plugin, ignoring legacy plugin. 'container' is used for updates")
35+
return nil
36+
}
37+
3238
ctx := context.Background()
3339
containerCli, err := container.NewContainerClient()
3440
if err != nil {

0 commit comments

Comments
 (0)