Skip to content
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

Fixes #13054: License incorrectly interpreted in several plugins #81

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api-authorizations/build.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ for API tokens.</p>"""
# - x.y(.z): plugin major.minor.micro. Micro should be omitted. When omitted, z is assumed to be 0.
# For the build, we split the information between two properties, rudder branch and plugin version,
# which must be concaneted with "-" to build the plugin version.
plugin-branch=1.1-SNAPSHOT
plugin-branch=1.1

# rudder branch comes from parent
plugin-version=${rudder-branch}-${plugin-branch}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ object ApiAuthorizationsConf {
lazy val pluginStatusService = new CheckRudderPluginEnableImpl()

// override default service level
RudderConfig.apiAuthorizationLevelService.overrideLevel(AclLevel)
if(pluginStatusService.isEnabled) {
RudderConfig.apiAuthorizationLevelService.overrideLevel(AclLevel)
}

lazy val userApi = new UserApi(
RudderConfig.restExtractorService
Expand All @@ -80,8 +82,8 @@ object ApiAuthorizationsConf {
class ApiAuthorizationPluginConf extends Loggable with ApplicationContextAware with InitializingBean {
@Bean def apiAuthorizationsModuleDef = new ApiAuthorizationsPluginDef(ApiAuthorizationsConf.pluginStatusService)

@Bean def apiAccountsExtention = new ApiAccountsExtension()
@Bean def userInformationExtention = new UserInformationExtension()
@Bean def apiAccountsExtention = new ApiAccountsExtension(ApiAuthorizationsConf.pluginStatusService)
@Bean def userInformationExtention = new UserInformationExtension(ApiAuthorizationsConf.pluginStatusService)

// spring thingies
var appContext : ApplicationContext = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
package com.normation.plugins.apiauthorizations

import bootstrap.liftweb.PluginsInfo
import com.normation.plugins.PluginStatus
import com.normation.plugins.{SnippetExtensionKey, SnippetExtensionPoint}
import com.normation.rudder.rest.AllApi
import com.normation.rudder.rest.ApiKind
Expand All @@ -47,14 +48,16 @@ import net.liftweb.util.Helpers._

import scala.xml.NodeSeq

class ApiAccountsExtension extends SnippetExtensionPoint[ApiAccounts] with Loggable {
class ApiAccountsExtension(status: PluginStatus) extends SnippetExtensionPoint[ApiAccounts] with Loggable {

val extendsAt = SnippetExtensionKey(classOf[ApiAccounts].getSimpleName)

def guard(f: NodeSeq => NodeSeq)(xml: NodeSeq): NodeSeq = if(status.isEnabled()) f(xml) else xml

def compose(snippet: ApiAccounts) : Map[String, NodeSeq => NodeSeq] = Map(
"render" -> render _
"render" -> render _
, "body" -> body _
)
).mapValues(guard _)


/*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
package com.normation.plugins.apiauthorizations

import com.normation.plugins.PluginStatus
import com.normation.plugins.{SnippetExtensionKey, SnippetExtensionPoint}
import com.normation.rudder.web.snippet.UserInformation
import net.liftweb.common.Loggable
import net.liftweb.util.Helpers._

import scala.xml.NodeSeq

class UserInformationExtension extends SnippetExtensionPoint[UserInformation] with Loggable {
class UserInformationExtension(status: PluginStatus) extends SnippetExtensionPoint[UserInformation] with Loggable {

val extendsAt = SnippetExtensionKey(classOf[UserInformation].getSimpleName)

def guard(f: NodeSeq => NodeSeq)(xml: NodeSeq): NodeSeq = if(status.isEnabled()) f(xml) else xml

def compose(snippet: UserInformation) : Map[String, NodeSeq => NodeSeq] = Map(
"userCredentials" -> render _
)
).mapValues(guard _)

def render(xml:NodeSeq) = {
/* xml is a menu entry which looks like:
Expand Down
2 changes: 1 addition & 1 deletion branding/build.conf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ plugin-web-description="""<p>
# - x.y(.z): plugin major.minor.micro. Micro should be omitted. When omitted, z is assumed to be 0.
# For the build, we split the information between two properties, rudder branch and plugin version,
# which must be concaneted with "-" to build the plugin version.
plugin-branch=1.2-SNAPSHOT
plugin-branch=1.2

# rudder branch comes from parent
plugin-version=${rudder-branch}-${plugin-branch}
24 changes: 0 additions & 24 deletions branding/src/main/assembly/plugin-with-own-dependencies.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ class BrandingPluginConf extends Loggable with ApplicationContextAware with Init
// spring thingies
var appContext : ApplicationContext = null

