Skip to content

Commit

Permalink
Profile with multiple activations should be processed only once. (Goo…
Browse files Browse the repository at this point in the history
  • Loading branch information
gsquared94 authored and IsaacPD committed Dec 23, 2020
1 parent ef6ec47 commit 15d800f
Show file tree
Hide file tree
Showing 6 changed files with 305 additions and 1 deletion.
36 changes: 36 additions & 0 deletions installers/windows/templates/LicenseAgreementDlg_HK.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<UI>
<Dialog Id="LicenseAgreementDlg_HK" Width="370" Height="270" Title="!(loc.LicenseAgreementDlg_Title)">
<Control Id="LicenseAcceptedCheckBox" Type="CheckBox" X="20" Y="207" Width="330" Height="18" CheckBoxValue="1" Property="LicenseAccepted"
Text="!(loc.LicenseAgreementDlgLicenseAcceptedCheckBox)" />
<Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="!(loc.WixUIBack)" />
<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUINext)">
<Publish Event="SpawnWaitDialog" Value="WaitForCostingDlg">CostingComplete = 1</Publish>
<Condition Action="disable"><![CDATA[LicenseAccepted <> "1"]]></Condition>
<Condition Action="enable">LicenseAccepted = "1"</Condition>
</Control>
<Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
<Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
</Control>
<Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.LicenseAgreementDlgBannerBitmap)" />
<Control Id="LicenseText" Type="ScrollableText" X="20" Y="60" Width="330" Height="140" Sunken="yes" TabSkip="no">

{{if gt (.License | len) 0}}
<Text SourceFile="{{.License}}" />
{{end}}

</Control>
<Control Id="Print" Type="PushButton" X="112" Y="243" Width="56" Height="17" Text="!(loc.WixUIPrint)">
<Publish Event="DoAction" Value="WixUIPrintEula">1</Publish>
</Control>
<Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
<Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
<Control Id="Description" Type="Text" X="25" Y="23" Width="340" Height="15" Transparent="yes" NoPrefix="yes" Text="!(loc.LicenseAgreementDlgDescription)" />
<Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes" Text="!(loc.LicenseAgreementDlgTitle)" />
</Dialog>
</UI>
</Fragment>
</Wix>
65 changes: 65 additions & 0 deletions installers/windows/templates/WixUI_HK.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>

<UI Id="WixUI_HK">
<TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
<TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="12" />
<TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" />

<Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />
<Property Id="WixUI_Mode" Value="InstallDir" />

<DialogRef Id="BrowseDlg" />
<DialogRef Id="DiskCostDlg" />
<DialogRef Id="ErrorDlg" />
<DialogRef Id="FatalError" />
<DialogRef Id="FilesInUse" />
<DialogRef Id="MsiRMFilesInUse" />
<DialogRef Id="PrepareDlg" />
<DialogRef Id="ProgressDlg" />
<DialogRef Id="ResumeDlg" />
<DialogRef Id="UserExit" />

<!-- Make sure to include custom dialogs in the installer database via a DialogRef command,
especially if they are not included explicitly in the publish chain below -->
<DialogRef Id="LicenseAgreementDlg_HK"/>

<Publish Dialog="BrowseDlg" Control="OK" Event="DoAction" Value="WixUIValidatePath" Order="3">1</Publish>
<Publish Dialog="BrowseDlg" Control="OK" Event="SpawnDialog" Value="InvalidDirDlg" Order="4"><![CDATA[WIXUI_INSTALLDIR_VALID<>"1"]]></Publish>

<Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish>

<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog"
{{if gt (.License | len) 0}}
Value="LicenseAgreementDlg_HK"
{{else}}
Value="InstallDirDlg"
{{end}}
>NOT Installed</Publish>
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">Installed AND PATCH</Publish>

