MCPcopy Create free account
hub / github.com/cloudquery/cloudquery / runPluginUIAssetsUpload

Function runPluginUIAssetsUpload

cli/cmd/plugin_uiassets_upload.go:55–88  ·  view source on GitHub ↗
(ctx context.Context, cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

53}
54
55func runPluginUIAssetsUpload(ctx context.Context, cmd *cobra.Command, args []string) error {
56 tc := auth.NewTokenClient()
57 token, err := tc.GetToken()
58 if err != nil {
59 return fmt.Errorf("failed to get auth token: %w", err)
60 }
61
62 pluginRef, err := hub.ParseHubPluginRef(args[0])
63 if err != nil {
64 return err
65 }
66
67 uiAssetsDir := cmd.Flag("assets-dir").Value.String()
68 st, err := os.Stat(uiAssetsDir)
69 if err != nil {
70 return err
71 } else if !st.IsDir() {
72 return fmt.Errorf("%s is not a directory", uiAssetsDir)
73 }
74
75 fmt.Printf("Uploading UI assets for plugin %v...\n", pluginRef)
76
77 c, err := api.NewClient(token.Value)
78 if err != nil {
79 return err
80 }
81
82 if err := publish.UploadPluginUIAssets(ctx, c, pluginRef.TeamName, pluginRef.Kind, pluginRef.Name, pluginRef.Version, uiAssetsDir); err != nil {
83 return fmt.Errorf("failed to upload UI assets: %w", err)
84 }
85
86 fmt.Println("Success!")
87 return nil
88}

Callers 1

Calls 4

ErrorfMethod · 0.80
PrintfMethod · 0.80
PrintlnMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected