-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
198 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Copyright 2024, Pulumi Corporation. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package cmd | ||
|
||
import "fmt" | ||
|
||
// The source of download URLs for use during metadata generation. | ||
type downloadURLs interface { | ||
schemaURL() string | ||
indexURL() string | ||
installationConfigurationURL() string | ||
} | ||
|
||
var ( | ||
_ downloadURLs = githubDownloadURLs{} | ||
_ downloadURLs = rawDownloadURLs{} | ||
) | ||
|
||
// The set of URLs that can be downloaded from GitHub. | ||
type githubDownloadURLs struct { | ||
repoSlug repoSlug | ||
|
||
providerName string | ||
version string | ||
schemaFile string | ||
} | ||
|
||
func (s githubDownloadURLs) schemaURL() string { | ||
if s.schemaFile == "" { | ||
s.schemaFile = fmt.Sprintf("provider/cmd/pulumi-resource-%s/schema.json", s.providerName) | ||
} | ||
|
||
// we should be able to take the repo URL + the version + the schema url and | ||
// construct a file that we can download and read | ||
return fmt.Sprintf("https://raw.githubusercontent.com/%s/%s/%s", | ||
s.repoSlug, s.version, s.schemaFile) | ||
} | ||
|
||
func (s githubDownloadURLs) docsURL(name string) string { | ||
return "https://raw.githubusercontent.com/" + s.repoSlug.String() + "/" + s.version + "/docs/" + name | ||
} | ||
|
||
func (s githubDownloadURLs) indexURL() string { | ||
return s.docsURL("_index.md") | ||
} | ||
|
||
func (s githubDownloadURLs) installationConfigurationURL() string { | ||
return s.docsURL("installation-configuration.md") | ||
} | ||
|
||
type rawDownloadURLs struct { | ||
schemaFileURL string | ||
indexFileURL string | ||
installationConfigurationFileURL string | ||
} | ||
|
||
func (s rawDownloadURLs) schemaURL() string { return s.schemaFileURL } | ||
func (s rawDownloadURLs) indexURL() string { return s.indexFileURL } | ||
func (s rawDownloadURLs) installationConfigurationURL() string { | ||
return s.installationConfigurationFileURL | ||
} |
7 changes: 7 additions & 0 deletions
7
tools/resourcedocsgen/cmd/testdata/TestMissingMetadataFile/index/_index.md.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
# WARNING: this file was fetched from http://127.0.0.1:*****/docs/_index.md | ||
# Do not edit by hand unless you're certain you know what you are doing! | ||
layout: package | ||
--- | ||
|
||
# some docs |
1 change: 1 addition & 0 deletions
1
tools/resourcedocsgen/cmd/testdata/TestMissingMetadataFile/index/directory-structure.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[]string{"_index.md"} |
1 change: 1 addition & 0 deletions
1
.../resourcedocsgen/cmd/testdata/TestMissingMetadataFile/metadata/directory-structure.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[]string{"test.yaml"} |
16 changes: 16 additions & 0 deletions
16
tools/resourcedocsgen/cmd/testdata/TestMissingMetadataFile/metadata/test.yaml.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# WARNING: this file was generated by resourcedocsgen | ||
# Do not edit by hand unless you're certain you know what you are doing! | ||
category: Cloud | ||
component: false | ||
description: "" | ||
featured: false | ||
logo_url: "" | ||
name: test | ||
native: true | ||
package_status: ga | ||
publisher: example | ||
repo_url: https://github.com/pulumi/pulumi-test | ||
schema_file_url: http://127.0.0.1:*****/schema.json | ||
title: test | ||
updated_on: ********** | ||
version: 1.0.0 |