<Publish Dialog="LicenseAgreementDlg_HK" Control="Back" Event="NewDialog" Value="WelcomeDlg">1</Publish>
<Publish Dialog="LicenseAgreementDlg_HK" Control="Next" Event="NewDialog" Value="InstallDirDlg">LicenseAccepted = "1"</Publish>

<Publish Dialog="InstallDirDlg" Control="Back" Event="NewDialog" Value="LicenseAgreementDlg_HK">1</Publish>
<Publish Dialog="InstallDirDlg" Control="Next" Event="SetTargetPath" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
<Publish Dialog="InstallDirDlg" Control="Next" Event="DoAction" Value="WixUIValidatePath" Order="2">NOT WIXUI_DONTVALIDATEPATH</Publish>
<Publish Dialog="InstallDirDlg" Control="Next" Event="SpawnDialog" Value="InvalidDirDlg" Order="3"><![CDATA[NOT WIXUI_DONTVALIDATEPATH AND WIXUI_INSTALLDIR_VALID<>"1"]]></Publish>
<Publish Dialog="InstallDirDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" Order="4">WIXUI_DONTVALIDATEPATH OR WIXUI_INSTALLDIR_VALID="1"</Publish>

<Publish Dialog="InstallDirDlg" Control="ChangeFolder" Property="_BrowseProperty" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
<Publish Dialog="InstallDirDlg" Control="ChangeFolder" Event="SpawnDialog" Value="BrowseDlg" Order="2">1</Publish>

<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="2">Installed</Publish>

<Publish Dialog="MaintenanceWelcomeDlg" Control="Next" Event="NewDialog" Value="MaintenanceTypeDlg">1</Publish>

<Publish Dialog="MaintenanceTypeDlg" Control="RepairButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
<Publish Dialog="MaintenanceTypeDlg" Control="RemoveButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
<Publish Dialog="MaintenanceTypeDlg" Control="Back" Event="NewDialog" Value="MaintenanceWelcomeDlg">1</Publish>
</UI>

<UIRef Id="WixUI_Common" />
</Fragment>
</Wix>
139 changes: 139 additions & 0 deletions installers/windows/templates/product.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
<?xml version="1.0"?>

<?if $(sys.BUILDARCH)="x86"?>
<?define Program_Files="ProgramFilesFolder"?>
<?elseif $(sys.BUILDARCH)="x64"?>
<?define Program_Files="ProgramFiles64Folder"?>
<?else?>
<?error Unsupported value of sys.BUILDARCH=$(sys.BUILDARCH)?>
<?endif?>

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">

<Product Id="*" UpgradeCode="{{.UpgradeCode}}"
Name="{{.Product}}"
Version="{{.VersionOk}}"
Manufacturer="{{.Company}}"
Language="1033">

<Package InstallerVersion="200" Compressed="yes" Comments="Windows Installer Package" InstallScope="perMachine"/>

<Media Id="1" Cabinet="product.cab" EmbedCab="yes"/>

<Upgrade Id="{{.UpgradeCode}}">
<UpgradeVersion Minimum="{{.VersionOk}}" OnlyDetect="yes" Property="NEWERVERSIONDETECTED"/>
<UpgradeVersion Minimum="0.0.0" Maximum="{{.VersionOk}}" IncludeMinimum="yes" IncludeMaximum="no"
Property="OLDERVERSIONBEINGUPGRADED"/>
</Upgrade>
<Condition Message="A newer version of this software is already installed.">NOT NEWERVERSIONDETECTED</Condition>

<Directory Id="TARGETDIR" Name="SourceDir">

<Directory Id="$(var.Program_Files)">
<Directory Id="INSTALLDIR" Name="{{.Product}}">
{{if gt (.Files.Items | len) 0}}
<Component Id="ApplicationFiles" Guid="{{.Files.GUID}}">
{{range $i, $e := .Files.Items}}
<File Id="ApplicationFile{{$i}}" Source="{{$e}}"/>
{{end}}
</Component>
{{end}}
{{if gt (.Directories | len) 0}}
{{range $i, $e := .Directories}}
<Directory Id="APPDIR{{$i}}" Name="{{$e}}" />
{{end}}
{{end}}
</Directory>
</Directory>

