Skip to content

Commit f47e930

Browse files
makingadriancole
authored andcommitted
Replace banner.txt with new logo (#2738)
1 parent 644bb0f commit f47e930

File tree

9 files changed

+251
-28
lines changed

9 files changed

+251
-28
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@
654654
<exclude>**/test/data/**/*.json</exclude>
655655
<exclude>LICENSE</exclude>&gt;
656656
<exclude>**/*.md</exclude>
657-
<exclude>**/src/main/resources/banner.txt</exclude>
657+
<exclude>**/src/main/resources/zipkin.txt</exclude>
658658
<exclude>**/src/main/resources/*.yml</exclude>
659659
<exclude>**/spring.factories</exclude>
660660
<!-- Cassandra integration tests break when license headers are present -->

zipkin-server/src/main/java/zipkin/server/ZipkinServer.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.springframework.boot.builder.SpringApplicationBuilder;
1818
import zipkin2.server.internal.EnableZipkinServer;
1919
import zipkin2.server.internal.RegisterZipkinHealthIndicators;
20+
import zipkin2.server.internal.banner.ZipkinBanner;
2021

2122
@SpringBootApplication
2223
@EnableZipkinServer
@@ -29,7 +30,8 @@ public class ZipkinServer {
2930

3031
public static void main(String[] args) {
3132
new SpringApplicationBuilder(ZipkinServer.class)
32-
.listeners(new RegisterZipkinHealthIndicators())
33-
.properties("spring.config.name=zipkin-server").run(args);
33+
.listeners(new RegisterZipkinHealthIndicators())
34+
.banner(new ZipkinBanner())
35+
.properties("spring.config.name=zipkin-server").run(args);
3436
}
3537
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright 2015-2019 The OpenZipkin Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5+
* in compliance with the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License
10+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11+
* or implied. See the License for the specific language governing permissions and limitations under
12+
* the License.
13+
*/
14+
package zipkin2.server.internal.banner;
15+
16+
import org.springframework.boot.ansi.AnsiElement;
17+
18+
/**
19+
* <code>AnsiElement</code> implementation for Ansi256 Color<br>
20+
* TODO: This class should be deleted when this feature is provided by Spring Boot
21+
* @see <a href="https://github.com/spring-projects/spring-boot/pull/18264">https://github.com/spring-projects/spring-boot/pull/18264</a>
22+
*/
23+
public class ZipkinAnsi256Color implements AnsiElement {
24+
25+
private final int xtermNumber;
26+
27+
ZipkinAnsi256Color(int xtermNumber) {
28+
if (xtermNumber < 0 || xtermNumber > 255) {
29+
throw new IllegalArgumentException("'xtermNumber' must be 0-255!");
30+
}
31+
this.xtermNumber = xtermNumber;
32+
}
33+
34+
@Override
35+
public String toString() {
36+
return "38;5;" + this.xtermNumber;
37+
}
38+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright 2015-2019 The OpenZipkin Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5+
* in compliance with the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License
10+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11+
* or implied. See the License for the specific language governing permissions and limitations under
12+
* the License.
13+
*/
14+
package zipkin2.server.internal.banner;
15+
16+
import org.springframework.boot.ansi.AnsiElement;
17+
import org.springframework.boot.ansi.AnsiOutput;
18+
import org.springframework.core.env.PropertySource;
19+
import org.springframework.util.StringUtils;
20+
21+
/**
22+
* This class enable to use Ansi256 Color in the banner txt file
23+
* via <code>${ZipkinAnsi256Color.XYZ}</code> format (<code>XYZ</code> must be 0-255.).<br>
24+
* All supported colors can be found <a href="https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit">here</a>.<br>
25+
* TODO: This class should be deleted when this feature is provided by Spring Boot
26+
* @see <a href="https://github.com/spring-projects/spring-boot/pull/18264">https://github.com/spring-projects/spring-boot/pull/18264</a>
27+
*/
28+
public class ZipkinAnsi256ColorPropertySource extends PropertySource<AnsiElement> {
29+
30+
private static final String PREFIX = "ZipkinAnsi256Color.";
31+
32+
ZipkinAnsi256ColorPropertySource(String name) {
33+
super(name);
34+
}
35+
36+
@Override
37+
public Object getProperty(String name) {
38+
if (StringUtils.hasLength(name)) {
39+
if (name.startsWith(PREFIX)) {
40+
int xtermNumber = Integer.parseInt(name.substring(PREFIX.length()));
41+
return AnsiOutput.encode(new ZipkinAnsi256Color(xtermNumber));
42+
}
43+
}
44+
return null;
45+
}
46+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright 2015-2019 The OpenZipkin Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5+
* in compliance with the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License
10+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11+
* or implied. See the License for the specific language governing permissions and limitations under
12+
* the License.
13+
*/
14+
package zipkin2.server.internal.banner;
15+
16+
import org.springframework.boot.ResourceBanner;
17+
import org.springframework.core.env.Environment;
18+
import org.springframework.core.env.MutablePropertySources;
19+
import org.springframework.core.env.PropertyResolver;
20+
import org.springframework.core.env.PropertySourcesPropertyResolver;
21+
import org.springframework.core.io.ClassPathResource;
22+
23+
import java.util.List;
24+
25+
/**
26+
* <code>Banner</code> implemetation for Ansi256 Color<br>
27+
* TODO: This class should be deleted when this feature is provided by Spring Boot
28+
* @see <a href="https://github.com/spring-projects/spring-boot/pull/18264">https://github.com/spring-projects/spring-boot/pull/18264</a>
29+
*/
30+
public class ZipkinBanner extends ResourceBanner {
31+
32+
public ZipkinBanner() {
33+
super(new ClassPathResource("zipkin.txt"));
34+
}
35+
36+
@Override
37+
protected List<PropertyResolver> getPropertyResolvers(Environment environment, Class<?> sourceClass) {
38+
final List<PropertyResolver> propertyResolvers = super.getPropertyResolvers(environment, sourceClass);
39+
propertyResolvers.add(getZipkinAnsi256Resolver());
40+
return propertyResolvers;
41+
}
42+
43+
private PropertyResolver getZipkinAnsi256Resolver() {
44+
MutablePropertySources sources = new MutablePropertySources();
45+
sources.addFirst(new ZipkinAnsi256ColorPropertySource("zipkinAnsi256"));
46+
return new PropertySourcesPropertyResolver(sources);
47+
}
48+
}

zipkin-server/src/main/resources/banner.txt

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
${ZipkinAnsi256Color.208}
2+
oo
3+
oooo
4+
oooooo
5+
oooooooo
6+
oooooooooo
7+
oooooooooooo
8+
ooooooo ooooooo
9+
oooooo ooooooo
10+
oooooo ooooooo
11+
oooooo o o oooooo
12+
oooooo oo oo oooooo
13+
ooooooo oooo oooo ooooooo
14+
oooooo ooooo ooooo ooooooo
15+
oooooo oooooo oooooo ooooooo
16+
oooooooo oo oo oooooooo
17+
ooooooooooooo oo oo ooooooooooooo
18+
oooooooooooo oooooooooooo
19+
oooooooo oooooooo
20+
oooo oooo
21+
${AnsiStyle.NORMAL}
22+
________ ____ _ _____ _ _
23+
|__ /_ _| _ \| |/ /_ _| \ | |
24+
/ / | || |_) | ' / | || \| |
25+
/ /_ | || __/| . \ | || |\ |
26+
|____|___|_| |_|\_\___|_| \_|
27+
28+
${AnsiColor.GREEN}:: Powered by Spring Boot :: ${AnsiStyle.FAINT}${AnsiColor.BLACK}${spring-boot.formatted-version}${AnsiStyle.NORMAL}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright 2015-2019 The OpenZipkin Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5+
* in compliance with the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License
10+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11+
* or implied. See the License for the specific language governing permissions and limitations under
12+
* the License.
13+
*/
14+
package zipkin2.server.internal.banner;
15+
16+
import org.junit.After;
17+
import org.junit.Before;
18+
import org.junit.Test;
19+
import org.springframework.boot.ansi.AnsiOutput;
20+
21+
import static org.assertj.core.api.Assertions.assertThat;
22+
23+
public class ZipkinAnsi256ColorPropertySourceTest {
24+
25+
@Before
26+
public void setUp() throws Exception {
27+
AnsiOutput.setEnabled(AnsiOutput.Enabled.ALWAYS);
28+
}
29+
30+
@After
31+
public void tearDown() throws Exception {
32+
AnsiOutput.setEnabled(AnsiOutput.Enabled.DETECT);
33+
}
34+
35+
@Test
36+
public void getPropertyFoundShouldConvertAnsiColor() {
37+
final ZipkinAnsi256ColorPropertySource propertySource = new ZipkinAnsi256ColorPropertySource("test");
38+
final Object property = propertySource.getProperty("ZipkinAnsi256Color.100");
39+
assertThat(property).isEqualTo("\033[38;5;100m");
40+
}
41+
42+
@Test
43+
public void getPropertyNotFoundShouldReturnNull() {
44+
final ZipkinAnsi256ColorPropertySource propertySource = new ZipkinAnsi256ColorPropertySource("test");
45+
final Object property = propertySource.getProperty("foo");
46+
assertThat(property).isNull();
47+
}
48+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright 2015-2019 The OpenZipkin Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5+
* in compliance with the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License
10+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11+
* or implied. See the License for the specific language governing permissions and limitations under
12+
* the License.
13+
*/
14+
package zipkin2.server.internal.banner;
15+
16+
import org.junit.Test;
17+
18+
import static org.assertj.core.api.Assertions.assertThat;
19+
import static org.assertj.core.api.Assertions.failBecauseExceptionWasNotThrown;
20+
21+
public class ZipkinAnsi256ColorTest {
22+
23+
@Test
24+
public void testToString() {
25+
final ZipkinAnsi256Color ansi256Color = new ZipkinAnsi256Color(208);
26+
assertThat(ansi256Color.toString()).isEqualTo("38;5;208");
27+
}
28+
29+
@Test
30+
public void testIllegalXtermNumber() {
31+
try {
32+
new ZipkinAnsi256Color(256);
33+
failBecauseExceptionWasNotThrown(IllegalArgumentException.class);
34+
} catch (IllegalArgumentException e) {
35+
assertThat(e.getMessage()).isEqualTo("'xtermNumber' must be 0-255!");
36+
}
37+
}
38+
}

0 commit comments

Comments
 (0)