-
Notifications
You must be signed in to change notification settings - Fork 9
/
plugin_mock.go
66 lines (57 loc) · 1.43 KB
/
plugin_mock.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package plugins
import (
"encoding/json"
"github.com/mach-composer/mach-composer-plugin-sdk/plugin"
"github.com/mach-composer/mach-composer-plugin-sdk/schema"
)
type MockPlugin struct {
Environment string
Provider string
}
func NewMockPluginV1() schema.MachComposerPlugin {
state := MockPlugin{}
return plugin.NewPlugin(&schema.PluginSchema{
Configure: state.Configure,
GetValidationSchema: state.GetValidationSchema,
RenderTerraformComponent: state.RenderTerraformComponent,
IsEnabled: func() bool { return true },
})
}
func (p *MockPlugin) Configure(environment string, provider string) error {
p.Environment = environment
if provider != "" {
p.Provider = provider
}
return nil
}
func (p *MockPlugin) GetValidationSchema() (*schema.ValidationSchema, error) {
content := []byte(`
{
"type": "object",
"required": ["requiredValue"],
"additionalProperties": false,
"properties": {
"boolValue": {
"type": "boolean"
},
"stringValue": {
"type": "string"
},
"requiredValue": {
"type": "string"
},
"intValue": {
"type": "number"
}
}
}
`)
result := schema.ValidationSchema{}
if err := json.Unmarshal(content, &result.SiteConfigSchema); err != nil {
panic(err)
}
return &result, nil
}
func (p *MockPlugin) RenderTerraformComponent(site string, component string) (*schema.ComponentSchema, error) {
return &schema.ComponentSchema{}, nil
}