Skip to content
This repository has been archived by the owner on May 21, 2023. It is now read-only.

#5 job-api poc #6

Open
wants to merge 1 commit 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
29 changes: 13 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,20 @@ You add this to your `pom.xml`:
## [Job](https://kubernetes.io/docs/concepts/workloads/controllers/job/) API

```java
import com.h1alexbel.k8sojo.Container;

import com.h1alexbel.k8sojo.DcContainer;
import com.h1alexbel.k8sojo.Kojo;
import com.h1alexbel.k8sojo.Metadata;
import com.h1alexbel.k8sojo.Spec;

final Container realo = new DcContainer("realo", "abialiauski/realo", List.of("-java"));
Kojo kojo = new JobKojo(
new JobMetadata("realo-job"),
new JobSpec(
new JobTemplate(
new JobTemplateSpec(
List.of(realo), "Never"
)
),
4)
);

final Container realo=new DcContainer("realo","abialiauski/realo",List.of("-java"));
Kojo kojo=new JobKojo(
new JobMetadata("realo-job"),
new JobSpec(
new JobTemplate(
new JobTemplateSpec(
List.of(realo),"Never"
)
),
4)
);
```

## Pod API
Expand Down
20 changes: 20 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,30 @@ SOFTWARE.
<artifactId>cactoos</artifactId>
<version>${cactoos.version}</version>
</dependency>
<dependency>
<groupId>com.jcabi.incubator</groupId>
<artifactId>xembly</artifactId>
<version>0.26.0</version>
</dependency>
<dependency>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-xml</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<version>2.13.4</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.24.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
39 changes: 38 additions & 1 deletion src/main/java/com/h1alexbel/k8sojo/Container.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

package com.h1alexbel.k8sojo;

import lombok.RequiredArgsConstructor;

/**
* Container.
*
Expand Down Expand Up @@ -50,4 +52,39 @@ public interface Container {
* @return list of commands
*/
Iterable<String> commands();
}

/**
* Docker container.
*/
@RequiredArgsConstructor
final class Dc implements Container {

/**
* Name.
*/
private final String name;
/**
* Image.
*/
private final String image;
/**
* Commands.
*/
private final Iterable<String> commands;

@Override
public String name() {
return this.name;
}

@Override
public String image() {
return "docker.io/" + this.image;
}

@Override
public Iterable<String> commands() {
return this.commands;
}
}
}
63 changes: 0 additions & 63 deletions src/main/java/com/h1alexbel/k8sojo/DcContainer.java

This file was deleted.

101 changes: 101 additions & 0 deletions src/main/java/com/h1alexbel/k8sojo/Job.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
///*
// * Copyright (c) 2022 Aliaksei Bialiauski
// *
// * Permission is hereby granted, free of charge, to any person obtaining a copy
// * of this software and associated documentation files (the "Software"), to deal
// * in the Software without restriction, including without limitation the rights
// * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// * copies of the Software, and to permit persons to whom the Software is
// * furnished to do so, subject to the following conditions:
// *
// * The above copyright notice and this permission notice shall be included in all
// * copies or substantial portions of the Software.
// *
// * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// * SOFTWARE.
// */
//
//package com.h1alexbel.k8sojo;
//
//import com.h1alexbel.k8sojo.yml.YamlJob;
//import com.h1alexbel.k8sojo.yml.YamlMetadata;
//import com.h1alexbel.k8sojo.yml.YamlSpec;
//import com.h1alexbel.k8sojo.yml.YamlTemplate;
//import lombok.RequiredArgsConstructor;
//
///**
// * Kubernetes Object.
// *
// * @author Aliaksei Bialiauski (abialiauski@solvd.com)
// * @since 0.0.1
// */
//public interface Job {
//
// Job apply();
//
// /**
// * Api version.
// *
// * @return api version as string
// */
// String apiVersion();
//
// /**
// * Kind.
// *
// * @return kind as string
// */
// String kind();
//
// /**
// * Metadata.
// *
// * @return metadata
// */
// Metadata meta();
//
// Spec spec();
//
// @RequiredArgsConstructor
// final class Simple implements Job {
//
// private final Metadata metadata;
// private final Spec spec;
//
// @Override
// public Job apply() {
// return new YamlJob(this.apiVersion(), this.kind(),
// new YamlMetadata(this.metadata.name()),
// new YamlSpec(
// new YamlTemplate(""),
// this.spec.backoffLimit()
// )
// );
// }
//
// @Override
// public String apiVersion() {
// return "batch/v1";
// }
//
// @Override
// public String kind() {
// return "Job";
// }
//
// @Override
// public Metadata meta() {
// return this.metadata;
// }
//
// @Override
// public Spec spec() {
// return this.spec;
// }
// }
//}
60 changes: 0 additions & 60 deletions src/main/java/com/h1alexbel/k8sojo/Kojo.java

This file was deleted.

16 changes: 16 additions & 0 deletions src/main/java/com/h1alexbel/k8sojo/Metadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

package com.h1alexbel.k8sojo;

import lombok.RequiredArgsConstructor;

/**
* Kubernetes metadata.
*
Expand All @@ -36,4 +38,18 @@ public interface Metadata {
* @return name as string
*/
String name();

@RequiredArgsConstructor
final class Simple implements Metadata {

/**
* Name.
*/
private final String name;

@Override
public String name() {
return this.name;
}
}
}
12 changes: 1 addition & 11 deletions src/main/java/com/h1alexbel/k8sojo/Spec.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,7 @@
*/
public interface Spec {

/**
* Template.
*
* @return template
*/
Template template();

/**
* BackOffLimit.
*
* @return backoff limit as int
*/
int backOffLimit();
int backoffLimit();
}
Loading