{{if gt (.Env.Vars | len) 0}}
<Component Id="ENVS" Guid="{{.Env.GUID}}">
{{range $i, $e := .Env.Vars}}
<Environment Id="ENV{{$i}}"
Name="{{$e.Name}}"
Value="{{$e.Value}}"
Permanent="{{$e.Permanent}}"
Part="{{$e.Part}}"
Action="{{$e.Action}}"
System="{{$e.System}}" />
{{end}}
</Component>
{{end}}

{{if gt (.Shortcuts.Items | len) 0}}
<Directory Id="ProgramMenuFolder">
<Directory Id="ProgramMenuSubfolder" Name="{{.Product}}">
<Component Id="ApplicationShortcuts" Guid="{{.Shortcuts.GUID}}">
{{range $i, $e := .Shortcuts.Items}}
<Shortcut Id="ApplicationShortcut{{$i}}"
Name="{{$e.Name}}"
Description="{{$e.Description}}"
Target="{{$e.Target}}"
WorkingDirectory="{{$e.WDir}}"
{{if gt ($e.Arguments | len) 0}}
Arguments="{{$e.Arguments}}"
{{end}}
>
{{if gt ($e.Icon | len) 0}}
<Icon Id="Icon{{$i}}" SourceFile="{{$e.Icon}}" />
{{end}}
</Shortcut>
<RegistryValue Root="HKCU"
Key="Software\{{$.Company}}\{{$.Product}}"
Name="installed{{$i}}"
Type="integer" Value="1" KeyPath="yes"/>
{{end}}
<RemoveFolder Id="ProgramMenuSubfolder" On="uninstall"/>
</Component>
</Directory>
</Directory>
{{end}}

</Directory>

{{range $i, $e := .InstallHooks}}
<SetProperty Id="CustomInstallExec{{$i}}" Value="{{$e.CookedCommand}}" Before="CustomInstallExec{{$i}}" Sequence="execute"/>
<CustomAction Id="CustomInstallExec{{$i}}" BinaryKey="WixCA" DllEntry="WixQuietExec" Execute="deferred" Return="check" Impersonate="no"/>
{{end}}
{{range $i, $e := .UninstallHooks}}
<SetProperty Id="CustomUninstallExec{{$i}}" Value="{{$e.CookedCommand}}" Before="CustomUninstallExec{{$i}}" Sequence="execute"/>
<CustomAction Id="CustomUninstallExec{{$i}}" BinaryKey="WixCA" DllEntry="WixQuietExec" Execute="deferred" Return="check" Impersonate="no"/>
{{end}}
<InstallExecuteSequence>
<RemoveExistingProducts After="InstallValidate"/>
{{range $i, $e := .InstallHooks}}
<Custom Action="CustomInstallExec{{$i}}" After="{{if eq $i 0}}InstallFiles{{else}}CustomInstallExec{{dec $i}}{{end}}">NOT Installed AND NOT REMOVE</Custom>
{{end}}
{{range $i, $e := .UninstallHooks}}
<Custom Action="CustomUninstallExec{{$i}}" After="{{if eq $i 0}}InstallInitialize{{else}}CustomUninstallExec{{dec $i}}{{end}}">REMOVE ~= "ALL"</Custom>
{{end}}
</InstallExecuteSequence>

<Feature Id="DefaultFeature" Level="1">
{{if gt (.Env.Vars | len) 0}}
<ComponentRef Id="ENVS"/>
{{end}}
{{if gt (.Files.Items | len) 0}}
<ComponentRef Id="ApplicationFiles"/>
{{end}}
{{if gt (.Shortcuts.Items | len) 0}}
<ComponentRef Id="ApplicationShortcuts"/>
{{end}}
{{range $i, $e := .Directories}}
<ComponentGroupRef Id="AppFiles{{$i}}" />
{{end}}
</Feature>

