|
1 | 1 | package provider |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "fmt" |
5 | | - |
6 | 4 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" |
7 | 5 | ) |
8 | 6 |
|
9 | | -func resourceFlash() *schema.Resource { |
10 | | - return &schema.Resource{ |
11 | | - Create: resourceFlashCreate, |
12 | | - Read: resourceFlashRead, |
13 | | - Delete: resourceFlashDelete, |
14 | | - // No Update function is defined, so ForceNew is required for fields that trigger recreation |
| 7 | +func Provider() *schema.Provider { |
| 8 | + return &schema.Provider{ |
15 | 9 | Schema: map[string]*schema.Schema{ |
16 | | - "node": { |
17 | | - Type: schema.TypeInt, |
| 10 | + "username": { |
| 11 | + Type: schema.TypeString, |
18 | 12 | Required: true, |
19 | | - Description: "Node ID to flash firmware", |
20 | | - ForceNew: true, // Force resource recreation if this changes |
| 13 | + Description: "The username for BMC authentication", |
21 | 14 | }, |
22 | | - "firmware_file": { |
| 15 | + "password": { |
23 | 16 | Type: schema.TypeString, |
24 | 17 | Required: true, |
25 | | - Description: "Path to the firmware file", |
26 | | - ForceNew: true, // Force resource recreation if this changes |
| 18 | + Description: "The password for BMC authentication", |
27 | 19 | }, |
28 | 20 | }, |
| 21 | + ResourcesMap: map[string]*schema.Resource{ |
| 22 | + "turingpi_power": resourcePower(), |
| 23 | + "turingpi_flash": resourceFlash(), |
| 24 | + "turingpi_node": resourceNode(), |
| 25 | + }, |
29 | 26 | } |
30 | 27 | } |
31 | | - |
32 | | -func resourceFlashCreate(d *schema.ResourceData, meta interface{}) error { |
33 | | - node := d.Get("node").(int) |
34 | | - firmware := d.Get("firmware_file").(string) |
35 | | - |
36 | | - // Example logic for flashing |
37 | | - fmt.Printf("Flashing node %d with firmware %s\n", node, firmware) |
38 | | - |
39 | | - // Set a unique ID for the resource |
40 | | - d.SetId(fmt.Sprintf("node-%d", node)) |
41 | | - return nil |
42 | | -} |
43 | | - |
44 | | -func resourceFlashRead(d *schema.ResourceData, meta interface{}) error { |
45 | | - // Example logic for reading flash status |
46 | | - fmt.Printf("Reading flash status for node %s\n", d.Id()) |
47 | | - return nil |
48 | | -} |
49 | | - |
50 | | -func resourceFlashDelete(d *schema.ResourceData, meta interface{}) error { |
51 | | - // Example logic for flash cleanup if needed |
52 | | - fmt.Printf("Deleting flash resource for node %s\n", d.Id()) |
53 | | - return nil |
54 | | -} |
0 commit comments