fix permalink (#3970)

This commit is contained in:
Erin Krengel 2020-02-26 09:45:39 -08:00 committed by GitHub
parent ec539bbb6c
commit 111c63fbe9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 6 deletions

View file

@ -445,7 +445,7 @@ func (b *cloudBackend) parsePolicyPackReference(s string) (backend.PolicyPackRef
orgName = currentUser
}
return newCloudBackendPolicyPackReference(orgName, tokens.QName(policyPackName)), nil
return newCloudBackendPolicyPackReference(b.CloudConsoleURL(), orgName, tokens.QName(policyPackName)), nil
}
func (b *cloudBackend) GetPolicyPack(ctx context.Context, policyPack string,
@ -463,7 +463,7 @@ func (b *cloudBackend) GetPolicyPack(ctx context.Context, policyPack string,
apiToken := account.AccessToken
return &cloudPolicyPack{
ref: newCloudBackendPolicyPackReference(
ref: newCloudBackendPolicyPackReference(b.CloudConsoleURL(),
policyPackRef.OrgName(), policyPackRef.Name()),
b: b,
cl: client.NewClient(b.CloudURL(), apiToken, d)}, nil

View file

@ -77,9 +77,13 @@ func (rp *cloudRequiredPolicy) Install(ctx context.Context) (string, error) {
}
func newCloudBackendPolicyPackReference(
orgName string, name tokens.QName) *cloudBackendPolicyPackReference {
cloudConsoleURL, orgName string, name tokens.QName) *cloudBackendPolicyPackReference {
return &cloudBackendPolicyPackReference{orgName: orgName, name: name}
return &cloudBackendPolicyPackReference{
orgName: orgName,
name: name,
cloudConsoleURL: cloudConsoleURL,
}
}
// cloudBackendPolicyPackReference is a reference to a PolicyPack implemented by the Pulumi service.
@ -92,6 +96,10 @@ type cloudBackendPolicyPackReference struct {
// versionTag of the Policy Pack. This is typically the version specified in
// a package.json, setup.py, or similar file.
versionTag string
// cloudConsoleURL is the root URL of where the Policy Pack can be found in the console. The
// version must be appended to the returned URL.
cloudConsoleURL string
}
var _ backend.PolicyPackReference = (*cloudBackendPolicyPackReference)(nil)
@ -108,6 +116,10 @@ func (pr *cloudBackendPolicyPackReference) Name() tokens.QName {
return pr.name
}
func (pr *cloudBackendPolicyPackReference) CloudConsoleURL() string {
return fmt.Sprintf("%s/%s/policypacks/%s", pr.cloudConsoleURL, pr.orgName, pr.Name())
}
// cloudPolicyPack is a the Pulumi service implementation of the PolicyPack interface.
type cloudPolicyPack struct {
// ref uniquely identifies the PolicyPack in the Pulumi service.
@ -182,7 +194,8 @@ func (pack *cloudPolicyPack) Publish(
return result.FromError(err)
}
fmt.Printf("\nPermalink: %s/policypacks/%s/%s\n", pack.Backend().URL(), pack.ref.Name(), publishedVersion)
fmt.Printf("\nPermalink: %s/%s\n", pack.ref.CloudConsoleURL(), publishedVersion)
return nil
}

View file

@ -350,7 +350,7 @@ func HasPluginGTE(plug PluginInfo) (bool, error) {
return false, nil
}
// GetPolicyDir returns the directory in which policies on the current machine are managed.
// GetPolicyDir returns the directory in which an organization's Policy Packs on the current machine are managed.
func GetPolicyDir(orgName string) (string, error) {
return GetPulumiPath(PolicyDir, orgName)
}