summaryrefslogtreecommitdiffstats
path: root/kubernetes/portal/Makefile
blob: 8af301d7aec64e745bba3f6f6c76303b01d6ddb9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Copyright © 2020 Samsung Electronics
#
# 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
#
#       http://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.

ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
OUTPUT_DIR := $(ROOT_DIR)/../dist
PACKAGE_DIR := $(OUTPUT_DIR)/packages
SECRET_DIR := $(OUTPUT_DIR)/secrets

EXCLUDES := dist resources templates charts docker
HELM_CHARTS := $(filter-out $(EXCLUDES), $(sort $(patsubst %/.,%,$(wildcard */.))))

.PHONY: $(EXCLUDES) $(HELM_CHARTS)

all: $(HELM_CHARTS)

$(HELM_CHARTS):
	@echo "\n[$@]"
	@make package-$@

make-%:
	@if [ -f $*/Makefile ]; then make -C $*; fi

dep-%: make-%
	@if [ -f $*/requirements.yaml ]; then helm dep up $*; fi

lint-%: dep-%
	@if [ -f $*/Chart.yaml ]; then helm lint $*; fi

package-%: lint-%
	@mkdir -p $(PACKAGE_DIR)
	@if [ -f $*/Chart.yaml ]; then helm package -d $(PACKAGE_DIR) $*; fi
	@helm repo index $(PACKAGE_DIR)

clean:
	@rm -f */requirements.lock
	@rm -f *tgz */charts/*tgz
	@rm -rf $(PACKAGE_DIR)
%:
	@:
} /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
/*-
 * ============LICENSE_START=======================================================
 * SDC
 * ================================================================================
 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
 * ================================================================================
 * 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
 * 
 *      http://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.
 * ============LICENSE_END=========================================================
 */

package org.openecomp.sdc.versioning;

import org.openecomp.core.dao.BaseDao;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.versioning.dao.types.Version;
import org.openecomp.sdc.versioning.dao.types.VersionableEntity;
import org.openecomp.sdc.versioning.errors.RequestedVersionInvalidErrorBuilder;
import org.openecomp.sdc.versioning.errors.VersionableSubEntityNotFoundErrorBuilder;
import org.openecomp.sdc.versioning.types.VersionInfo;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * The type Versioning util.
 */
public class VersioningUtil {

  /**
   * Validate entity existence.
   *
   * @param <T>                   the type parameter
   * @param retrievedEntity       the retrieved entity
   * @param inputEntity           the input entity
   * @param firstClassCitizenType the first class citizen type
   */
  public static <T extends VersionableEntity> void validateEntityExistence(Object retrievedEntity,
                                                                 T inputEntity,
                                                                 String firstClassCitizenType) {
    if (retrievedEntity == null) {
      throw new CoreException(new VersionableSubEntityNotFoundErrorBuilder(
          inputEntity.getEntityType(),
          inputEntity.getId(),
          firstClassCitizenType,
          inputEntity.getFirstClassCitizenId(),
          inputEntity.getVersion()).build());
    }
  }

  /**
   * Validate entities existence.
   *
   * @param <T>                   the type parameter
   * @param <D>                   the type parameter
   * @param entityIds             the entity ids
   * @param entity                the entity
   * @param entityDao             the entity dao
   * @param firstClassCitizenType the first class citizen type
   */
  public static <T extends VersionableEntity, D extends BaseDao<T>> void validateEntitiesExistence(
      Set<String> entityIds, T entity, D entityDao, String firstClassCitizenType) {
    if (entityIds == null) {
      return;
    }

    List<String> nonExistingIds = new ArrayList<>();
    for (String entityId : entityIds) {
      entity.setId(entityId);
      if (entityDao.get(entity) == null) {
        nonExistingIds.add(entityId);
      }
    }

    if (nonExistingIds.size() > 0) {
      if (nonExistingIds.size() == 1) {
        throw new CoreException(new VersionableSubEntityNotFoundErrorBuilder(
            entity.getEntityType(),
            nonExistingIds.get(0),
            firstClassCitizenType,
            entity.getFirstClassCitizenId(),
            entity.getVersion()).build());
      }
      throw new CoreException(new VersionableSubEntityNotFoundErrorBuilder(
          entity.getEntityType(),
          nonExistingIds,
          firstClassCitizenType,
          entity.getFirstClassCitizenId(),
          entity.getVersion()).build());
    }
  }

  /**
   * Validate contained entities existence.
   *
   * @param <T>                         the type parameter
   * @param containedEntityType         the contained entity type
   * @param inputContainedEntityIds     the input contained entity ids
   * @param containingEntity            the containing entity
   * @param retrievedContainedEntityIds the retrieved contained entity ids
   */
  public static <T extends VersionableEntity> void validateContainedEntitiesExistence(
      String containedEntityType, Set<String> inputContainedEntityIds, T containingEntity,
      Set<String> retrievedContainedEntityIds) {
    if (inputContainedEntityIds == null) {
      return;
    }

    List<String> nonExistingIds = inputContainedEntityIds.stream()
        .filter(entityId -> !retrievedContainedEntityIds.contains(entityId))
        .collect(Collectors.toList());

    if (nonExistingIds.size() > 0) {
      if (nonExistingIds.size() == 1) {
        throw new CoreException(new VersionableSubEntityNotFoundErrorBuilder(
            containedEntityType,
            nonExistingIds.get(0),
            containingEntity.getEntityType(),
            containingEntity.getId(),
            containingEntity.getVersion()).build());
      }
      throw new CoreException(new VersionableSubEntityNotFoundErrorBuilder(
          containedEntityType,
          nonExistingIds,
          containingEntity.getEntityType(),
          containingEntity.getId(),
          containingEntity.getVersion()).build());
    }
  }

  /**
   * Resolve version version.
   *
   * @param requestedVersion the requested version
   * @param versionInfo      the version info
   * @param finalOnly        the final only
   * @return the version
   */
  public static Version resolveVersion(Version requestedVersion, VersionInfo versionInfo,
                                       boolean finalOnly) {
    if (requestedVersion == null) {
      if (finalOnly) {
        if (versionInfo.getLatestFinalVersion() == null) {
          throw new CoreException(new RequestedVersionInvalidErrorBuilder().build());
        }
        requestedVersion = versionInfo.getLatestFinalVersion();
      } else {
        requestedVersion = versionInfo.getActiveVersion();
      }
    } else {
      if ((finalOnly && !requestedVersion.isFinal())
          || !versionInfo.getViewableVersions().contains(requestedVersion)) {
        throw new CoreException(new RequestedVersionInvalidErrorBuilder().build());
      }
    }
    return requestedVersion;
  }

  /**
   * Resolve version version.
   *
   * @param requestedVersion the requested version
   * @param versionInfo      the version info
   * @return the version
   */
  public static Version resolveVersion(Version requestedVersion, VersionInfo versionInfo) {
    if (requestedVersion == null) {
      requestedVersion = versionInfo.getActiveVersion();
    } else {
      if (!versionInfo.getViewableVersions().contains(requestedVersion)) {
        throw new CoreException(new RequestedVersionInvalidErrorBuilder().build());
      }
    }
    return requestedVersion;
  }
}