Skip to content

Commit

Permalink
revert(sdk/go): Revert changes to String & marshaling method receivers
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronFriel committed Oct 13, 2022
1 parent 7b09ad1 commit ab1ec4f
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 18 deletions.
8 changes: 4 additions & 4 deletions sdk/go/common/resource/asset.go
Expand Up @@ -351,11 +351,11 @@ func (a *Asset) readPath() (*Blob, error) {
}

func (a *Asset) readURI() (*Blob, error) {
url, isUrl, err := a.GetURIURL()
url, isURL, err := a.GetURIURL()
if err != nil {
return nil, err
}
contract.Assertf(isUrl, "Expected a URI-based asset")
contract.Assertf(isURL, "Expected a URI-based asset")
switch s := url.Scheme; s {
case "http", "https":
resp, err := httputil.GetWithRetry(url.String(), http.DefaultClient)
Expand Down Expand Up @@ -885,11 +885,11 @@ func (a *Archive) readPath() (ArchiveReader, error) {

func (a *Archive) readURI() (ArchiveReader, error) {
// To read a URI-based archive, fetch the contents remotely and use the extension to pick the format to use.
url, isurl, err := a.GetURIURL()
url, isURL, err := a.GetURIURL()
if err != nil {
return nil, err
}
contract.Assertf(isurl, "Expected a URI-based asset")
contract.Assertf(isURL, "Expected a URI-based asset")

format := detectArchiveFormat(url.Path)
if format == NotArchive {
Expand Down
6 changes: 3 additions & 3 deletions sdk/go/common/resource/config/key.go
Expand Up @@ -70,7 +70,7 @@ func (k *Key) Name() string {
return k.name
}

func (k *Key) MarshalJSON() ([]byte, error) {
func (k Key) MarshalJSON() ([]byte, error) {
return json.Marshal(k.String())
}

Expand All @@ -90,7 +90,7 @@ func (k *Key) UnmarshalJSON(b []byte) error {
return nil
}

func (k *Key) MarshalYAML() (interface{}, error) {
func (k Key) MarshalYAML() (interface{}, error) {
return k.String(), nil
}

Expand All @@ -110,7 +110,7 @@ func (k *Key) UnmarshalYAML(unmarshal func(interface{}) error) error {
return nil
}

func (k *Key) String() string {
func (k Key) String() string {
return k.namespace + ":" + k.name
}

Expand Down
4 changes: 2 additions & 2 deletions sdk/go/common/resource/resource_id.go
Expand Up @@ -30,8 +30,8 @@ import (
type ID string

// String converts a resource ID into a string.
func (id *ID) String() string {
return string(*id)
func (id ID) String() string {
return string(id)
}

// StringPtr converts an optional ID into an optional string.
Expand Down
2 changes: 1 addition & 1 deletion sdk/go/common/util/cmdutil/console.go
Expand Up @@ -152,7 +152,7 @@ func MeasureText(text string) int {
return uniseg.GraphemeClusterCount(clean)
}

func (table Table) ToStringWithGap(columnGap string) string {
func (table *Table) ToStringWithGap(columnGap string) string {
columnCount := len(table.Headers)

// Figure out the preferred column width for each column. It will be set to the max length of
Expand Down
13 changes: 7 additions & 6 deletions sdk/go/common/workspace/plugins.go
Expand Up @@ -622,7 +622,7 @@ func (info *PluginInfo) Spec() PluginSpec {
return PluginSpec{Name: info.Name, Kind: info.Kind, Version: info.Version}
}

func (info *PluginInfo) String() string {
func (info PluginInfo) String() string {
var version string
if v := info.Version; v != nil {
version = fmt.Sprintf("-%s", v)
Expand Down Expand Up @@ -1094,11 +1094,12 @@ func (p dirPlugin) writeToDir(dstRoot string) error {
})
}

// InstallWithContext installs a plugin's tarball into the cache. It validates that plugin names are in the expected format.
// Previous versions of Pulumi extracted the tarball to a temp directory first, and then renamed the temp directory
// to the final directory. The rename operation fails often enough on Windows due to aggressive virus scanners opening
// files in the temp directory. To address this, we now extract the tarball directly into the final directory, and use
// file locks to prevent concurrent installs.
// InstallWithContext installs a plugin's tarball into the cache. It validates that plugin names are in the expected
// format. Previous versions of Pulumi extracted the tarball to a temp directory first, and then renamed the temp
// directory to the final directory. The rename operation fails often enough on Windows due to aggressive virus scanners
// opening files in the temp directory. To address this, we now extract the tarball directly into the final directory,
// and use file locks to prevent concurrent installs.
//
// Each plugin has its own file lock, with the same name as the plugin directory, with a `.lock` suffix.
// During installation an empty file with a `.partial` suffix is created, indicating that installation is in-progress.
// The `.partial` file is deleted when installation is complete, indicating that the plugin has finished installing.
Expand Down
4 changes: 2 additions & 2 deletions sdk/go/common/workspace/project.go
Expand Up @@ -348,7 +348,7 @@ func (info *ProjectRuntimeInfo) SetOption(key string, value interface{}) {
info.options[key] = value
}

func (info *ProjectRuntimeInfo) MarshalYAML() (interface{}, error) {
func (info ProjectRuntimeInfo) MarshalYAML() (interface{}, error) {
if info.options == nil || len(info.options) == 0 {
return info.name, nil
}
Expand All @@ -359,7 +359,7 @@ func (info *ProjectRuntimeInfo) MarshalYAML() (interface{}, error) {
}, nil
}

func (info *ProjectRuntimeInfo) MarshalJSON() ([]byte, error) {
func (info ProjectRuntimeInfo) MarshalJSON() ([]byte, error) {
if info.options == nil || len(info.options) == 0 {
return json.Marshal(info.name)
}
Expand Down

0 comments on commit ab1ec4f

Please sign in to comment.