Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable lint #84

Merged
merged 2 commits into from
Jan 4, 2024
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
2 changes: 0 additions & 2 deletions .ci-mgmt.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
provider: http
major-version: 0
lint: false
providerDefaultBranch: main
makeTemplate: bridged
publishRegistry: false
env:
HTTP_TOKEN: ${{ secrets.HTTP_TOKEN }}
team: ecosystem
4 changes: 4 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ jobs:
s3FullURI="s3://${{ secrets.S3_COVERAGE_BUCKET_NAME }}/summaries/${summaryName}"

aws s3 cp "${{ env.COVERAGE_OUTPUT_DIR }}/summary.json" "${s3FullURI}" --acl bucket-owner-full-control
lint:
name: lint
uses: ./.github/workflows/lint.yml
secrets: inherit
license_check:
name: License Check
uses: ./.github/workflows/license.yml
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ jobs:
- dotnet
- go
- java
lint:
name: lint
uses: ./.github/workflows/lint.yml
secrets: inherit
license_check:
name: License Check
uses: ./.github/workflows/license.yml
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ jobs:
- dotnet
- go
- java
lint:
name: lint
uses: ./.github/workflows/lint.yml
secrets: inherit
license_check:
name: License Check
uses: ./.github/workflows/license.yml
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/run-acceptance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ jobs:
issue-number: ${{ github.event.client_payload.github.payload.issue.number }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
token: ${{ secrets.PULUMI_BOT_TOKEN }}
lint:
if: github.event_name == 'repository_dispatch' ||
github.event.pull_request.head.repo.full_name == github.repository
name: lint
uses: ./.github/workflows/lint.yml
secrets: inherit
prerequisites:
if: github.event_name == 'repository_dispatch' ||
github.event.pull_request.head.repo.full_name == github.repository
Expand Down Expand Up @@ -264,6 +270,7 @@ jobs:
needs:
- test
- license_check
- lint
runs-on: ubuntu-latest
steps:
- name: Workflow is not a success
Expand Down
1 change: 1 addition & 0 deletions provider/cmd/pulumi-resource-http/bridge-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
}
}
},
"auto-settings": {},
"renames": {
"functions": {
"http:index/getHttp:getHttp": "http"
Expand Down
70 changes: 6 additions & 64 deletions provider/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,11 @@ package provider

import (
_ "embed" // Embed bridge metadata
"fmt"
"os"
"path"

"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/x"
shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
"github.com/pulumi/pulumi/sdk/v3/go/common/resource"
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/tokens"

"github.com/pulumi/pulumi-http/provider/pkg/version"
)
Expand All @@ -36,32 +32,6 @@ const providerName = "http"

var pkgVersion = version.Version

// TODO: preConfigureCallback validates configuration to provide actionable errors. This is
// generally needed when the upstream provider does not provide high quality error messages.
func preConfigureCallback(vars resource.PropertyMap, c shim.ResourceConfig) error {
// stringValue := func(vars resource.PropertyMap, prop resource.PropertyKey, envs []string) (string, error) {
// val, ok := vars[prop]
// if ok && val.IsString() {
// return val.StringValue(), nil
// }
// for _, env := range envs {
// val, ok := os.LookupEnv(env)
// if ok {
// return val, nil
// }
// }
// return "", fmt.Errorf("provider configuration %s:%s and env vars %v not defined", providerName, prop, envs)
// }

// _, err := stringValue(vars, "token", []string{"HTTP_TOKEN"})

// if err != nil {
// return fmt.Errorf("failed to configure API token: %w", err)
// }

return nil
}

// Provider returns additional overlaid schema and metadata associated with the provider..
func Provider() tfbridge.ProviderInfo {
prov := tfbridge.ProviderInfo{
Expand All @@ -77,18 +47,8 @@ func Provider() tfbridge.ProviderInfo {
// Change this to your personal name (or a company name) that you
// would like to be shown in the Pulumi Registry if this package is published
// there.
Publisher: "Pulumi",
// LogoURL is optional but useful to help identify your package in the Pulumi Registry
// if this package is published there.
//
// You may host a logo on a domain you control or add an SVG logo for your package
// in your repository and use the raw content URL for that file as your logo URL.
LogoURL: "",
// PluginDownloadURL is an optional URL used to download the Provider
// for use in Pulumi programs
// e.g https://github.com/org/pulumi-provider-name/releases/
PluginDownloadURL: "",
Description: "A Pulumi package for creating and managing HTTP cloud resources.",
Publisher: "Pulumi",
Description: "A Pulumi package for creating and managing HTTP cloud resources.",
// category/cloud tag helps with categorizing the package in the Pulumi Registry.
// For all available categories, see `Keywords` in
// https://www.pulumi.com/docs/guides/pulumi-packages/schema/#package.
Expand All @@ -99,16 +59,6 @@ func Provider() tfbridge.ProviderInfo {
// The GitHub Org hosting the upstream provider - defaults to `terraform-providers`. Note that
// this should match the TF provider module's require directive, not any replace directives.
GitHubOrg: "terraform-providers",
Config: map[string]*tfbridge.SchemaInfo{
// Add any required configuration here, this provides structured docs for configuration.
// "mode": {
// Default: &tfbridge.DefaultInfo{
// EnvVars: []string{"HTTP_MODE"}, // Multiple vars can be used
// Value: "local",
// },
// },
},
PreConfigureCallback: preConfigureCallback,
JavaScript: &tfbridge.JavaScriptInfo{
Dependencies: map[string]string{
"@pulumi/pulumi": "^3.0.0",
Expand Down Expand Up @@ -150,18 +100,10 @@ func Provider() tfbridge.ProviderInfo {
},
}

err := x.ComputeDefaults(
&prov,
x.TokensSingleModule(
fmt.Sprintf("%s_", providerName),
"index",
x.MakeStandardToken(providerName),
),
)
contract.AssertNoErrorf(err, "Failed to compute defaults")
prov.MustComputeTokens(tokens.SingleModule(providerName+"_", "index",
tokens.MakeStandard(providerName)))

err = x.AutoAliasing(&prov, prov.GetMetadata())
contract.AssertNoErrorf(err, "Failed to apply aliasing")
prov.MustApplyAutoAliases()

prov.SetAutonaming(255, "-")

Expand Down
Loading