Skip to content

Commit b244af1

Browse files
committed
fix
Signed-off-by: Smyslov Maxim <maksim.smyslov@flant.com>
1 parent 1b61ae9 commit b244af1

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

cmd/plugins/plugins.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package plugins
1919
import (
2020
"context"
2121
"encoding/json"
22+
"errors"
2223
"fmt"
2324
"log/slog"
2425
"os"
@@ -76,6 +77,20 @@ func NewCommand(logger *dkplog.Logger) *cobra.Command {
7677
PersistentPreRun: func(_ *cobra.Command, _ []string) {
7778
// init plugin services for subcommands after flags are parsed
7879
pc.InitPluginServices()
80+
81+
err := os.MkdirAll(flags.DeckhousePluginsDir+"/plugins", 0755)
82+
// if permission failed
83+
if errors.Is(err, os.ErrPermission) {
84+
pc.logger.Warn("use homedir instead of default d8 plugins path in '/opt/deckhouse/lib/deckhouse-cli'", slog.String("new_path", flags.DeckhousePluginsDir), dkplog.Err(err))
85+
86+
flags.DeckhousePluginsDir, err = os.UserHomeDir()
87+
if err != nil {
88+
logger.Warn("failed to receive home dir to create plugins dir", slog.String("error", err.Error()))
89+
return
90+
}
91+
92+
flags.DeckhousePluginsDir = path.Join(flags.DeckhousePluginsDir, ".deckhouse-cli")
93+
}
7994
},
8095
}
8196

pkg/registry/service/plugin_service.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,13 @@ func (s *PluginService) GetPluginContract(ctx context.Context, pluginName, tag s
8181
return nil, fmt.Errorf("no manifests found in index manifest")
8282
}
8383

84-
// hardcoded first
84+
// hardcoded first manifest (all contracts must be the same for all manifests)
8585
digest := indexManifest.GetManifests()[0].GetDigest()
8686
if digest.String() == "" {
8787
return nil, fmt.Errorf("no digest found in manifest")
8888
}
8989

90-
digestClient := pluginClient.WithSegment("meta")
91-
92-
digestManifestResult, err = digestClient.GetManifest(ctx, "@"+digest.String())
90+
digestManifestResult, err = pluginClient.GetManifest(ctx, "@"+digest.String())
9391
if err != nil {
9492
return nil, fmt.Errorf("failed to get manifest: %w", err)
9593
}

0 commit comments

Comments
 (0)