-
Notifications
You must be signed in to change notification settings - Fork 17
Migrate plistutil to v2 #299
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,15 @@ | ||
| package exportoptionsgenerator | ||
|
|
||
| import ( | ||
| plistutilv1 "github.com/bitrise-io/go-xcode/plistutil" | ||
| "github.com/bitrise-io/go-xcode/v2/plistutil" | ||
| ) | ||
|
|
||
| // TODO: remove this function when export package is migrated to v2 and uses plistutil/v2 | ||
| func convertToV1PlistData(bundleIDEntitlementsMap map[string]plistutil.PlistData) map[string]plistutilv1.PlistData { | ||
| converted := map[string]plistutilv1.PlistData{} | ||
| for bundleID, entitlements := range bundleIDEntitlementsMap { | ||
| converted[bundleID] = plistutilv1.PlistData(entitlements) | ||
| } | ||
| return converted | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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,220 @@ | ||
| package plistutil | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are two changes compared to the v1 version:
|
||
|
|
||
| import ( | ||
| "errors" | ||
| "time" | ||
|
|
||
| "github.com/bitrise-io/go-plist" | ||
| ) | ||
|
|
||
| // PlistData ... | ||
| type PlistData map[string]interface{} | ||
|
|
||
| // NewPlistDataFromContent ... | ||
| func NewPlistDataFromContent(plistContent string) (PlistData, error) { | ||
| var data PlistData | ||
| if _, err := plist.Unmarshal([]byte(plistContent), &data); err != nil { | ||
| return PlistData{}, err | ||
| } | ||
| return data, nil | ||
| } | ||
|
|
||
| // GetString ... | ||
| func (data PlistData) GetString(forKey string) (string, bool) { | ||
| value, ok := data[forKey] | ||
| if !ok { | ||
| return "", false | ||
| } | ||
|
|
||
| casted, ok := value.(string) | ||
| if !ok { | ||
| return "", false | ||
| } | ||
|
|
||
| return casted, true | ||
| } | ||
|
|
||
| // GetUInt64 ... | ||
| func (data PlistData) GetUInt64(forKey string) (uint64, bool) { | ||
| value, ok := data[forKey] | ||
| if !ok { | ||
| return 0, false | ||
| } | ||
|
|
||
| casted, ok := value.(uint64) | ||
| if !ok { | ||
| return 0, false | ||
| } | ||
| return casted, true | ||
| } | ||
|
|
||
| // GetFloat64 ... | ||
| func (data PlistData) GetFloat64(forKey string) (float64, bool) { | ||
| value, ok := data[forKey] | ||
| if !ok { | ||
| return 0, false | ||
| } | ||
|
|
||
| casted, ok := value.(float64) | ||
| if !ok { | ||
| return 0, false | ||
| } | ||
| return casted, true | ||
| } | ||
|
|
||
| // GetBool ... | ||
| func (data PlistData) GetBool(forKey string) (bool, bool) { | ||
| value, ok := data[forKey] | ||
| if !ok { | ||
| return false, false | ||
| } | ||
|
|
||
| casted, ok := value.(bool) | ||
| if !ok { | ||
| return false, false | ||
| } | ||
|
|
||
| return casted, true | ||
| } | ||
|
|
||
| // GetTime ... | ||
| func (data PlistData) GetTime(forKey string) (time.Time, bool) { | ||
| value, ok := data[forKey] | ||
| if !ok { | ||
| return time.Time{}, false | ||
| } | ||
|
|
||
| casted, ok := value.(time.Time) | ||
| if !ok { | ||
| return time.Time{}, false | ||
| } | ||
| return casted, true | ||
| } | ||
|
|
||
| // GetUInt64Array ... | ||
| func (data PlistData) GetUInt64Array(forKey string) ([]uint64, bool) { | ||
| value, ok := data[forKey] | ||
| if !ok { | ||
| return nil, false | ||
| } | ||
|
|
||
| if casted, ok := value.([]uint64); ok { | ||
| return casted, true | ||
| } | ||
|
|
||
| casted, ok := value.([]interface{}) | ||
| if !ok { | ||
| return nil, false | ||
| } | ||
|
|
||
| var array []uint64 | ||
| for _, v := range casted { | ||
| casted, ok := v.(uint64) | ||
| if !ok { | ||
| return nil, false | ||
| } | ||
|
|
||
| array = append(array, casted) | ||
| } | ||
| return array, true | ||
| } | ||
|
|
||
| // GetStringArray ... | ||
| func (data PlistData) GetStringArray(forKey string) ([]string, bool) { | ||
| value, ok := data[forKey] | ||
| if !ok { | ||
| return nil, false | ||
| } | ||
|
|
||
| if casted, ok := value.([]string); ok { | ||
| return casted, true | ||
| } | ||
|
|
||
| casted, ok := value.([]interface{}) | ||
| if !ok { | ||
| return nil, false | ||
| } | ||
|
|
||
| var array []string | ||
| for _, v := range casted { | ||
| casted, ok := v.(string) | ||
| if !ok { | ||
| return nil, false | ||
| } | ||
|
|
||
| array = append(array, casted) | ||
| } | ||
| return array, true | ||
| } | ||
|
|
||
| // GetByteArrayArray ... | ||
| func (data PlistData) GetByteArrayArray(forKey string) ([][]byte, bool) { | ||
| value, ok := data[forKey] | ||
| if !ok { | ||
| return nil, false | ||
| } | ||
|
|
||
| if casted, ok := value.([][]byte); ok { | ||
| return casted, true | ||
| } | ||
|
|
||
| casted, ok := value.([]interface{}) | ||
| if !ok { | ||
| return nil, false | ||
| } | ||
|
|
||
| var array [][]byte | ||
| for _, v := range casted { | ||
| casted, ok := v.([]byte) | ||
| if !ok { | ||
| return nil, false | ||
| } | ||
|
|
||
| array = append(array, casted) | ||
| } | ||
| return array, true | ||
| } | ||
|
|
||
| // GetMapStringInterface ... | ||
| func (data PlistData) GetMapStringInterface(forKey string) (PlistData, bool) { | ||
| value, ok := data[forKey] | ||
| if !ok { | ||
| return nil, false | ||
| } | ||
|
|
||
| if casted, ok := value.(map[string]interface{}); ok { | ||
| return casted, true | ||
| } | ||
| return nil, false | ||
| } | ||
|
|
||
| func castToMapStringInterfaceArray(obj interface{}) ([]PlistData, error) { | ||
| array, ok := obj.([]interface{}) | ||
| if !ok { | ||
| return nil, errors.New("failed to cast to []interface{}") | ||
| } | ||
|
|
||
| var casted []PlistData | ||
| for _, item := range array { | ||
| mapStringInterface, ok := item.(map[string]interface{}) | ||
| if !ok { | ||
| return nil, errors.New("failed to cast to map[string]interface{}") | ||
| } | ||
| casted = append(casted, mapStringInterface) | ||
| } | ||
|
|
||
| return casted, nil | ||
| } | ||
|
|
||
| // GetMapStringInterfaceArray ... | ||
| func (data PlistData) GetMapStringInterfaceArray(forKey string) ([]PlistData, bool) { | ||
| value, ok := data[forKey] | ||
| if !ok { | ||
| return nil, false | ||
| } | ||
| mapStringInterfaceArray, err := castToMapStringInterfaceArray(value) | ||
| if err != nil { | ||
| return nil, false | ||
| } | ||
| return mapStringInterfaceArray, true | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exportpackage is on V1 and uses V1 plistutil, until we migrateexportpackage convertToV1PlistData converts between v2 and v1 plistutil.