@ -1,18 +1,22 @@
import angular from 'angular' ;
import { FeatureId } from '@/react/portainer/feature-flags/enums' ;
// import trackEvent directly because the event only fires once with $analytics.trackEvent
import { trackEvent } from '@/angulartics.matomo/analytics-services' ;
import { options } from './options' ;
angular . module ( 'portainer.app' ) . controller ( 'SettingsController' , [
'$scope' ,
'$analytics' ,
'$state' ,
'Notifications' ,
'SettingsService' ,
'ModalService' ,
'StateManager' ,
'BackupService' ,
'FileSaver' ,
'Blob' ,
function ( $scope , $ state, Notifications , Settings Service, StateManager , BackupService , FileSaver ) {
function ( $scope , $ analytics, $ state, Notifications , Settings Service, Modal Service, StateManager , BackupService , FileSaver ) {
$scope . customBannerFeatureId = FeatureId . CUSTOM _LOGIN _BANNER ;
$scope . s3BackupFeatureId = FeatureId . S3 _BACKUP _SETTING ;
$scope . enforceDeploymentOptions = FeatureId . ENFORCE _DEPLOYMENT _OPTIONS ;
@ -53,6 +57,7 @@ angular.module('portainer.app').controller('SettingsController', [
$scope . formValues = {
customLogo : false ,
ShowKomposeBuildOption : false ,
KubeconfigExpiry : undefined ,
HelmRepositoryURL : undefined ,
BlackListedLabels : [ ] ,
@ -64,6 +69,8 @@ angular.module('portainer.app').controller('SettingsController', [
backupFormType : $scope . BACKUP _FORM _TYPES . FILE ,
} ;
$scope . initialFormValues = { } ;
$scope . onToggleEnableTelemetry = function onToggleEnableTelemetry ( checked ) {
$scope . $evalAsync ( ( ) => {
$scope . formValues . enableTelemetry = checked ;
@ -76,6 +83,33 @@ angular.module('portainer.app').controller('SettingsController', [
} ) ;
} ;
$scope . onToggleShowKompose = async function onToggleShowKompose ( checked ) {
if ( checked ) {
ModalService . confirmWarn ( {
title : 'Are you sure?' ,
message : ` <p>In a forthcoming Portainer release, we plan to remove support for docker-compose format manifests for Kubernetes deployments, and the Kompose conversion tool which enables this. The reason for this is because Kompose now poses a security risk, since it has a number of Common Vulnerabilities and Exposures (CVEs).</p>
< p > Unfortunately , while the Kompose project has a maintainer and is part of the CNCF , it is not being actively maintained . Releases are very infrequent and new pull requests to the project ( including ones we ' ve submitted ) are taking months to be merged , with new CVEs arising in the meantime . < / p > ` ,
buttons : {
confirm : {
label : 'Ok' ,
className : 'btn-warning' ,
} ,
} ,
callback : function ( confirmed ) {
$scope . setShowCompose ( confirmed ) ;
} ,
} ) ;
return ;
}
$scope . setShowCompose ( checked ) ;
} ;
$scope . setShowCompose = function setShowCompose ( checked ) {
return $scope . $evalAsync ( ( ) => {
$scope . formValues . ShowKomposeBuildOption = checked ;
} ) ;
} ;
$scope . onToggleAutoBackups = function onToggleAutoBackups ( checked ) {
$scope . $evalAsync ( ( ) => {
$scope . formValues . scheduleAutomaticBackups = checked ;
@ -152,8 +186,13 @@ angular.module('portainer.app').controller('SettingsController', [
KubeconfigExpiry : $scope . formValues . KubeconfigExpiry ,
HelmRepositoryURL : $scope . formValues . HelmRepositoryURL ,
GlobalDeploymentOptions : $scope . formValues . GlobalDeploymentOptions ,
ShowKomposeBuildOption : $scope . formValues . ShowKomposeBuildOption ,
} ;
if ( kubeSettingsPayload . ShowKomposeBuildOption !== $scope . initialFormValues . ShowKomposeBuildOption && $scope . initialFormValues . enableTelemetry ) {
trackEvent ( 'kubernetes-allow-compose' , { category : 'kubernetes' , metadata : { 'kubernetes-allow-compose' : kubeSettingsPayload . ShowKomposeBuildOption } } ) ;
}
$scope . state . kubeSettingsActionInProgress = true ;
updateSettings ( kubeSettingsPayload , 'Kubernetes settings updated' ) ;
} ;
@ -165,6 +204,8 @@ angular.module('portainer.app').controller('SettingsController', [
StateManager . updateLogo ( settings . LogoURL ) ;
StateManager . updateSnapshotInterval ( settings . SnapshotInterval ) ;
StateManager . updateEnableTelemetry ( settings . EnableTelemetry ) ;
$scope . initialFormValues . ShowKomposeBuildOption = response . ShowKomposeBuildOption ;
$scope . initialFormValues . enableTelemetry = response . EnableTelemetry ;
$scope . formValues . BlackListedLabels = response . BlackListedLabels ;
} )
. catch ( function error ( err ) {
@ -193,6 +234,12 @@ angular.module('portainer.app').controller('SettingsController', [
$scope . formValues . KubeconfigExpiry = settings . KubeconfigExpiry ;
$scope . formValues . HelmRepositoryURL = settings . HelmRepositoryURL ;
$scope . formValues . BlackListedLabels = settings . BlackListedLabels ;
if ( settings . ShowKomposeBuildOption ) {
$scope . formValues . ShowKomposeBuildOption = settings . ShowKomposeBuildOption ;
}
$scope . initialFormValues . ShowKomposeBuildOption = settings . ShowKomposeBuildOption ;
$scope . initialFormValues . enableTelemetry = settings . EnableTelemetry ;
} )
. catch ( function error ( err ) {
Notifications . error ( 'Failure' , err , 'Unable to retrieve application settings' ) ;