Repository: amp-labs/connectors
Pull request #120 (2024-03-21 18:25:17)

fix silent bug
There was if statement that will never be executed because the condition is always false. It did not affect anything and didn't do any harm, but need to be cleaned up. 


Patch:
diff --git a/.github/PULL_REQUEST_TEMPLATE/new_connector.md b/.github/PULL_REQUEST_TEMPLATE/new_connector.md
new file mode 100644
index 00000000..f93279a0
--- /dev/null
+++ b/.github/PULL_REQUEST_TEMPLATE/new_connector.md
@@ -0,0 +1,23 @@
+## Checklist
+- [ ] Ran Linter
+- [ ] Catalog tests passing
+
+## Catalog variables
+<Does the provider's info include any template variables such as `{{workspace}}`?>
+* {{workspace}}
+
+## Notes
+
+## Testing
+### GET
+URL: <localhost:4444/v2/some-api-call>
+Postman screenshot (must show the request URL, the response status code & body clearly)
+
+### POST
+URL: <localhost:4444/v2/some-api-call>
+Postman screenshot (must show the request URL, the response status code & body clearly)
+
+<Please add the same information for all other methods available - PUT, PATCH, DELETE, etc>
+
+## Pagination
+Please add screenshots that show successful pagination using the connector. 
diff --git a/Makefile b/Makefile
index db707789..1ce0c75d 100644
--- a/Makefile
+++ b/Makefile
@@ -26,3 +26,10 @@ format: fix
 .PHONY: test
 test:
 	go test -v ./...
+
+# Creates PR URLs for each template
+# Click on one of them or manually add ?template=<file.md> to the URL if you are creating a PR via the Github website
+# Templates: Under github/PULL_REQUEST_TEMPLATE directory you can add more templates
+.PHONY: pr-template
+pr-template:
+	. ./scripts/bash/pr_options.sh; pr_template
diff --git a/providers/catalog.go b/providers/catalog.go
index 320f5e68..0f525e86 100644
--- a/providers/catalog.go
+++ b/providers/catalog.go
@@ -12,6 +12,7 @@ const (
 	Outreach          Provider = "outreach"
 	Pipedrive         Provider = "pipedrive"
 	Copper            Provider = "copper"
+	ZohoCRM           Provider = "zohoCRM"
 	Sellsy            Provider = "sellsy"
 	Attio             Provider = "attio"
 	Close             Provider = "close"
@@ -177,6 +178,25 @@ var catalog = CatalogType{ // nolint:gochecknoglobals
 		},
 	},
 
+	// ZohoCRM configuration
+	ZohoCRM: {
+		AuthType: Oauth2,
+		BaseURL:  "https://www.zohoapis.com",
+		OauthOpts: OauthOpts{
+			AuthURL:                   "https://accounts.zoho.com/oauth/v2/auth",
+			TokenURL:                  "https://accounts.zoho.com/oauth/v2/token",
+			ExplicitScopesRequired:    true,
+			ExplicitWorkspaceRequired: false,
+		},
+		Support: Support{
+			BulkWrite: false,
+			Proxy:     false,
+			Read:      false,
+			Subscribe: false,
+			Write:     false,
+		},
+	},
+
 	// Sellsy configuration
 	Sellsy: {
 		AuthType: Oauth2,
diff --git a/providers/utils.go b/providers/utils.go
index 7090063d..7a2f9ba4 100644
--- a/providers/utils.go
+++ b/providers/utils.go
@@ -4,9 +4,9 @@ import (
 	"bytes"
 	"encoding/gob"
 	"errors"
-	"html/template"
 	"reflect"
 	"strings"
+	"text/template" // nosemgrep: go.lang.security.audit.xss.import-text-template.import-text-template
 
 	"github.com/go-playground/validator"
 )
diff --git a/salesforce/bulkwrite.go b/salesforce/bulkwrite.go
index 6ac5eadb..d02c8d09 100644
--- a/salesforce/bulkwrite.go
+++ b/salesforce/bulkwrite.go
@@ -374,10 +374,6 @@ func (c *Connector) getPartialFailureDetails(ctx context.Context, jobInfo *GetJo
 			failureMap = failInfo.FailedCreates
 		}
 
-		if failureMap == nil {
-			failureMap[errMsg] = []string{}
-		}
-
 		failureMap[errMsg] = append(failureMap[errMsg], externalId)
 	}
 
diff --git a/scripts/bash/pr_options.sh b/scripts/bash/pr_options.sh
new file mode 100755
index 00000000..abb5e0d7
--- /dev/null
+++ b/scripts/bash/pr_options.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+#
+# Referenced from Makefile
+#
+pr_template() {
+  SOURCE_BRANCH=$(git rev-parse --abbrev-ref HEAD); # current branch from which PR is created
+  TARGET_BRANCH="main"
+
+  USER_NAME=$(git config user.name)
+  REPO_NAME=$(basename -s .git `git config --get remote.origin.url`) # your repo name, can be fork name
+
+  echo "PR templates"
+  # For every template markdown file construct a URL
+  for FILE_NAME in ".github/PULL_REQUEST_TEMPLATE"/*
+  do
+    TEMPLATE=$(basename "$FILE_NAME")
+    # Construct URL for comparing branch against main origin
+    PR_URL="https://github.com/amp-labs/connectors/compare/${TARGET_BRANCH}...${USER_NAME}:${REPO_NAME}:${SOURCE_BRANCH}?template=${TEMPLATE}"
+
+    # Display 2 columns with ident, where first column is min 40 chars
+    printf "\t %-40s %--s\n" "${TEMPLATE}:" "$PR_URL"
+  done
+}


Test patch:
diff --git a/providers/catalog_test.go b/providers/catalog_test.go
index 44fe8bca..b626369f 100644
--- a/providers/catalog_test.go
+++ b/providers/catalog_test.go
@@ -203,6 +203,29 @@ var testCases = []struct { // nolint
 		expectedErr: nil,
 	},
 
+	{
+		provider:    ZohoCRM,
+		description: "Valid ZohoCRM provider config with no substitutions",
+		expected: &ProviderInfo{
+			Support: Support{
+				Read:      false,
+				Write:     false,
+				BulkWrite: false,
+				Subscribe: false,
+				Proxy:     false,
+			},
+			AuthType: Oauth2,
+			OauthOpts: OauthOpts{
+				AuthURL:                   "https://accounts.zoho.com/oauth/v2/auth",
+				TokenURL:                  "https://accounts.zoho.com/oauth/v2/token",
+				ExplicitScopesRequired:    true,
+				ExplicitWorkspaceRequired: false,
+			},
+			BaseURL: "https://www.zohoapis.com",
+		},
+		expectedErr: nil,
+	},
+
 	{
 		provider: Sellsy,
 		expected: &ProviderInfo{