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

[Issue] #4880 change task namespace deployment dynamically in Kuberne… #5142

Open
wants to merge 1 commit into
base: main
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
4 changes: 4 additions & 0 deletions spring-cloud-dataflow-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,9 @@
<groupId>org.springframework.hateoas</groupId>
<artifactId>spring-hateoas</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-deployer-kubernetes</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* Copyright 2015-2019 the original author or authors.
*
* 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
*
* https://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 org.springframework.cloud.dataflow.core;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

/**
* Accounts Entity
*
* @author Carlos Miquel
*/
@Entity
@Table(name = "ACCOUNTS")
public class Account {

/**
* Name of account.
*/
@Id
@Column(name = "ACCOUNT_NAME")
private String accountName;

@Column(name = "DEPLOYMENT_PROPERTIES")
private String deploymentProperties;

/**
* Empty constructor
*/
public Account() {

}

/**
* All Args Constructor
* @param accountName Account Identifier
* @param deploymentProperties Deployment Properties
*/
public Account(String accountName, String deploymentProperties) {
super();
this.accountName = accountName;
this.deploymentProperties = deploymentProperties;
}

/**
* @return the accountName
*/
public String getAccountName() {
return accountName;
}

/**
* @param accountName the accountName to set
*/
public void setAccountName(String accountName) {
this.accountName = accountName;
}

/**
* @return the deploymentProperties
*/
public String getDeploymentProperties() {
return deploymentProperties;
}

/**
* @param deploymentProperties the deploymentProperties to set
*/
public void setDeploymentProperties(String deploymentProperties) {
this.deploymentProperties = deploymentProperties;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Copyright 2015-2018 the original author or authors.
*
* 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
*
* https://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 org.springframework.cloud.dataflow.rest.resource;

import org.springframework.cloud.dataflow.core.Account;
import org.springframework.cloud.deployer.spi.kubernetes.KubernetesDeployerProperties;
import org.springframework.hateoas.RepresentationModel;

/**
* A HATEOAS representation of a {@link Account}.
*
*/
public class AccountResource extends RepresentationModel<AccountResource> {

private String accountName;

private KubernetesDeployerProperties properties;

/**
* @return the accountName
*/
public String getAccountName() {
return accountName;
}

/**
* @param accountName the accountName to set
*/
public void setAccountName(String accountName) {
this.accountName = accountName;
}

/**
* @return the properties
*/
public KubernetesDeployerProperties getProperties() {
return properties;
}

/**
* @param properties the properties to set
*/
public void setProperties(KubernetesDeployerProperties properties) {
this.properties = properties;
}

public AccountResource(String accountName, KubernetesDeployerProperties properties) {
super();
this.accountName = accountName;
this.properties = properties;
}

public AccountResource() {
super();
}

}
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
/*
* Copyright 2009-2010 the original author or authors.
*
* 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
*
* https://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.
*/
/*
* Copyright 2009-2010 the original author or authors.
*
* 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
*
* https://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 org.springframework.cloud.dataflow.server.batch;

import org.springframework.batch.core.JobExecutionException;
import org.springframework.batch.core.JobExecutionException;

@SuppressWarnings("serial")
@SuppressWarnings("serial")
public class NoSuchStepExecutionException extends JobExecutionException {

public NoSuchStepExecutionException(String msg, Throwable cause) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import org.springframework.cloud.dataflow.server.config.features.ConditionalOnTasksEnabled;
import org.springframework.cloud.dataflow.server.config.features.FeaturesProperties;
import org.springframework.cloud.dataflow.server.controller.AboutController;
import org.springframework.cloud.dataflow.server.controller.AccountController;
import org.springframework.cloud.dataflow.server.controller.AppRegistryController;
import org.springframework.cloud.dataflow.server.controller.AuditRecordController;
import org.springframework.cloud.dataflow.server.controller.CompletionController;
Expand Down Expand Up @@ -97,6 +98,7 @@
import org.springframework.cloud.dataflow.server.job.LauncherRepository;
import org.springframework.cloud.dataflow.server.repository.StreamDefinitionRepository;
import org.springframework.cloud.dataflow.server.repository.TaskDefinitionRepository;
import org.springframework.cloud.dataflow.server.service.AccountService;
import org.springframework.cloud.dataflow.server.service.LauncherService;
import org.springframework.cloud.dataflow.server.service.SchedulerService;
import org.springframework.cloud.dataflow.server.service.SpringSecurityAuditorAware;
Expand Down Expand Up @@ -151,6 +153,7 @@
* @author Andy Clement
* @author Glenn Renfro
* @author Christian Tzolov
* @author Carlos Miquel
*/
@SuppressWarnings("all")
@Configuration
Expand Down Expand Up @@ -209,6 +212,11 @@ public UiController uiController() {
public RestControllerAdvice restControllerAdvice() {
return new RestControllerAdvice();
}

@Bean
public AccountController accountController(AccountService accountService) {
return new AccountController(accountService);
}

@Configuration
public static class AppRegistryConfiguration {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright 2016-2020 the original author or authors.
*
* 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
*
* https://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 org.springframework.cloud.dataflow.server.config.features;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.cloud.dataflow.server.job.LauncherRepository;
import org.springframework.cloud.dataflow.server.repository.AccountRepository;
import org.springframework.cloud.dataflow.server.repository.DatabaseLauncherRepository;
import org.springframework.cloud.dataflow.server.service.AccountService;
import org.springframework.cloud.dataflow.server.service.impl.DefaultAccountService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

/**
* Account feature configuration
* @author Carlos Miquel
*/
@Configuration
public class AccountConfiguration {

/**
* Logger
*/
private static final Log log = LogFactory.getLog(AccountConfiguration.class);

/**
* Account service bean
* @param accountRepository Account database repository.
* @return Account service.
*/
@Bean
public AccountService accountService(AccountRepository accountRepository) {
return new DefaultAccountService(accountRepository);
}

/**
* If account database feature is enabled, override launcher repository.
* @param accountRepository Account repository.
* @return Launcher repository.
*/
@Bean
@ConditionalOnProperty(value = "spring.cloud.dataflow.task.platform.kubernetes.accounts.database", havingValue = "true", matchIfMissing = false)
@Primary
public LauncherRepository databaseLauncherRepository(AccountRepository accountRepository) {
log.debug("Account info in database feature.");
return new DatabaseLauncherRepository(accountRepository, false);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
* @author Ilayaperumal Gopinathan
*/
@Configuration
@Import({ StreamConfiguration.class, TaskConfiguration.class, SchedulerConfiguration.class })
@Import({ StreamConfiguration.class, TaskConfiguration.class, SchedulerConfiguration.class, AccountConfiguration.class })
public class FeaturesConfiguration {
}
Loading