Skip to content

Commit

Permalink
Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
koltyakov committed Mar 26, 2023
1 parent 39bc5b4 commit 485c5cf
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 22 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ Provision and seed some sample data. [See more](./cmd/seed/README.md). Which sat
```bash
# .env or env vars export
# See more details in https://go.spflow.com/auth/strategies
SP_AUTH_STRATEGY=ondemand
SP_SITE_URL=https://contoso.sharepoint.com/sites/site
```

Expand All @@ -298,7 +297,7 @@ spec:
destinations: ["sqlite"]
spec:
auth:
strategy: "${SP_AUTH_STRATEGY}"
strategy: "ondemand"
creds:
siteUrl: ${SP_SITE_URL}
# align creds with the used strategy
Expand Down
27 changes: 12 additions & 15 deletions cmd/seed/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,24 @@ Creates dummy lists and feeds random data into them.
- SharePoint Online Addn-Only auth credentials
- Go 1.19+

## Configure connection

- Create `./config/private.json` file
- Populate with credentials and strategy name, e.g.:

```json
{
"strategy": "addin",
"siteUrl": "https://contoso.sharepoint.com/sites/cloudquery",
"clientId": "e1990a0a-dcf7-4b71-8b96-2a53c7e323e0",
"clientSecret": "1wlWvB7V...zG1AqSP8="
}
```

## Run provisioning

On a Mac/Linux machine, run the following command:

```bash
SP_SITE_URL="https://contoso.sharepoint.com/sites/site" go run ./cmd/seed/...
```

On a Windows machine, run the following command:

```powershell
$env:SP_SITE_URL="https://contoso.sharepoint.com/sites/site"
go run ./cmd/seed/...
```

It sould create lists and feed bunch of random data.
> If you are using On-Premise SharePoint with NTLM authentication, modify `./cmd/demo/main.go` to use `ntlm` auth provider.
It should create lists and feed bunch of random data.

The process takes time due to the number of seeding items. Amend `./cmd/demo/main.go` to reduce or increase the number of items.

Expand Down
17 changes: 13 additions & 4 deletions cmd/seed/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,27 @@ package main
import (
"fmt"
"log"
"os"

"github.com/koltyakov/gosip"
"github.com/koltyakov/gosip-sandbox/strategies/ondemand"
"github.com/koltyakov/gosip/api"
"github.com/koltyakov/gosip/auth"
// "github.com/koltyakov/gosip/auth"
)

func main() {
authCnfg, err := auth.NewAuthFromFile("./config/private.json")
if err != nil {
log.Fatalf("failed to create auth config: %s", err)
authCnfg := &ondemand.AuthCnfg{
SiteURL: os.Getenv("SP_SITE_URL"),
}

// `ondemand` won't work for On-Premise with NTLM auth
// see more https://go.spflow.com/auth/strategies/ntlm
// Uncomment the the below lines to use NTLM auth
// authCnfg, err := auth.NewAuthFromFile("./config/private.json")
// if err != nil {
// log.Fatalf("failed to create auth config: %s", err)
// }

client := &gosip.SPClient{AuthCnfg: authCnfg}
sp := api.NewSP(client)

Expand Down
2 changes: 1 addition & 1 deletion resources/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/koltyakov/gosip"
ntlm2 "github.com/koltyakov/gosip-sandbox/strategies/ntlm"
ondemand "github.com/koltyakov/gosip-sandbox/strategies/ondemand"
"github.com/koltyakov/gosip-sandbox/strategies/ondemand"
"github.com/koltyakov/gosip/api"
"github.com/koltyakov/gosip/auth"
)
Expand Down

0 comments on commit 485c5cf

Please sign in to comment.