Skip to content

Commit

Permalink
fix: wip - resource testing and importing (#5)
Browse files Browse the repository at this point in the history
* mass commit

* Update pkg/config-api-provider/provider/resources/group.go
  • Loading branch information
MaraisKruger authored Aug 21, 2024
1 parent ff8b096 commit 6c830b9
Show file tree
Hide file tree
Showing 8 changed files with 363 additions and 31 deletions.
6 changes: 3 additions & 3 deletions pkg/config-api-provider/examples/full-demo/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ resource "uxi_group" "group" {
parent_uid = "9999"
}

output "group" {
value = uxi_group.group
}
# output "group" {
# value = uxi_group.group
# }
86 changes: 86 additions & 0 deletions pkg/config-api-provider/future_plan.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// This file describes a potential layout for a manifest defined by the customer
// This file will be used as reference when building the terraform datasources and resources

# Note:
# general data source | some sort of root_group_query
# investigate implementation of import block -> conflict of user defined fields
# assessment to see how difficult it would be for a user get the uid of various resources
# revisit the flow of a user onboarding existing resources -> moving from data source to resource

data "uxi_group" "root_group" {
filter {
some_sort_of_filter = ""
}
}

resource "uxi_group" "group" {
name = "group_name" # required, mutable
parent_uid = data.group.root_group.uid # required, immutable -> recreate on update
}

# Sensor
resource "uxi_sensor" "sensor" {
name = "name" # mutable
address_note = "address_note" # mutable
notes = "note" # mutable
pcap_mode = "light" # mutable
}

resource "uxi_sensor_group_assignment" "sensor_group_assignment" {
sensor_id = uxi_sensor.sensor.id # required, immutable -> recreate on update
group_id = uxi_group.group.id # required, immutable -> recreate on update
}

# Agent
resource "uxi_agent" "agent_sensor" {
name = "name" # mutable
address_note = "address_note" # mutable
notes = "note" # mutable
pcap_mode = "light" # mutable
}

resource "uxi_agent_group_assignment" "agent_group_assignment" {
agent_id = uxi_agent.agent_sensor.id # required, immutable -> recreate on update
group_id = uxi_group.group.id # required, immutable -> recreate on update
}

# wireless networks
data "uxi_wireless_network" "wireless_network" {
uid = ""
}

resource "uxi_network_group_assignment" "wireless_network_group_assignment" {
network_id = uxi_wireless_network.wireless_network.id # required, immutable -> recreate on update
group_id = uxi_group.group.id # required, immutable -> recreate on update
}

# wired networks
data "uxi_wired_network" "wired_network" {
uid = ""
}

resource "uxi_network_group_assignment" "wired_network_group_assignment" {
network_id = uxi_wired_network.wired_network.id # required, immutable -> recreate on update
group_id = uxi_group.group.id # required, immutable -> recreate on update
}

# service-test
data "uxi_service_test" "service_test" {
uid = ""
}

resource "uxi_service_test_group_assignment" "service_test_group_assignment" {
service_test_id = uxi_service_test.service_test.id # required, immutable -> recreate on update
group_id = uxi_group.group.id # required, immutable -> recreate on update
}


# ----------------------------------
import {
to = "asfasdf"
id = uid
}

resource "uxi_sensor_group_assignment" ""

# terraform refresh-state
43 changes: 38 additions & 5 deletions pkg/config-api-provider/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,62 @@ go 1.21

toolchain go1.22.5

require github.com/hashicorp/terraform-plugin-framework v1.9.0
require (
github.com/golang/mock v1.6.0
github.com/hashicorp/terraform-plugin-framework v1.9.0
github.com/hashicorp/terraform-plugin-go v0.23.0
github.com/hashicorp/terraform-plugin-testing v1.10.0
)

require (
github.com/ProtonMail/go-crypto v1.1.0-alpha.2 // indirect
github.com/agext/levenshtein v1.2.2 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
github.com/hashicorp/go-hclog v1.6.3 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-plugin v1.6.0 // indirect
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/terraform-plugin-go v0.23.0 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
github.com/hashicorp/hc-install v0.8.0 // indirect
github.com/hashicorp/hcl/v2 v2.21.0 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-exec v0.21.0 // indirect
github.com/hashicorp/terraform-json v0.22.1 // indirect
github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect
github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0 // indirect
github.com/hashicorp/terraform-registry-address v0.2.3 // indirect
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/oklog/run v1.0.0 // indirect
github.com/stretchr/testify v1.9.0 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
github.com/zclconf/go-cty v1.15.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/mod v0.19.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.23.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.34.0 // indirect
Expand Down
Loading

0 comments on commit 6c830b9

Please sign in to comment.