@@ -24,9 +24,15 @@ type omniClusterResource struct {
2424}
2525
2626type omniClusterModel struct {
27- ID types.String `tfsdk:"id"`
28- OrganizationID types.String `tfsdk:"organization_id"`
29- ClusterID types.String `tfsdk:"cluster_id"`
27+ ID types.String `tfsdk:"id"`
28+ OrganizationID types.String `tfsdk:"organization_id"`
29+ ClusterID types.String `tfsdk:"cluster_id"`
30+ Status * omniClusterStatusModel `tfsdk:"status"`
31+ }
32+
33+ type omniClusterStatusModel struct {
34+ OmniAgentVersion types.String `tfsdk:"omni_agent_version"`
35+ PodCIDR types.String `tfsdk:"pod_cidr"`
3036}
3137
3238func newOmniClusterResource () resource.Resource {
@@ -62,6 +68,26 @@ func (r *omniClusterResource) Schema(_ context.Context, _ resource.SchemaRequest
6268 stringplanmodifier .RequiresReplace (),
6369 },
6470 },
71+ "status" : schema.SingleNestedAttribute {
72+ Optional : true ,
73+ Description : "Current status of the cluster to report on registration." ,
74+ Attributes : map [string ]schema.Attribute {
75+ "omni_agent_version" : schema.StringAttribute {
76+ Required : true ,
77+ Description : "Version of the omni agent running on the cluster." ,
78+ PlanModifiers : []planmodifier.String {
79+ stringplanmodifier .RequiresReplace (),
80+ },
81+ },
82+ "pod_cidr" : schema.StringAttribute {
83+ Required : true ,
84+ Description : "Pod CIDR of the cluster." ,
85+ PlanModifiers : []planmodifier.String {
86+ stringplanmodifier .RequiresReplace (),
87+ },
88+ },
89+ },
90+ },
6591 },
6692 }
6793}
@@ -91,11 +117,19 @@ func (r *omniClusterResource) Create(ctx context.Context, req resource.CreateReq
91117 return
92118 }
93119
120+ body := omni.RegisteredCluster {}
121+ if plan .Status != nil {
122+ body .Status = & omni.RegisteredClusterStatus {
123+ OmniAgentVersion : plan .Status .OmniAgentVersion .ValueString (),
124+ PodCidr : plan .Status .PodCIDR .ValueString (),
125+ }
126+ }
127+
94128 client := r .client .omniAPI
95129 organizationID := plan .OrganizationID .ValueString ()
96130 clusterID := plan .ClusterID .ValueString ()
97131
98- apiResp , err := client .ClustersAPIRegisterClusterWithResponse (ctx , organizationID , clusterID , omni. ClustersAPIRegisterClusterJSONRequestBody {} )
132+ apiResp , err := client .ClustersAPIRegisterClusterWithResponse (ctx , organizationID , clusterID , body )
99133 if err != nil {
100134 resp .Diagnostics .AddError ("Failed to register omni cluster" , err .Error ())
101135 return
0 commit comments