Skip to content

Commit

Permalink
add code from post
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaslin committed Jul 8, 2015
1 parent a3eb20b commit 55558f3
Show file tree
Hide file tree
Showing 37 changed files with 1,476 additions and 1 deletion.
31 changes: 31 additions & 0 deletions echo-notifications/echo-notifications.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2015 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

apply from: "$rootDir/gradle/groovy-module.gradle"

dependencies {
spinnaker.group("test")
spinnaker.group("bootWeb")
spinnaker.group("retrofitDefault")
compile spinnaker.dependency("groovy")
compile spinnaker.dependency("kork")
compile spinnaker.dependency("rxJava")
compile "javax.mail:mail:1.4.1"
compile "org.springframework:spring-context-support:4.0.8.RELEASE"
compile "org.apache.velocity:velocity:1.7"
compile "org.jsoup:jsoup:1.8.2"
testCompile "com.icegreen:greenmail:1.4.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright 2015 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.netflix.spinnaker.echo

import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.boot.builder.SpringApplicationBuilder
import org.springframework.boot.context.web.SpringBootServletInitializer
import org.springframework.context.annotation.ComponentScan
import org.springframework.context.annotation.Configuration

/**
* Application entry point.
*/
@Configuration
@EnableAutoConfiguration
@ComponentScan('com.netflix.spinnaker.echo.config')
class Application extends SpringBootServletInitializer {

static final Map<String, String> DEFAULT_PROPS = [
'netflix.environment' : 'test',
'netflix.account' : System.getProperty('netflix.environment', 'test'),
'netflix.stack' : 'test',
'spring.config.location': "${System.properties['user.home']}/.spinnaker/",
'spring.config.name' : 'post',
'spring.profiles.active': "${System.getProperty('netflix.environment', 'test')},local"
]

static {
applyDefaults()
}

static void applyDefaults() {
DEFAULT_PROPS.each { k, v ->
System.setProperty(k, System.getProperty(k, v))
}
}

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
builder.sources(Application)
}

static void main(_) {
SpringApplication.run this, [] as String[]
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.netflix.spinnaker.echo.api

class Notification {
Type notificationType
Collection<String> to
String templateGroup
Severity severity

Source source
Map<String, Object> additionalContext = [:]

static class Source {
String executionType
String executionId
String application
}

static enum Type {
HIPCHAT,
EMAIL,
SMS
}

static enum Severity {
NORMAL,
HIGH
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2015 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.netflix.spinnaker.echo.config

import com.netflix.appinfo.InstanceInfo
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.ComponentScan
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.FilterType

/**
* Finds spring beans (@Component, @Resource, @Controller, etc.) on your classpath.
* If you don't like classpath scanning, don't use it, you'll always have the choice.
* I generally exclude @Configuration's from this scan, as picking those up can affect your tests.
*/
@Configuration
@ComponentScan(
basePackages = ['com.netflix.spinnaker.echo'],
excludeFilters = @ComponentScan.Filter(value = Configuration, type = FilterType.ANNOTATION)
)
class ComponentConfig {
@Bean
InstanceInfo.InstanceStatus instanceStatus() {
InstanceInfo.InstanceStatus.UNKNOWN
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright 2015 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.netflix.spinnaker.echo.config

import static retrofit.Endpoints.newFixedEndpoint

import com.netflix.spinnaker.echo.echo.EchoService
import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j
import org.springframework.beans.factory.annotation.Value
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import retrofit.Endpoint
import retrofit.RestAdapter
import retrofit.RestAdapter.LogLevel
import retrofit.client.Client

@Configuration
@Slf4j
@CompileStatic
class EchoConfig {

@Bean
Endpoint echoEndpoint(@Value('${echo.baseUrl}') String echoBaseUrl) {
newFixedEndpoint(echoBaseUrl)
}

@Bean
EchoService echoService(Endpoint echoEndpoint, Client retrofitClient, LogLevel retrofitLogLevel) {

log.info('echo service loaded')

new RestAdapter.Builder()
.setEndpoint(echoEndpoint)
.setClient(retrofitClient)
.setLogLevel(retrofitLogLevel)
.build()
.create(EchoService)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright 2015 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.netflix.spinnaker.echo.config

import org.springframework.beans.factory.annotation.Value
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.mail.javamail.JavaMailSender
import org.springframework.mail.javamail.JavaMailSenderImpl

/**
* Configuration for the mail service
*/
@Configuration
class EmailConfig {

@Bean
JavaMailSender mailSender(@Value('${mail.host}') String host) {
JavaMailSenderImpl sender = new JavaMailSenderImpl()
sender.setHost(host)
sender
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright 2015 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.netflix.spinnaker.echo.config

import static retrofit.Endpoints.newFixedEndpoint

import com.netflix.spinnaker.echo.hipchat.HipchatService
import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j
import org.springframework.beans.factory.annotation.Value
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import retrofit.Endpoint
import retrofit.RestAdapter
import retrofit.client.Client

@Configuration
@Slf4j
@CompileStatic
class HipchatConfig {

@Bean
Endpoint hipchatEndpoint(@Value('${hipchat.baseUrl}') String hipchatBaseUrl) {
newFixedEndpoint(hipchatBaseUrl)
}

@Bean
HipchatService hipchatService(Endpoint hipchatEndpoint, Client retrofitClient, RestAdapter.LogLevel retrofitLogLevel) {

log.info('hipchat service loaded')

new RestAdapter.Builder()
.setEndpoint(hipchatEndpoint)
.setClient(retrofitClient)
.setLogLevel(retrofitLogLevel)
.build()
.create(HipchatService)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright 2015 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.netflix.spinnaker.echo.config

import static retrofit.Endpoints.newFixedEndpoint

import com.netflix.spinnaker.echo.mayo.MayoService
import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j
import org.springframework.beans.factory.annotation.Value
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import retrofit.Endpoint
import retrofit.RestAdapter
import retrofit.RestAdapter.LogLevel
import retrofit.client.Client
import retrofit.client.OkClient

@Configuration
@Slf4j
@CompileStatic
class MayoConfig {

@Bean
Client retrofitClient() {
new OkClient()
}

@Bean
LogLevel retrofitLogLevel() {
LogLevel.NONE
}

@Bean
Endpoint mayoEndpoint(@Value('${mayo.baseUrl}') String mayoBaseUrl) {
newFixedEndpoint(mayoBaseUrl)
}

@Bean
MayoService mayoService(Endpoint mayoEndpoint, Client retrofitClient, LogLevel retrofitLogLevel) {
log.info('mayo service loaded')
new RestAdapter.Builder()
.setEndpoint(mayoEndpoint)
.setClient(retrofitClient)
.setLogLevel(retrofitLogLevel)
.build()
.create(MayoService)
}

}
Loading

0 comments on commit 55558f3

Please sign in to comment.