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

Add support for specifying location for artifact registry #21

Merged
merged 4 commits into from
Aug 7, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
"formats",
"registries",
"repos"
})
@Generated("jsonschema2pojo")
public class ArtifactRegistry implements Serializable
{

/**
* Set of formats - in upper case- to create artifact registries for, as defined in https://cloud.google.com/artifact-registry/docs/supported-formats . Examples is DOCKER, PYTHON
* A list of registries/repositories to create
*
*/
@JsonProperty("formats")
@JsonPropertyDescription("Set of formats - in upper case- to create artifact registries for, as defined in https://cloud.google.com/artifact-registry/docs/supported-formats . Examples is DOCKER, PYTHON")
@JsonProperty("registries")
@JsonPropertyDescription("A list of registries/repositories to create")
@Valid
private List<String> formats = new ArrayList<String>();
private List<Registry> registries = new ArrayList<Registry>();
/**
* A list of github repositories under Statistics Norway-organisation that is allowed to push to Artifact Registry repositories of the team.
*
Expand All @@ -44,7 +44,7 @@ public class ArtifactRegistry implements Serializable
@JsonIgnore
@Valid
private Map<String, Object> additionalProperties = new LinkedHashMap<String, Object>();
private final static long serialVersionUID = -2223012852394825404L;
private final static long serialVersionUID = 2962162576379499060L;

/**
* No args constructor for use in serialization
Expand All @@ -55,14 +55,14 @@ public ArtifactRegistry() {

/**
*
* @param formats
* Set of formats - in upper case- to create artifact registries for, as defined in https://cloud.google.com/artifact-registry/docs/supported-formats . Examples is DOCKER, PYTHON.
* @param repos
* A list of github repositories under Statistics Norway-organisation that is allowed to push to Artifact Registry repositories of the team.
* @param registries
* A list of registries/repositories to create.
*/
public ArtifactRegistry(List<String> formats, List<String> repos) {
public ArtifactRegistry(List<Registry> registries, List<String> repos) {
super();
this.formats = formats;
this.registries = registries;
this.repos = repos;
}

Expand All @@ -71,21 +71,21 @@ public static ArtifactRegistry.ArtifactRegistryBuilderBase builder() {
}

/**
* Set of formats - in upper case- to create artifact registries for, as defined in https://cloud.google.com/artifact-registry/docs/supported-formats . Examples is DOCKER, PYTHON
* A list of registries/repositories to create
*
*/
@JsonProperty("formats")
public List<String> getFormats() {
return formats;
@JsonProperty("registries")
public List<Registry> getRegistries() {
return registries;
}

/**
* Set of formats - in upper case- to create artifact registries for, as defined in https://cloud.google.com/artifact-registry/docs/supported-formats . Examples is DOCKER, PYTHON
* A list of registries/repositories to create
*
*/
@JsonProperty("formats")
public void setFormats(List<String> formats) {
this.formats = formats;
@JsonProperty("registries")
public void setRegistries(List<Registry> registries) {
this.registries = registries;
}

/**
Expand Down Expand Up @@ -120,9 +120,9 @@ public void setAdditionalProperty(String name, Object value) {
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(ArtifactRegistry.class.getName()).append('@').append(Integer.toHexString(System.identityHashCode(this))).append('[');
sb.append("formats");
sb.append("registries");
sb.append('=');
sb.append(((this.formats == null)?"<null>":this.formats));
sb.append(((this.registries == null)?"<null>":this.registries));
sb.append(',');
sb.append("repos");
sb.append('=');
Expand All @@ -143,7 +143,7 @@ public String toString() {
@Override
public int hashCode() {
int result = 1;
result = ((result* 31)+((this.formats == null)? 0 :this.formats.hashCode()));
result = ((result* 31)+((this.registries == null)? 0 :this.registries.hashCode()));
result = ((result* 31)+((this.additionalProperties == null)? 0 :this.additionalProperties.hashCode()));
result = ((result* 31)+((this.repos == null)? 0 :this.repos.hashCode()));
return result;
Expand All @@ -158,7 +158,7 @@ public boolean equals(Object other) {
return false;
}
ArtifactRegistry rhs = ((ArtifactRegistry) other);
return ((((this.formats == rhs.formats)||((this.formats!= null)&&this.formats.equals(rhs.formats)))&&((this.additionalProperties == rhs.additionalProperties)||((this.additionalProperties!= null)&&this.additionalProperties.equals(rhs.additionalProperties))))&&((this.repos == rhs.repos)||((this.repos!= null)&&this.repos.equals(rhs.repos))));
return ((((this.registries == rhs.registries)||((this.registries!= null)&&this.registries.equals(rhs.registries)))&&((this.additionalProperties == rhs.additionalProperties)||((this.additionalProperties!= null)&&this.additionalProperties.equals(rhs.additionalProperties))))&&((this.repos == rhs.repos)||((this.repos!= null)&&this.repos.equals(rhs.repos))));
}

public static class ArtifactRegistryBuilder
Expand All @@ -170,8 +170,8 @@ public ArtifactRegistryBuilder() {
super();
}

public ArtifactRegistryBuilder(List<String> formats, List<String> repos) {
super(formats, repos);
public ArtifactRegistryBuilder(List<Registry> registries, List<String> repos) {
super(registries, repos);
}

}
Expand All @@ -189,10 +189,10 @@ public ArtifactRegistryBuilderBase() {
}

@SuppressWarnings("unchecked")
public ArtifactRegistryBuilderBase(List<String> formats, List<String> repos) {
public ArtifactRegistryBuilderBase(List<Registry> registries, List<String> repos) {
// Skip initialization when called from subclass
if (this.getClass().equals(ArtifactRegistry.ArtifactRegistryBuilder.class)) {
this.instance = ((T) new ArtifactRegistry(formats, repos));
this.instance = ((T) new ArtifactRegistry(registries, repos));
}
}

Expand All @@ -203,8 +203,8 @@ public T build() {
return result;
}

public ArtifactRegistry.ArtifactRegistryBuilderBase withFormats(List<String> formats) {
((ArtifactRegistry) this.instance).formats = formats;
public ArtifactRegistry.ArtifactRegistryBuilderBase withRegistries(List<Registry> registries) {
((ArtifactRegistry) this.instance).registries = registries;
return this;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@

package no.ssb.dapla.kuben.v1;

import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.annotation.processing.Generated;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import jakarta.validation.Valid;

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
"format",
"location"
})
@Generated("jsonschema2pojo")
public class Registry implements Serializable
{

/**
* The format of the registry, in upper case. See https://cloud.google.com/artifact-registry/docs/supported-formats.
*
*/
@JsonProperty("format")
@JsonPropertyDescription("The format of the registry, in upper case. See https://cloud.google.com/artifact-registry/docs/supported-formats.")
private String format;
/**
* The location for the registry.
*
*/
@JsonProperty("location")
@JsonPropertyDescription("The location for the registry.")
private String location;
@JsonIgnore
@Valid
private Map<String, Object> additionalProperties = new LinkedHashMap<String, Object>();
private final static long serialVersionUID = 4121737796544565051L;

/**
* No args constructor for use in serialization
*
*/
public Registry() {
}

/**
*
* @param format
* The format of the registry, in upper case. See https://cloud.google.com/artifact-registry/docs/supported-formats.
* @param location
* The location for the registry.
*/
public Registry(String format, String location) {
super();
this.format = format;
this.location = location;
}

public static Registry.RegistryBuilderBase builder() {
return new Registry.RegistryBuilder();
}

/**
* The format of the registry, in upper case. See https://cloud.google.com/artifact-registry/docs/supported-formats.
*
*/
@JsonProperty("format")
public String getFormat() {
return format;
}

/**
* The format of the registry, in upper case. See https://cloud.google.com/artifact-registry/docs/supported-formats.
*
*/
@JsonProperty("format")
public void setFormat(String format) {
this.format = format;
}

/**
* The location for the registry.
*
*/
@JsonProperty("location")
public String getLocation() {
return location;
}

/**
* The location for the registry.
*
*/
@JsonProperty("location")
public void setLocation(String location) {
this.location = location;
}

@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}

@JsonAnySetter
public void setAdditionalProperty(String name, Object value) {
this.additionalProperties.put(name, value);
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(Registry.class.getName()).append('@').append(Integer.toHexString(System.identityHashCode(this))).append('[');
sb.append("format");
sb.append('=');
sb.append(((this.format == null)?"<null>":this.format));
sb.append(',');
sb.append("location");
sb.append('=');
sb.append(((this.location == null)?"<null>":this.location));
sb.append(',');
sb.append("additionalProperties");
sb.append('=');
sb.append(((this.additionalProperties == null)?"<null>":this.additionalProperties));
sb.append(',');
if (sb.charAt((sb.length()- 1)) == ',') {
sb.setCharAt((sb.length()- 1), ']');
} else {
sb.append(']');
}
return sb.toString();
}

@Override
public int hashCode() {
int result = 1;
result = ((result* 31)+((this.format == null)? 0 :this.format.hashCode()));
result = ((result* 31)+((this.location == null)? 0 :this.location.hashCode()));
result = ((result* 31)+((this.additionalProperties == null)? 0 :this.additionalProperties.hashCode()));
return result;
}

@Override
public boolean equals(Object other) {
if (other == this) {
return true;
}
if ((other instanceof Registry) == false) {
return false;
}
Registry rhs = ((Registry) other);
return ((((this.format == rhs.format)||((this.format!= null)&&this.format.equals(rhs.format)))&&((this.location == rhs.location)||((this.location!= null)&&this.location.equals(rhs.location))))&&((this.additionalProperties == rhs.additionalProperties)||((this.additionalProperties!= null)&&this.additionalProperties.equals(rhs.additionalProperties))));
}

public static class RegistryBuilder
extends Registry.RegistryBuilderBase<Registry>
{


public RegistryBuilder() {
super();
}

public RegistryBuilder(String format, String location) {
super(format, location);
}

}

public static abstract class RegistryBuilderBase<T extends Registry >{

protected T instance;

@SuppressWarnings("unchecked")
public RegistryBuilderBase() {
// Skip initialization when called from subclass
if (this.getClass().equals(Registry.RegistryBuilder.class)) {
this.instance = ((T) new Registry());
}
}

@SuppressWarnings("unchecked")
public RegistryBuilderBase(String format, String location) {
// Skip initialization when called from subclass
if (this.getClass().equals(Registry.RegistryBuilder.class)) {
this.instance = ((T) new Registry(format, location));
}
}

public T build() {
T result;
result = this.instance;
this.instance = null;
return result;
}

public Registry.RegistryBuilderBase withFormat(String format) {
((Registry) this.instance).format = format;
return this;
}

public Registry.RegistryBuilderBase withLocation(String location) {
((Registry) this.instance).location = location;
return this;
}

public Registry.RegistryBuilderBase withAdditionalProperty(String name, Object value) {
((Registry) this.instance).additionalProperties.put(name, value);
return this;
}

}

}
17 changes: 13 additions & 4 deletions src/v1/kuben-team-definition.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,21 @@
"artifact_registry": {
"type": "object",
"properties": {
"formats": {
"registries": {
"type": "array",
"description": "Set of formats - in upper case- to create artifact registries for, as defined in https://cloud.google.com/artifact-registry/docs/supported-formats . Examples is DOCKER, PYTHON",
"description": "A list of registries/repositories to create",
"items": {
"type": "string",
"pattern": "^[A-Z-_]*$"
"type": "object",
"properties": {
"format": {
"type": "string",
"description": "The format of the registry, in upper case. See https://cloud.google.com/artifact-registry/docs/supported-formats."
},
"location": {
"type": "string",
"description": "The location for the registry."
}
}
}
},
"repos": {
Expand Down
Loading