Skip to content

Commit

Permalink
changed ioutils to os
Browse files Browse the repository at this point in the history
Signed-off-by: vivekr-splunk <[email protected]>
  • Loading branch information
vivekr-splunk committed Sep 12, 2023
1 parent fe0cce8 commit fed6f8a
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 26 deletions.
18 changes: 9 additions & 9 deletions pkg/gateway/splunk/license-manager/fixture/license_fixture.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"path/filepath"

//"encoding/json"
"io/ioutil"

"net/http"

"github.com/go-logr/logr"
Expand Down Expand Up @@ -94,7 +94,7 @@ func (p *fixtureGateway) GetLicenseGroup(ctx context.Context) (*[]licensemodel.L
log.Error(err, "fixture: unable to find path")
return nil, err
}
content, err := ioutil.ReadFile(relativePath + "/license_group.json")
content, err := os.ReadFile(relativePath + "/license_group.json")
if err != nil {
log.Error(err, "fixture: error in get cluster config")
return nil, err
Expand Down Expand Up @@ -142,7 +142,7 @@ func (p *fixtureGateway) GetLicense(ctx context.Context) (*[]licensemodel.Licens
log.Error(err, "fixture: unable to find path")
return nil, err
}
content, err := ioutil.ReadFile(relativePath + "/license.json")
content, err := os.ReadFile(relativePath + "/license.json")
if err != nil {
log.Error(err, "fixture: error in get cluster config")
return nil, err
Expand Down Expand Up @@ -199,7 +199,7 @@ func (p *fixtureGateway) GetLicenseLocalPeer(ctx context.Context) (*[]licensemod
log.Error(err, "fixture: unable to find path")
return nil, err
}
content, err := ioutil.ReadFile(relativePath + "/license_local_peer.json")
content, err := os.ReadFile(relativePath + "/license_local_peer.json")
if err != nil {
log.Error(err, "fixture: error in get cluster config")
return nil, err
Expand Down Expand Up @@ -255,7 +255,7 @@ func (p *fixtureGateway) GetLicenseMessage(ctx context.Context) (*[]licensemodel
log.Error(err, "fixture: unable to find path")
return nil, err
}
content, err := ioutil.ReadFile(relativePath + "/license_message.json")
content, err := os.ReadFile(relativePath + "/license_message.json")
if err != nil {
log.Error(err, "fixture: error in get cluster config")
return nil, err
Expand Down Expand Up @@ -311,7 +311,7 @@ func (p *fixtureGateway) GetLicensePools(ctx context.Context) (*[]licensemodel.L
log.Error(err, "fixture: unable to find path")
return nil, err
}
content, err := ioutil.ReadFile(relativePath + "/license_pools.json")
content, err := os.ReadFile(relativePath + "/license_pools.json")
if err != nil {
log.Error(err, "fixture: error in get cluster config")
return nil, err
Expand Down Expand Up @@ -367,7 +367,7 @@ func (p *fixtureGateway) GetLicensePeers(context context.Context) (*[]licensemod
log.Error(err, "fixture: unable to find path")
return nil, err
}
content, err := ioutil.ReadFile(relativePath + "/license_peers.json")
content, err := os.ReadFile(relativePath + "/license_peers.json")
if err != nil {
log.Error(err, "fixture: error in get cluster config")
return nil, err
Expand Down Expand Up @@ -423,7 +423,7 @@ func (p *fixtureGateway) GetLicenseUsage(ctx context.Context) (*[]licensemodel.L
log.Error(err, "fixture: unable to find path")
return nil, err
}
content, err := ioutil.ReadFile(relativePath + "/license_usage.json")
content, err := os.ReadFile(relativePath + "/license_usage.json")
if err != nil {
log.Error(err, "fixture: error in get cluster config")
return nil, err
Expand Down Expand Up @@ -479,7 +479,7 @@ func (p *fixtureGateway) GetLicenseStacks(ctx context.Context) (*[]licensemodel.
log.Error(err, "fixture: unable to find path")
return nil, err
}
content, err := ioutil.ReadFile(relativePath + "/license_stack.json")
content, err := os.ReadFile(relativePath + "/license_stack.json")
if err != nil {
log.Error(err, "fixture: error in get cluster config")
return nil, err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package impl
import (
"context"
"fmt"
"os"
"time"

"github.com/go-resty/resty/v2"
Expand All @@ -12,7 +13,6 @@ import (

//managermodel "github.com/splunk/splunk-operator/pkg/gateway/splunk/model/services/cluster/manager"
//peermodel "github.com/splunk/splunk-operator/pkg/gateway/splunk/model/services/cluster/peer"
"io/ioutil"
"testing"

logz "sigs.k8s.io/controller-runtime/pkg/log/zap"
Expand Down Expand Up @@ -61,7 +61,7 @@ func GetLicenseGroup(t *testing.T) {
ctx := context.TODO()
sm := setCreds(t)
httpmock.ActivateNonDefault(sm.client.GetClient())
content, err := ioutil.ReadFile("../fixture/license_group.json")
content, err := os.ReadFile("../fixture/license_group.json")
if err != nil {
t.Errorf("fixture: error in get cluster manager health %v", err)
}
Expand Down
15 changes: 8 additions & 7 deletions pkg/gateway/splunk/services/fixture/fixture.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"path/filepath"

//"encoding/json"
"io/ioutil"

"net/http"

"github.com/go-logr/logr"
Expand All @@ -19,6 +19,7 @@ import (
clustermodel "github.com/splunk/splunk-operator/pkg/gateway/splunk/model/services/cluster"
managermodel "github.com/splunk/splunk-operator/pkg/gateway/splunk/model/services/cluster/manager"
model "github.com/splunk/splunk-operator/pkg/splunk/model"

// peermodel "github.com/splunk/splunk-operator/pkg/gateway/splunk/model/services/cluster/peer"
// searchheadmodel "github.com/splunk/splunk-operator/pkg/gateway/splunk/model/services/cluster/searchhead"
// commonmodel "github.com/splunk/splunk-operator/pkg/gateway/splunk/model/services/common"
Expand Down Expand Up @@ -101,7 +102,7 @@ func (p *fixtureGateway) GetClusterManagerInfo(ctx context.Context) (*[]managerm
log.Error(err, "fixture: unable to find path")
return nil, err
}
content, err := ioutil.ReadFile(relativePath + "/cluster_config.json")
content, err := os.ReadFile(relativePath + "/cluster_config.json")
if err != nil {
log.Error(err, "fixture: error in get cluster config")
return nil, err
Expand Down Expand Up @@ -150,7 +151,7 @@ func (p *fixtureGateway) GetClusterManagerPeers(ctx context.Context) (*[]manager
}
// Read entire file content, giving us little control but
// making it very simple. No need to close the file.
content, err := ioutil.ReadFile(relativePath + "cluster_config.json")
content, err := os.ReadFile(relativePath + "cluster_config.json")
if err != nil {
log.Error(err, "fixture: error in get cluster config")
return nil, err
Expand Down Expand Up @@ -204,7 +205,7 @@ func (p *fixtureGateway) GetClusterManagerHealth(ctx context.Context) (*[]manage

// Read entire file content, giving us little control but
// making it very simple. No need to close the file.
content, err := ioutil.ReadFile(relativePath + "cluster_config.json")
content, err := os.ReadFile(relativePath + "cluster_config.json")
if err != nil {
log.Error(err, "fixture: error in get cluster config")
return nil, err
Expand Down Expand Up @@ -255,7 +256,7 @@ func (p *fixtureGateway) GetClusterManagerSites(ctx context.Context) (*[]manager
}
// Read entire file content, giving us little control but
// making it very simple. No need to close the file.
content, err := ioutil.ReadFile(relativePath + "/cluster_config.json")
content, err := os.ReadFile(relativePath + "/cluster_config.json")
if err != nil {
log.Error(err, "fixture: error in get cluster config")
return nil, err
Expand Down Expand Up @@ -304,7 +305,7 @@ func (p *fixtureGateway) GetClusterManagerStatus(ctx context.Context) (*[]manage
}
// Read entire file content, giving us little control but
// making it very simple. No need to close the file.
content, err := ioutil.ReadFile(relativePath + "/cluster_manager_status.json")
content, err := os.ReadFile(relativePath + "/cluster_manager_status.json")
if err != nil {
log.Error(err, "fixture: error in get cluster manager search heads")
return nil, err
Expand Down Expand Up @@ -355,7 +356,7 @@ func (p *fixtureGateway) SetClusterInMaintenanceMode(context context.Context, mo
}
// Read entire file content, giving us little control but
// making it very simple. No need to close the file.
content, err := ioutil.ReadFile(relativePath + "/cluster_maintenance.json")
content, err := os.ReadFile(relativePath + "/cluster_maintenance.json")
if err != nil {
log.Error(err, "fixture: error in post cluster maintenance")
return err
Expand Down
11 changes: 6 additions & 5 deletions pkg/gateway/splunk/services/implementation/splunk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package impl
import (
"context"
"fmt"
"os"
"time"

"github.com/go-resty/resty/v2"
Expand All @@ -12,7 +13,7 @@ import (

//managermodel "github.com/splunk/splunk-operator/pkg/gateway/splunk/model/services/cluster/manager"
//peermodel "github.com/splunk/splunk-operator/pkg/gateway/splunk/model/services/cluster/peer"
"io/ioutil"

"testing"

logz "sigs.k8s.io/controller-runtime/pkg/log/zap"
Expand Down Expand Up @@ -61,7 +62,7 @@ func TestGetClusterManagerHealth(t *testing.T) {
ctx := context.TODO()
sm := setCreds(t)
httpmock.ActivateNonDefault(sm.client.GetClient())
content, err := ioutil.ReadFile("../fixture/cluster_manager_health.json")
content, err := os.ReadFile("../fixture/cluster_manager_health.json")
if err != nil {
t.Errorf("fixture: error in get cluster manager health %v", err)
}
Expand All @@ -83,7 +84,7 @@ func TestGetClusterManagerInfo(t *testing.T) {
ctx := context.TODO()
sm := setCreds(t)
httpmock.ActivateNonDefault(sm.client.GetClient())
content, err := ioutil.ReadFile("../fixture/cluster_manager_info.json")
content, err := os.ReadFile("../fixture/cluster_manager_info.json")
if err != nil {
t.Errorf("fixture: error in get cluster manager info %v", err)
}
Expand All @@ -105,7 +106,7 @@ func TestGetClusterManagerPeers(t *testing.T) {
ctx := context.TODO()
sm := setCreds(t)
httpmock.ActivateNonDefault(sm.client.GetClient())
content, err := ioutil.ReadFile("../fixture/cluster_manager_peers.json")
content, err := os.ReadFile("../fixture/cluster_manager_peers.json")
if err != nil {
t.Errorf("fixture: error in get cluster manager peers %v", err)
}
Expand All @@ -130,7 +131,7 @@ func TestSetClusterInMaintenanceeMode(t *testing.T) {
ctx := context.TODO()
sm := setCreds(t)
httpmock.ActivateNonDefault(sm.client.GetClient())
content, err := ioutil.ReadFile("../fixture/cluster_maintenance.json")
content, err := os.ReadFile("../fixture/cluster_maintenance.json")
if err != nil {
t.Errorf("fixture: error in get cluster manager peers %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/provisioner/splunk/implementation/license_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ func TestGetLicenseLocalPeer(t *testing.T) {
t.Errorf("fixture: error in set cluster manager %v", err)
}
if conditions == nil || len(*conditions) == 0 {
t.Errorf("fixture: error in conditions for lm %v", err)
t.Errorf("fixture: error in conditions for license manager %v", err)
}
}
2 changes: 0 additions & 2 deletions pkg/provisioner/splunk/implementation/splunk.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,6 @@ func (p *splunkProvisioner) GetClusterManagerStatus(ctx context.Context, conditi
meta.SetStatusCondition(conditions, condition)
}

// business logic starts here
//healthList, err := callGetClusterManagerHealth(ctx, p)
healthList, err := callGetClusterManagerHealth(ctx, p)
if err != nil {
return result, err
Expand Down

0 comments on commit fed6f8a

Please sign in to comment.