<UI>
<!-- Define the installer UI -->
<UIRef Id="WixUI_HK" />
</UI>

<Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" />

<!-- this should help to propagate env var changes -->
<CustomActionRef Id="WixBroadcastEnvironmentChange" />

</Product>

</Wix>
49 changes: 49 additions & 0 deletions installers/windows/wix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"product": "skaffold",
"company": "Google",
"license": "../../LICENSE",
"upgrade-code": "41137530-0334-40af-9088-dd946657dd01",
"files": {
"guid": "507b0333-b1c3-4c9f-a4f0-2425cd5b9176",
"items": [
"../../out/skaffold.exe"
]
},
"directories": [
],
"env": {
"guid": "413fa49f-614f-4af4-a00b-f5f4ea9b1ff2",
"vars": [
{
"name": "PATH",
"value": "[INSTALLDIR]",
"permanent": "no",
"system": "no",
"action": "set",
"part": "last"
}
]
},
"shortcuts": {
"guid": "923eee34-9ef5-492a-90ce-87cfd318ee45",
"items": [
{
"name": "skaffold",
"description": "Repeatable kubernetes development",
"target": "[INSTALLDIR]\\skaffold.exe",
"wdir": "INSTALLDIR",
"arguments": "",
"icon": ""
}
]
},
"hooks": [
{"when": "install", "command": "setx path \"%path%;[INSTALLDIR]\""},
{"when": "uninstall", "command": "setx path \"%path:[INSTALLDIR];=%\""}
],
"choco": {
"description": "Fast. Repeatable. Simple. Local Kubernetes Development",
"project-url": "https://github.com/GoogleContainerTools/skaffold",
"license-url": "https://github.com/GoogleContainerTools/skaffold/blob/master/LICENSE"
}
}
3 changes: 2 additions & 1 deletion pkg/skaffold/schema/profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func activatedProfiles(profiles []latest.Profile, opts cfg.SkaffoldOptions) ([]s
contextSpecificProfiles = append(contextSpecificProfiles, profile.Name)
}
activated = append(activated, profile.Name)
break
}
}
}
Expand All @@ -113,7 +114,7 @@ func activatedProfiles(profiles []latest.Profile, opts cfg.SkaffoldOptions) ([]s
for _, profile := range opts.Profiles {
if strings.HasPrefix(profile, "-") {
activated = removeValue(activated, strings.TrimPrefix(profile, "-"))
} else {
} else if !skutil.StrSliceContains(activated, profile) {
activated = append(activated, profile)
}
}
Expand Down
14 changes: 14 additions & 0 deletions pkg/skaffold/schema/profiles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,20 @@ func TestActivatedProfiles(t *testing.T) {
{Name: "regex-activated-substring-match", Activation: []latest.Activation{{Env: "KEY=^VAL"}}},
},
expected: []string{"activated", "also-activated", "regex-activated", "regex-activated-two", "regex-activated-substring-match"},
}, {
description: "Profile with multiple valid activations",
envs: map[string]string{"KEY": "VALUE"},
opts: cfg.SkaffoldOptions{
ProfileAutoActivation: true,
Command: "dev",
Profiles: []string{"activated", "also-activated"},
},
profiles: []latest.Profile{
{Name: "activated", Activation: []latest.Activation{{Env: "KEY=VALUE"}, {Command: "dev"}}},
{Name: "not-activated", Activation: []latest.Activation{{Env: "KEY=OTHER"}}},
{Name: "also-activated", Activation: []latest.Activation{{Env: "KEY=!OTHER"}}},
},
expected: []string{"activated", "also-activated"},
}, {
description: "Invalid env variable",
envs: map[string]string{"KEY": "VALUE"},
Expand Down

0 comments on commit 15d800f

Please sign in to comment.