@@ -21,7 +21,6 @@ import (
2121)
2222
2323var drupalComponentName string
24- var drupalRootfsPath string
2524
2625const (
2726 cachePageWarningThreshold = int64 (1 << 30 )
@@ -148,18 +147,17 @@ var componentExtensionSetCmd = &cobra.Command{
148147 },
149148}
150149
151- var debugExtensionCmd = & cobra.Command {
152- Use : "__debug" ,
153- Short : "Internal debug extension command" ,
154- Hidden : true ,
155- RunE : func (cmd * cobra.Command , args []string ) error {
156- rendered , err := renderDrupalDebug (cmd .Context ())
157- if err != nil {
158- return err
159- }
160- _ , err = fmt .Fprintln (cmd .OutOrStdout (), rendered )
161- return err
162- },
150+ // drupalDebugRunner implements plugin.DebugRunner for the drupal plugin.
151+ type drupalDebugRunner struct {
152+ rootfsPath string
153+ }
154+
155+ func (r * drupalDebugRunner ) BindFlags (cmd * cobra.Command ) {
156+ cmd .Flags ().StringVar (& r .rootfsPath , "drupal-rootfs" , "" , "Drupal rootfs path override" )
157+ }
158+
159+ func (r * drupalDebugRunner ) Render (cmd * cobra.Command , ctx * config.Context ) (string , error ) {
160+ return renderDrupalDebugBody (cmd .Context (), ctx , r .rootfsPath )
163161}
164162
165163func init () {
@@ -169,19 +167,13 @@ func init() {
169167 componentExtensionCmd .AddCommand (componentExtensionDescribeCmd )
170168 componentExtensionCmd .AddCommand (componentExtensionReconcileCmd )
171169 componentExtensionCmd .AddCommand (componentExtensionSetCmd )
172-
173- debugExtensionCmd .Flags ().StringVar (& drupalRootfsPath , "drupal-rootfs" , "" , "Drupal rootfs path override" )
174170}
175171
176- func renderDrupalDebug (runCtx context.Context ) (string , error ) {
172+ func renderDrupalDebugBody (runCtx context.Context , ctx * config. Context , rootfsOverride string ) (string , error ) {
177173 slog .Debug ("starting plugin debug" , "plugin" , "drupal" )
178174 if sdk == nil {
179175 return "" , fmt .Errorf ("plugin sdk is not initialized" )
180176 }
181- ctx , err := sdk .GetContext ()
182- if err != nil {
183- return "" , err
184- }
185177 slog .Debug ("resolved plugin context" , "plugin" , "drupal" , "context" , ctx .Name , "project_dir" , ctx .ProjectDir )
186178 slog .Debug ("creating file accessor" , "plugin" , "drupal" )
187179 files , err := sdk .GetFileAccessor ()
@@ -190,7 +182,7 @@ func renderDrupalDebug(runCtx context.Context) (string, error) {
190182 }
191183 defer files .Close ()
192184
193- rootfs := strings .TrimSpace (drupalRootfsPath )
185+ rootfs := strings .TrimSpace (rootfsOverride )
194186 if rootfs == "" {
195187 rootfs = ctx .EffectiveDrupalRootfs ()
196188 }
@@ -262,8 +254,8 @@ func renderDrupalDebug(runCtx context.Context) (string, error) {
262254 }
263255 body = append (body , "" , strings .Join (patchLines , "\n " ))
264256
265- slog .Debug ("finished plugin debug" , "plugin" , "drupal" )
266- return debugui . RenderPanel ( "drupal" , strings .Join (body , "\n " ) ), nil
257+ slog .Debug ("finished plugin debug body " , "plugin" , "drupal" )
258+ return strings .Join (body , "\n " ), nil
267259}
268260
269261func renderCachePageSummary (runCtx context.Context ) (string , error ) {
0 commit comments