Skip to content

Commit 2ada630

Browse files
Add registry docs and automation (#101)
* Add registry docs and automation * Re-word data sources --> functions * Skip upstream support section * lint
1 parent 1c6ac99 commit 2ada630

File tree

4 files changed

+159
-43
lines changed

4 files changed

+159
-43
lines changed

.ci-mgmt.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ actions:
2323
run: |
2424
cd provider && go test -v -json -count=1 -cover -timeout 2h -tags=${{ matrix.language }} -parallel 4 . 2>&1 | tee /tmp/gotest.log | gotestfmt
2525
pulumiConvert: 1
26+
registryDocs: true

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ development: install_plugins provider build_sdks install_sdks
2929

3030
build: install_plugins provider build_sdks install_sdks
3131

32-
build_sdks: build_nodejs build_python build_dotnet build_go build_java
32+
build_sdks: build_nodejs build_python build_dotnet build_go build_java build_registry_docs
3333

3434
install_go_sdk:
3535

@@ -96,6 +96,10 @@ build_python: upstream
9696
cd ./bin && \
9797
../venv/bin/python -m build .
9898

99+
# Run the bridge's registry-docs command to generated the content of the installation docs/ folder at provider repo root
100+
build_registry_docs:
101+
$(WORKING_DIR)/bin/$(TFGEN) registry-docs --out $(WORKING_DIR)/docs
102+
99103
clean:
100104
rm -rf sdk/{dotnet,nodejs,go,python}
101105

docs/_index.md

Lines changed: 123 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,151 @@
11
---
2-
title: Strata Cloud Manager (Palo Alto SCM)
3-
meta_desc: Provides an overview of the Strata Cloud Manager Provider for Pulumi.
4-
layout: overview
2+
title: Scm Provider
3+
meta_desc: Provides an overview on how to configure the Pulumi Scm provider.
4+
layout: package
55
---
6+
## Installation
67

7-
The Strata Cloud Manager Resource Provider lets you manage [Strata Cloud Manager](https://docs.paloaltonetworks.com/strata-cloud-manager) resources. This is a bridged provider from the terraform SCM provider, located at [github.com/PaloAltoNetworks/terraform-provider-scm](https://github.com/PaloAltoNetworks/terraform-provider-scm).
8+
The scm provider is available as a package in all Pulumi languages:
89

9-
## Example
10+
* JavaScript/TypeScript: [`@pulumi/scm`](https://www.npmjs.com/package/@pulumi/scm)
11+
* Python: [`pulumi-scm`](https://pypi.org/project/pulumi-scm/)
12+
* Go: [`github.com/pulumi/pulumi-scm/sdk/go/scm`](https://github.com/pulumi/pulumi-scm)
13+
* .NET: [`Pulumi.Scm`](https://www.nuget.org/packages/Pulumi.Scm)
14+
* Java: [`com.pulumi/scm`](https://central.sonatype.com/artifact/com.pulumi/scm)
15+
## Overview
1016

11-
{{< chooser language "typescript,python,go,csharp" >}}
12-
{{% choosable language typescript %}}
17+
The `scm` provider provides resources and functions to manage and query Strata Cloud Manager.
18+
19+
This provider covers the following aspects of Strata Cloud Manager:
20+
* Unified Networking Security
21+
## Example Usage
1322

14-
```typescript
15-
import * as pulumi from "@pulumi/pulumi";
16-
import * as scm from "@pulumi/scm";
23+
{{< chooser language "typescript,python,go,csharp,java,yaml" >}}
24+
{{% choosable language typescript %}}
25+
```yaml
26+
# Pulumi.yaml provider configuration file
27+
name: configuration-example
28+
runtime: nodejs
29+
config:
30+
scm:clientId:
31+
value: your-id@12345
32+
scm:clientSecret:
33+
value: secret
34+
scm:host:
35+
value: api.strata.paloaltonetworks.com
36+
scm:scope:
37+
value: tsg_id:12345
1738

18-
const example = new scm.Service("example", {});
1939
```
2040

2141
{{% /choosable %}}
2242
{{% choosable language python %}}
43+
```yaml
44+
# Pulumi.yaml provider configuration file
45+
name: configuration-example
46+
runtime: python
47+
config:
48+
scm:clientId:
49+
value: your-id@12345
50+
scm:clientSecret:
51+
value: secret
52+
scm:host:
53+
value: api.strata.paloaltonetworks.com
54+
scm:scope:
55+
value: tsg_id:12345
2356

24-
```python
25-
import pulumi
26-
import pulumi_scm as scm
57+
```
58+
59+
{{% /choosable %}}
60+
{{% choosable language csharp %}}
61+
```yaml
62+
# Pulumi.yaml provider configuration file
63+
name: configuration-example
64+
runtime: dotnet
65+
config:
66+
scm:clientId:
67+
value: your-id@12345
68+
scm:clientSecret:
69+
value: secret
70+
scm:host:
71+
value: api.strata.paloaltonetworks.com
72+
scm:scope:
73+
value: tsg_id:12345
2774

28-
example = scm.Service("example")
2975
```
3076

3177
{{% /choosable %}}
3278
{{% choosable language go %}}
79+
```yaml
80+
# Pulumi.yaml provider configuration file
81+
name: configuration-example
82+
runtime: go
83+
config:
84+
scm:clientId:
85+
value: your-id@12345
86+
scm:clientSecret:
87+
value: secret
88+
scm:host:
89+
value: api.strata.paloaltonetworks.com
90+
scm:scope:
91+
value: tsg_id:12345
3392

34-
```go
35-
package main
36-
37-
import (
38-
"github.com/pulumi/pulumi-scm/sdk/go/scm"
39-
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
93+
```
4094

41-
)
95+
{{% /choosable %}}
96+
{{% choosable language yaml %}}
97+
```yaml
98+
# Pulumi.yaml provider configuration file
99+
name: configuration-example
100+
runtime: yaml
101+
config:
102+
scm:clientId:
103+
value: your-id@12345
104+
scm:clientSecret:
105+
value: secret
106+
scm:host:
107+
value: api.strata.paloaltonetworks.com
108+
scm:scope:
109+
value: tsg_id:12345
42110

43-
func main() {
44-
pulumi.Run(func(ctx *pulumi.Context) error {
45-
_, err := scm.NewService(ctx, "example", nil)
46-
if err != nil {
47-
return err
48-
}
49-
return nil
50-
})
51-
}
52111
```
53112

54113
{{% /choosable %}}
55-
{{% choosable language csharp %}}
56-
57-
```csharp
58-
using System.Collections.Generic;
59-
using Pulumi;
60-
using Scm = Pulumi.Scm;
114+
{{% choosable language java %}}
115+
```yaml
116+
# Pulumi.yaml provider configuration file
117+
name: configuration-example
118+
runtime: java
119+
config:
120+
scm:clientId:
121+
value: your-id@12345
122+
scm:clientSecret:
123+
value: secret
124+
scm:host:
125+
value: api.strata.paloaltonetworks.com
126+
scm:scope:
127+
value: tsg_id:12345
61128

62-
return await Deployment.RunAsync(() =>
63-
{
64-
var example = new Scm.Service("example");
65-
});
66129
```
67130

68131
{{% /choosable %}}
69-
70132
{{< /chooser >}}
133+
## Provider Parameter Priority
134+
135+
There are multiple ways to specify the provider's parameters. If overlapping values are configured for the provider, then this is the resolution order:
136+
137+
1. Statically configured in the provider configuration
138+
2. Environment variable (where applicable)
139+
3. Taken from the JSON config file
140+
## Configuration Reference
141+
142+
- `authFile` (String) The file path to the JSON file with auth creds for SCM.
143+
- `authUrl` (String) The URL to send auth credentials to which will return a JWT. Default: `https://auth.apps.paloaltonetworks.com/auth/v1/oauth2/access_token`. Environment variable: `SCM_AUTH_URL`. JSON config file variable: `authUrl`.
144+
- `clientId` (String) The client ID for the connection. Environment variable: `SCM_CLIENT_ID`. JSON config file variable: `clientId`.
145+
- `clientSecret` (String, Sensitive) The client secret for the connection. Environment variable: `SCM_CLIENT_SECRET`. JSON config file variable: `clientSecret`.
146+
- `headers` (Map of String) Custom HTTP headers to be sent with all API commands. Environment variable: `SCM_HEADERS`. JSON config file variable: `headers`.
147+
- `host` (String) The hostname of Strata Cloud Manager API. Default: `api.sase.paloaltonetworks.com`. Environment variable: `SCM_HOST`. JSON config file variable: `host`.
148+
- `logging` (String) The logging level of the provider and the underlying communication. Default: `quiet`. Environment variable: `SCM_LOGGING`. JSON config file variable: `logging`.
149+
- `port` (Number) The port number to use for API commands, if non-standard for the given protocol. Environment variable: `SCM_PORT`. JSON config file variable: `port`.
150+
- `protocol` (String) The protocol to use for SCM. This should be 'http' or 'https'. Default: `https`. Environment variable: `SCM_PROTOCOL`. JSON config file variable: `protocol`.
151+
- `scope` (String) The client scope. Environment variable: `SCM_SCOPE`. JSON config file variable: `scope`.

provider/resources.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package provider
1616

1717
import (
18+
"bytes"
1819
"fmt"
1920
"path/filepath"
2021

@@ -26,6 +27,7 @@ import (
2627
pf "github.com/pulumi/pulumi-terraform-bridge/pf/tfbridge"
2728
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
2829
tfbridgetokens "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/tokens"
30+
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen"
2931

3032
"github.com/pulumi/pulumi-scm/provider/pkg/version"
3133
)
@@ -77,6 +79,7 @@ func Provider() tfbridge.ProviderInfo {
7779
MetadataInfo: tfbridge.NewProviderMetadata(bridgeMetadata),
7880
TFProviderVersion: "0.2.1",
7981
Version: version.Version,
82+
DocRules: &tfbridge.DocRuleInfo{EditRules: editRules},
8083
Config: map[string]*tfbridge.SchemaInfo{},
8184
Resources: map[string]*tfbridge.ResourceInfo{},
8285
DataSources: map[string]*tfbridge.DataSourceInfo{},
@@ -132,3 +135,30 @@ func Provider() tfbridge.ProviderInfo {
132135

133136
return prov
134137
}
138+
139+
func editRules(defaults []tfbridge.DocsEdit) []tfbridge.DocsEdit {
140+
return append(
141+
defaults,
142+
// Fix up the example code for the converter to work
143+
tfbridge.DocsEdit{
144+
Path: "index.md",
145+
Edit: func(_ string, content []byte) ([]byte, error) {
146+
b := bytes.ReplaceAll(
147+
content,
148+
[]byte("paloaltonetworks/terraform-provider-scm"),
149+
[]byte("paloaltonetworks/scm"),
150+
)
151+
return b, nil
152+
},
153+
},
154+
// Skip "Support" section, which concerns the upstream support
155+
tfbridge.DocsEdit{
156+
Path: "index.md",
157+
Edit: func(_ string, content []byte) ([]byte, error) {
158+
return tfgen.SkipSectionByHeaderContent(content, func(headerText string) bool {
159+
return headerText == "Support"
160+
})
161+
},
162+
},
163+
)
164+
}

0 commit comments

Comments
 (0)