Skip to content

Commit

Permalink
Add support for "terraform import"
Browse files Browse the repository at this point in the history
  • Loading branch information
SchoolGuy committed Oct 25, 2024
1 parent 9a73f02 commit ecdb387
Show file tree
Hide file tree
Showing 24 changed files with 102 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cobbler/resource_cobbler_distro.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ func resourceDistro() *schema.Resource {
ReadContext: resourceDistroRead,
UpdateContext: resourceDistroUpdate,
DeleteContext: resourceDistroDelete,
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},

Schema: map[string]*schema.Schema{
"arch": {
Expand Down
5 changes: 5 additions & 0 deletions cobbler/resource_cobbler_distro_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ func TestAccCobblerDistro_basic(t *testing.T) {
testAccCobblerCheckDistroExists("cobbler_distro.foo", &distro),
),
},
{
ResourceName: "cobbler_distro.foo",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
Expand Down
3 changes: 3 additions & 0 deletions cobbler/resource_cobbler_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ func resourceProfile() *schema.Resource {
ReadContext: resourceProfileRead,
UpdateContext: resourceProfileUpdate,
DeleteContext: resourceProfileDelete,
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},

Schema: map[string]*schema.Schema{
"autoinstall": {
Expand Down
5 changes: 5 additions & 0 deletions cobbler/resource_cobbler_profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ func TestAccCobblerProfile_basic(t *testing.T) {
testAccCobblerCheckProfileExists("cobbler_profile.foo", &profile),
),
},
{
ResourceName: "cobbler_profile.foo",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
Expand Down
3 changes: 3 additions & 0 deletions cobbler/resource_cobbler_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ func resourceRepo() *schema.Resource {
ReadContext: resourceRepoRead,
UpdateContext: resourceRepoUpdate,
DeleteContext: resourceRepoDelete,
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},

Schema: map[string]*schema.Schema{
"apt_components": {
Expand Down
5 changes: 5 additions & 0 deletions cobbler/resource_cobbler_repo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ func TestAccCobblerRepo_basic(t *testing.T) {
testAccCobblerCheckRepoExists("cobbler_repo.foo", &repo),
),
},
{
ResourceName: "cobbler_repo.foo",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
Expand Down
3 changes: 3 additions & 0 deletions cobbler/resource_cobbler_snippet.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ func resourceSnippet() *schema.Resource {
ReadContext: resourceSnippetRead,
UpdateContext: resourceSnippetUpdate,
DeleteContext: resourceSnippetDelete,
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},

Schema: map[string]*schema.Schema{
"name": {
Expand Down
5 changes: 5 additions & 0 deletions cobbler/resource_cobbler_snippet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ func TestAccCobblerSnippet_basic(t *testing.T) {
testAccCobblerCheckSnippetExists("cobbler_snippet.foo", &snippet),
),
},
{
ResourceName: "cobbler_snippet.foo",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
Expand Down
3 changes: 3 additions & 0 deletions cobbler/resource_cobbler_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ func resourceSystem() *schema.Resource {
ReadContext: resourceSystemRead,
UpdateContext: resourceSystemUpdate,
DeleteContext: resourceSystemDelete,
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},

Schema: map[string]*schema.Schema{
"autoinstall": {
Expand Down
5 changes: 5 additions & 0 deletions cobbler/resource_cobbler_system_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ func TestAccCobblerSystem_basic(t *testing.T) {
testAccCobblerCheckSystemExists("cobbler_system.foo", &system),
),
},
{
ResourceName: "cobbler_system.foo",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
Expand Down
3 changes: 3 additions & 0 deletions cobbler/resource_cobbler_template_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ func resourceTemplateFile() *schema.Resource {
ReadContext: resourceTemplateFileRead,
UpdateContext: resourceTemplateFileUpdate,
DeleteContext: resourceTemplateFileDelete,
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},

Schema: map[string]*schema.Schema{
"name": {
Expand Down
5 changes: 5 additions & 0 deletions cobbler/resource_cobbler_template_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ func TestAccCobblerTemplateFile_basic(t *testing.T) {
testAccCobblerCheckTemplateFileExists("cobbler_template_file.foo", &ks),
),
},
{
ResourceName: "cobbler_template.foo",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
Expand Down
8 changes: 8 additions & 0 deletions docs/resources/distro.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,11 @@ resource "cobbler_distro" "Ubuntu-2004-x86_64" {
### Read-Only

- `id` (String) The ID of this resource.

## Import

Import is supported using the following syntax:

```shell
terraform import cobbler_distro.foo foo
```
8 changes: 8 additions & 0 deletions docs/resources/profile.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,11 @@ resource "cobbler_profile" "my_profile" {
### Read-Only

- `id` (String) The ID of this resource.

## Import

Import is supported using the following syntax:

```shell
terraform import cobbler_profile.foo foo
```
8 changes: 8 additions & 0 deletions docs/resources/repo.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,11 @@ resource "cobbler_repo" "my_repo" {
### Read-Only

- `id` (String) The ID of this resource.

## Import

Import is supported using the following syntax:

```shell
terraform import cobbler_repo.foo foo
```
8 changes: 8 additions & 0 deletions docs/resources/snippet.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,11 @@ resource "cobbler_snippet" "my_snippet" {
### Read-Only

- `id` (String) The ID of this resource.

## Import

Import is supported using the following syntax:

```shell
terraform import cobbler_snippet.foo foo
```
8 changes: 8 additions & 0 deletions docs/resources/system.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,11 @@ Optional:
- `static` (Boolean) Whether the interface should be static or DHCP.
- `static_routes` (List of String) Static routes for the interface.
- `virt_bridge` (String) The virtual bridge to attach to.

## Import

Import is supported using the following syntax:

```shell
terraform import cobbler_system.foo foo
```
8 changes: 8 additions & 0 deletions docs/resources/template_file.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,11 @@ resource "cobbler_template_file" "my_template" {
### Read-Only

- `id` (String) The ID of this resource.

## Import

Import is supported using the following syntax:

```shell
terraform import cobbler_template.foo foo
```
1 change: 1 addition & 0 deletions examples/resources/cobbler_distro/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import cobbler_distro.foo foo
1 change: 1 addition & 0 deletions examples/resources/cobbler_profile/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import cobbler_profile.foo foo
1 change: 1 addition & 0 deletions examples/resources/cobbler_repo/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import cobbler_repo.foo foo
1 change: 1 addition & 0 deletions examples/resources/cobbler_snippet/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import cobbler_snippet.foo foo
1 change: 1 addition & 0 deletions examples/resources/cobbler_system/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import cobbler_system.foo foo
1 change: 1 addition & 0 deletions examples/resources/cobbler_template_file/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import cobbler_template.foo foo

0 comments on commit ecdb387

Please sign in to comment.