Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(oss): Support Alibaba Cloud Object Storage Service #1138

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions front50-oss/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## Configuring OSS store for front50

#### OSS:
```yaml
oss:
enabled: true
endpoint: oss-cn-hangzhou.aliyuncs.com
bucket:
accessKeyId:
accessSecretKey:
versioning: true
readOnlyMode: false
```

[Get started with OSS>>](https://www.alibabacloud.com/help/en/object-storage-service/latest/get-started-with-oss)
33 changes: 33 additions & 0 deletions front50-oss/front50-oss.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2022 Alibaba Group.
*
* 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.
*/

dependencies {
implementation project(":front50-core")
implementation project(":front50-api")

implementation "org.springframework.boot:spring-boot-starter-web"
implementation "org.springframework.boot:spring-boot-starter-actuator"
implementation "org.springframework.boot:spring-boot-autoconfigure"
implementation "io.spinnaker.kork:kork-core"
implementation "com.netflix.eureka:eureka-client"
implementation "com.aliyun.oss:aliyun-sdk-oss:3.10.2"
implementation "javax.xml.bind:jaxb-api:2.3.1"
implementation "javax.activation:activation:1.1.1"
implementation "org.glassfish.jaxb:jaxb-runtime:2.3.3"


testImplementation project(":front50-test")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2022 Alibaba Group.
*
* 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.front50.config;

import com.aliyun.oss.ClientConfiguration;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClient;
import com.aliyun.oss.common.auth.DefaultCredentialProvider;

public class OssClientFactory {
public static OSS client(OssProperties ossProperties) {
return new OSSClient(
ossProperties.getEndpoint(),
new DefaultCredentialProvider(
ossProperties.getAccessKeyId(), ossProperties.getAccessSecretKey()),
new ClientConfiguration());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright 2022 Alibaba Group.
*
* 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.front50.config;

import com.aliyun.oss.OSS;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.netflix.spinnaker.front50.model.OssStorageService;
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.Configuration;

@Configuration
@ConditionalOnProperty("spinnaker.oss.enabled")
@EnableConfigurationProperties(OssProperties.class)
public class OssConfig {
@Bean
public OSS ossClient(OssProperties ossProperties) {
return OssClientFactory.client(ossProperties);
}

@Bean
public OssStorageService ossStorageService(OSS oss, OssProperties ossProperties) {
OssStorageService storageService =
new OssStorageService(
new ObjectMapper(),
oss,
ossProperties.getBucket(),
ossProperties.getRootFolder(),
ossProperties.getVersioning(),
ossProperties.getReadOnlyMode(),
ossProperties.getMaxKeys());
storageService.ensureBucketExists();
return storageService;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* Copyright 2022 Alibaba Group.
*
* 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.front50.config;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties("spinnaker.oss")
public class OssProperties {
private String endpoint;
private String bucket;
private String accessKeyId;
private String accessSecretKey;
private Integer maxKeys = 1000;
private String rootFolder = "front50";
private Boolean versioning;
private Boolean readOnlyMode;

public String getEndpoint() {
return endpoint;
}

public void setEndpoint(String endpoint) {
this.endpoint = endpoint;
}

public String getBucket() {
return bucket;
}

public void setBucket(String bucket) {
this.bucket = bucket;
}

public String getAccessKeyId() {
return accessKeyId;
}

public void setAccessKeyId(String accessKeyId) {
this.accessKeyId = accessKeyId;
}

@JsonIgnore
public String getAccessSecretKey() {
return accessSecretKey;
}

public void setAccessSecretKey(String accessSecretKey) {
this.accessSecretKey = accessSecretKey;
}

public Integer getMaxKeys() {
return maxKeys;
}

public void setMaxKeys(Integer maxKeys) {
this.maxKeys = maxKeys;
}

public String getRootFolder() {
return rootFolder;
}

public void setRootFolder(String rootFolder) {
this.rootFolder = rootFolder;
}

public Boolean getVersioning() {
return versioning;
}

public void setVersioning(Boolean versioning) {
this.versioning = versioning;
}

public Boolean getReadOnlyMode() {
return readOnlyMode;
}

public void setReadOnlyMode(Boolean readOnlyMode) {
this.readOnlyMode = readOnlyMode;
}
}
Loading