parent
d1e12fcf64
commit
24b7387db9
140 changed files with 1597 additions and 7 deletions
|
|
@ -330,6 +330,8 @@ func (r *clusterDataSource) Read(ctx context.Context, req datasource.ReadRequest
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := state.ProjectId.ValueString()
|
||||
name := state.Name.ValueString()
|
||||
region := r.providerData.GetRegionWithOverride(state.Region)
|
||||
|
|
@ -352,6 +354,8 @@ func (r *clusterDataSource) Read(ctx context.Context, req datasource.ReadRequest
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFields(ctx, clusterResp, &state, region)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading cluster", fmt.Sprintf("Processing API payload: %v", err))
|
||||
|
|
|
|||
|
|
@ -721,6 +721,8 @@ func (r *clusterResource) Create(ctx context.Context, req resource.CreateRequest
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
region := model.Region.ValueString()
|
||||
clusterName := model.Name.ValueString()
|
||||
|
|
@ -890,6 +892,12 @@ func (r *clusterResource) createOrUpdateCluster(ctx context.Context, diags *diag
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// The passed context to createOrUpdateCluster will not be updated outside of this function.
|
||||
// Call tflog.Info here, to log the information of the updated context
|
||||
tflog.Info(ctx, "Triggered create/update cluster")
|
||||
|
||||
waitResp, err := skeWait.CreateOrUpdateClusterWaitHandler(ctx, r.skeClient, projectId, region, name).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, diags, "Error creating/updating cluster", fmt.Sprintf("Cluster creation waiting: %v", err))
|
||||
|
|
@ -2104,6 +2112,9 @@ func (r *clusterResource) Read(ctx context.Context, req resource.ReadRequest, re
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := state.ProjectId.ValueString()
|
||||
name := state.Name.ValueString()
|
||||
region := r.providerData.GetRegionWithOverride(state.Region)
|
||||
|
|
@ -2122,6 +2133,8 @@ func (r *clusterResource) Read(ctx context.Context, req resource.ReadRequest, re
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFields(ctx, clResp, &state, region)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading cluster", fmt.Sprintf("Processing API payload: %v", err))
|
||||
|
|
@ -2144,6 +2157,8 @@ func (r *clusterResource) Update(ctx context.Context, req resource.UpdateRequest
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
clName := model.Name.ValueString()
|
||||
region := model.Region.ValueString()
|
||||
|
|
@ -2178,6 +2193,9 @@ func (r *clusterResource) Delete(ctx context.Context, req resource.DeleteRequest
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
name := model.Name.ValueString()
|
||||
region := model.Region.ValueString()
|
||||
|
|
@ -2191,6 +2209,9 @@ func (r *clusterResource) Delete(ctx context.Context, req resource.DeleteRequest
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting cluster", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
_, err = skeWait.DeleteClusterWaitHandler(ctx, r.skeClient, projectId, region, name).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting cluster", fmt.Sprintf("Cluster deletion waiting: %v", err))
|
||||
|
|
|
|||
|
|
@ -245,6 +245,9 @@ func (r *kubeconfigResource) Create(ctx context.Context, req resource.CreateRequ
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
clusterName := model.ClusterName.ValueString()
|
||||
kubeconfigUUID := uuid.New().String()
|
||||
|
|
@ -258,6 +261,9 @@ func (r *kubeconfigResource) Create(ctx context.Context, req resource.CreateRequ
|
|||
ctx = tflog.SetField(ctx, "region", region)
|
||||
|
||||
err := r.createKubeconfig(ctx, &model)
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating kubeconfig", fmt.Sprintf("Creating kubeconfig: %v", err))
|
||||
return
|
||||
|
|
@ -285,6 +291,8 @@ func (r *kubeconfigResource) Read(ctx context.Context, req resource.ReadRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
clusterName := model.ClusterName.ValueString()
|
||||
kubeconfigUUID := model.KubeconfigId.ValueString()
|
||||
|
|
@ -318,6 +326,8 @@ func (r *kubeconfigResource) Read(ctx context.Context, req resource.ReadRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// check if kubeconfig has expired
|
||||
hasExpired, err := checkHasExpired(&model, time.Now())
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue