Commit 1bf09be6 authored by Kostis Trantzas's avatar Kostis Trantzas
Browse files

Merge branch 'develop' into 'main'

MR for Release 2024Q4

Closes #10

See merge request !10
parents b344ac8f 8c8e53f5
Loading
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ include:
      - ci-templates/default.yml
      - ci-templates/build.yml
    rules:
      - if: '$CI_COMMIT_REF_PROTECTED && $CI_COMMIT_REF_NAME != "main" && $CI_COMMIT_REF_NAME != "develop"'
      - if: '$CI_COMMIT_REF_PROTECTED == "true" && $CI_COMMIT_REF_NAME != "main" && $CI_COMMIT_REF_NAME != "develop"'

  - project: osl/code/org.etsi.osl.main
    ref: develop
@@ -29,7 +29,7 @@ include:
      - ci-templates/default.yml
      - ci-templates/build_unprotected.yml
    rules:
      - if: '$CI_COMMIT_REF_NAME != "main" && $CI_COMMIT_REF_NAME != "develop" && !$CI_COMMIT_REF_PROTECTED'
      - if: '$CI_COMMIT_REF_NAME != "main" && $CI_COMMIT_REF_NAME != "develop" && $CI_COMMIT_REF_PROTECTED == "false"'

maven_build:
  extends: .maven_build
+2 −1
Original line number Diff line number Diff line
@@ -5,12 +5,13 @@
	<parent>
		<groupId>org.etsi.osl</groupId>
		<artifactId>org.etsi.osl.main</artifactId>
		<version>1.0.0</version>
		<version>2024Q4</version>
		<relativePath>../org.etsi.osl.main</relativePath>
	</parent>


	<artifactId>org.etsi.osl.model.k8s</artifactId>
	<version>${org.etsi.osl.model.k8s.version}</version>
	

	<properties>
+2 −2
Original line number Diff line number Diff line
@@ -115,7 +115,7 @@ public class KubernetesCRV1 extends DomainModelDefinition
		rsc.addResourceSpecificationCharacteristicItemShort( "UID", "", EValueType.TEXT.getValue(), "", false);
		rsc.addResourceSpecificationCharacteristicItemShort( "namespace", "", EValueType.TEXT.getValue(), "", false);
		rsc.addResourceSpecificationCharacteristicItemShort( "metadata", "", EValueType.TEXT.getValue(), "", false);
		rsc.addResourceSpecificationCharacteristicItemShort( "yaml", "", EValueType.TEXT.getValue(), "", false);
//		rsc.addResourceSpecificationCharacteristicItemShort( "yaml", "", EValueType.TEXT.getValue(), "", false);
        rsc.addResourceSpecificationCharacteristicItemShort( "json", "", EValueType.TEXT.getValue(), "", false);

        rsc.addResourceSpecificationCharacteristicItemShort( "_CR_SPEC", "", EValueType.TEXT.getValue(), "Used for providing the json Custom Resource description to apply", false);
@@ -179,7 +179,7 @@ public class KubernetesCRV1 extends DomainModelDefinition
		rs.addResourceCharacteristicItemShort("UID", this.UID, EValueType.TEXT.getValue());
		rs.addResourceCharacteristicItemShort("namespace", this.namespace, EValueType.TEXT.getValue());
		rs.addResourceCharacteristicItemShort("metadata", this.metadata, EValueType.TEXT.getValue());
		rs.addResourceCharacteristicItemShort("yaml", this.yaml, EValueType.TEXT.getValue());
//		rs.addResourceCharacteristicItemShort("yaml", this.yaml, EValueType.TEXT.getValue());
        rs.addResourceCharacteristicItemShort("json", this.json, EValueType.TEXT.getValue());
        

+219 −0
Original line number Diff line number Diff line
package org.etsi.osl.domain.model.kubernetes;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
import org.etsi.osl.domain.model.DomainModelDefinition;
import org.etsi.osl.domain.model.ITMFRCM634_ModelTransformer;
import org.etsi.osl.domain.model.ITMFRI639_ModelTransformer;
import org.etsi.osl.tmf.common.model.ELifecycle;
import org.etsi.osl.tmf.common.model.EValueType;
import org.etsi.osl.tmf.rcm634.model.ResourceSpecification;
import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationCreate;
import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationRef;
import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationUpdate;
import org.etsi.osl.tmf.ri639.model.ResourceCreate;
import org.etsi.osl.tmf.ri639.model.ResourceOperationalStateType;
import org.etsi.osl.tmf.ri639.model.ResourceStatusType;
import org.etsi.osl.tmf.ri639.model.ResourceUpdate;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;

