Skip to content

Commit

Permalink
include more/all installer fields in API responses
Browse files Browse the repository at this point in the history
  • Loading branch information
jantari committed Jan 8, 2023
1 parent 4b90303 commit 0673605
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 11 deletions.
4 changes: 2 additions & 2 deletions models/api_1_1_0.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ type API_Installer_1_1_0 struct {
Commands []string `yaml:"Commands" json:",omitempty"`
Protocols []string `yaml:"Protocols" json:",omitempty"`
FileExtensions []string `yaml:"FileExtensions" json:",omitempty"`
Dependencies Dependencies_1_1_0 `yaml:"Dependencies"`
Dependencies API_Dependencies_1_1_0 `yaml:"Dependencies"`
PackageFamilyName string `yaml:"PackageFamilyName" json:",omitempty"`
ProductCode string `yaml:"ProductCode"`
Capabilities []string `yaml:"Capabilities" json:",omitempty"`
Expand Down Expand Up @@ -173,7 +173,7 @@ type API_ManifestSearchVersion_1_1_0 struct {

// https://github.com/microsoft/winget-cli/blob/56df5adb2f974230c3db8fb7f84d2fe3150eb859/schemas/JSON/manifests/v1.1.0/manifest.installer.1.1.0.json#L229
// https://github.com/microsoft/winget-cli-restsource/blob/main/documentation/WinGet-1.1.0.yaml#L969
type Dependencies_1_1_0 struct {
type API_Dependencies_1_1_0 struct {
WindowsFeatures []string `yaml:"WindowsFeatures" json:",omitempty"`
WindowsLibraries []string `yaml:"WindowsLibraries" json:",omitempty"`
PackageDependencies []struct {
Expand Down
8 changes: 4 additions & 4 deletions models/api_1_4_0.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ type API_Installer_1_4_0 struct {
InstallerSha256 string `yaml:"InstallerSha256"`
SignatureSha256 string `yaml:"SignatureSha256" json:",omitempty"` // winget runs into an exception internally when this is an empty string (ParseFromHexString: Invalid value size), so omit in API responses if empty
InstallModes []string `yaml:"InstallModes"`
InstallerSwitches InstallerSwitches_1_4_0 `yaml:"InstallerSwitches"`
InstallerSwitches API_InstallerSwitches_1_4_0 `yaml:"InstallerSwitches"`
InstallerSuccessCodes []int64 `yaml:"InstallerSuccessCodes" json:",omitempty"`
ExpectedReturnCodes []API_ExpectedReturnCode_1_4_0 `yaml:"ExpectedReturnCodes"`
UpgradeBehavior string `yaml:"UpgradeBehavior" json:",omitempty"`
Commands []string `yaml:"Commands" json:",omitempty"`
Protocols []string `yaml:"Protocols" json:",omitempty"`
FileExtensions []string `yaml:"FileExtensions" json:",omitempty"`
Dependencies Dependencies_1_4_0 `yaml:"Dependencies"`
Dependencies API_Dependencies_1_4_0 `yaml:"Dependencies"`
PackageFamilyName string `yaml:"PackageFamilyName" json:",omitempty"`
ProductCode string `yaml:"ProductCode"`
Capabilities []string `yaml:"Capabilities" json:",omitempty"`
Expand Down Expand Up @@ -198,7 +198,7 @@ type API_ManifestSearchVersion_1_4_0 struct {

// https://github.com/microsoft/winget-cli/blob/master/schemas/JSON/manifests/v1.4.0/manifest.installer.1.4.0.json#L294
// https://github.com/microsoft/winget-cli-restsource/blob/main/documentation/WinGet-1.4.0.yaml#L1015
type Dependencies_1_4_0 struct {
type API_Dependencies_1_4_0 struct {
WindowsFeatures []string `yaml:"WindowsFeatures" json:",omitempty"`
WindowsLibraries []string `yaml:"WindowsLibraries" json:",omitempty"`
PackageDependencies []struct {
Expand All @@ -209,7 +209,7 @@ type Dependencies_1_4_0 struct {
}

// https://github.com/microsoft/winget-cli-restsource/blob/main/documentation/WinGet-1.4.0.yaml#L856
type InstallerSwitches_1_4_0 struct {
type API_InstallerSwitches_1_4_0 struct {
Silent string `yaml:"Silent" json:",omitempty"`
SilentWithProgress string `yaml:"SilentWithProgress" json:",omitempty"`
Interactive string `yaml:"Interactive" json:",omitempty"`
Expand Down
37 changes: 34 additions & 3 deletions models/manifests_1_1_0.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ type Manifest_InstallerManifest_1_1_0 struct {
Commands []string `yaml:"Commands" json:",omitempty"`
Protocols []string `yaml:"Protocols" json:",omitempty"`
FileExtensions []string `yaml:"FileExtensions" json:",omitempty"`
Dependencies Dependencies_1_1_0 `yaml:"Dependencies" json:",omitempty"`
Dependencies Manifest_Dependencies_1_1_0 `yaml:"Dependencies" json:",omitempty"`
PackageFamilyName string `yaml:"PackageFamilyName" json:",omitempty"`
ProductCode string `yaml:"ProductCode" json:",omitempty"`
Capabilities []string `yaml:"Capabilities" json:",omitempty"`
Expand All @@ -69,7 +69,7 @@ type Manifest_InstallerManifest_1_1_0 struct {
ReleaseDate string `yaml:"ReleaseDate" json:",omitempty"`
InstallLocationRequired bool `yaml:"InstallLocationRequired" json:",omitempty"`
RequireExplicitUpgrade bool `yaml:"RequireExplicitUpgrade" json:",omitempty"`
UnsupportedOSArchitectures []string `yaml:"UnsupportedOSArchitectures" json:",omitempty"`
UnsupportedOSArchitectures []string `yaml:"UnsupportedOSArchitectures"`
AppsAndFeaturesEntries []struct {
DisplayName string `yaml:"DisplayName" json:",omitempty"`
Publisher string `yaml:"Publisher" json:",omitempty"`
Expand Down Expand Up @@ -99,6 +99,8 @@ func (instm Manifest_InstallerManifest_1_1_0) ToApiInstallers() []API_InstallerI
}

apiInstallers = append(apiInstallers, API_Installer_1_1_0 {
InstallerIdentifier: "", // This is in the API schema but idk where to get it from
InstallerLocale: nonDefault(installer.InstallerLocale, instm.InstallerLocale),
Architecture: installer.Architecture, // Already mandatory per-Installer
MinimumOSVersion: nonDefault(installer.MinimumOSVersion, instm.MinimumOSVersion), // Already mandatory per-Installer
Platform: nonDefault(installer.Platform, instm.Platform),
Expand All @@ -107,11 +109,28 @@ func (instm Manifest_InstallerManifest_1_1_0) ToApiInstallers() []API_InstallerI
InstallerUrl: installer.InstallerUrl, // Already mandatory per-Installer
InstallerSha256: installer.InstallerSha256, // Already mandatory per-Installer
SignatureSha256: installer.SignatureSha256, // Can only be set per-Installer, impossible to copy from global manifest properties
InstallerSwitches: API_InstallerSwitches_1_1_0(nonDefault(installer.InstallerSwitches, instm.InstallerSwitches)), // Can be converted directly as they're identical structs
InstallModes: nonDefault(installer.InstallModes, instm.InstallModes),
InstallerSuccessCodes: nonDefault(installer.InstallerSuccessCodes, instm.InstallerSuccessCodes),
ExpectedReturnCodes: nonDefault(installer_API_ExpectedReturnCodes, instm_API_ExpectedReturnCodes),
UpgradeBehavior: nonDefault(installer.UpgradeBehavior, instm.UpgradeBehavior),
Commands: nonDefault(installer.Commands, instm.Commands),
Protocols: nonDefault(installer.Protocols, instm.Protocols),
FileExtensions: nonDefault(installer.FileExtensions, instm.FileExtensions),
Dependencies: API_Dependencies_1_1_0(nonDefault(installer.Dependencies, instm.Dependencies)),
PackageFamilyName: nonDefault(installer.PackageFamilyName, instm.PackageFamilyName),
ProductCode: nonDefault(installer.ProductCode, instm.ProductCode),
Capabilities: nonDefault(installer.Capabilities, instm.Capabilities),
RestrictedCapabilities: nonDefault(installer.RestrictedCapabilities, instm.RestrictedCapabilities),
MSStoreProductIdentifier: "", // This is in the API schema but idk where to get it from
Markets: nonDefault(installer.Markets, instm.Markets),
InstallerAbortsTerminal: nonDefault(installer.InstallerAbortsTerminal, instm.InstallerAbortsTerminal),
ReleaseDate: nonDefault(installer.ReleaseDate, instm.ReleaseDate),
InstallLocationRequired: nonDefault(installer.InstallLocationRequired, instm.InstallLocationRequired),
RequireExplicitUpgrade: nonDefault(installer.RequireExplicitUpgrade, instm.RequireExplicitUpgrade),
UnsupportedOSArchitectures: nonDefault(nonDefault(installer.UnsupportedOSArchitectures, instm.UnsupportedOSArchitectures), []string{}), // Workaround for https://github.com/golang/go/issues/27589
AppsAndFeaturesEntries: nonDefault(installer.AppsAndFeaturesEntries, instm.AppsAndFeaturesEntries),
ElevationRequirement: nonDefault(installer.ElevationRequirement, instm.ElevationRequirement),
})
}

Expand All @@ -136,7 +155,7 @@ type Manifest_Installer_1_1_0 struct {
Commands []string `yaml:"Commands" json:",omitempty"`
Protocols []string `yaml:"Protocols" json:",omitempty"`
FileExtensions []string `yaml:"FileExtensions" json:",omitempty"`
Dependencies Dependencies_1_1_0 `yaml:"Dependencies"`
Dependencies Manifest_Dependencies_1_1_0 `yaml:"Dependencies"`
PackageFamilyName string `yaml:"PackageFamilyName" json:",omitempty"`
ProductCode string `yaml:"ProductCode"`
Capabilities []string `yaml:"Capabilities" json:",omitempty"`
Expand Down Expand Up @@ -313,3 +332,15 @@ type Manifest_ExpectedReturnCode_1_1_0 struct {
InstallerReturnCode int64 `yaml:"InstallerReturnCode"`
ReturnResponse string `yaml:"ReturnResponse"`
}

// https://github.com/microsoft/winget-cli/blob/56df5adb2f974230c3db8fb7f84d2fe3150eb859/schemas/JSON/manifests/v1.1.0/manifest.installer.1.1.0.json#L229
type Manifest_Dependencies_1_1_0 struct {
WindowsFeatures []string `yaml:"WindowsFeatures" json:",omitempty"`
WindowsLibraries []string `yaml:"WindowsLibraries" json:",omitempty"`
PackageDependencies []struct {
PackageIdentifier string `yaml:"PackageIdentifier"`
MinimumVersion string `yaml:"MinimumVersion"`
} `yaml:"PackageDependencies" json:",omitempty"`
ExternalDependencies []string `yaml:"ExternalDependencies" json:",omitempty"`
}

35 changes: 33 additions & 2 deletions models/manifests_1_2_0.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ type Manifest_InstallerManifest_1_2_0 struct {
Commands []string `yaml:"Commands" json:",omitempty"`
Protocols []string `yaml:"Protocols" json:",omitempty"`
FileExtensions []string `yaml:"FileExtensions" json:",omitempty"`
Dependencies Dependencies_1_1_0 `yaml:"Dependencies" json:",omitempty"`
Dependencies Manifest_Dependencies_1_2_0 `yaml:"Dependencies" json:",omitempty"`
PackageFamilyName string `yaml:"PackageFamilyName" json:",omitempty"`
ProductCode string `yaml:"ProductCode" json:",omitempty"`
Capabilities []string `yaml:"Capabilities" json:",omitempty"`
Expand Down Expand Up @@ -107,6 +107,8 @@ func (instm Manifest_InstallerManifest_1_2_0) ToApiInstallers() []API_InstallerI
}

apiInstallers = append(apiInstallers, API_Installer_1_4_0 {
InstallerIdentifier: "", // This is in the API schema but idk where to get it from
InstallerLocale: nonDefault(installer.InstallerLocale, instm.InstallerLocale),
Architecture: installer.Architecture, // Already mandatory per-Installer
MinimumOSVersion: nonDefault(installer.MinimumOSVersion, instm.MinimumOSVersion), // Already mandatory per-Installer
Platform: nonDefault(installer.Platform, instm.Platform),
Expand All @@ -115,11 +117,29 @@ func (instm Manifest_InstallerManifest_1_2_0) ToApiInstallers() []API_InstallerI
InstallerUrl: installer.InstallerUrl, // Already mandatory per-Installer
InstallerSha256: installer.InstallerSha256, // Already mandatory per-Installer
SignatureSha256: installer.SignatureSha256, // Can only be set per-Installer, impossible to copy from global manifest properties
InstallerSwitches: API_InstallerSwitches_1_4_0(nonDefault(installer.InstallerSwitches, instm.InstallerSwitches)), // Can be converted directly as they're identical structs
InstallModes: nonDefault(installer.InstallModes, instm.InstallModes),
InstallerSuccessCodes: nonDefault(installer.InstallerSuccessCodes, instm.InstallerSuccessCodes),
ExpectedReturnCodes: nonDefault(installer_API_ExpectedReturnCodes, instm_API_ExpectedReturnCodes),
UpgradeBehavior: nonDefault(installer.UpgradeBehavior, instm.UpgradeBehavior),
Commands: nonDefault(installer.Commands, instm.Commands),
Protocols: nonDefault(installer.Protocols, instm.Protocols),
FileExtensions: nonDefault(installer.FileExtensions, instm.FileExtensions),
Dependencies: API_Dependencies_1_4_0(nonDefault(installer.Dependencies, instm.Dependencies)),
PackageFamilyName: nonDefault(installer.PackageFamilyName, instm.PackageFamilyName),
ProductCode: nonDefault(installer.ProductCode, instm.ProductCode),
Capabilities: nonDefault(installer.Capabilities, instm.Capabilities),
RestrictedCapabilities: nonDefault(installer.RestrictedCapabilities, instm.RestrictedCapabilities),
MSStoreProductIdentifier: "", // This is in the API schema but idk where to get it from
Markets: nonDefault(installer.Markets, instm.Markets),
InstallerAbortsTerminal: nonDefault(installer.InstallerAbortsTerminal, instm.InstallerAbortsTerminal),
ReleaseDate: nonDefault(installer.ReleaseDate, instm.ReleaseDate),
InstallLocationRequired: nonDefault(installer.InstallLocationRequired, instm.InstallLocationRequired),
RequireExplicitUpgrade: nonDefault(installer.RequireExplicitUpgrade, instm.RequireExplicitUpgrade),
DisplayInstallWarnings: nonDefault(installer.DisplayInstallWarnings, instm.DisplayInstallWarnings),
UnsupportedOSArchitectures: nonDefault(installer.UnsupportedOSArchitectures, instm.UnsupportedOSArchitectures), // field is nullable in 1.4.0 API spec, workaround from 1.1.0 not needed
AppsAndFeaturesEntries: nonDefault(installer.AppsAndFeaturesEntries, instm.AppsAndFeaturesEntries),
ElevationRequirement: nonDefault(installer.ElevationRequirement, instm.ElevationRequirement),
})
}

Expand All @@ -144,7 +164,7 @@ type Manifest_Installer_1_2_0 struct {
Commands []string `yaml:"Commands" json:",omitempty"`
Protocols []string `yaml:"Protocols" json:",omitempty"`
FileExtensions []string `yaml:"FileExtensions" json:",omitempty"`
Dependencies Dependencies_1_1_0 `yaml:"Dependencies"`
Dependencies Manifest_Dependencies_1_2_0 `yaml:"Dependencies"`
PackageFamilyName string `yaml:"PackageFamilyName" json:",omitempty"`
ProductCode string `yaml:"ProductCode"`
Capabilities []string `yaml:"Capabilities" json:",omitempty"`
Expand Down Expand Up @@ -326,6 +346,17 @@ type Manifest_ExpectedReturnCode_1_2_0 struct {
ReturnResponseUrl string `yaml:"ReturnResponseUrl"`
}

// https://github.com/microsoft/winget-cli/blob/master/schemas/JSON/manifests/v1.2.0/manifest.installer.1.2.0.json#L251
type Manifest_Dependencies_1_2_0 struct {
WindowsFeatures []string `yaml:"WindowsFeatures" json:",omitempty"`
WindowsLibraries []string `yaml:"WindowsLibraries" json:",omitempty"`
PackageDependencies []struct {
PackageIdentifier string `yaml:"PackageIdentifier"`
MinimumVersion string `yaml:"MinimumVersion"`
} `yaml:"PackageDependencies" json:",omitempty"`
ExternalDependencies []string `yaml:"ExternalDependencies" json:",omitempty"`
}

type Manifest_Documentation_1_2_0 struct {
DocumentLabel string `yaml:"DocumentLabel"`
DocumentUrl string `yaml:"DocumentUrl"`
Expand Down

0 comments on commit 0673605

Please sign in to comment.