|
| 1 | +public class BuildCredentials |
| 2 | +{ |
| 3 | + public GitHubCredentials GitHub { get; private set; } |
| 4 | + public GitterCredentials Gitter { get; private set; } |
| 5 | + public DockerHubCredentials Docker { get; private set; } |
| 6 | + public NugetCredentials Nuget { get; private set; } |
| 7 | + public ChocolateyCredentials Chocolatey { get; private set; } |
| 8 | + public TfxCredentials Tfx { get; private set; } |
| 9 | + public RubyGemCredentials RubyGem { get; private set; } |
| 10 | + public CodeCovCredentials CodeCov { get; private set; } |
| 11 | + |
| 12 | + public static BuildCredentials GetCredentials(ICakeContext context) |
| 13 | + { |
| 14 | + return new BuildCredentials |
| 15 | + { |
| 16 | + GitHub = GitHubCredentials.GetGitHubCredentials(context), |
| 17 | + Gitter = GitterCredentials.GetGitterCredentials(context), |
| 18 | + Docker = DockerHubCredentials.GetDockerHubCredentials(context), |
| 19 | + Nuget = NugetCredentials.GetNugetCredentials(context), |
| 20 | + Chocolatey = ChocolateyCredentials.GetChocolateyCredentials(context), |
| 21 | + Tfx = TfxCredentials.GetTfxCredentials(context), |
| 22 | + RubyGem = RubyGemCredentials.GetRubyGemCredentials(context), |
| 23 | + CodeCov = CodeCovCredentials.GetCodeCovCredentials(context), |
| 24 | + }; |
| 25 | + } |
| 26 | +} |
| 27 | + |
| 28 | +public class GitHubCredentials |
| 29 | +{ |
| 30 | + public string UserName { get; private set; } |
| 31 | + public string Password { get; private set; } |
| 32 | + public string Token { get; private set; } |
| 33 | + |
| 34 | + public GitHubCredentials(string userName, string password, string token) |
| 35 | + { |
| 36 | + UserName = userName; |
| 37 | + Password = password; |
| 38 | + Token = token; |
| 39 | + } |
| 40 | + |
| 41 | + public static GitHubCredentials GetGitHubCredentials(ICakeContext context) |
| 42 | + { |
| 43 | + return new GitHubCredentials( |
| 44 | + context.EnvironmentVariable("GITHUB_USERNAME"), |
| 45 | + context.EnvironmentVariable("GITHUB_PASSWORD"), |
| 46 | + context.EnvironmentVariable("GITHUB_TOKEN")); |
| 47 | + } |
| 48 | +} |
| 49 | + |
| 50 | +public class GitterCredentials |
| 51 | +{ |
| 52 | + public string Token { get; private set; } |
| 53 | + public string RoomId { get; private set; } |
| 54 | + |
| 55 | + public GitterCredentials(string token, string roomId) |
| 56 | + { |
| 57 | + Token = token; |
| 58 | + RoomId = roomId; |
| 59 | + } |
| 60 | + |
| 61 | + public static GitterCredentials GetGitterCredentials(ICakeContext context) |
| 62 | + { |
| 63 | + return new GitterCredentials( |
| 64 | + context.EnvironmentVariable("GITTER_TOKEN"), |
| 65 | + context.EnvironmentVariable("GITTER_ROOM_ID") |
| 66 | + ); |
| 67 | + } |
| 68 | +} |
| 69 | + |
| 70 | +public class DockerHubCredentials |
| 71 | +{ |
| 72 | + public string UserName { get; private set; } |
| 73 | + public string Password { get; private set; } |
| 74 | + |
| 75 | + public DockerHubCredentials(string userName, string password) |
| 76 | + { |
| 77 | + UserName = userName; |
| 78 | + Password = password; |
| 79 | + } |
| 80 | + |
| 81 | + public static DockerHubCredentials GetDockerHubCredentials(ICakeContext context) |
| 82 | + { |
| 83 | + return new DockerHubCredentials( |
| 84 | + context.EnvironmentVariable("DOCKER_USERNAME"), |
| 85 | + context.EnvironmentVariable("DOCKER_PASSWORD")); |
| 86 | + } |
| 87 | +} |
| 88 | + |
| 89 | +public class NugetCredentials |
| 90 | +{ |
| 91 | + public string ApiKey { get; private set; } |
| 92 | + public string ApiUrl { get; private set; } |
| 93 | + |
| 94 | + public NugetCredentials(string apiKey, string apiUrl) |
| 95 | + { |
| 96 | + ApiKey = apiKey; |
| 97 | + ApiUrl = apiUrl; |
| 98 | + } |
| 99 | + |
| 100 | + public static NugetCredentials GetNugetCredentials(ICakeContext context) |
| 101 | + { |
| 102 | + return new NugetCredentials( |
| 103 | + context.EnvironmentVariable("NUGET_API_KEY"), |
| 104 | + context.EnvironmentVariable("NUGET_API_URL")); |
| 105 | + } |
| 106 | +} |
| 107 | + |
| 108 | +public class ChocolateyCredentials |
| 109 | +{ |
| 110 | + public string ApiKey { get; private set; } |
| 111 | + public string ApiUrl { get; private set; } |
| 112 | + |
| 113 | + public ChocolateyCredentials(string apiKey, string apiUrl) |
| 114 | + { |
| 115 | + ApiKey = apiKey; |
| 116 | + ApiUrl = apiUrl; |
| 117 | + } |
| 118 | + |
| 119 | + public static ChocolateyCredentials GetChocolateyCredentials(ICakeContext context) |
| 120 | + { |
| 121 | + return new ChocolateyCredentials( |
| 122 | + context.EnvironmentVariable("CHOCOLATEY_API_KEY"), |
| 123 | + context.EnvironmentVariable("CHOCOLATEY_API_URL")); |
| 124 | + } |
| 125 | +} |
| 126 | + |
| 127 | +public class TfxCredentials |
| 128 | +{ |
| 129 | + public string Token { get; private set; } |
| 130 | + |
| 131 | + public TfxCredentials(string token) |
| 132 | + { |
| 133 | + Token = token; |
| 134 | + } |
| 135 | + |
| 136 | + public static TfxCredentials GetTfxCredentials(ICakeContext context) |
| 137 | + { |
| 138 | + return new TfxCredentials(context.EnvironmentVariable("TFX_TOKEN")); |
| 139 | + } |
| 140 | +} |
| 141 | + |
| 142 | +public class RubyGemCredentials |
| 143 | +{ |
| 144 | + public string ApiKey { get; private set; } |
| 145 | + |
| 146 | + public RubyGemCredentials(string apiKey) |
| 147 | + { |
| 148 | + ApiKey = apiKey; |
| 149 | + } |
| 150 | + |
| 151 | + public static RubyGemCredentials GetRubyGemCredentials(ICakeContext context) |
| 152 | + { |
| 153 | + return new RubyGemCredentials(context.EnvironmentVariable("RUBY_GEM_API_KEY")); |
| 154 | + } |
| 155 | +} |
| 156 | + |
| 157 | +public class CodeCovCredentials |
| 158 | +{ |
| 159 | + public string Token { get; private set; } |
| 160 | + |
| 161 | + public CodeCovCredentials(string token) |
| 162 | + { |
| 163 | + Token = token; |
| 164 | + } |
| 165 | + |
| 166 | + public static CodeCovCredentials GetCodeCovCredentials(ICakeContext context) |
| 167 | + { |
| 168 | + return new CodeCovCredentials(context.EnvironmentVariable("CODECOV_TOKEN")); |
| 169 | + } |
| 170 | +} |
0 commit comments