nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: Nerzal/gocloak
Pull request #113 (2019-12-09 00:45:34)

Adding CreateChildGroup method
Depends-on: #112 


Patch:
diff --git a/README.md b/README.md
index a8ceda2..23f150d 100644
--- a/README.md
+++ b/README.md
@@ -119,6 +119,7 @@ type GoCloak interface {
 
 	CreateUser(token string, realm string, user User) (string, error)
 	CreateGroup(accessToken string, realm string, group Group) error
+	CreateChildGroup(token string, realm string, groupID string, group Group) (string, error)
 	CreateClientRole(accessToken string, realm string, clientID string, role Role) error
 	CreateClient(accessToken string, realm string, clientID Client) error
 	CreateClientScope(accessToken string, realm string, scope ClientScope) error
diff --git a/client.go b/client.go
index c01017e..d62330e 100644
--- a/client.go
+++ b/client.go
@@ -382,6 +382,18 @@ func (client *gocloak) CreateGroup(token, realm string, group Group) (string, er
 	return getID(resp), nil
 }
 
+// CreateChildGroup creates a new child group
+func (client *gocloak) CreateChildGroup(token string, realm string, groupID string, group Group) (string, error) {
+	resp, err := client.getRequestWithBearerAuth(token).
+		SetBody(group).
+		Post(client.getAdminRealmURL(realm, "groups", groupID, "children"))
+
+	if err := checkForError(resp, err); err != nil {
+		return "", err
+	}
+	return getID(resp), nil
+}
+
 func (client *gocloak) CreateComponent(token, realm string, component Component) (string, error) {
 	resp, err := client.getRequestWithBearerAuth(token).
 		SetBody(component).
diff --git a/gocloak.go b/gocloak.go
index 26729de..9c3b92a 100644
--- a/gocloak.go
+++ b/gocloak.go
@@ -48,6 +48,8 @@ type GoCloak interface {
 
 	// CreateGroup creates a new group
 	CreateGroup(accessToken, realm string, group Group) (string, error)
+	// CreateChildGroup creates a new child group
+	CreateChildGroup(token string, realm string, groupID string, group Group) (string, error)
 	// CreateClient creates a new client
 	CreateClient(accessToken, realm string, clientID Client) (string, error)
 	// CreateClientScope creates a new clientScope


Test patch:
diff --git a/client_test.go b/client_test.go
index 1bf8030..3af43d2 100644
--- a/client_test.go
+++ b/client_test.go
@@ -644,7 +644,7 @@ func TestGocloak_SetPassword(t *testing.T) {
 	FailIfErr(t, err, "Failed to set password")
 }
 
-func TestGocloak_CreateListGetUpdateDeleteGroup(t *testing.T) {
+func TestGocloak_CreateListGetUpdateDeleteGetChildGroup(t *testing.T) {
 	t.Parallel()
 	cfg := GetConfig(t)
 	client := NewClientWithDebug(t)
@@ -687,6 +687,23 @@ func TestGocloak_CreateListGetUpdateDeleteGroup(t *testing.T) {
 	)
 	assert.NoError(t, err, "GetGroup failed")
 	assert.Equal(t, *(createdGroup.Name), *(updatedGroup.Name))
+
+	childGroupID, err := client.CreateChildGroup(
+		token.AccessToken,
+		cfg.GoCloak.Realm,
+		groupID,
+		Group{
+			Name: GetRandomNameP("GroupName"),
+		},
+	)
+	assert.NoError(t, err, "CreateChildGroup failed")
+
+	_, err = client.GetGroup(
+		token.AccessToken,
+		cfg.GoCloak.Realm,
+		childGroupID,
+	)
+	assert.NoError(t, err, "GetGroup failed")
 }
 
 func CreateClientRole(t *testing.T, client GoCloak) (func(), string) {
Repository: Nerzal/gocloak
Pull request #124 (2019-12-22 11:35:12)

Fix golangci-lint issues
```
% golangci-lint run ./...
client_test.go:533:2: SA4006: this value of `rpt` is never used (staticcheck)
        rpt, err := client.GetRequestingPartyToken(token.AccessToken, cfg.GoCloak.Realm, RequestingPartyTokenOptions{
        ^
client.go:1517:26: error strings should not be capitalized or end with punctuation or a newline (golint)
                return nil, errors.New("Type of a policy required")
                                       ^
client.go:1593:26: error strings should not be capitalized or end with punctuation or a newline (golint)
                return nil, errors.New("Type of a permission required")
```


Patch:
diff --git a/client.go b/client.go
index fc53470..01474e9 100644
--- a/client.go
+++ b/client.go
@@ -1514,7 +1514,7 @@ func (client *gocloak) GetPolicies(token string, realm string, clientID string,
 // CreatePolicy creates a policy associated with the client
 func (client *gocloak) CreatePolicy(token string, realm string, clientID string, policy PolicyRepresentation) (*PolicyRepresentation, error) {
 	if NilOrEmpty(policy.Type) {
-		return nil, errors.New("Type of a policy required")
+		return nil, errors.New("type of a policy required")
 	}
 	var result PolicyRepresentation
 	resp, err := client.getRequestWithBearerAuth(token).
@@ -1590,7 +1590,7 @@ func (client *gocloak) GetPermissions(token string, realm string, clientID strin
 // CreatePermission creates a permission associated with the client
 func (client *gocloak) CreatePermission(token string, realm string, clientID string, permission PermissionRepresentation) (*PermissionRepresentation, error) {
 	if NilOrEmpty(permission.Type) {
-		return nil, errors.New("Type of a permission required")
+		return nil, errors.New("type of a permission required")
 	}
 	var result PermissionRepresentation
 	resp, err := client.getRequestWithBearerAuth(token).


Test patch:
diff --git a/client_test.go b/client_test.go
index e06af73..f84788c 100644
--- a/client_test.go
+++ b/client_test.go
@@ -537,6 +537,7 @@ func TestGocloak_RequestPermission(t *testing.T) {
 		},
 	})
 	assert.Error(t, err, "GetRequestingPartyToken failed")
+	assert.Nil(t, rpt)
 
 	rpt, err = client.GetRequestingPartyToken(token.AccessToken, cfg.GoCloak.Realm, RequestingPartyTokenOptions{
 		Audience: StringP(cfg.GoCloak.ClientID),
@@ -545,6 +546,7 @@ func TestGocloak_RequestPermission(t *testing.T) {
 		},
 	})
 	assert.NoError(t, err, "GetRequestingPartyToken failed")
+	assert.NotNil(t, rpt)
 
 	rptResult, err := client.RetrospectToken(
 		rpt.AccessToken,
Repository: Nerzal/gocloak
Pull request #142 (2020-02-09 12:44:46)

Adding UpdateRealm method
These method will allow to change realm parameters after realm creation (i.e. update SMTP configuration, change default roles and etc)


Patch:
diff --git a/README.md b/README.md
index 5dcaa9f..a1ae959 100644
--- a/README.md
+++ b/README.md
@@ -195,7 +195,8 @@ type GoCloak interface {
 
 	GetRealm(token string, realm string) (*RealmRepresentation, error)
 	GetRealms(token string) ([]*RealmRepresentation, error)
-	CreateRealm(token string, realm RealmRepresentation) error
+	CreateRealm(token string, realm RealmRepresentation) (string, error)
+	UpdateRealm(token string, realm RealmRepresentation) error
 	DeleteRealm(token string, realm string) error
 	ClearRealmCache(token string, realm string) error
 	ClearUserCache(token string, realm string) error
diff --git a/client.go b/client.go
index ad29694..4447586 100644
--- a/client.go
+++ b/client.go
@@ -1179,6 +1179,15 @@ func (client *gocloak) CreateRealm(token string, realm RealmRepresentation) (str
 	return getID(resp), nil
 }
 
+// UpdateRealm updates a given realm
+func (client *gocloak) UpdateRealm(token string, realm RealmRepresentation) error {
+	resp, err := client.getRequestWithBearerAuth(token).
+		SetBody(realm).
+		Put(client.getAdminRealmURL(PString(realm.Realm)))
+
+	return checkForError(resp, err)
+}
+
 // DeleteRealm removes a realm
 func (client *gocloak) DeleteRealm(token string, realm string) error {
 	resp, err := client.getRequestWithBearerAuth(token).
diff --git a/gocloak.go b/gocloak.go
index 6c425f2..fade9e7 100644
--- a/gocloak.go
+++ b/gocloak.go
@@ -203,6 +203,8 @@ type GoCloak interface {
 	GetRealms(token string) ([]*RealmRepresentation, error)
 	// CreateRealm creates a realm
 	CreateRealm(token string, realm RealmRepresentation) (string, error)
+	// UpdateRealm updates a given realm
+	UpdateRealm(token string, realm RealmRepresentation) error
 	// DeleteRealm removes a realm
 	DeleteRealm(token string, realm string) error
 	// ClearRealmCache clears realm cache


Test patch:
diff --git a/client_test.go b/client_test.go
index 5642bfb..406ee07 100644
--- a/client_test.go
+++ b/client_test.go
@@ -1452,6 +1452,22 @@ func TestGocloak_CreateRealm(t *testing.T) {
 	defer tearDown()
 }
 
+func TestGocloak_UpdateRealm(t *testing.T) {
+	t.Parallel()
+	client := NewClientWithDebug(t)
+	token := GetAdminToken(t, client)
+
+	tearDown, realmID := CreateRealm(t, client)
+	defer tearDown()
+
+	realm, err := client.GetRealm(token.AccessToken, realmID)
+	assert.NoError(t, err, "GetRealm failed")
+
+	realm.Enabled = BoolP(false)
+	err = client.UpdateRealm(token.AccessToken, *realm)
+	assert.NoError(t, err, "UpdateRealm failed")
+}
+
 func TestGocloak_ClearRealmCache(t *testing.T) {
 	t.Parallel()
 	client := NewClientWithDebug(t)
Repository: Nerzal/gocloak
Pull request #199 (2020-08-07 16:56:05)

Adding GetGroupParams to GetUserGroups method


Patch:
diff --git a/README.md b/README.md
index 92a479d..d74c144 100644
--- a/README.md
+++ b/README.md
@@ -171,7 +171,7 @@ type GoCloak interface {
 	GetUserByID(ctx context.Context, accessToken, realm, userID string) (*User, error)
 	GetUserCount(ctx context.Context, accessToken, realm string, params GetUsersParams) (int, error)
 	GetUsers(ctx context.Context, accessToken, realm string, params GetUsersParams) ([]*User, error)
-	GetUserGroups(ctx context.Context, accessToken, realm, userID string) ([]*UserGroup, error)
+	GetUserGroups(ctx context.Context, accessToken, realm, userID string, params GetGroupsParams) ([]*UserGroup, error)
 	GetComponents(ctx context.Context, accessToken, realm string) ([]*Component, error)
 	GetGroups(ctx context.Context, accessToken, realm string, params GetGroupsParams) ([]*Group, error)
 	GetGroupsCount(ctx context.Context, token, realm string, params GetGroupsParams) (int, error)
diff --git a/client.go b/client.go
index 3840960..b8807a5 100644
--- a/client.go
+++ b/client.go
@@ -1645,12 +1645,18 @@ func (client *gocloak) GetUserCount(ctx context.Context, token string, realm str
 }
 
 // GetUserGroups get all groups for user
-func (client *gocloak) GetUserGroups(ctx context.Context, token, realm, userID string) ([]*UserGroup, error) {
+func (client *gocloak) GetUserGroups(ctx context.Context, token, realm, userID string, params GetGroupsParams) ([]*UserGroup, error) {
 	const errMessage = "could not get user groups"
 
 	var result []*UserGroup
+	queryParams, err := GetQueryParams(params)
+	if err != nil {
+		return nil, errors.Wrap(err, errMessage)
+	}
+
 	resp, err := client.getRequestWithBearerAuth(ctx, token).
 		SetResult(&result).
+		SetQueryParams(queryParams).
 		Get(client.getAdminRealmURL(realm, "users", userID, "groups"))
 
 	if err := checkForError(resp, err, errMessage); err != nil {
diff --git a/gocloak.go b/gocloak.go
index 0da5cc9..31eba30 100644
--- a/gocloak.go
+++ b/gocloak.go
@@ -247,7 +247,7 @@ type GoCloak interface {
 	// GetUsers gets all users of the given realm
 	GetUsers(ctx context.Context, accessToken, realm string, params GetUsersParams) ([]*User, error)
 	// GetUserGroups gets the groups of the given user
-	GetUserGroups(ctx context.Context, accessToken, realm, userID string) ([]*UserGroup, error)
+	GetUserGroups(ctx context.Context, accessToken, realm, userID string, params GetGroupsParams) ([]*UserGroup, error)
 	// GetUsersByRoleName returns all users have a given role
 	GetUsersByRoleName(ctx context.Context, token, realm, roleName string) ([]*User, error)
 	// GetUsersByClientRoleName returns all users have a given client role


Test patch:
diff --git a/client_test.go b/client_test.go
index 53c7fb3..6f69f8b 100644
--- a/client_test.go
+++ b/client_test.go
@@ -2336,7 +2336,8 @@ func TestGocloak_GetUserGroups(t *testing.T) {
 		context.Background(),
 		token.AccessToken,
 		cfg.GoCloak.Realm,
-		userID)
+		userID,
+		gocloak.GetGroupsParams{})
 	require.NoError(t, err)
 	require.NotEmpty(t, groups)
 	require.Equal(t, groupID, *groups[0].ID)
Repository: Nerzal/gocloak
Pull request #254 (2021-01-18 09:46:40)

added `first` & `max` to client query parameters to support pagination
added `first` & `max` to client query parameters to support pagination for the GetClients call.

Keycloak admin API supports pagination for fetching the clients
eg:-
```http://localhost:$PORT/auth/admin/realms/$REALM/clients?first=0&max=10"```




Patch:
diff --git a/models.go b/models.go
index c87ee40..9b06dd0 100644
--- a/models.go
+++ b/models.go
@@ -603,6 +603,8 @@ type ProtocolMapperRepresentation struct {
 type GetClientsParams struct {
 	ClientID     *string `json:"clientId,omitempty"`
 	ViewableOnly *bool   `json:"viewableOnly,string,omitempty"`
+	First        *int    `json:"first,string,omitempty"`
+	Max          *int    `json:"max,string,omitempty"`
 }
 
 // UserInfoAddress is representation of the address sub-filed of UserInfo


Test patch:
diff --git a/client_test.go b/client_test.go
index dd577da..41d8daf 100644
--- a/client_test.go
+++ b/client_test.go
@@ -5273,3 +5273,35 @@ func TestGocloak_TestSetFunctionalOptions(t *testing.T) {
 	cfg := GetConfig(t)
 	gocloak.NewClient(cfg.HostName, gocloak.SetAuthRealms("foo"), gocloak.SetAuthAdminRealms("bar"))
 }
+
+func TestGocloak_GetClientsWithPagination(t *testing.T) {
+	cfg := GetConfig(t)
+	client := NewClientWithDebug(t)
+	token := GetAdminToken(t, client)
+	clientID := GetRandomNameP("ClientID")
+
+	testClient := gocloak.Client{
+		ClientID: clientID,
+		BaseURL:  gocloak.StringP("http://example.com"),
+	}
+	t.Logf("Client ID: %s", *clientID)
+
+	// Creating a client
+	tearDown, createdClientID := CreateClient(t, client, &testClient)
+	defer tearDown()
+	t.Log(createdClientID)
+	first := 0
+	max := 1
+	// Looking for a created client
+	clients, err := client.GetClients(
+		context.Background(),
+		token.AccessToken,
+		cfg.GoCloak.Realm,
+		gocloak.GetClientsParams{
+			First: &first,
+			Max:   &max,
+		},
+	)
+	require.NoError(t, err)
+	require.Equal(t, max, len(clients))
+}
Repository: Nerzal/gocloak
Pull request #319 (2021-11-10 14:54:33)

defaults for P* utils
Default values for bool, ints and floats if provided pointer is nil in `P*` util functions


Patch:
diff --git a/utils.go b/utils.go
index 4a0216b..e9421ab 100644
--- a/utils.go
+++ b/utils.go
@@ -30,6 +30,9 @@ func BoolP(value bool) *bool {
 
 // PBool returns a boolean value from a pointer
 func PBool(value *bool) bool {
+	if value == nil {
+		return false
+	}
 	return *value
 }
 
@@ -50,16 +53,25 @@ func Int64P(value int64) *int64 {
 
 // PInt returns an integer value from a pointer
 func PInt(value *int) int {
+	if value == nil {
+		return 0
+	}
 	return *value
 }
 
 // PInt32 returns an int32 value from a pointer
 func PInt32(value *int32) int32 {
+	if value == nil {
+		return 0
+	}
 	return *value
 }
 
 // PInt64 returns an int64 value from a pointer
 func PInt64(value *int64) int64 {
+	if value == nil {
+		return 0
+	}
 	return *value
 }
 
@@ -75,11 +87,17 @@ func Float64P(value float64) *float64 {
 
 // PFloat32 returns an flaot32 value from a pointer
 func PFloat32(value *float32) float32 {
+	if value == nil {
+		return 0
+	}
 	return *value
 }
 
 // PFloat64 returns an flaot64 value from a pointer
 func PFloat64(value *float64) float64 {
+	if value == nil {
+		return 0
+	}
 	return *value
 }
 


Test patch:
diff --git a/utils_test.go b/utils_test.go
index 8a80f07..9725e68 100644
--- a/utils_test.go
+++ b/utils_test.go
@@ -42,6 +42,9 @@ func TestPBool(t *testing.T) {
 	p = false
 	v = gocloak.PBool(&p)
 	assert.False(t, v)
+
+	v = gocloak.PBool(nil)
+	assert.False(t, v)
 }
 
 func TestIntP(t *testing.T) {
@@ -66,6 +69,10 @@ func TestPInt(t *testing.T) {
 	v := gocloak.PInt(&p)
 	assert.Equal(t, p, v)
 	assert.IsType(t, p, v)
+
+	v = gocloak.PInt(nil)
+	assert.Equal(t, int(0), v)
+	assert.IsType(t, int(0), v)
 }
 
 func TestPInt32(t *testing.T) {
@@ -73,6 +80,10 @@ func TestPInt32(t *testing.T) {
 	v := gocloak.PInt32(&p)
 	assert.Equal(t, p, v)
 	assert.IsType(t, p, v)
+
+	v = gocloak.PInt32(nil)
+	assert.Equal(t, int32(0), v)
+	assert.IsType(t, int32(0), v)
 }
 
 func TestPInt64(t *testing.T) {
@@ -80,6 +91,10 @@ func TestPInt64(t *testing.T) {
 	v := gocloak.PInt64(&p)
 	assert.Equal(t, p, v)
 	assert.IsType(t, p, v)
+
+	v = gocloak.PInt64(nil)
+	assert.Equal(t, int64(0), v)
+	assert.IsType(t, int64(0), v)
 }
 
 func TestFloat32P(t *testing.T) {
@@ -98,12 +113,20 @@ func TestPFloat32(t *testing.T) {
 	v := gocloak.PFloat32(&p)
 	assert.Equal(t, p, v)
 	assert.IsType(t, p, v)
+
+	v = gocloak.PFloat32(nil)
+	assert.Equal(t, float32(0), v)
+	assert.IsType(t, float32(0), v)
 }
 func TestPFloat64(t *testing.T) {
 	p := 42.42
 	v := gocloak.PFloat64(&p)
 	assert.Equal(t, p, v)
 	assert.IsType(t, p, v)
+
+	v = gocloak.PFloat64(nil)
+	assert.Equal(t, float64(0), v)
+	assert.IsType(t, float64(0), v)
 }
 func TestNilOrEmptyArray(t *testing.T) {
 	a := gocloak.NilOrEmptyArray(&[]string{"c", "d"})
Repository: Nerzal/gocloak
Pull request #380 (2022-10-19 12:33:11)

upgrade gocloak version
Thanks for your contribution!
Hi, if there is an issue, that your PR adresses, please link it! 



Patch:
diff --git a/README.md b/README.md
index 7df6e9a..b1d99fb 100644
--- a/README.md
+++ b/README.md
@@ -32,13 +32,13 @@ For release notes please consult the specific releases [here](https://github.com
 ### Installation
 
 ```shell
-go get github.com/Nerzal/gocloak/v11
+go get github.com/Nerzal/gocloak/v12
 ```
 
 ### Importing
 
 ```go
- import "github.com/Nerzal/gocloak/v11"
+ import "github.com/Nerzal/gocloak/v12"
 ```
 
 ### Create New User
diff --git a/client.go b/client.go
index d83a8ec..69d24b6 100644
--- a/client.go
+++ b/client.go
@@ -18,7 +18,7 @@ import (
 	"github.com/pkg/errors"
 	"github.com/segmentio/ksuid"
 
-	"github.com/Nerzal/gocloak/v11/pkg/jwx"
+	"github.com/Nerzal/gocloak/v12/pkg/jwx"
 )
 
 // GoCloak provides functionalities to talk to Keycloak.
diff --git a/go.mod b/go.mod
index db07a20..3359f49 100644
--- a/go.mod
+++ b/go.mod
@@ -1,4 +1,4 @@
-module github.com/Nerzal/gocloak/v11
+module github.com/Nerzal/gocloak/v12
 
 go 1.18
 


Test patch:
diff --git a/client_benchmark_test.go b/client_benchmark_test.go
index e097fbd..cbd3eba 100644
--- a/client_benchmark_test.go
+++ b/client_benchmark_test.go
@@ -4,7 +4,7 @@ import (
 	"context"
 	"testing"
 
-	"github.com/Nerzal/gocloak/v11"
+	"github.com/Nerzal/gocloak/v12"
 
 	"github.com/stretchr/testify/assert"
 )
diff --git a/client_test.go b/client_test.go
index 69dbab3..1312cd8 100644
--- a/client_test.go
+++ b/client_test.go
@@ -26,7 +26,7 @@ import (
 	"github.com/stretchr/testify/require"
 	"golang.org/x/crypto/pkcs12"
 
-	"github.com/Nerzal/gocloak/v11"
+	"github.com/Nerzal/gocloak/v12"
 )
 
 type configAdmin struct {
diff --git a/model_test.go b/model_test.go
index 4c8a76b..ce342ba 100644
--- a/model_test.go
+++ b/model_test.go
@@ -5,7 +5,7 @@ import (
 	"errors"
 	"testing"
 
-	"github.com/Nerzal/gocloak/v11"
+	"github.com/Nerzal/gocloak/v12"
 
 	"github.com/stretchr/testify/assert"
 )
diff --git a/utils_test.go b/utils_test.go
index 92cfa21..0e2d5c7 100644
--- a/utils_test.go
+++ b/utils_test.go
@@ -5,7 +5,7 @@ import (
 
 	"github.com/stretchr/testify/assert"
 
-	"github.com/Nerzal/gocloak/v11"
+	"github.com/Nerzal/gocloak/v12"
 )
 
 func TestStringP(t *testing.T) {
Repository: NetApp/harvest
Pull request #261 (2021-06-27 20:08:12)

Better validation


Patch:
diff --git a/cmd/tools/doctor/doctor.go b/cmd/tools/doctor/doctor.go
index 718d8232..32132890 100644
--- a/cmd/tools/doctor/doctor.go
+++ b/cmd/tools/doctor/doctor.go
@@ -87,7 +87,7 @@ func checkExporterTypes(config conf.HarvestConfig) validation {
 			continue
 		}
 		switch *exporter.Type {
-		case "Prometheus", "InfluxDB":
+		case "Prometheus", "InfluxDB", "PrometheusConsul":
 			break
 		default:
 			invalidTypes[name] = *exporter.Type
diff --git a/harvest.cue b/harvest.cue
index 93c6cf64..6506db47 100644
--- a/harvest.cue
+++ b/harvest.cue
@@ -7,6 +7,7 @@ Exporters: [Name=_]: #Prom | #Influx | #PromConsul
 	exporter:    "Prometheus"
 	port?:       int
 	port_range?: string
+	allow_addrs_regex?: [...string]
 }
 
 #PromConsul: {


Test patch:
diff --git a/cmd/tools/doctor/testdata/testConfig.yml b/cmd/tools/doctor/testdata/testConfig.yml
index f95e5b93..bb9e1583 100644
--- a/cmd/tools/doctor/testdata/testConfig.yml
+++ b/cmd/tools/doctor/testdata/testConfig.yml
@@ -13,15 +13,17 @@ Exporters:
     port: 12990
     allow_addrs_regex:
       - ^192.168.0.\d+$
-  pluto: # name of your exporter, can be any valid yaml string
+  prometheus-dup:
     exporter: Prometheus
-    port: 12990              # ignored since this exporter contains a consul block
-    consul: # consul block added because we want service discovery
-      host: 1.2.3.4          # ip or hostname of Consul cluster
-      service_name: monitor  # all pollers exporting to pluto will be registered with the service name of 'monitor'
-      tags:
-        - netapp             # each of the pollers exporting to pluto will be tagged with two tags: 'netapp' and 'harvest'
-        - harvest
+    addr: 0.0.0.0
+    port: 12990
+  pluto: # name of your exporter, can be any valid yaml string
+    exporter: PrometheusConsul
+    addr: 1.2.3.4          # ip or hostname of Consul cluster
+    service_name: monitor  # all pollers exporting to pluto will be registered with the service name of 'monitor'
+    tags:
+      - netapp             # each of the pollers exporting to pluto will be tagged with two tags: 'netapp' and 'harvest'
+      - harvest
   influxy:
     exporter: InfluxDB
     addr: localhost
Repository: NetApp/harvest
Pull request #372 (2021-08-02 15:26:58)

chore: relax commitlint rules


Patch:
diff --git a/cmd/poller/collector/helpers.go b/cmd/poller/collector/helpers.go
index 3e80a6bf..90d1d610 100644
--- a/cmd/poller/collector/helpers.go
+++ b/cmd/poller/collector/helpers.go
@@ -115,9 +115,13 @@ func (c *AbstractCollector) ImportSubTemplate(model, filename string, ver [3]int
 	return tree.Import("yaml", subTemplateFp)
 }
 
-//getClosestIndex input versions should be sorted
-// returns -1 if not match else returns equals or closest match to the left
+//getClosestIndex returns the closest left match to the sorted list of input versions
+// returns -1 when the versions list is empty
+// returns equal or closest match to the left
 func getClosestIndex(versions []*version.Version, version *version.Version) int {
+	if len(versions) == 0 {
+		return -1
+	}
 	var l = 0
 	var r = len(versions) - 1
 	for l <= r {
@@ -131,6 +135,9 @@ func getClosestIndex(versions []*version.Version, version *version.Version) int
 			return m
 		}
 	}
+	if l == 0 {
+		return 0
+	}
 	return l - 1
 }
 
diff --git a/commitlint.config.js b/commitlint.config.js
index 90d8b721..b72bbbe7 100644
--- a/commitlint.config.js
+++ b/commitlint.config.js
@@ -1,7 +1,10 @@
 module.exports = {
     extends: ['@commitlint/config-conventional'],
     rules: {
+        // Disable the following ones
         'body-max-line-length': [0, 'always'],
+        'subject-case': [0, 'always'],
+        'footer-max-line-length': [0, 'always'],
         'scope-enum': [
             2,
             'always',


Test patch:
diff --git a/cmd/poller/collector/helpers_test.go b/cmd/poller/collector/helpers_test.go
index 9a22b58c..5b8ee593 100644
--- a/cmd/poller/collector/helpers_test.go
+++ b/cmd/poller/collector/helpers_test.go
@@ -33,7 +33,7 @@ func Test_getClosestIndex(t *testing.T) {
 
 	tests := []test{
 		{"MatchCase", args{setupVersions([]string{"9.8.0", "9.8.1", "9.9.0", "10.10.10"}), buildVersion("9.8.1")}, 1},
-		{"NonMatchCase", args{setupVersions([]string{"9.8.0", "9.8.1", "9.9.0", "10.10.10"}), buildVersion("9.7.1")}, -1},
+		{"MatchFirstYolo", args{setupVersions([]string{"9.8.0", "9.8.1", "9.9.0", "10.10.10"}), buildVersion("9.7.1")}, 0},
 		{"ClosestMatchCase", args{setupVersions([]string{"9.8.0", "9.8.1", "9.9.0", "10.10.10"}), buildVersion("9.9.2")}, 2},
 		{"EmptyCase", args{setupVersions([]string{}), buildVersion("9.8.1")}, -1},
 	}