Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terraform to use coraglogix sdk #267

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/acc-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
GO111MODULE: on
strategy:
matrix:
go-version: [ 1.20.x ]
go-version: [ 1.23 ]
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
GO111MODULE: on
strategy:
matrix:
go-version: [ 1.20.x ]
go-version: [ 1.23 ]
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
steps:
Expand Down
81 changes: 0 additions & 81 deletions coralogix/clientset/actions-client.go

This file was deleted.

80 changes: 0 additions & 80 deletions coralogix/clientset/apikeys-client.go

This file was deleted.

18 changes: 0 additions & 18 deletions coralogix/clientset/clientset.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,17 @@ type ClientSet struct {
dataSet *DataSetClient
dashboards *DashboardsClient
grafana *GrafanaClient
actions *ActionsClient
recordingRuleGroups *RecordingRulesGroupsSetsClient
tcoPolicies *TCOPoliciesClient
webhooks *WebhooksClient
events2Metrics *Events2MetricsClient
slis *SLIClient
archiveRetentions *ArchiveRetentionsClient
archiveMetrics *ArchiveMetricsClient
archiveLogs *ArchiveLogsClient
alertsSchedulers *AlertsSchedulersClient
teams *TeamsClient
slos *SLOsClient
dahboardsFolders *DashboardsFoldersClient
apiKeys *ApikeysClient
groups *GroupsClient
users *UsersClient
customRole *RolesClient
Expand Down Expand Up @@ -66,10 +63,6 @@ func (c *ClientSet) Grafana() *GrafanaClient {
return c.grafana
}

func (c *ClientSet) Actions() *ActionsClient {
return c.actions
}

func (c *ClientSet) RecordingRuleGroupsSets() *RecordingRulesGroupsSetsClient {
return c.recordingRuleGroups
}
Expand All @@ -86,10 +79,6 @@ func (c *ClientSet) Events2Metrics() *Events2MetricsClient {
return c.events2Metrics
}

func (c *ClientSet) SLIs() *SLIClient {
return c.slis
}

func (c *ClientSet) ArchiveRetentions() *ArchiveRetentionsClient {
return c.archiveRetentions
}
Expand All @@ -110,10 +99,6 @@ func (c *ClientSet) Teams() *TeamsClient {
return c.teams
}

func (c *ClientSet) ApiKeys() *ApikeysClient {
return c.apiKeys
}

func (c *ClientSet) CustomRoles() *RolesClient {
return c.customRole
}
Expand Down Expand Up @@ -153,19 +138,16 @@ func NewClientSet(targetUrl, apiKey string) *ClientSet {
dataSet: NewDataSetClient(apikeyCPC),
dashboards: NewDashboardsClient(apikeyCPC),
grafana: NewGrafanaClient(apikeyCPC),
actions: NewActionsClient(apikeyCPC),
recordingRuleGroups: NewRecordingRuleGroupsClient(apikeyCPC),
tcoPolicies: NewTCOPoliciesClient(apikeyCPC),
webhooks: NewWebhooksClient(apikeyCPC),
slis: NewSLIsClient(apikeyCPC),
archiveRetentions: NewArchiveRetentionsClient(apikeyCPC),
archiveMetrics: NewArchiveMetricsClient(apikeyCPC),
archiveLogs: NewArchiveLogsClient(apikeyCPC),
alertsSchedulers: NewAlertsSchedulersClient(apikeyCPC),
teams: NewTeamsClient(apikeyCPC),
slos: NewSLOsClient(apikeyCPC),
dahboardsFolders: NewDashboardsFoldersClient(apikeyCPC),
apiKeys: NewApiKeysClient(apikeyCPC),
groups: NewGroupsClient(apikeyCPC),
users: NewUsersClient(apikeyCPC),
customRole: NewRolesClient(apikeyCPC),
Expand Down
19 changes: 9 additions & 10 deletions coralogix/data_source_coralogix_action.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright 2024 Coralogix Ltd.
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// https://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -21,8 +21,7 @@ import (

"google.golang.org/protobuf/encoding/protojson"

"terraform-provider-coralogix/coralogix/clientset"
actions "terraform-provider-coralogix/coralogix/clientset/grpc/actions/v2"
cxsdk "github.com/coralogix/coralogix-management-sdk/go"

"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/resource"
Expand All @@ -39,7 +38,7 @@ func NewActionDataSource() datasource.DataSource {
}

type ActionDataSource struct {
client *clientset.ActionsClient
client *cxsdk.ActionsClient
}

func (d *ActionDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
Expand All @@ -51,7 +50,7 @@ func (d *ActionDataSource) Configure(_ context.Context, req datasource.Configure
return
}

clientSet, ok := req.ProviderData.(*clientset.ClientSet)
clientSet, ok := req.ProviderData.(*cxsdk.ClientSet)
if !ok {
resp.Diagnostics.AddError(
"Unexpected Resource Configure Type",
Expand Down Expand Up @@ -81,8 +80,8 @@ func (d *ActionDataSource) Read(ctx context.Context, req datasource.ReadRequest,
//Get refreshed Action value from Coralogix
id := data.ID.ValueString()
log.Printf("[INFO] Reading Action: %s", id)
getActionReq := &actions.GetActionRequest{Id: wrapperspb.String(id)}
getActionResp, err := d.client.GetAction(ctx, getActionReq)
getActionReq := &cxsdk.GetActionRequest{Id: wrapperspb.String(id)}
getActionResp, err := d.client.Get(ctx, getActionReq)
if err != nil {
log.Printf("[ERROR] Received error: %s", err.Error())
if status.Code(err) == codes.NotFound {
Expand All @@ -91,7 +90,7 @@ func (d *ActionDataSource) Read(ctx context.Context, req datasource.ReadRequest,
} else {
resp.Diagnostics.AddError(
"Error reading Action",
formatRpcErrors(err, getActionURL, protojson.Format(getActionReq)),
formatRpcErrors(err, cxsdk.GetActionRpc, protojson.Format(getActionReq)),
)
}
return
Expand Down
Loading
Loading