MCPcopy Index your code
hub / github.com/cloudquery/cloudquery / runPluginDocsUpload

Function runPluginDocsUpload

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

Source from the content-addressed store, hash-verified

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

Callers 1

newCmdPluginDocsUploadFunction · 0.85

Calls 4

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

Tested by

no test coverage detected