Skip to content

Commit 335de07

Browse files
committed
Merge branch '3.4.x'
Closes gh-45630
2 parents 01b6df1 + f045ef4 commit 335de07

File tree

2 files changed

+51
-17
lines changed

2 files changed

+51
-17
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/docs/antora/modules/api/pages/rest/actuator/info.adoc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,12 @@ include::partial$rest/actuator/info/response-fields-beneath-git.adoc[]
4747

4848
NOTE: This is the "simple" output.
4949
The contributor can also be configured to output all available data.
50+
51+
52+
[[info.retrieving.response-structure.os]]
53+
==== OS Response Structure
54+
55+
The following table describes the structure of the `os` section of the response:
56+
57+
[cols="2,1,3"]
58+
include::partial$rest/actuator/info/response-fields-beneath-os.adoc[]

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/info/InfoEndpointDocumentationTests.java

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,15 @@
2727
import org.springframework.boot.actuate.info.GitInfoContributor;
2828
import org.springframework.boot.actuate.info.InfoContributor;
2929
import org.springframework.boot.actuate.info.InfoEndpoint;
30+
import org.springframework.boot.actuate.info.OsInfoContributor;
3031
import org.springframework.boot.info.BuildProperties;
3132
import org.springframework.boot.info.GitProperties;
3233
import org.springframework.context.annotation.Bean;
3334
import org.springframework.context.annotation.Configuration;
3435
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation;
36+
import org.springframework.restdocs.payload.FieldDescriptor;
3537
import org.springframework.restdocs.payload.JsonFieldType;
38+
import org.springframework.restdocs.payload.ResponseFieldsSnippet;
3639

3740
import static org.assertj.core.api.Assertions.assertThat;
3841
import static org.springframework.restdocs.payload.PayloadDocumentation.beneathPath;
@@ -49,23 +52,40 @@ class InfoEndpointDocumentationTests extends MockMvcEndpointDocumentationTests {
4952
@Test
5053
void info() {
5154
assertThat(this.mvc.get().uri("/actuator/info")).hasStatusOk()
52-
.apply(MockMvcRestDocumentation.document("info",
53-
responseFields(beneathPath("git"),
54-
fieldWithPath("branch").description("Name of the Git branch, if any."),
55-
fieldWithPath("commit").description("Details of the Git commit, if any."),
56-
fieldWithPath("commit.time").description("Timestamp of the commit, if any.")
57-
.type(JsonFieldType.VARIES),
58-
fieldWithPath("commit.id").description("ID of the commit, if any.")),
59-
responseFields(beneathPath("build"),
60-
fieldWithPath("artifact").description("Artifact ID of the application, if any.").optional(),
61-
fieldWithPath("group").description("Group ID of the application, if any.").optional(),
62-
fieldWithPath("name").description("Name of the application, if any.")
63-
.type(JsonFieldType.STRING)
64-
.optional(),
65-
fieldWithPath("version").description("Version of the application, if any.").optional(),
66-
fieldWithPath("time").description("Timestamp of when the application was built, if any.")
67-
.type(JsonFieldType.VARIES)
68-
.optional())));
55+
.apply(MockMvcRestDocumentation.document("info", gitInfo(), buildInfo(), osInfo()));
56+
}
57+
58+
private ResponseFieldsSnippet gitInfo() {
59+
return responseFields(beneathPath("git"),
60+
fieldWithPath("branch").description("Name of the Git branch, if any."),
61+
fieldWithPath("commit").description("Details of the Git commit, if any."),
62+
fieldWithPath("commit.time").description("Timestamp of the commit, if any.").type(JsonFieldType.VARIES),
63+
fieldWithPath("commit.id").description("ID of the commit, if any."));
64+
}
65+
66+
private ResponseFieldsSnippet buildInfo() {
67+
return responseFields(beneathPath("build"),
68+
fieldWithPath("artifact").description("Artifact ID of the application, if any.").optional(),
69+
fieldWithPath("group").description("Group ID of the application, if any.").optional(),
70+
fieldWithPath("name").description("Name of the application, if any.")
71+
.type(JsonFieldType.STRING)
72+
.optional(),
73+
fieldWithPath("version").description("Version of the application, if any.").optional(),
74+
fieldWithPath("time").description("Timestamp of when the application was built, if any.")
75+
.type(JsonFieldType.VARIES)
76+
.optional());
77+
}
78+
79+
private ResponseFieldsSnippet osInfo() {
80+
return responseFields(beneathPath("os"), osInfoField("name", "Name"), osInfoField("version", "Version"),
81+
osInfoField("arch", "Architecture"));
82+
}
83+
84+
private FieldDescriptor osInfoField(String field, String desc) {
85+
return fieldWithPath(field)
86+
.description("Operating System " + desc + " (as obtained from the 'os." + field + "' system property).")
87+
.type(JsonFieldType.STRING)
88+
.optional();
6989
}
7090

7191
@Configuration(proxyBeanMethods = false)
@@ -97,6 +117,11 @@ BuildInfoContributor buildInfoContributor() {
97117
return new BuildInfoContributor(buildProperties);
98118
}
99119

120+
@Bean
121+
OsInfoContributor osInfoContributor() {
122+
return new OsInfoContributor();
123+
}
124+
100125
}
101126

102127
}

0 commit comments

Comments
 (0)