Skip to content

Commit

Permalink
Use subnet service for MFKE
Browse files Browse the repository at this point in the history
  • Loading branch information
ducvm29 committed Sep 26, 2024
1 parent c5ffc14 commit 8118bc5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 55 deletions.
19 changes: 8 additions & 11 deletions fptcloud/mfke/resource_mfke.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var (
type resourceManagedKubernetesEngine struct {
client *commons.Client
mfkeClient *MfkeApiClient
subnetClient *fptcloud_subnet.SubnetClient
subnetClient fptcloud_subnet.SubnetService
}

func NewResourceManagedKubernetesEngine() resource.Resource {
Expand Down Expand Up @@ -272,7 +272,7 @@ func (r *resourceManagedKubernetesEngine) Configure(ctx context.Context, request

r.client = client
r.mfkeClient = newMfkeApiClient(r.client)
r.subnetClient = fptcloud_subnet.NewSubnetClient(r.client)
r.subnetClient = fptcloud_subnet.NewSubnetService(r.client)
}
func (r *resourceManagedKubernetesEngine) topFields() map[string]schema.Attribute {
topLevelAttributes := map[string]schema.Attribute{}
Expand Down Expand Up @@ -705,21 +705,18 @@ func (r *resourceManagedKubernetesEngine) getOsVersion(ctx context.Context, vers
return nil, &diag
}

func getNetworkId(ctx context.Context, client *fptcloud_subnet.SubnetClient, vpcId string, networkName string) (string, error) {
func getNetworkId(ctx context.Context, client fptcloud_subnet.SubnetService, vpcId string, networkName string) (string, error) {
tflog.Info(ctx, "Resolving network ID for VPC "+vpcId+", network "+networkName)

networks, err := client.ListNetworks(vpcId)
networks, err := client.FindSubnetByName(fptcloud_subnet.FindSubnetDTO{
NetworkName: networkName,
VpcId: vpcId,
})
if err != nil {
return "", err
}

for _, network := range networks {
if network.Name == networkName {
return network.ID, nil
}
}

return "", errors.New("couldn't find network with name " + networkName)
return networks.ID, nil
}
func getClusterName(name string) string {
var indices []int
Expand Down
44 changes: 0 additions & 44 deletions fptcloud/subnet/subnetClient.go

This file was deleted.

0 comments on commit 8118bc5

Please sign in to comment.