blob: 2917a5ae2879827acd563ee4d2b52abb811044ce [file] [log] [blame]
garciadeblas8d8cd992024-05-21 16:04:14 +02001#!/bin/bash
2#######################################################################################
3# Copyright ETSI Contributors and Others.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14# implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#######################################################################################
18
19set -e -o pipefail
20
21export HERE=$(dirname "$(readlink --canonicalize "$BASH_SOURCE")")
22source "${HERE}/library/functions.sh"
23source "${HERE}/library/trap.sh"
24
25
garciadeblas8a28f6d2025-06-11 11:11:56 +020026# Preparation for Openshift
27if [ -n "${OPENSHIFT_MGMT_CLUSTER}" ]; then
28 m "Detected OpenShift management cluster, initilializing flux with SCC..." "${GREEN}"
29 # Preparation for Openshift
30 pushd "${FLEET_REPO_DIR}" > /dev/null
31 FLUX_SYSTEM_DIR="clusters/_management/flux-system"
32 FLUX_SYSTEM_SW_CATALOG_DIR="${HERE}/../templates/sw-catalogs/cloud-resources/flux-remote-bootstrap/cluster-base-openshift/templates/flux-system"
33 mkdir -p "${FLUX_SYSTEM_DIR}"
34 touch "${FLUX_SYSTEM_DIR}/gotk-components.yaml"
35 touch "${FLUX_SYSTEM_DIR}/gotk-sync.yaml"
36 cp "${FLUX_SYSTEM_SW_CATALOG_DIR}/scc.yaml" "${FLUX_SYSTEM_DIR}"
37 cp "${FLUX_SYSTEM_SW_CATALOG_DIR}/kustomization.yaml" "${FLUX_SYSTEM_DIR}"
38 # git status
39 git add -A
40 git commit -m "init flux"
41 git pull origin main
42 git push -u origin main
43 popd > /dev/null
44fi
45
garciadeblas8d8cd992024-05-21 16:04:14 +020046# Bootstrap
garciadeblas8d8cd992024-05-21 16:04:14 +020047GIT_PATH=./clusters/_management
48GIT_BRANCH=main
garciadeblas8a28f6d2025-06-11 11:11:56 +020049if [ -n "${MGMT_CLUSTER_CA_FILE}" ]; then
50 flux bootstrap git \
51 --url=${FLEET_REPO_HTTP_URL} \
52 --allow-insecure-http=true \
53 --username=${FLEET_REPO_GIT_USERNAME} \
54 --password="${FLEET_REPO_GIT_USER_PASS}" \
55 --token-auth=true \
56 --branch=${GIT_BRANCH} \
57 --ca-file=${MGMT_CLUSTER_CA_FILE} \
58 --path=${GIT_PATH}
59else
60 flux bootstrap git \
61 --url=${FLEET_REPO_HTTP_URL} \
62 --allow-insecure-http=true \
63 --username=${FLEET_REPO_GIT_USERNAME} \
64 --password="${FLEET_REPO_GIT_USER_PASS}" \
65 --token-auth=true \
66 --branch=${GIT_BRANCH} \
67 --path=${GIT_PATH}
68fi
garciadeblas8d8cd992024-05-21 16:04:14 +020069
70# Check if successful
71flux check