Skip to content

Commit

Permalink
Remove Port from ServerHealth plugin - actually it was moved from Ser…
Browse files Browse the repository at this point in the history
…verSubject to JenkinsProject, so that it does not show for ServerHealth.
  • Loading branch information
krzysztof-lorenc committed Apr 12, 2019
1 parent 22e23b0 commit 9f8bac1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 29 deletions.
21 changes: 18 additions & 3 deletions src/Soloplan.WhatsON.Jenkins/JenkinsProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
[SubjectType("Jenkins Project Status", Description = "Retrieve the current status of a Jenkins project.")]
[ConfigurationItem(ProjectName, typeof(string), Optional = false, Priority = 300)]
[ConfigurationItem(RedirectPlugin, typeof(bool), Priority = 400)] // defines use of Display URL API Plugin https://wiki.jenkins.io/display/JENKINS/Display+URL+API+Plugin
[ConfigurationItem(ServerPort, typeof(int), Priority = 200)]
public class JenkinsProject : ServerSubject
{
public const string ProjectName = "ProjectName";
Expand All @@ -18,6 +19,11 @@ public class JenkinsProject : ServerSubject
/// </summary>
public const string RedirectPlugin = "RedirectPlugin";

/// <summary>
/// The server port.
/// </summary>
public const string ServerPort = "Port";

/// <summary>
/// API class for accessing Jenkins.
/// </summary>
Expand All @@ -36,12 +42,10 @@ public JenkinsProject(SubjectConfiguration configuration, IJenkinsApi api)

public string Project => this.GetProject();

private JenkinsStatus PreviousCheckStatus { get; set; }

/// <summary>
/// Gets the port number.
/// </summary>
public override int Port
public int Port
{
get
{
Expand All @@ -55,6 +59,8 @@ public override int Port
}
}

private JenkinsStatus PreviousCheckStatus { get; set; }

/// <summary>
/// Gets the project.
/// </summary>
Expand All @@ -64,6 +70,15 @@ public string GetProject()
return this.SubjectConfiguration.GetConfigurationByKey(JenkinsProject.ProjectName).Value;
}

/// <summary>
/// Gets the port.
/// </summary>
/// <returns>The port number.</returns>
public string GetPort()
{
return this.SubjectConfiguration.GetConfigurationByKey(ServerPort).Value;
}

protected override async Task ExecuteQuery(CancellationToken cancellationToken, params string[] args)
{
var job = await this.api.GetJenkinsJob(this, cancellationToken);
Expand Down
21 changes: 0 additions & 21 deletions src/Soloplan.WhatsON.ServerBase/ServerSubject.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
namespace Soloplan.WhatsON.ServerBase
{
[ConfigurationItem(ServerAddress, typeof(string), Optional = false, Priority = 100)]
[ConfigurationItem(ServerPort, typeof(int), Priority = 200)]
public abstract class ServerSubject : Subject
{
public const string ServerAddress = "Address";
public const string ServerPort = "Port";

/// <summary>
/// Initializes a new instance of the <see cref="ServerSubject"/> class.
Expand All @@ -24,24 +22,5 @@ public string Address
get => this.SubjectConfiguration.GetConfigurationByKey(ServerAddress).Value;
set => this.SubjectConfiguration.GetConfigurationByKey(ServerAddress).Value = value;
}

/// <summary>
/// Gets or sets the port.
/// </summary>
public virtual int Port
{
get
{
var configItem = this.SubjectConfiguration.GetConfigurationByKey(ServerPort);
if (configItem != null)
{
return int.TryParse(configItem.Value, out var port) ? port : 0;
}

return 0;
}

set => this.SubjectConfiguration.GetConfigurationByKey(ServerPort).Value = value.ToString();
}
}
}
5 changes: 0 additions & 5 deletions src/Soloplan.WhatsON.ServerBase/SubjectExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,5 @@ public static string GetAddress(this ServerSubject subject)
{
return subject.SubjectConfiguration.GetConfigurationByKey(ServerSubject.ServerAddress).Value;
}

public static string GetPort(this ServerSubject subject)
{
return subject.SubjectConfiguration.GetConfigurationByKey(ServerSubject.ServerPort).Value;
}
}
}

0 comments on commit 9f8bac1

Please sign in to comment.