-
Notifications
You must be signed in to change notification settings - Fork 633
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- GCS configuration - /fetch controller will synchronously dump retrieved metrics verbatim into a bucket (still placeholder logic)
- Loading branch information
duftler
committed
Mar 1, 2017
1 parent
57c732a
commit d152a42
Showing
25 changed files
with
489 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
dependencies { | ||
compile spinnaker.dependency('bootWeb') | ||
compile spinnaker.dependency('lombok') | ||
spinnaker.group('jackson') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...rc/main/java/com/netflix/spinnaker/kayenta/storage/MapBackedStorageServiceRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright 2017 Google, 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.kayenta.storage; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
public class MapBackedStorageServiceRepository implements StorageServiceRepository { | ||
|
||
@Autowired(required = false) | ||
List<StorageService> storageServices = Collections.emptyList(); | ||
|
||
@Override | ||
public Optional<StorageService> getOne(String accountName) { | ||
return storageServices | ||
.stream() | ||
.filter(s -> s.servicesAccount(accountName)) | ||
.findFirst(); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
kayenta-core/src/main/java/com/netflix/spinnaker/kayenta/storage/ObjectType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright 2017 Google, 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.kayenta.storage; | ||
|
||
import lombok.Getter; | ||
|
||
public enum ObjectType { | ||
METRICS("metrics", "metrics.json"); | ||
|
||
@Getter | ||
final String group; | ||
|
||
@Getter | ||
final String defaultMetadataFilename; | ||
|
||
ObjectType(String group, String defaultMetadataFilename) { | ||
this.group = group; | ||
this.defaultMetadataFilename = defaultMetadataFilename; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
kayenta-core/src/main/java/com/netflix/spinnaker/kayenta/storage/StorageService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright 2017 Google, 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.kayenta.storage; | ||
|
||
import java.io.IOException; | ||
import java.util.Map; | ||
|
||
public interface StorageService { | ||
boolean servicesAccount(String accountName); | ||
<T> void storeObject(String accountName, ObjectType objectType, String objectKey, T obj); | ||
} |
23 changes: 23 additions & 0 deletions
23
...ta-core/src/main/java/com/netflix/spinnaker/kayenta/storage/StorageServiceRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright 2017 Google, 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.kayenta.storage; | ||
|
||
import java.util.Optional; | ||
|
||
public interface StorageServiceRepository { | ||
Optional<StorageService> getOne(String accountName); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
dependencies { | ||
compile project(":kayenta-core") | ||
compile project(":kayenta-google") | ||
compile spinnaker.dependency('bootWeb') | ||
compile spinnaker.dependency('lombok') | ||
spinnaker.group('google') | ||
} |
61 changes: 61 additions & 0 deletions
61
kayenta-gcs/src/main/java/com/netflix/spinnaker/kayenta/gcs/config/GcsConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright 2017 Google, 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.kayenta.gcs.config; | ||
|
||
import com.netflix.spinnaker.kayenta.gcs.storage.GcsStorageService; | ||
import com.netflix.spinnaker.kayenta.google.security.GoogleNamedAccountCredentials; | ||
import com.netflix.spinnaker.kayenta.security.AccountCredentials; | ||
import com.netflix.spinnaker.kayenta.security.AccountCredentialsRepository; | ||
import com.netflix.spinnaker.kayenta.storage.StorageService; | ||
import com.netflix.spinnaker.kayenta.storage.StorageServiceRepository; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.DependsOn; | ||
|
||
@Configuration | ||
@EnableConfigurationProperties | ||
@ConditionalOnProperty("kayenta.gcs.enabled") | ||
@ComponentScan({"com.netflix.spinnaker.kayenta.gcs"}) | ||
@Slf4j | ||
public class GcsConfiguration { | ||
|
||
@Bean | ||
@DependsOn({"registerGoogleCredentials"}) | ||
public StorageService storageService(AccountCredentialsRepository accountCredentialsRepository) { | ||
GcsStorageService.GcsStorageServiceBuilder gcsStorageServiceBuilder = GcsStorageService.builder(); | ||
|
||
for (AccountCredentials accountCredentials : accountCredentialsRepository.getAll()) { | ||
if (accountCredentials instanceof GoogleNamedAccountCredentials) { | ||
GoogleNamedAccountCredentials googleNamedAccountCredentials = (GoogleNamedAccountCredentials)accountCredentials; | ||
|
||
if (googleNamedAccountCredentials.getSupportedTypes().contains(AccountCredentials.Type.OBJECT_STORE)) { | ||
gcsStorageServiceBuilder.accountName(googleNamedAccountCredentials.getName()); | ||
} | ||
} | ||
} | ||
|
||
GcsStorageService gcsStorageService = gcsStorageServiceBuilder.build(); | ||
|
||
log.info("Populated GcsStorageService with {} Google accounts.", gcsStorageService.getAccountNames().size()); | ||
|
||
return gcsStorageService; | ||
} | ||
} |
Oops, something went wrong.