Skip to content

Commit

Permalink
refactor(provider/cf): move cf Job classes to correct modules to avoi…
Browse files Browse the repository at this point in the history
…d siloed code (#4667)

Co-authored-by: Zach Smith <zachsmith@Zachs-MBP-2.attlocal.net>
Co-authored-by: Zach Smith <zachsmith@Zachs-MacBook-Pro-2.local>
  • Loading branch information
3 people committed Jun 11, 2020
1 parent d68a92e commit ae32d54
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,20 @@
* 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.clouddriver.cloudfoundry.job;
package com.netflix.spinnaker.clouddriver.cloudfoundry.deploy.converters;

import static com.netflix.spinnaker.clouddriver.orchestration.AtomicOperations.RUN_JOB;

import com.netflix.spinnaker.clouddriver.cloudfoundry.CloudFoundryOperation;
import com.netflix.spinnaker.clouddriver.cloudfoundry.client.CloudFoundryClient;
import com.netflix.spinnaker.clouddriver.cloudfoundry.deploy.converters.AbstractCloudFoundryAtomicOperationConverter;
import com.netflix.spinnaker.clouddriver.cloudfoundry.deploy.description.CloudFoundryRunJobOperationDescription;
import com.netflix.spinnaker.clouddriver.cloudfoundry.deploy.ops.CloudFoundryRunJobOperation;
import com.netflix.spinnaker.clouddriver.cloudfoundry.model.CloudFoundryServerGroup;
import com.netflix.spinnaker.clouddriver.cloudfoundry.model.CloudFoundrySpace;
import com.netflix.spinnaker.clouddriver.cloudfoundry.security.CloudFoundryCredentials;
import com.netflix.spinnaker.clouddriver.orchestration.AtomicOperation;
import java.util.Map;
import org.springframework.stereotype.Component;
Expand All @@ -42,7 +45,9 @@ public CloudFoundryRunJobOperationDescription convertDescription(Map input) {
CloudFoundryRunJobOperationDescription converted =
getObjectMapper().convertValue(input, CloudFoundryRunJobOperationDescription.class);

CloudFoundryClient client = getClient(input);
CloudFoundryCredentials credentials = getCredentialsObject(input.get("credentials").toString());
converted.setCredentials(credentials);
CloudFoundryClient client = credentials.getClient();
converted.setClient(client);
String jobName = (String) input.get("jobName");
String region = (String) input.get("region");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,31 @@
* 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.clouddriver.cloudfoundry.job;
package com.netflix.spinnaker.clouddriver.cloudfoundry.deploy.description;

import com.netflix.spinnaker.clouddriver.cloudfoundry.deploy.description.AbstractCloudFoundryDescription;
import com.netflix.frigga.Names;
import com.netflix.spinnaker.clouddriver.cloudfoundry.model.CloudFoundryServerGroup;
import com.netflix.spinnaker.clouddriver.security.resources.ApplicationNameable;
import java.util.Collection;
import java.util.Collections;
import javax.annotation.Nullable;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = true)
public class CloudFoundryRunJobOperationDescription extends AbstractCloudFoundryDescription {
public class CloudFoundryRunJobOperationDescription extends AbstractCloudFoundryDescription
implements ApplicationNameable {

private CloudFoundryServerGroup serverGroup;
@Nullable private String jobName;
private String command;

@Override
public Collection<String> getApplications() {
return Collections.singletonList(Names.parseName(serverGroup.getName()).getApp());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
* 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.clouddriver.cloudfoundry.job;
package com.netflix.spinnaker.clouddriver.cloudfoundry.deploy.ops;

import com.netflix.spinnaker.clouddriver.cloudfoundry.client.CloudFoundryClient;
import com.netflix.spinnaker.clouddriver.cloudfoundry.client.model.v3.Task;
import com.netflix.spinnaker.clouddriver.cloudfoundry.deploy.description.CloudFoundryRunJobOperationDescription;
import com.netflix.spinnaker.clouddriver.cloudfoundry.model.CloudFoundryServerGroup;
import com.netflix.spinnaker.clouddriver.data.task.TaskRepository;
import com.netflix.spinnaker.clouddriver.deploy.DeploymentResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
* 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.clouddriver.cloudfoundry.job;
package com.netflix.spinnaker.clouddriver.cloudfoundry.model;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.netflix.spinnaker.clouddriver.cloudfoundry.CloudFoundryCloudProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
* 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.clouddriver.cloudfoundry.job;
package com.netflix.spinnaker.clouddriver.cloudfoundry.provider.view;

import com.netflix.spinnaker.clouddriver.cloudfoundry.CloudFoundryCloudProvider;
import com.netflix.spinnaker.clouddriver.cloudfoundry.client.model.v3.Task;
import com.netflix.spinnaker.clouddriver.cloudfoundry.model.CloudFoundryJobStatus;
import com.netflix.spinnaker.clouddriver.cloudfoundry.security.CloudFoundryCredentials;
import com.netflix.spinnaker.clouddriver.model.JobProvider;
import com.netflix.spinnaker.clouddriver.security.AccountCredentials;
Expand Down

0 comments on commit ae32d54

Please sign in to comment.