val commonBranding = new CommonBranding
val loginBranding = new LoginBranding
@Bean def commonBranding = new CommonBranding(BrandingPluginConf.pluginStatusService)
@Bean def loginBranding = new LoginBranding(BrandingPluginConf.pluginStatusService, brandingModuleDef.version)
override def afterPropertiesSet() : Unit = {
val ext = appContext.getBean(classOf[SnippetExtensionRegister])
ext.register(commonBranding)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,21 @@ import net.liftweb.common.{Full, Loggable}
import net.liftweb.util._
import Helpers._
import bootstrap.rudder.plugin.BrandingPluginConf
import com.normation.plugins.PluginStatus

import scala.xml.NodeSeq



class CommonBranding extends SnippetExtensionPoint[CommonLayout] with Loggable {
class CommonBranding(status: PluginStatus) extends SnippetExtensionPoint[CommonLayout] with Loggable {

val extendsAt = SnippetExtensionKey(classOf[CommonLayout].getSimpleName)

def guard(f: NodeSeq => NodeSeq)(xml: NodeSeq): NodeSeq = if(status.isEnabled()) f(xml) else xml

def compose(snippet:CommonLayout) : Map[String, NodeSeq => NodeSeq] = Map(
"display" -> display _
)
).mapValues(guard _)

private [this] val confRepo = BrandingPluginConf.brandingConfService

Expand All @@ -74,7 +77,6 @@ class CommonBranding extends SnippetExtensionPoint[CommonLayout] with Loggable
case _ => NodeSeq.Empty
}
("* -*" #> bar).apply(xml)

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
package com.normation.plugins.branding.snippet

import bootstrap.rudder.plugin.BrandingPluginConf
import com.normation.plugins.PluginStatus
import com.normation.plugins.PluginVersion
import com.normation.plugins.{SnippetExtensionKey, SnippetExtensionPoint}
import com.normation.rudder.web.snippet.Login
import net.liftweb.common.{Full, Loggable}
Expand All @@ -47,12 +49,15 @@ import net.liftweb.util.Helpers._
import scala.xml.NodeSeq


class LoginBranding extends SnippetExtensionPoint[Login] with Loggable {
class LoginBranding(status: PluginStatus, version: PluginVersion) extends SnippetExtensionPoint[Login] with Loggable {

val extendsAt = SnippetExtensionKey(classOf[Login].getSimpleName)

def guard(f: NodeSeq => NodeSeq)(xml: NodeSeq): NodeSeq = if(status.isEnabled()) f(xml) else xml

def compose(snippet:Login) : Map[String, NodeSeq => NodeSeq] = Map(
"display" -> display _)
"display" -> display _
).mapValues(guard _)


private [this] val confRepo = BrandingPluginConf.brandingConfService
Expand All @@ -61,7 +66,7 @@ class LoginBranding extends SnippetExtensionPoint[Login] with Loggable {
val legend =
<p class="legend col-xs-12">
<img src="/images/login/logo-rudder.svg" data-lift="with-cached-resource" alt="Rudder"></img>
<span>${{rudder-major-version}}</span>
<span>{version.prefix.replaceAll("-", "")}</span>
</p>
val bar = data match {
case Full(data) if (data.displayBarLogin) =>
Expand Down Expand Up @@ -94,7 +99,5 @@ class LoginBranding extends SnippetExtensionPoint[Login] with Loggable {
( ".legend" #> legendBar &
".welcome *" #> motd
) (xml)

}

}
2 changes: 1 addition & 1 deletion node-external-reports/build.conf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ plugin-web-description=<p>This is a plugin that allows to disaply external text
# - x.y(.z): plugin major.minor.micro. Micro should be omitted. When omitted, z is assumed to be 0.
# For the build, we split the information between two properties, rudder branch and plugin version,
# which must be concaneted with "-" to build the plugin version.
plugin-branch=1.6-SNAPSHOT
plugin-branch=1.6

# rudder branch comes from parent
plugin-version=${rudder-branch}-${plugin-branch}
Expand Down
4 changes: 4 additions & 0 deletions node-external-reports/pom-template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
of report available for the node.
</description>

<properties>
<destDirectory>nodeexternalreports</destDirectory>
</properties>

<build>
<plugins>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,6 @@ class NodeExternalReportsPluginConf extends Loggable with ApplicationContextAwar

@Bean def nodeExternalReportDef = new NodeExternalReportsPluginDef(externalNodeReportApi, NodeExternalReportsConf.pluginStatusService)

@Bean def tabExtension = new CreateNodeDetailsExtension(readReport)
@Bean def tabExtension = new CreateNodeDetailsExtension(readReport, NodeExternalReportsConf.pluginStatusService)

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@

package com.normation.plugins.nodeexternalreports.extension

import com.normation.plugins.PluginStatus

import scala.xml.NodeSeq
import com.normation.plugins.{SnippetExtensionKey, SnippetExtensionPoint}
import com.normation.rudder.web.components.ShowNodeDetailsFromNode
Expand All @@ -45,14 +47,16 @@ import net.liftweb.util.Helpers._
import com.normation.plugins.nodeexternalreports.service.ReadExternalReports
import com.normation.plugins.nodeexternalreports.service.NodeExternalReport

class CreateNodeDetailsExtension(externalReport: ReadExternalReports) extends SnippetExtensionPoint[ShowNodeDetailsFromNode] with Loggable {
class CreateNodeDetailsExtension(externalReport: ReadExternalReports, status: PluginStatus) extends SnippetExtensionPoint[ShowNodeDetailsFromNode] with Loggable {

val extendsAt = SnippetExtensionKey(classOf[ShowNodeDetailsFromNode].getSimpleName)

def guard(f: NodeSeq => NodeSeq)(xml: NodeSeq): NodeSeq = if(status.isEnabled()) f(xml) else xml

def compose(snippet: ShowNodeDetailsFromNode) : Map[String, NodeSeq => NodeSeq] = Map(
"popupDetails" -> addExternalReportTab(snippet) _
, "mainDetails" -> addExternalReportTab(snippet) _
)
"popupDetails" -> addExternalReportTab(snippet) _
, "mainDetails" -> addExternalReportTab(snippet) _
).mapValues(guard _)

/**
* Add a tab:
Expand Down