File tree Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,9 @@ type PluginRequest struct {
35
35
// Universe represents the modified file contents that gets updated over a series of plugin runs
36
36
// across the plugin chain. Initially, it starts out as empty.
37
37
Universe map [string ]string `json:"universe"`
38
+
39
+ // Config stores the project configuration file.
40
+ Config string `json:"config"`
38
41
}
39
42
40
43
// PluginResponse is returned to kubebuilder by the plugin and contains all files
@@ -63,6 +66,9 @@ type PluginResponse struct {
63
66
// Flags contains the plugin specific flags that the plugin returns to Kubebuilder when it receives
64
67
// a request for a list of supported flags from Kubebuilder
65
68
Flags []Flag `json:"flags,omitempty"`
69
+
70
+ // Config stores the project configuration file.
71
+ Config string `json:"config"`
66
72
}
67
73
68
74
// Flag is meant to represent a CLI flag that is used by Kubebuilder to define flags that are parsed
Original file line number Diff line number Diff line change @@ -17,18 +17,22 @@ limitations under the License.
17
17
package external
18
18
19
19
import (
20
+ "fmt"
20
21
"github.com/spf13/pflag"
21
22
23
+ "sigs.k8s.io/kubebuilder/v3/pkg/config"
22
24
"sigs.k8s.io/kubebuilder/v3/pkg/machinery"
23
25
"sigs.k8s.io/kubebuilder/v3/pkg/plugin"
24
26
"sigs.k8s.io/kubebuilder/v3/pkg/plugin/external"
27
+ "sigs.k8s.io/yaml"
25
28
)
26
29
27
30
var _ plugin.InitSubcommand = & initSubcommand {}
28
31
29
32
type initSubcommand struct {
30
- Path string
31
- Args []string
33
+ Path string
34
+ Args []string
35
+ config config.Config
32
36
}
33
37
34
38
func (p * initSubcommand ) UpdateMetadata (_ plugin.CLIMetadata , subcmdMeta * plugin.SubcommandMetadata ) {
@@ -40,16 +44,29 @@ func (p *initSubcommand) BindFlags(fs *pflag.FlagSet) {
40
44
}
41
45
42
46
func (p * initSubcommand ) Scaffold (fs machinery.Filesystem ) error {
47
+ configBytes , err := yaml .Marshal (p .config )
48
+ if err != nil {
49
+ return err
50
+ }
51
+
52
+ fmt .Println ("Scaffolding with config:" , string (configBytes ))
53
+
43
54
req := external.PluginRequest {
44
55
APIVersion : defaultAPIVersion ,
45
56
Command : "init" ,
46
57
Args : p .Args ,
58
+ Config : string (configBytes ),
47
59
}
48
60
49
- err : = handlePluginResponse (fs , req , p .Path )
61
+ err = handlePluginResponse (fs , req , p .Path )
50
62
if err != nil {
51
63
return err
52
64
}
53
65
54
66
return nil
55
67
}
68
+
69
+ func (p * initSubcommand ) InjectConfig (c config.Config ) error {
70
+ p .config = c
71
+ return nil
72
+ }
You can’t perform that action at this time.
0 commit comments