Skip to content
Merged
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
4 changes: 4 additions & 0 deletions .biased_lang_exclude
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pkg/splunk/common/urls.go
pkg/splunk/common/urls_testingcode.go
pkg/splunk/common/paths.go
deploy/olm-catalog/
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line adds the Legacy CRDs as exceptions for the Bias Language process.

13 changes: 7 additions & 6 deletions pkg/splunk/client/enterprise.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"crypto/tls"
"encoding/json"
"fmt"
splcommon "github.com/splunk/splunk-operator/pkg/splunk/common"
"io/ioutil"
"net/http"
"regexp"
Expand Down Expand Up @@ -412,7 +413,7 @@ func (c *SplunkClient) GetClusterMasterInfo() (*ClusterMasterInfo, error) {
Content ClusterMasterInfo `json:"content"`
} `json:"entry"`
}{}
path := "/services/cluster/master/info"
path := splcommon.URIClusterManagerGetInfo
err := c.Get(path, &apiResponse)
if err != nil {
return nil, err
Expand Down Expand Up @@ -459,7 +460,7 @@ func (c *SplunkClient) GetIndexerClusterPeerInfo() (*IndexerClusterPeerInfo, err
Content IndexerClusterPeerInfo `json:"content"`
} `json:"entry"`
}{}
path := "/services/cluster/slave/info"
path := splcommon.URIPeerGetInfo
err := c.Get(path, &apiResponse)
if err != nil {
return nil, err
Expand Down Expand Up @@ -582,7 +583,7 @@ func (c *SplunkClient) GetClusterMasterPeers() (map[string]ClusterMasterPeerInfo
Content ClusterMasterPeerInfo `json:"content"`
} `json:"entry"`
}{}
path := "/services/cluster/master/peers"
path := splcommon.URIClusterManagerGetPeers
err := c.Get(path, &apiResponse)
if err != nil {
return nil, err
Expand All @@ -602,7 +603,7 @@ func (c *SplunkClient) GetClusterMasterPeers() (map[string]ClusterMasterPeerInfo
// See https://docs.splunk.com/Documentation/Splunk/8.0.2/Indexer/Removepeerfrommasterlist
func (c *SplunkClient) RemoveIndexerClusterPeer(id string) error {
// sent request to remove a peer from Cluster Manager peers list
endpoint := fmt.Sprintf("%s/services/cluster/master/control/control/remove_peers?peers=%s", c.ManagementURI, id)
endpoint := fmt.Sprintf("%s%speers=%s", c.ManagementURI, splcommon.URIClusterManagerRemovePeers, id)
request, err := http.NewRequest("POST", endpoint, nil)
if err != nil {
return err
Expand All @@ -619,7 +620,7 @@ func (c *SplunkClient) DecommissionIndexerClusterPeer(enforceCounts bool) error
if enforceCounts {
enforceCountsAsInt = 1
}
endpoint := fmt.Sprintf("%s/services/cluster/slave/control/control/decommission?enforce_counts=%d", c.ManagementURI, enforceCountsAsInt)
endpoint := fmt.Sprintf("%s%senforce_counts=%d", c.ManagementURI, splcommon.URIPeerDecommission, enforceCountsAsInt)
request, err := http.NewRequest("POST", endpoint, nil)
if err != nil {
return err
Expand All @@ -630,7 +631,7 @@ func (c *SplunkClient) DecommissionIndexerClusterPeer(enforceCounts bool) error

// BundlePush pushes the Cluster manager apps bundle to all the indexer peers
func (c *SplunkClient) BundlePush(ignoreIdenticalBundle bool) error {
endpoint := fmt.Sprintf("%s/services/cluster/master/control/default/apply", c.ManagementURI)
endpoint := fmt.Sprintf("%s%s", c.ManagementURI, splcommon.URIClusterManagerApplyBundle)
reqBody := fmt.Sprintf("&ignore_identical_bundle=%t", ignoreIdenticalBundle)

request, err := http.NewRequest("POST", endpoint, strings.NewReader(reqBody))
Expand Down
35 changes: 18 additions & 17 deletions pkg/splunk/client/enterprise_test.go

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions pkg/splunk/common/paths.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package common

// List of all Paths used in the Splunk Operator

//List of Splunk Enterprise Paths
const (

//PeerAppsLoc = "etc/slave-apps"
PeerAppsLoc = "etc/slave-apps"

//ManagerAppsLoc = "etc/master-apps"
ManagerAppsLoc = "etc/master-apps"

//SHCluster = "etc/shcluster"
SHCluster = "etc/shcluster"

//SHClusterAppsLoc = "etc/shcluster/apps"
SHClusterAppsLoc = SHCluster + "/apps"
)
107 changes: 107 additions & 0 deletions pkg/splunk/common/urls.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package common

// URLs for Splunk APIs and REST Endpoints

// ***** Cluster Manager *****

// List of URIs - Cluster Manager
const (

//ClusterManager = "cluster-master"
ClusterManager = "cluster-master"

//URIClusterManagerClusterConfig = "/services/cluster/config?"
URIClusterManagerClusterConfig = "/services/cluster/config?"

//URICLusterManagerServices = "/services/cluster/master"
URICLusterManagerServices = "/services/cluster/master"

//URIClusterManagerGetInfo = "/services/cluster/master/info"
URIClusterManagerGetInfo = URICLusterManagerServices + "/info"

//URIClusterManagerGetPeers = "/services/cluster/master/peers"
URIClusterManagerGetPeers = URICLusterManagerServices + "/peers"

//URIClusterManagerRemovePeers = "/services/cluster/master/control/control/remove_peers?"
URIClusterManagerRemovePeers = URICLusterManagerServices + "/control/control/remove_peers?"

//URIClusterManagerApplyBundle = "/services/cluster/master/control/default/apply"
URIClusterManagerApplyBundle = URICLusterManagerServices + "/control/default/apply"

//URIClusterManagerGetHealth = "/services/cluster/master/health?"
URIClusterManagerGetHealth = URICLusterManagerServices + "/health?"

//URIClusterManagerGetSites = "/services/cluster/master/sites?"
URIClusterManagerGetSites = URICLusterManagerServices + "/sites?"

//URIClusterManagerGetSearchHeads = "/services/cluster/master/searchheads?"
URIClusterManagerGetSearchHeads = URICLusterManagerServices + "/searchheads?"
)

// List of URLs - Cluster Manager
const (

//LocalURLClusterManagerApplyBundle = "https://localhost:8089/services/cluster/master/control/default/apply"
LocalURLClusterManagerApplyBundle = "https://localhost:8089" + URIClusterManagerApplyBundle

//LocalURLClusterManagerGetInfo = "https://localhost:8089/services/cluster/master/info?count=0&output_mode=json"
LocalURLClusterManagerGetInfo = "https://localhost:8089" + URIClusterManagerGetInfo + "?count=0&output_mode=json"

//LocalURLClusterManagerGetInfoJSONOutput = "https://localhost:8089/services/cluster/master/info?output_mode=json"
LocalURLClusterManagerGetInfoJSONOutput = "https://localhost:8089" + URIClusterManagerGetInfo + "output_mode=json"

//LocalURLClusterManagerGetPeers = "https://localhost:8089/services/cluster/master/peers?count=0&output_mode=json"
LocalURLClusterManagerGetPeers = "https://localhost:8089" + URIClusterManagerGetPeers + "?count=0&output_mode=json"

//LocalURLClusterManagerGetPeersJSONOutput = "https://localhost:8089/services/cluster/master/peers?output_mode=json"
LocalURLClusterManagerGetPeersJSONOutput = "https://localhost:8089" + URIClusterManagerGetPeers + "output_mode=json"

//LocalURLClusterManagerRemovePeers = "https://localhost:8089/services/cluster/master/control/control/remove_peers?
LocalURLClusterManagerRemovePeers = "https://localhost:8089" + URIClusterManagerRemovePeers

//LocalURLClusterManagerGetSite = https://localhost:8089/services/cluster/master/sites?output_mode=json
LocalURLClusterManagerGetSite = "https://localhost:8089" + URIClusterManagerGetSites + "output_mode=json"

//LocalURLClusterManagerGetHealth = "https://localhost:8089/services/cluster/master/health?output_mode=json"
LocalURLClusterManagerGetHealth = "https://localhost:8089" + URIClusterManagerGetHealth + "output_mode=json"

//LocalURLClusterManagerGetSearchHeads = "https://localhost:8089/services/cluster/master/searchheads?output_mode=json"
LocalURLClusterManagerGetSearchHeads = "https://localhost:8089" + URIClusterManagerGetSearchHeads + "output_mode=json"
)

// ***** Cluster Peers *****

// List of URIs - Cluster Peers
const (

//URIPeerGetInfo = "/services/cluster/slave/info"
URIPeerGetInfo = "/services/cluster/slave/info"

//URIPeerDecommission = "/services/cluster/slave/control/control/decommission?"
URIPeerDecommission = "/services/cluster/slave/control/control/decommission?"
)

// List of URLs - Cluster Peers
const (

//URLPeerInfo = "https://localhost:8089/services/cluster/slave/info?count=0&output_mode=json"
URLPeerInfo = "https://localhost:8089" + URIPeerGetInfo + "?count=0&output_mode=json"

//URLPeerDecommission = "https://localhost:8089/services/cluster/slave/control/control/decommission?
URLPeerDecommission = "https://localhost:8089" + URIPeerDecommission
)

// ***** License Manager *****

// List of URIs - License Manager
const (
//LicenseManager = "license-master"
LicenseManager = "license-master"
)

// List of URLs - License Manager/Peer
const (

//LocalURLLicensePeerJSONOutput = "https://localhost:8089/services/licenser/localslave?output_mode=json"
LocalURLLicensePeerJSONOutput = "https://localhost:8089/services/licenser/localslave?output_mode=json"
)
Loading