/**
 * @author ctranoris
 */
@Getter
@Setter
public class KubernetesConfigMap extends DomainModelDefinition
		implements ITMFRCM634_ModelTransformer, ITMFRI639_ModelTransformer {

	public static final String OSL_KUBCMAP_RSPEC_NAME = "kubernetes-configmap.openslice.io";
	public static final String OSL_KUBCMAP_RSPEC_VERSION = "0.0.1";
	public static final String OSL_KUBCMAP_RSPEC_CATEGORY = "ConfigMap/Kubernetes/v1";
	public static final String OSL_KUBCMAP_RESOURCE_CATEGORY = "ConfigMap/Kubernetes/v1";
	public static final String OSL_KUBCMAP_RSPEC_TYPE = "LogicalResourceSpecification";
	public static final String OSL_KUBCMAP_RSPEC_DESCRIPTION = "This Specification is used to describe a generic Kubernetes Service";

	private String osl_KUBCRD_RSPEC_UUID = null; //this is assigned by the system through the DB for a specific instance
	
	private String clusterMasterURL;
	private String currentContextCluster;
	private String fullResourceName;
	private String kind;
	private String apiGroup;
	private String UID;
	private String metadata;
	private String yaml;
	private String json;
    private String namespace;
	

    private Map<String, String> data;
    private String dataObj;
	private Map<String, String> properties;


	@Builder
	public KubernetesConfigMap(String osl_KUBCRD_RSPEC_UUID, String uuid, String name, String version, String description, String category,
			String clusterMasterURL, String currentContextCluster, String fullResourceName, String namespace,
			String kind, String apiGroup, String uID,
			String metadata,
			String yaml,
			String json) {
		super(uuid, name, version, description, category);
		this.osl_KUBCRD_RSPEC_UUID = osl_KUBCRD_RSPEC_UUID;
		this.clusterMasterURL = clusterMasterURL;
		this.currentContextCluster = currentContextCluster;
		this.fullResourceName = fullResourceName;
		this.kind = kind;
		this.apiGroup = apiGroup;
        this.namespace = namespace;
		this.UID = uID;
		this.metadata = metadata;
		this.yaml = yaml;
		this.json = json;
        this.properties = new HashMap<>();
        this.data = new HashMap<>();
		this.category = OSL_KUBCMAP_RSPEC_CATEGORY;
	}
	
	

	@Override
	public ResourceSpecificationCreate toRSpecCreate_InitRepo() {

		ResourceSpecificationCreate rsc = this.toRSpecCreate();
		rsc.setName( OSL_KUBCMAP_RSPEC_NAME );
		rsc.setCategory( OSL_KUBCMAP_RSPEC_CATEGORY );
		rsc.setVersion(OSL_KUBCMAP_RSPEC_VERSION);
		rsc.setDescription( OSL_KUBCMAP_RSPEC_DESCRIPTION );
		rsc.setType( OSL_KUBCMAP_RSPEC_TYPE );
		
		

		return rsc;
	}
	
	@Override
	public ResourceSpecificationCreate toRSpecCreate() {

		ResourceSpecificationCreate rsc = new ResourceSpecificationCreate();
		rsc.setName( this.name );
		rsc.setCategory( OSL_KUBCMAP_RSPEC_CATEGORY );
		rsc.setVersion( this.version );
		rsc.setDescription( this.version );
		rsc.setType( OSL_KUBCMAP_RSPEC_TYPE );
		
		rsc.setLifecycleStatus( ELifecycle.ACTIVE.getValue() );
		rsc.addResourceSpecificationCharacteristicItemShort("clusterMasterURL", this.clusterMasterURL, EValueType.TEXT.getValue(), "URL of cluster",  false);
		rsc.addResourceSpecificationCharacteristicItemShort("currentContextCluster", this.currentContextCluster, EValueType.TEXT.getValue(), "", false);
		rsc.addResourceSpecificationCharacteristicItemShort("fullResourceName", this.fullResourceName, EValueType.TEXT.getValue(), "", false);
		rsc.addResourceSpecificationCharacteristicItemShort("Kind", this.kind, EValueType.TEXT.getValue(), "", false);
		rsc.addResourceSpecificationCharacteristicItemShort("apiGroup", this.apiGroup, EValueType.TEXT.getValue(), "", false);
		rsc.addResourceSpecificationCharacteristicItemShort("UID", this.UID, EValueType.TEXT.getValue(), "", false);
		rsc.addResourceSpecificationCharacteristicItemShort("metadata", this.metadata, EValueType.OBJECT.getValue(), "", false);
//		rsc.addResourceSpecificationCharacteristicItemShort("yaml", this.yaml, EValueType.TEXT.getValue(), "", false);
		rsc.addResourceSpecificationCharacteristicItemShort("json", this.json, EValueType.TEXT.getValue(), "", false);
        rsc.addResourceSpecificationCharacteristicItemShort("data", this.dataObj, EValueType.OBJECT.getValue(), "", false);
        
		if (this.properties != null)
		  this.properties.forEach((kPropName, vProVal) -> {
		    EValueType etype;		 
		    etype = EValueType.TEXT;
		    rsc.addResourceSpecificationCharacteristicItemShort(kPropName , vProVal, etype.getValue(), "", false);

		  });
		if (this.data != null)
		  this.data.forEach((kPropName, vProVal) -> {
		    EValueType etype;        
		    etype = EValueType.TEXT;
		    rsc.addResourceSpecificationCharacteristicItemShort(kPropName , vProVal, etype.getValue(), "", false);

		  });
		


		return rsc;
	}
	
	@Override
	public ResourceSpecificationUpdate toRSpecUpdate() {
		return this.toRSpecCreate();
	}

	@Override
	public KubernetesConfigMap fromRSpec(ResourceSpecification rSpec) {
		this.osl_KUBCRD_RSPEC_UUID = rSpec.getUuid();
		return this;
	}
	
	@Override
	public ResourceCreate toResourceCreate() {

		if (osl_KUBCRD_RSPEC_UUID == null) {
			return null;
		}

		ResourceSpecificationRef rSpecRef = new ResourceSpecificationRef();
		rSpecRef.setId( osl_KUBCRD_RSPEC_UUID  );
		rSpecRef.setName( OSL_KUBCMAP_RSPEC_NAME );
		rSpecRef.setVersion( OSL_KUBCMAP_RSPEC_VERSION );
		
		ResourceCreate rs = new ResourceCreate();
		rs.name( this.name )
		.category( OSL_KUBCMAP_RESOURCE_CATEGORY )
		.description( this.description )
		.resourceStatus( ResourceStatusType.AVAILABLE )
		.operationalState( ResourceOperationalStateType.ENABLE )
		.resourceSpecification( rSpecRef )
		.resourceVersion( this.version);
		
	      String cprefix = "";
	        if ( this.name.indexOf('@')>0) {
	            String firstToken = this.name.substring(  0, this.name.indexOf('@') );
	            cprefix = this.kind + "." + firstToken + ".";         
	        }
	        
	        
		rs.addResourceCharacteristicItemShort("clusterMasterURL", this.clusterMasterURL, EValueType.TEXT.getValue());
		rs.addResourceCharacteristicItemShort("currentContextCluster", this.currentContextCluster, EValueType.TEXT.getValue());
		rs.addResourceCharacteristicItemShort("fullResourceName", this.fullResourceName, EValueType.TEXT.getValue());
		rs.addResourceCharacteristicItemShort("Kind", this.kind, EValueType.TEXT.getValue());
		rs.addResourceCharacteristicItemShort("apiGroup", this.apiGroup, EValueType.TEXT.getValue());
		rs.addResourceCharacteristicItemShort("UID", this.UID, EValueType.TEXT.getValue());
		rs.addResourceCharacteristicItemShort("metadata", this.metadata, EValueType.OBJECT.getValue());
//		//rs.addResourceCharacteristicItemShort("yaml", this.yaml, EValueType.TEXT.getValue());
		rs.addResourceCharacteristicItemShort("json", this.json, EValueType.TEXT.getValue());
		rs.addResourceCharacteristicItemShort("data", this.dataObj, EValueType.OBJECT.getValue());
		

		if (this.properties != null)
		  this.properties.forEach((kPropName, vProVal) -> {
		    EValueType etype;
		    etype = EValueType.TEXT;

		    rs.addResourceCharacteristicItemShort( kPropName , vProVal, etype.getValue());

		  });
        if (this.data != null)
          this.data.forEach((kPropName, vProVal) -> {
            EValueType etype;        
            etype = EValueType.TEXT;
            rs.addResourceCharacteristicItemShort( kPropName , vProVal, etype.getValue());

          });




		return rs;
	}
	
	@Override
	public ResourceUpdate toResourceUpdate() {
	
		return this.toResourceCreate();
	}

}
+12 −6
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@ package org.etsi.osl.domain.model.kubernetes;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
import org.etsi.osl.domain.model.DomainModelDefinition;
import org.etsi.osl.domain.model.ITMFRCM634_ModelTransformer;
import org.etsi.osl.domain.model.ITMFRI639_ModelTransformer;
@@ -112,7 +113,7 @@ public class KubernetesSecret extends DomainModelDefinition
		rsc.addResourceSpecificationCharacteristicItemShort("apiGroup", this.apiGroup, EValueType.TEXT.getValue(), "", false);
		rsc.addResourceSpecificationCharacteristicItemShort("UID", this.UID, EValueType.TEXT.getValue(), "", false);
		rsc.addResourceSpecificationCharacteristicItemShort("metadata", this.metadata, EValueType.OBJECT.getValue(), "", false);
		rsc.addResourceSpecificationCharacteristicItemShort("yaml", this.yaml, EValueType.TEXT.getValue(), "", false);
