package tk.antoine_roux.wiki.configuration; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; @Configuration(proxyBeanMethods = false) public class GitConfiguration { @Bean public YAMLFactory yamlFactory() { return YAMLFactory.builder().build(); } @Bean(name = "YAMLObjectMapper") public ObjectMapper ObjectMapper(YAMLFactory yamlFactory) { return new ObjectMapper(yamlFactory); } @Bean public UsernamePasswordCredentialsProvider credentialsProvider(GitlabCIContextProperties gitlabCIContextProperties, Environment environment) { return new UsernamePasswordCredentialsProvider(gitlabCIContextProperties.getUsername(), gitlabCIContextProperties.getPassword()); } @ConfigurationProperties("gitlab-ci") public static class GitlabCIContextProperties { private String username; private String password; public String getUsername() { return this.username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return this.password; } public void setPassword(String password) { this.password = password; } } }