//		rsc.addResourceSpecificationCharacteristicItemShort("yaml", this.yaml, EValueType.TEXT.getValue(), "", false);
		rsc.addResourceSpecificationCharacteristicItemShort("json", this.json, EValueType.TEXT.getValue(), "", false);
        rsc.addResourceSpecificationCharacteristicItemShort("data", this.dataObj, EValueType.OBJECT.getValue(), "", false);
        
@@ -168,6 +169,13 @@ public class KubernetesSecret extends DomainModelDefinition
		.resourceSpecification( rSpecRef )
		.resourceVersion( this.version);
		
        String cprefix = "";
        if ( this.name.indexOf('@')>0) {
            String firstToken = this.name.substring(  0, this.name.indexOf('@') );
            cprefix = this.kind + "." + firstToken + ".";         
        }
        
        
		rs.addResourceCharacteristicItemShort("clusterMasterURL", this.clusterMasterURL, EValueType.TEXT.getValue());
		rs.addResourceCharacteristicItemShort("currentContextCluster", this.currentContextCluster, EValueType.TEXT.getValue());
		rs.addResourceCharacteristicItemShort("fullResourceName", this.fullResourceName, EValueType.TEXT.getValue());
@@ -175,13 +183,11 @@ public class KubernetesSecret extends DomainModelDefinition
		rs.addResourceCharacteristicItemShort("apiGroup", this.apiGroup, EValueType.TEXT.getValue());
		rs.addResourceCharacteristicItemShort("UID", this.UID, EValueType.TEXT.getValue());
		rs.addResourceCharacteristicItemShort("metadata", this.metadata, EValueType.OBJECT.getValue());
		rs.addResourceCharacteristicItemShort("yaml", this.yaml, EValueType.TEXT.getValue());
//		//rs.addResourceCharacteristicItemShort("yaml", this.yaml, EValueType.TEXT.getValue());
		rs.addResourceCharacteristicItemShort("json", this.json, EValueType.TEXT.getValue());
        rs.addResourceCharacteristicItemShort("data", this.dataObj, EValueType.OBJECT.getValue());
		


        
		if (this.properties != null)
		  this.properties.forEach((kPropName, vProVal) -> {
		    EValueType etype;
Loading