Compare commits
109 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2395ab6e14 | ||
|
|
8efe053ffa | ||
|
|
612600b88c | ||
|
|
4d7df52dbe | ||
|
|
b6c63a1aa4 | ||
|
|
a4788ce6bb | ||
|
|
0ba6fc1b36 | ||
|
|
0e35c209d9 | ||
|
|
3b9b2cbe9f | ||
|
|
45240bdb71 | ||
|
|
22a5ac7f0f | ||
|
|
d55d185044 | ||
|
|
2bb09697ce | ||
|
|
f316aff2d3 | ||
|
|
433628791b | ||
|
|
4f52b77563 | ||
|
|
52145c045d | ||
|
|
512761080e | ||
|
|
037a5b71fd | ||
|
|
b66bdec61a | ||
|
|
16f52610ab | ||
|
|
b2f018e29b | ||
|
|
1f497cac44 | ||
|
|
4abe69f90a | ||
|
|
75023011d3 | ||
|
|
09f145d880 | ||
|
|
811cd4248f | ||
|
|
a4871724ac | ||
|
|
a7d6446d8f | ||
|
|
635a17ef1e | ||
|
|
6280fbce17 | ||
|
|
daa72e72b0 | ||
|
|
35bb770697 | ||
|
|
9cc5a7d8de | ||
|
|
9b62f01b53 | ||
|
|
a643a82006 | ||
|
|
82b74d8689 | ||
|
|
a5825bb9f5 | ||
|
|
88a890d717 | ||
|
|
be6fab795d | ||
|
|
7a5b9e2991 | ||
|
|
ee1f70841c | ||
|
|
adc3d17eab | ||
|
|
f909d6fde2 | ||
|
|
016a388147 | ||
|
|
aea442e7e1 | ||
|
|
bb013ceb28 | ||
|
|
dd65e9b89d | ||
|
|
12146eda8c | ||
|
|
cd87fbba0d | ||
|
|
c73541f81f | ||
|
|
4618998792 | ||
|
|
0a3b581aa9 | ||
|
|
aaa319b9bf | ||
|
|
25e782177b | ||
|
|
e940fd3d1f | ||
|
|
31d5cb4ad8 | ||
|
|
21576fe459 | ||
|
|
65863a2cb8 | ||
|
|
cdd055bfa6 | ||
|
|
fedf960a5f | ||
|
|
4546fa3270 | ||
|
|
979f3f557c | ||
|
|
48a38a8a5d | ||
|
|
9880b32b0a | ||
|
|
e664ef7a8d | ||
|
|
7cfef379d0 | ||
|
|
093a91c7fc | ||
|
|
94687a047f | ||
|
|
38fdc603ad | ||
|
|
55cecb7f96 | ||
|
|
32e949598e | ||
|
|
6d0c8aff4b | ||
|
|
5eecf03af6 | ||
|
|
76e9884032 | ||
|
|
9867c4baf0 | ||
|
|
2bc05c8cbd | ||
|
|
d15b0107e4 | ||
|
|
c64cb1304d | ||
|
|
c1f209c7a5 | ||
|
|
116ccd6b3b | ||
|
|
b6f30ae3e1 | ||
|
|
5c522ed2e1 | ||
|
|
bc29b80912 | ||
|
|
cfbc17fbf8 | ||
|
|
af0c939302 | ||
|
|
e02538d38d | ||
|
|
001d37567c | ||
|
|
af82ce31a6 | ||
|
|
12ad4908fa | ||
|
|
40ef94ab45 | ||
|
|
8834ab0210 | ||
|
|
128d23720f | ||
|
|
90f4891ca9 | ||
|
|
61ac81c4d9 | ||
|
|
bd05a8173c | ||
|
|
e3d6461a80 | ||
|
|
2bb582f7ed | ||
|
|
2f9a52852f | ||
|
|
137f083b4d | ||
|
|
11f4c54a40 | ||
|
|
c813eaf6d1 | ||
|
|
ffdaa9dfe9 | ||
|
|
182928002b | ||
|
|
7222af2b7e | ||
|
|
034ead5272 | ||
|
|
eca1f19e95 | ||
|
|
ec70c14649 | ||
|
|
65d906a735 |
17
.github/aur/flux-bin/.SRCINFO.template
vendored
Normal file
17
.github/aur/flux-bin/.SRCINFO.template
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
pkgbase = flux-bin
|
||||||
|
pkgdesc = Open and extensible continuous delivery solution for Kubernetes
|
||||||
|
pkgver = ${PKGVER}
|
||||||
|
pkgrel = ${PKGREL}
|
||||||
|
url = https://fluxcd.io/
|
||||||
|
arch = x86_64
|
||||||
|
arch = armv6h
|
||||||
|
arch = armv7h
|
||||||
|
arch = aarch64
|
||||||
|
license = APACHE
|
||||||
|
optdepends = kubectl
|
||||||
|
source_x86_64 = flux-bin-${PKGVER}.tar.gz::https://github.com/fluxcd/flux2/releases/download/v1/flux_${PKGVER}_linux_amd64.tar.gz
|
||||||
|
source_armv6h = flux-bin-${PKGVER}.tar.gz::https://github.com/fluxcd/flux2/releases/download/v1/flux_${PKGVER}_linux_arm.tar.gz
|
||||||
|
source_armv7h = flux-bin-${PKGVER}.tar.gz::https://github.com/fluxcd/flux2/releases/download/v1/flux_${PKGVER}_linux_arm.tar.gz
|
||||||
|
source_aarch64 = flux-bin-${PKGVER}.tar.gz::https://github.com/fluxcd/flux2/releases/download/v1/flux_${PKGVER}_linux_arm64.tar.gz
|
||||||
|
|
||||||
|
pkgname = flux-bin
|
||||||
1
.github/aur/flux-bin/.gitignore
vendored
Normal file
1
.github/aur/flux-bin/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.pkg
|
||||||
39
.github/aur/flux-bin/PKGBUILD.template
vendored
Normal file
39
.github/aur/flux-bin/PKGBUILD.template
vendored
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
# Maintainer: Aurel Canciu <aurelcanciu@gmail.com>
|
||||||
|
# Maintainer: Hidde Beydals <hello@hidde.co>
|
||||||
|
|
||||||
|
pkgname=flux-bin
|
||||||
|
pkgver=${PKGVER}
|
||||||
|
pkgrel=${PKGREL}
|
||||||
|
pkgdesc="Open and extensible continuous delivery solution for Kubernetes"
|
||||||
|
url="https://fluxcd.io/"
|
||||||
|
arch=("x86_64" "armv6h" "armv7h" "aarch64")
|
||||||
|
license=("APACHE")
|
||||||
|
optdepends=("kubectl")
|
||||||
|
source_x86_64=(
|
||||||
|
"$pkgname-$pkgver.tar.gz::https://github.com/fluxcd/flux2/releases/download/v${pkgver}/flux_${pkgver}_linux_amd64.tar.gz"
|
||||||
|
)
|
||||||
|
source_armv6h=(
|
||||||
|
"$pkgname-$pkgver.tar.gz::https://github.com/fluxcd/flux2/releases/download/v${pkgver}/flux_${pkgver}_linux_arm.tar.gz"
|
||||||
|
)
|
||||||
|
source_armv7h=(
|
||||||
|
"$pkgname-$pkgver.tar.gz::https://github.com/fluxcd/flux2/releases/download/v${pkgver}/flux_${pkgver}_linux_arm.tar.gz"
|
||||||
|
)
|
||||||
|
source_aarch64=(
|
||||||
|
"$pkgname-$pkgver.tar.gz::https://github.com/fluxcd/flux2/releases/download/v${pkgver}/flux_${pkgver}_linux_arm64.tar.gz"
|
||||||
|
)
|
||||||
|
sha256sums_x86_64=(
|
||||||
|
${SHA256SUM_AMD64}
|
||||||
|
)
|
||||||
|
sha256sums_armv6h=(
|
||||||
|
${SHA256SUM_ARM}
|
||||||
|
)
|
||||||
|
sha256sums_armv7h=(
|
||||||
|
${SHA256SUM_ARM}
|
||||||
|
)
|
||||||
|
sha256sums_aarch64=(
|
||||||
|
${SHA256SUM_ARM64}
|
||||||
|
)
|
||||||
|
|
||||||
|
package() {
|
||||||
|
install -Dm755 flux "$pkgdir/usr/bin/flux"
|
||||||
|
}
|
||||||
55
.github/aur/flux-bin/publish.sh
vendored
Executable file
55
.github/aur/flux-bin/publish.sh
vendored
Executable file
@@ -0,0 +1,55 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
WD=$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd)
|
||||||
|
PKGNAME=$(basename $WD)
|
||||||
|
ROOT=${WD%/.github/aur/$PKGNAME}
|
||||||
|
|
||||||
|
LOCKFILE=/tmp/aur-$PKGNAME.lock
|
||||||
|
exec 100>$LOCKFILE || exit 0
|
||||||
|
flock -n 100 || exit 0
|
||||||
|
trap "rm -f $LOCKFILE" EXIT
|
||||||
|
|
||||||
|
export VERSION=$1
|
||||||
|
echo "Publishing to AUR as version ${VERSION}"
|
||||||
|
|
||||||
|
cd $WD
|
||||||
|
|
||||||
|
export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
|
||||||
|
|
||||||
|
eval $(ssh-agent -s)
|
||||||
|
ssh-add <(echo "$AUR_BOT_SSH_PRIVATE_KEY")
|
||||||
|
|
||||||
|
GITDIR=$(mktemp -d /tmp/aur-$PKGNAME-XXX)
|
||||||
|
trap "rm -rf $GITDIR" EXIT
|
||||||
|
git clone aur@aur.archlinux.org:$PKGNAME $GITDIR 2>&1
|
||||||
|
|
||||||
|
CURRENT_PKGVER=$(cat $GITDIR/.SRCINFO | grep pkgver | awk '{ print $3 }')
|
||||||
|
CURRENT_PKGREL=$(cat $GITDIR/.SRCINFO | grep pkgrel | awk '{ print $3 }')
|
||||||
|
|
||||||
|
export PKGVER=${VERSION/-/}
|
||||||
|
|
||||||
|
if [[ "${CURRENT_PKGVER}" == "${PKGVER}" ]]; then
|
||||||
|
export PKGREL=$((CURRENT_PKGREL+1))
|
||||||
|
else
|
||||||
|
export PKGREL=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
export SHA256SUM_ARM=$(sha256sum ${ROOT}/dist/flux_${PKGVER}_linux_arm.tar.gz | awk '{ print $1 }')
|
||||||
|
export SHA256SUM_ARM64=$(sha256sum ${ROOT}/dist/flux_${PKGVER}_linux_arm64.tar.gz | awk '{ print $1 }')
|
||||||
|
export SHA256SUM_AMD64=$(sha256sum ${ROOT}/dist/flux_${PKGVER}_linux_amd64.tar.gz | awk '{ print $1 }')
|
||||||
|
|
||||||
|
envsubst '$PKGVER $PKGREL $SHA256SUM_AMD64 $SHA256SUM_ARM $SHA256SUM_ARM64' < .SRCINFO.template > $GITDIR/.SRCINFO
|
||||||
|
envsubst '$PKGVER $PKGREL $SHA256SUM_AMD64 $SHA256SUM_ARM $SHA256SUM_ARM64' < PKGBUILD.template > $GITDIR/PKGBUILD
|
||||||
|
|
||||||
|
cd $GITDIR
|
||||||
|
git config user.name "fluxcdbot"
|
||||||
|
git config user.email "fluxcdbot@users.noreply.github.com"
|
||||||
|
git add -A
|
||||||
|
if [ -z "$(git status --porcelain)" ]; then
|
||||||
|
echo "No changes."
|
||||||
|
else
|
||||||
|
git commit -m "Updated to version v${PKGVER} release ${PKGREL}"
|
||||||
|
git push origin master
|
||||||
|
fi
|
||||||
19
.github/aur/flux-go/.SRCINFO.template
vendored
Normal file
19
.github/aur/flux-go/.SRCINFO.template
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
pkgbase = flux-go
|
||||||
|
pkgdesc = Open and extensible continuous delivery solution for Kubernetes
|
||||||
|
pkgver = ${PKGVER}
|
||||||
|
pkgrel = ${PKGREL}
|
||||||
|
url = https://fluxcd.io/
|
||||||
|
arch = x86_64
|
||||||
|
arch = armv6h
|
||||||
|
arch = armv7h
|
||||||
|
arch = aarch64
|
||||||
|
license = APACHE
|
||||||
|
makedepends = go
|
||||||
|
depends = glibc
|
||||||
|
optdepends = kubectl
|
||||||
|
provides = flux-bin
|
||||||
|
conflicts = flux-bin
|
||||||
|
replaces = flux-cli
|
||||||
|
source = flux-go-${PKGVER}.tar.gz::https://github.com/fluxcd/flux2/archive/v${PKGVER}.tar.gz
|
||||||
|
|
||||||
|
pkgname = flux-go
|
||||||
1
.github/aur/flux-go/.gitignore
vendored
Normal file
1
.github/aur/flux-go/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.pkg
|
||||||
43
.github/aur/flux-go/PKGBUILD.template
vendored
Normal file
43
.github/aur/flux-go/PKGBUILD.template
vendored
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
# Maintainer: Aurel Canciu <aurelcanciu@gmail.com>
|
||||||
|
# Maintainer: Hidde Beydals <hello@hidde.co>
|
||||||
|
|
||||||
|
pkgname=flux-go
|
||||||
|
pkgver=${PKGVER}
|
||||||
|
pkgrel=${PKGREL}
|
||||||
|
pkgdesc="Open and extensible continuous delivery solution for Kubernetes"
|
||||||
|
url="https://fluxcd.io/"
|
||||||
|
arch=("x86_64" "armv6h" "armv7h" "aarch64")
|
||||||
|
license=("APACHE")
|
||||||
|
provides=("flux-bin")
|
||||||
|
conflicts=("flux-bin")
|
||||||
|
replaces=("flux-cli")
|
||||||
|
depends=("glibc")
|
||||||
|
makedepends=("go")
|
||||||
|
optdepends=("kubectl")
|
||||||
|
source=(
|
||||||
|
"$pkgname-$pkgver.tar.gz::https://github.com/fluxcd/flux2/archive/v$pkgver.tar.gz"
|
||||||
|
)
|
||||||
|
sha256sums=(
|
||||||
|
${SHA256SUM}
|
||||||
|
)
|
||||||
|
|
||||||
|
build() {
|
||||||
|
cd "flux2-$pkgver"
|
||||||
|
export CGO_LDFLAGS="$LDFLAGS"
|
||||||
|
export CGO_CFLAGS="$CFLAGS"
|
||||||
|
export CGO_CXXFLAGS="$CXXFLAGS"
|
||||||
|
export CGO_CPPFLAGS="$CPPFLAGS"
|
||||||
|
export GOFLAGS="-buildmode=pie -trimpath -ldflags=-linkmode=external -mod=readonly -modcacherw"
|
||||||
|
go build -ldflags "-X main.VERSION=$pkgver" -o flux-bin ./cmd/flux
|
||||||
|
}
|
||||||
|
|
||||||
|
check() {
|
||||||
|
cd "flux2-$pkgver"
|
||||||
|
make test
|
||||||
|
}
|
||||||
|
|
||||||
|
package() {
|
||||||
|
cd "flux2-$pkgver"
|
||||||
|
install -Dm755 flux-bin "$pkgdir/usr/bin/flux"
|
||||||
|
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
|
||||||
|
}
|
||||||
53
.github/aur/flux-go/publish.sh
vendored
Executable file
53
.github/aur/flux-go/publish.sh
vendored
Executable file
@@ -0,0 +1,53 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
WD=$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd)
|
||||||
|
PKGNAME=$(basename $WD)
|
||||||
|
ROOT=${WD%/.github/aur/$PKGNAME}
|
||||||
|
|
||||||
|
LOCKFILE=/tmp/aur-$PKGNAME.lock
|
||||||
|
exec 100>$LOCKFILE || exit 0
|
||||||
|
flock -n 100 || exit 0
|
||||||
|
trap "rm -f $LOCKFILE" EXIT
|
||||||
|
|
||||||
|
export VERSION=$1
|
||||||
|
echo "Publishing to AUR as version ${VERSION}"
|
||||||
|
|
||||||
|
cd $WD
|
||||||
|
|
||||||
|
export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
|
||||||
|
|
||||||
|
eval $(ssh-agent -s)
|
||||||
|
ssh-add <(echo "$AUR_BOT_SSH_PRIVATE_KEY")
|
||||||
|
|
||||||
|
GITDIR=$(mktemp -d /tmp/aur-$PKGNAME-XXX)
|
||||||
|
trap "rm -rf $GITDIR" EXIT
|
||||||
|
git clone aur@aur.archlinux.org:$PKGNAME $GITDIR 2>&1
|
||||||
|
|
||||||
|
CURRENT_PKGVER=$(cat $GITDIR/.SRCINFO | grep pkgver | awk '{ print $3 }')
|
||||||
|
CURRENT_PKGREL=$(cat $GITDIR/.SRCINFO | grep pkgrel | awk '{ print $3 }')
|
||||||
|
|
||||||
|
export PKGVER=${VERSION/-/}
|
||||||
|
|
||||||
|
if [[ "${CURRENT_PKGVER}" == "${PKGVER}" ]]; then
|
||||||
|
export PKGREL=$((CURRENT_PKGREL+1))
|
||||||
|
else
|
||||||
|
export PKGREL=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
export SHA256SUM=$(curl -sL https://github.com/fluxcd/flux2/archive/v$PKGVER.tar.gz | sha256sum | awk '{ print $1 }')
|
||||||
|
|
||||||
|
envsubst '$PKGVER $PKGREL $SHA256SUM' < .SRCINFO.template > $GITDIR/.SRCINFO
|
||||||
|
envsubst '$PKGVER $PKGREL $SHA256SUM' < PKGBUILD.template > $GITDIR/PKGBUILD
|
||||||
|
|
||||||
|
cd $GITDIR
|
||||||
|
git config user.name "fluxcdbot"
|
||||||
|
git config user.email "fluxcdbot@users.noreply.github.com"
|
||||||
|
git add -A
|
||||||
|
if [ -z "$(git status --porcelain)" ]; then
|
||||||
|
echo "No changes."
|
||||||
|
else
|
||||||
|
git commit -m "Updated to version v${PKGVER} release ${PKGREL}"
|
||||||
|
git push origin master
|
||||||
|
fi
|
||||||
19
.github/aur/flux-scm/.SRCINFO.template
vendored
Normal file
19
.github/aur/flux-scm/.SRCINFO.template
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
pkgbase = flux-scm
|
||||||
|
pkgdesc = Open and extensible continuous delivery solution for Kubernetes
|
||||||
|
pkgver = ${PKGVER}
|
||||||
|
pkgrel = ${PKGREL}
|
||||||
|
url = https://fluxcd.io/
|
||||||
|
arch = x86_64
|
||||||
|
arch = armv6h
|
||||||
|
arch = armv7h
|
||||||
|
arch = aarch64
|
||||||
|
license = APACHE
|
||||||
|
makedepends = go
|
||||||
|
depends = glibc
|
||||||
|
optdepends = kubectl
|
||||||
|
provides = flux-bin
|
||||||
|
conflicts = flux-bin
|
||||||
|
source = git+https://github.com/fluxcd/flux2.git
|
||||||
|
md5sums = SKIP
|
||||||
|
|
||||||
|
pkgname = flux-scm
|
||||||
1
.github/aur/flux-scm/.gitignore
vendored
Normal file
1
.github/aur/flux-scm/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.pkg
|
||||||
45
.github/aur/flux-scm/PKGBUILD.template
vendored
Normal file
45
.github/aur/flux-scm/PKGBUILD.template
vendored
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
# Maintainer: Aurel Canciu <aurelcanciu@gmail.com>
|
||||||
|
# Maintainer: Hidde Beydals <hello@hidde.co>
|
||||||
|
|
||||||
|
pkgname=flux-scm
|
||||||
|
pkgver=${PKGVER}
|
||||||
|
pkgrel=${PKGREL}
|
||||||
|
pkgdesc="Open and extensible continuous delivery solution for Kubernetes"
|
||||||
|
url="https://fluxcd.io/"
|
||||||
|
arch=("x86_64" "armv6h" "armv7h" "aarch64")
|
||||||
|
license=("APACHE")
|
||||||
|
provides=("flux-bin")
|
||||||
|
conflicts=("flux-bin")
|
||||||
|
depends=("glibc")
|
||||||
|
makedepends=("go")
|
||||||
|
optdepends=("kubectl")
|
||||||
|
source=(
|
||||||
|
"git+https://github.com/fluxcd/flux2.git"
|
||||||
|
)
|
||||||
|
md5sums=('SKIP')
|
||||||
|
|
||||||
|
pkgver() {
|
||||||
|
cd "flux2"
|
||||||
|
printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
|
||||||
|
}
|
||||||
|
|
||||||
|
build() {
|
||||||
|
cd "flux2"
|
||||||
|
export CGO_LDFLAGS="$LDFLAGS"
|
||||||
|
export CGO_CFLAGS="$CFLAGS"
|
||||||
|
export CGO_CXXFLAGS="$CXXFLAGS"
|
||||||
|
export CGO_CPPFLAGS="$CPPFLAGS"
|
||||||
|
export GOFLAGS="-buildmode=pie -trimpath -ldflags=-linkmode=external -mod=readonly -modcacherw"
|
||||||
|
go build -ldflags "-X main.VERSION=$pkgver" -o flux-bin ./cmd/flux
|
||||||
|
}
|
||||||
|
|
||||||
|
check() {
|
||||||
|
cd "flux2"
|
||||||
|
make test
|
||||||
|
}
|
||||||
|
|
||||||
|
package() {
|
||||||
|
cd "flux2"
|
||||||
|
install -Dm755 flux-bin "$pkgdir/usr/bin/flux"
|
||||||
|
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
|
||||||
|
}
|
||||||
51
.github/aur/flux-scm/publish.sh
vendored
Executable file
51
.github/aur/flux-scm/publish.sh
vendored
Executable file
@@ -0,0 +1,51 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
WD=$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd)
|
||||||
|
PKGNAME=$(basename $WD)
|
||||||
|
ROOT=${WD%/.github/aur/$PKGNAME}
|
||||||
|
|
||||||
|
LOCKFILE=/tmp/aur-$PKGNAME.lock
|
||||||
|
exec 100>$LOCKFILE || exit 0
|
||||||
|
flock -n 100 || exit 0
|
||||||
|
trap "rm -f $LOCKFILE" EXIT
|
||||||
|
|
||||||
|
export VERSION=$1
|
||||||
|
echo "Publishing to AUR as version ${VERSION}"
|
||||||
|
|
||||||
|
cd $WD
|
||||||
|
|
||||||
|
export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
|
||||||
|
|
||||||
|
eval $(ssh-agent -s)
|
||||||
|
ssh-add <(echo "$AUR_BOT_SSH_PRIVATE_KEY")
|
||||||
|
|
||||||
|
GITDIR=$(mktemp -d /tmp/aur-$PKGNAME-XXX)
|
||||||
|
trap "rm -rf $GITDIR" EXIT
|
||||||
|
git clone aur@aur.archlinux.org:$PKGNAME $GITDIR 2>&1
|
||||||
|
|
||||||
|
CURRENT_PKGVER=$(cat $GITDIR/.SRCINFO | grep pkgver | awk '{ print $3 }')
|
||||||
|
CURRENT_PKGREL=$(cat $GITDIR/.SRCINFO | grep pkgrel | awk '{ print $3 }')
|
||||||
|
|
||||||
|
export PKGVER=${VERSION/-/}
|
||||||
|
|
||||||
|
if [[ "${CURRENT_PKGVER}" == "${PKGVER}" ]]; then
|
||||||
|
export PKGREL=$((CURRENT_PKGREL+1))
|
||||||
|
else
|
||||||
|
export PKGREL=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
envsubst '$PKGVER $PKGREL' < .SRCINFO.template > $GITDIR/.SRCINFO
|
||||||
|
envsubst '$PKGVER $PKGREL' < PKGBUILD.template > $GITDIR/PKGBUILD
|
||||||
|
|
||||||
|
cd $GITDIR
|
||||||
|
git config user.name "fluxcdbot"
|
||||||
|
git config user.email "fluxcdbot@users.noreply.github.com"
|
||||||
|
git add -A
|
||||||
|
if [ -z "$(git status --porcelain)" ]; then
|
||||||
|
echo "No changes."
|
||||||
|
else
|
||||||
|
git commit -m "Updated to version v${PKGVER} release ${PKGREL}"
|
||||||
|
git push origin master
|
||||||
|
fi
|
||||||
10
.github/workflows/e2e.yaml
vendored
10
.github/workflows/e2e.yaml
vendored
@@ -136,6 +136,16 @@ jobs:
|
|||||||
- name: flux delete source git
|
- name: flux delete source git
|
||||||
run: |
|
run: |
|
||||||
./bin/flux delete source git podinfo --silent
|
./bin/flux delete source git podinfo --silent
|
||||||
|
- name: flux create tenant
|
||||||
|
run: |
|
||||||
|
./bin/flux create tenant dev-team --with-namespace=apps
|
||||||
|
./bin/flux -n apps create source helm podinfo \
|
||||||
|
--url https://stefanprodan.github.io/podinfo
|
||||||
|
./bin/flux -n apps create hr podinfo-helm \
|
||||||
|
--source=HelmRepository/podinfo \
|
||||||
|
--chart=podinfo \
|
||||||
|
--chart-version="5.0.x" \
|
||||||
|
--service-account=dev-team
|
||||||
- name: flux check
|
- name: flux check
|
||||||
run: |
|
run: |
|
||||||
./bin/flux check
|
./bin/flux check
|
||||||
|
|||||||
22
.github/workflows/release.yaml
vendored
22
.github/workflows/release.yaml
vendored
@@ -59,24 +59,9 @@ jobs:
|
|||||||
|
|
||||||
# create tarball
|
# create tarball
|
||||||
cd ./output && tar -cvzf manifests.tar.gz $files
|
cd ./output && tar -cvzf manifests.tar.gz $files
|
||||||
- name: Create release
|
- name: Generate install manifest
|
||||||
id: create_release
|
run: |
|
||||||
uses: actions/create-release@latest
|
kustomize build ./manifests/install > ./output/install.yaml
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
tag_name: ${{ github.ref }}
|
|
||||||
release_name: ${{ github.ref }}
|
|
||||||
- name: Upload artifacts
|
|
||||||
id: upload-release-asset
|
|
||||||
uses: actions/upload-release-asset@v1
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
||||||
asset_path: ./output/manifests.tar.gz
|
|
||||||
asset_name: manifests.tar.gz
|
|
||||||
asset_content_type: application/gzip
|
|
||||||
- name: Run GoReleaser
|
- name: Run GoReleaser
|
||||||
uses: goreleaser/goreleaser-action@v1
|
uses: goreleaser/goreleaser-action@v1
|
||||||
with:
|
with:
|
||||||
@@ -85,3 +70,4 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
|
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
|
||||||
|
AUR_BOT_SSH_PRIVATE_KEY: ${{ secrets.AUR_BOT_SSH_PRIVATE_KEY }}
|
||||||
|
|||||||
2
.github/workflows/update.yml
vendored
2
.github/workflows/update.yml
vendored
@@ -40,6 +40,8 @@ jobs:
|
|||||||
bump_version kustomize-controller
|
bump_version kustomize-controller
|
||||||
bump_version source-controller
|
bump_version source-controller
|
||||||
bump_version notification-controller
|
bump_version notification-controller
|
||||||
|
bump_version image-reflector-controller
|
||||||
|
bump_version image-automation-controller
|
||||||
|
|
||||||
# add missing and remove unused modules
|
# add missing and remove unused modules
|
||||||
go mod tidy
|
go mod tidy
|
||||||
|
|||||||
@@ -50,3 +50,23 @@ brews:
|
|||||||
type: optional
|
type: optional
|
||||||
test: |
|
test: |
|
||||||
system "#{bin}/flux --version"
|
system "#{bin}/flux --version"
|
||||||
|
publishers:
|
||||||
|
- name: aur-pkg-bin
|
||||||
|
env:
|
||||||
|
- AUR_BOT_SSH_PRIVATE_KEY={{ .Env.AUR_BOT_SSH_PRIVATE_KEY }}
|
||||||
|
cmd: |
|
||||||
|
.github/aur/flux-bin/publish.sh {{ .Version }}
|
||||||
|
- name: aur-pkg-scm
|
||||||
|
env:
|
||||||
|
- AUR_BOT_SSH_PRIVATE_KEY={{ .Env.AUR_BOT_SSH_PRIVATE_KEY }}
|
||||||
|
cmd: |
|
||||||
|
.github/aur/flux-scm/publish.sh {{ .Version }}
|
||||||
|
- name: aur-pkg-go
|
||||||
|
env:
|
||||||
|
- AUR_BOT_SSH_PRIVATE_KEY={{ .Env.AUR_BOT_SSH_PRIVATE_KEY }}
|
||||||
|
cmd: |
|
||||||
|
.github/aur/flux-go/publish.sh {{ .Version }}
|
||||||
|
release:
|
||||||
|
extra_files:
|
||||||
|
- glob: ./output/manifests.tar.gz
|
||||||
|
- glob: ./output/install.yaml
|
||||||
|
|||||||
@@ -2,8 +2,17 @@ The maintainers are generally available in Slack at
|
|||||||
https://cloud-native.slack.com in #flux (https://cloud-native.slack.com/messages/CLAJ40HV3)
|
https://cloud-native.slack.com in #flux (https://cloud-native.slack.com/messages/CLAJ40HV3)
|
||||||
(obtain an invitation at https://slack.cncf.io/).
|
(obtain an invitation at https://slack.cncf.io/).
|
||||||
|
|
||||||
|
These maintainers are shared with other Flux v2-related git
|
||||||
|
repositories under https://github.com/fluxcd, as noted in their
|
||||||
|
respective MAINTAINERS files.
|
||||||
|
|
||||||
|
For convenience, they are reflected in the GitHub team
|
||||||
|
@fluxcd/flux2-maintainers -- if the list here changes, that team also
|
||||||
|
should.
|
||||||
|
|
||||||
In alphabetical order:
|
In alphabetical order:
|
||||||
|
|
||||||
Aurel Canciu, Sortlist <aurel@sortlist.com> (github: @relu, slack: relu)
|
Aurel Canciu, Sortlist <aurel@sortlist.com> (github: @relu, slack: relu)
|
||||||
Hidde Beydals, Weaveworks <hidde@weave.works> (github: @hiddeco, slack: hidde)
|
Hidde Beydals, Weaveworks <hidde@weave.works> (github: @hiddeco, slack: hidde)
|
||||||
|
Philip Laine, Xenit <philip.laine@xenit.se> (github: @phillebaba, slack: phillebaba)
|
||||||
Stefan Prodan, Weaveworks <stefan@weave.works> (github: @stefanprodan, slack: stefanprodan)
|
Stefan Prodan, Weaveworks <stefan@weave.works> (github: @stefanprodan, slack: stefanprodan)
|
||||||
|
|||||||
20
README.md
20
README.md
@@ -36,6 +36,15 @@ curl -s https://toolkit.fluxcd.io/install.sh | sudo bash
|
|||||||
. <(flux completion bash)
|
. <(flux completion bash)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Arch Linux (AUR) packages:
|
||||||
|
|
||||||
|
- [flux-bin](https://aur.archlinux.org/packages/flux-bin): install the latest
|
||||||
|
stable version using a pre-build binary (recommended)
|
||||||
|
- [flux-go](https://aur.archlinux.org/packages/flux-go): build the latest
|
||||||
|
stable version from source code
|
||||||
|
- [flux-scm](https://aur.archlinux.org/packages/flux-scm): build the latest
|
||||||
|
(unstable) version from source code from our git `main` branch
|
||||||
|
|
||||||
Binaries for macOS, Windows and Linux AMD64/ARM are available to download on the
|
Binaries for macOS, Windows and Linux AMD64/ARM are available to download on the
|
||||||
[release page](https://github.com/fluxcd/flux2/releases).
|
[release page](https://github.com/fluxcd/flux2/releases).
|
||||||
|
|
||||||
@@ -98,17 +107,18 @@ Depending on what you want to do, some of the following bits might be your first
|
|||||||
- To be part of the conversation about Flux's development, [join the flux-dev mailing list](https://lists.cncf.io/g/cncf-flux-dev).
|
- To be part of the conversation about Flux's development, [join the flux-dev mailing list](https://lists.cncf.io/g/cncf-flux-dev).
|
||||||
- Check out [how to contribute](CONTRIBUTING.md) to the project
|
- Check out [how to contribute](CONTRIBUTING.md) to the project
|
||||||
|
|
||||||
|
### Upcoming Events
|
||||||
|
|
||||||
|
- 14 Dec 2020 - [The Power of GitOps with Flux and Flagger with Leigh Capili](https://www.meetup.com/GitOps-Community/events/274924513/)
|
||||||
|
|
||||||
### Featured Talks
|
### Featured Talks
|
||||||
|
|
||||||
|
- 24 Nov 2020 - [Flux CD v2 with GitOps Toolkit - Kubernetes Deployment and Sync Mechanism](https://youtu.be/R6OeIgb7lUI)
|
||||||
- 28 Oct 2020 - [The Kubelist Podcast: Flux with Michael Bridgen](https://www.heavybit.com/library/podcasts/the-kubelist-podcast/ep-5-flux-with-michael-bridgen-of-weaveworks/)
|
- 28 Oct 2020 - [The Kubelist Podcast: Flux with Michael Bridgen](https://www.heavybit.com/library/podcasts/the-kubelist-podcast/ep-5-flux-with-michael-bridgen-of-weaveworks/)
|
||||||
- 19 Oct 2020 - [The Power of GitOps with Flux & GitOps Toolkit - Part 1 with Leigh Capili](https://youtu.be/0v5bjysXTL8)
|
- 19 Oct 2020 - [The Power of GitOps with Flux & GitOps Toolkit - Part 1 with Leigh Capili](https://youtu.be/0v5bjysXTL8)
|
||||||
|
- 30 Nov 2020 - [The Power of GitOps with Flux 2 - Part 3 with Leigh Capili](https://youtu.be/N_K5g7o9JKg)
|
||||||
- 12 Oct 2020 - [Rawkode Live: Introduction to GitOps Toolkit with Stefan Prodan](https://youtu.be/HqTzuOBP0eY)
|
- 12 Oct 2020 - [Rawkode Live: Introduction to GitOps Toolkit with Stefan Prodan](https://youtu.be/HqTzuOBP0eY)
|
||||||
- 4 Sep 2020 - [KubeCon Europe: The road to Flux v2 and Progressive Delivery with Stefan Prodan & Hidde Beydals](https://youtu.be/8v94nUkXsxU)
|
- 4 Sep 2020 - [KubeCon Europe: The road to Flux v2 and Progressive Delivery with Stefan Prodan & Hidde Beydals](https://youtu.be/8v94nUkXsxU)
|
||||||
- 25 June 2020 - [Cloud Native Nordics: Introduction to GitOps & GitOps Toolkit with Alexis Richardson & Stefan Prodan](https://youtu.be/qQBtSkgl7tI)
|
- 25 June 2020 - [Cloud Native Nordics: Introduction to GitOps & GitOps Toolkit with Alexis Richardson & Stefan Prodan](https://youtu.be/qQBtSkgl7tI)
|
||||||
- 7 May 2020 - [GitOps Days - Community Special: GitOps Toolkit Experimentation with Stefan Prodan](https://youtu.be/WHzxunv4DKk?t=6521)
|
|
||||||
|
|
||||||
### Upcoming Events
|
|
||||||
|
|
||||||
- 30 Nov 2020 - [The Power of GitOps with Flux & GitOps Toolkit - Part 3 with Leigh Capili](https://www.meetup.com/Weave-User-Group/events/274657228/)
|
|
||||||
|
|
||||||
We are looking forward to seeing you with us!
|
We are looking forward to seeing you with us!
|
||||||
|
|||||||
@@ -1,6 +1,57 @@
|
|||||||
# Flux GitHub Action
|
# Flux GitHub Action
|
||||||
|
|
||||||
Example workflow:
|
Usage:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- name: Setup Flux CLI
|
||||||
|
uses: fluxcd/flux2/action@main
|
||||||
|
- name: Run Flux commands
|
||||||
|
run: flux -v
|
||||||
|
```
|
||||||
|
|
||||||
|
### Automate Flux updates
|
||||||
|
|
||||||
|
Example workflow for updating Flux's components generated with `flux bootstrap --arch=amd64 --path=clusters/production`:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
name: update-flux
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
schedule:
|
||||||
|
- cron: "0 * * * *"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
components:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Setup Flux CLI
|
||||||
|
uses: fluxcd/flux2/action@main
|
||||||
|
- name: Check for updates
|
||||||
|
id: update
|
||||||
|
run: |
|
||||||
|
flux install --arch=amd64 \
|
||||||
|
--export > ./clusters/production/flux-system/gotk-components.yaml
|
||||||
|
|
||||||
|
VERSION="$(flux -v)"
|
||||||
|
echo "::set-output name=flux_version::$VERSION"
|
||||||
|
- name: Create Pull Request
|
||||||
|
uses: peter-evans/create-pull-request@v3
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
branch: update-flux
|
||||||
|
commit-message: Update to ${{ steps.update.outputs.flux_version }}
|
||||||
|
title: Update to ${{ steps.update.outputs.flux_version }}
|
||||||
|
body: |
|
||||||
|
${{ steps.update.outputs.flux_version }}
|
||||||
|
```
|
||||||
|
|
||||||
|
### End-to-end testing
|
||||||
|
|
||||||
|
Example workflow for running Flux in Kubernetes Kind:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
name: e2e
|
name: e2e
|
||||||
@@ -23,3 +74,6 @@ jobs:
|
|||||||
- name: Install Flux in Kubernetes Kind
|
- name: Install Flux in Kubernetes Kind
|
||||||
run: flux install
|
run: flux install
|
||||||
```
|
```
|
||||||
|
|
||||||
|
A complete e2e testing workflow is available here
|
||||||
|
[flux2-kustomize-helm-example](https://github.com/fluxcd/flux2-kustomize-helm-example/blob/main/.github/workflows/e2e.yaml)
|
||||||
|
|||||||
@@ -47,7 +47,8 @@ var bootstrapCmd = &cobra.Command{
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
bootstrapVersion string
|
bootstrapVersion string
|
||||||
bootstrapComponents []string
|
bootstrapDefaultComponents []string
|
||||||
|
bootstrapExtraComponents []string
|
||||||
bootstrapRegistry string
|
bootstrapRegistry string
|
||||||
bootstrapImagePullSecret string
|
bootstrapImagePullSecret string
|
||||||
bootstrapBranch string
|
bootstrapBranch string
|
||||||
@@ -58,6 +59,7 @@ var (
|
|||||||
bootstrapLogLevel = flags.LogLevel(defaults.LogLevel)
|
bootstrapLogLevel = flags.LogLevel(defaults.LogLevel)
|
||||||
bootstrapRequiredComponents = []string{"source-controller", "kustomize-controller"}
|
bootstrapRequiredComponents = []string{"source-controller", "kustomize-controller"}
|
||||||
bootstrapTokenAuth bool
|
bootstrapTokenAuth bool
|
||||||
|
bootstrapClusterDomain string
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -67,8 +69,10 @@ const (
|
|||||||
func init() {
|
func init() {
|
||||||
bootstrapCmd.PersistentFlags().StringVarP(&bootstrapVersion, "version", "v", defaults.Version,
|
bootstrapCmd.PersistentFlags().StringVarP(&bootstrapVersion, "version", "v", defaults.Version,
|
||||||
"toolkit version")
|
"toolkit version")
|
||||||
bootstrapCmd.PersistentFlags().StringSliceVar(&bootstrapComponents, "components", defaults.Components,
|
bootstrapCmd.PersistentFlags().StringSliceVar(&bootstrapDefaultComponents, "components", defaults.Components,
|
||||||
"list of components, accepts comma-separated values")
|
"list of components, accepts comma-separated values")
|
||||||
|
bootstrapCmd.PersistentFlags().StringSliceVar(&bootstrapExtraComponents, "components-extra", nil,
|
||||||
|
"list of components in addition to those supplied or defaulted, accepts comma-separated values")
|
||||||
bootstrapCmd.PersistentFlags().StringVar(&bootstrapRegistry, "registry", "ghcr.io/fluxcd",
|
bootstrapCmd.PersistentFlags().StringVar(&bootstrapRegistry, "registry", "ghcr.io/fluxcd",
|
||||||
"container registry where the toolkit images are published")
|
"container registry where the toolkit images are published")
|
||||||
bootstrapCmd.PersistentFlags().StringVar(&bootstrapImagePullSecret, "image-pull-secret", "",
|
bootstrapCmd.PersistentFlags().StringVar(&bootstrapImagePullSecret, "image-pull-secret", "",
|
||||||
@@ -84,17 +88,22 @@ func init() {
|
|||||||
"when enabled, the personal access token will be used instead of SSH deploy key")
|
"when enabled, the personal access token will be used instead of SSH deploy key")
|
||||||
bootstrapCmd.PersistentFlags().Var(&bootstrapLogLevel, "log-level", bootstrapLogLevel.Description())
|
bootstrapCmd.PersistentFlags().Var(&bootstrapLogLevel, "log-level", bootstrapLogLevel.Description())
|
||||||
bootstrapCmd.PersistentFlags().StringVar(&bootstrapManifestsPath, "manifests", "", "path to the manifest directory")
|
bootstrapCmd.PersistentFlags().StringVar(&bootstrapManifestsPath, "manifests", "", "path to the manifest directory")
|
||||||
|
bootstrapCmd.PersistentFlags().StringVar(&bootstrapClusterDomain, "cluster-domain", defaults.ClusterDomain, "internal cluster domain")
|
||||||
bootstrapCmd.PersistentFlags().MarkHidden("manifests")
|
bootstrapCmd.PersistentFlags().MarkHidden("manifests")
|
||||||
rootCmd.AddCommand(bootstrapCmd)
|
rootCmd.AddCommand(bootstrapCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func bootstrapComponents() []string {
|
||||||
|
return append(bootstrapDefaultComponents, bootstrapExtraComponents...)
|
||||||
|
}
|
||||||
|
|
||||||
func bootstrapValidate() error {
|
func bootstrapValidate() error {
|
||||||
|
components := bootstrapComponents()
|
||||||
for _, component := range bootstrapRequiredComponents {
|
for _, component := range bootstrapRequiredComponents {
|
||||||
if !utils.ContainsItemString(bootstrapComponents, component) {
|
if !utils.ContainsItemString(components, component) {
|
||||||
return fmt.Errorf("component %s is required", component)
|
return fmt.Errorf("component %s is required", component)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,7 +112,7 @@ func generateInstallManifests(targetPath, namespace, tmpDir string, localManifes
|
|||||||
BaseURL: localManifests,
|
BaseURL: localManifests,
|
||||||
Version: bootstrapVersion,
|
Version: bootstrapVersion,
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Components: bootstrapComponents,
|
Components: bootstrapComponents(),
|
||||||
Registry: bootstrapRegistry,
|
Registry: bootstrapRegistry,
|
||||||
ImagePullSecret: bootstrapImagePullSecret,
|
ImagePullSecret: bootstrapImagePullSecret,
|
||||||
Arch: bootstrapArch.String(),
|
Arch: bootstrapArch.String(),
|
||||||
@@ -114,6 +123,7 @@ func generateInstallManifests(targetPath, namespace, tmpDir string, localManifes
|
|||||||
ManifestFile: defaults.ManifestFile,
|
ManifestFile: defaults.ManifestFile,
|
||||||
Timeout: timeout,
|
Timeout: timeout,
|
||||||
TargetPath: targetPath,
|
TargetPath: targetPath,
|
||||||
|
ClusterDomain: bootstrapClusterDomain,
|
||||||
}
|
}
|
||||||
|
|
||||||
if localManifests == "" {
|
if localManifests == "" {
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ func bootstrapGitHubCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
if isInstall {
|
if isInstall {
|
||||||
// apply install manifests
|
// apply install manifests
|
||||||
logger.Actionf("installing components in %s namespace", namespace)
|
logger.Actionf("installing components in %s namespace", namespace)
|
||||||
if err := applyInstallManifests(ctx, manifest, bootstrapComponents); err != nil {
|
if err := applyInstallManifests(ctx, manifest, bootstrapComponents()); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
logger.Successf("install completed")
|
logger.Successf("install completed")
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ func bootstrapGitLabCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
if isInstall {
|
if isInstall {
|
||||||
// apply install manifests
|
// apply install manifests
|
||||||
logger.Actionf("installing components in %s namespace", namespace)
|
logger.Actionf("installing components in %s namespace", namespace)
|
||||||
if err := applyInstallManifests(ctx, manifest, bootstrapComponents); err != nil {
|
if err := applyInstallManifests(ctx, manifest, bootstrapComponents()); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
logger.Successf("install completed")
|
logger.Successf("install completed")
|
||||||
|
|||||||
@@ -17,13 +17,19 @@ limitations under the License.
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/util/validation"
|
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
"k8s.io/apimachinery/pkg/types"
|
||||||
|
"k8s.io/apimachinery/pkg/util/validation"
|
||||||
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
|
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
|
||||||
|
|
||||||
|
"github.com/fluxcd/flux2/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
var createCmd = &cobra.Command{
|
var createCmd = &cobra.Command{
|
||||||
@@ -46,6 +52,78 @@ func init() {
|
|||||||
rootCmd.AddCommand(createCmd)
|
rootCmd.AddCommand(createCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// upsertable is an interface for values that can be used in `upsert`.
|
||||||
|
type upsertable interface {
|
||||||
|
adapter
|
||||||
|
named
|
||||||
|
}
|
||||||
|
|
||||||
|
// upsert updates or inserts an object. Instead of providing the
|
||||||
|
// object itself, you provide a named (as in Name and Namespace)
|
||||||
|
// template value, and a mutate function which sets the values you
|
||||||
|
// want to update. The mutate function is nullary -- you mutate a
|
||||||
|
// value in the closure, e.g., by doing this:
|
||||||
|
//
|
||||||
|
// var existing Value
|
||||||
|
// existing.Name = name
|
||||||
|
// existing.Namespace = ns
|
||||||
|
// upsert(ctx, client, valueAdapter{&value}, func() error {
|
||||||
|
// value.Spec = onePreparedEarlier
|
||||||
|
// })
|
||||||
|
func (names apiType) upsert(ctx context.Context, kubeClient client.Client, object upsertable, mutate func() error) (types.NamespacedName, error) {
|
||||||
|
nsname := types.NamespacedName{
|
||||||
|
Namespace: object.GetNamespace(),
|
||||||
|
Name: object.GetName(),
|
||||||
|
}
|
||||||
|
|
||||||
|
op, err := controllerutil.CreateOrUpdate(ctx, kubeClient, object.asRuntimeObject(), mutate)
|
||||||
|
if err != nil {
|
||||||
|
return nsname, err
|
||||||
|
}
|
||||||
|
|
||||||
|
switch op {
|
||||||
|
case controllerutil.OperationResultCreated:
|
||||||
|
logger.Successf("%s created", names.kind)
|
||||||
|
case controllerutil.OperationResultUpdated:
|
||||||
|
logger.Successf("%s updated", names.kind)
|
||||||
|
}
|
||||||
|
return nsname, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type upsertWaitable interface {
|
||||||
|
upsertable
|
||||||
|
statusable
|
||||||
|
}
|
||||||
|
|
||||||
|
// upsertAndWait encodes the pattern of creating or updating a
|
||||||
|
// resource, then waiting for it to reconcile. See the note on
|
||||||
|
// `upsert` for how to work with the `mutate` argument.
|
||||||
|
func (names apiType) upsertAndWait(object upsertWaitable, mutate func() error) error {
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
kubeClient, err := utils.KubeClient(kubeconfig, kubecontext) // NB globals
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Generatef("generating %s", names.kind)
|
||||||
|
logger.Actionf("applying %s", names.kind)
|
||||||
|
|
||||||
|
namespacedName, err := imageRepositoryType.upsert(ctx, kubeClient, object, mutate)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Waitingf("waiting for %s reconciliation", names.kind)
|
||||||
|
if err := wait.PollImmediate(pollInterval, timeout,
|
||||||
|
isReady(ctx, kubeClient, namespacedName, object)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
logger.Successf("%s reconciliation completed", names.kind)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func parseLabels() (map[string]string, error) {
|
func parseLabels() (map[string]string, error) {
|
||||||
result := make(map[string]string)
|
result := make(map[string]string)
|
||||||
for _, label := range labels {
|
for _, label := range labels {
|
||||||
|
|||||||
38
cmd/flux/create_image.go
Normal file
38
cmd/flux/create_image.go
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
const createImageLong = `
|
||||||
|
The create image sub-commands work with image automation objects; that is,
|
||||||
|
object controlling updates to git based on e.g., new container images
|
||||||
|
being available.`
|
||||||
|
|
||||||
|
var createImageCmd = &cobra.Command{
|
||||||
|
Use: "image",
|
||||||
|
Short: "Create or update resources dealing with image automation",
|
||||||
|
Long: strings.TrimSpace(createImageLong),
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
createCmd.AddCommand(createImageCmd)
|
||||||
|
}
|
||||||
110
cmd/flux/create_image_policy.go
Normal file
110
cmd/flux/create_image_policy.go
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
corev1 "k8s.io/api/core/v1"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
|
imagev1 "github.com/fluxcd/image-reflector-controller/api/v1alpha1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var createImagePolicyCmd = &cobra.Command{
|
||||||
|
Use: "policy <name>",
|
||||||
|
Short: "Create or update an ImagePolicy object",
|
||||||
|
Long: `The create image policy command generates an ImagePolicy resource.
|
||||||
|
An ImagePolicy object calculates a "latest image" given an image
|
||||||
|
repository and a policy, e.g., semver.
|
||||||
|
|
||||||
|
The image that sorts highest according to the policy is recorded in
|
||||||
|
the status of the object.`,
|
||||||
|
RunE: createImagePolicyRun}
|
||||||
|
|
||||||
|
type imagePolicyFlags struct {
|
||||||
|
imageRef string
|
||||||
|
semver string
|
||||||
|
}
|
||||||
|
|
||||||
|
var imagePolicyArgs = imagePolicyFlags{}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
flags := createImagePolicyCmd.Flags()
|
||||||
|
flags.StringVar(&imagePolicyArgs.imageRef, "image-ref", "", "the name of an image repository object")
|
||||||
|
flags.StringVar(&imagePolicyArgs.semver, "semver", "", "a semver range to apply to tags; e.g., '1.x'")
|
||||||
|
|
||||||
|
createImageCmd.AddCommand(createImagePolicyCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
// getObservedGeneration is implemented here, since it's not
|
||||||
|
// (presently) needed elsewhere.
|
||||||
|
func (obj imagePolicyAdapter) getObservedGeneration() int64 {
|
||||||
|
return obj.ImagePolicy.Status.ObservedGeneration
|
||||||
|
}
|
||||||
|
|
||||||
|
func createImagePolicyRun(cmd *cobra.Command, args []string) error {
|
||||||
|
if len(args) < 1 {
|
||||||
|
return fmt.Errorf("ImagePolicy name is required")
|
||||||
|
}
|
||||||
|
objectName := args[0]
|
||||||
|
|
||||||
|
if imagePolicyArgs.imageRef == "" {
|
||||||
|
return fmt.Errorf("the name of an ImageRepository in the namespace is required (--image-ref)")
|
||||||
|
}
|
||||||
|
|
||||||
|
labels, err := parseLabels()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var policy = imagev1.ImagePolicy{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: objectName,
|
||||||
|
Namespace: namespace,
|
||||||
|
Labels: labels,
|
||||||
|
},
|
||||||
|
Spec: imagev1.ImagePolicySpec{
|
||||||
|
ImageRepositoryRef: corev1.LocalObjectReference{
|
||||||
|
Name: imagePolicyArgs.imageRef,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case imagePolicyArgs.semver != "":
|
||||||
|
policy.Spec.Policy.SemVer = &imagev1.SemVerPolicy{
|
||||||
|
Range: imagePolicyArgs.semver,
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("a policy must be provided with --semver")
|
||||||
|
}
|
||||||
|
|
||||||
|
if export {
|
||||||
|
return printExport(exportImagePolicy(&policy))
|
||||||
|
}
|
||||||
|
|
||||||
|
var existing imagev1.ImagePolicy
|
||||||
|
copyName(&existing, &policy)
|
||||||
|
err = imagePolicyType.upsertAndWait(imagePolicyAdapter{&existing}, func() error {
|
||||||
|
existing.Spec = policy.Spec
|
||||||
|
existing.SetLabels(policy.Labels)
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
return err
|
||||||
|
}
|
||||||
110
cmd/flux/create_image_repository.go
Normal file
110
cmd/flux/create_image_repository.go
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/go-containerregistry/pkg/name"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
corev1 "k8s.io/api/core/v1"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
|
imagev1 "github.com/fluxcd/image-reflector-controller/api/v1alpha1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var createImageRepositoryCmd = &cobra.Command{
|
||||||
|
Use: "repository <name>",
|
||||||
|
Short: "Create or update an ImageRepository object",
|
||||||
|
Long: `The create image repository command generates an ImageRepository resource.
|
||||||
|
An ImageRepository object specifies an image repository to scan.`,
|
||||||
|
RunE: createImageRepositoryRun,
|
||||||
|
}
|
||||||
|
|
||||||
|
type imageRepoFlags struct {
|
||||||
|
image string
|
||||||
|
secretRef string
|
||||||
|
timeout time.Duration
|
||||||
|
}
|
||||||
|
|
||||||
|
var imageRepoArgs = imageRepoFlags{}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
flags := createImageRepositoryCmd.Flags()
|
||||||
|
flags.StringVar(&imageRepoArgs.image, "image", "", "the image repository to scan; e.g., library/alpine")
|
||||||
|
flags.StringVar(&imageRepoArgs.secretRef, "secret-ref", "", "the name of a docker-registry secret to use for credentials")
|
||||||
|
// NB there is already a --timeout in the global flags, for
|
||||||
|
// controlling timeout on operations while e.g., creating objects.
|
||||||
|
flags.DurationVar(&imageRepoArgs.timeout, "scan-timeout", 0, "a timeout for scanning; this defaults to the interval if not set")
|
||||||
|
|
||||||
|
createImageCmd.AddCommand(createImageRepositoryCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func createImageRepositoryRun(cmd *cobra.Command, args []string) error {
|
||||||
|
if len(args) < 1 {
|
||||||
|
return fmt.Errorf("ImageRepository name is required")
|
||||||
|
}
|
||||||
|
objectName := args[0]
|
||||||
|
|
||||||
|
if imageRepoArgs.image == "" {
|
||||||
|
return fmt.Errorf("an image repository (--image) is required")
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := name.NewRepository(imageRepoArgs.image); err != nil {
|
||||||
|
return fmt.Errorf("unable to parse image value: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
labels, err := parseLabels()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var repo = imagev1.ImageRepository{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: objectName,
|
||||||
|
Namespace: namespace,
|
||||||
|
Labels: labels,
|
||||||
|
},
|
||||||
|
Spec: imagev1.ImageRepositorySpec{
|
||||||
|
Image: imageRepoArgs.image,
|
||||||
|
Interval: metav1.Duration{Duration: interval},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
if imageRepoArgs.timeout != 0 {
|
||||||
|
repo.Spec.Timeout = &metav1.Duration{Duration: imageRepoArgs.timeout}
|
||||||
|
}
|
||||||
|
if imageRepoArgs.secretRef != "" {
|
||||||
|
repo.Spec.SecretRef = &corev1.LocalObjectReference{
|
||||||
|
Name: imageRepoArgs.secretRef,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if export {
|
||||||
|
return printExport(exportImageRepository(&repo))
|
||||||
|
}
|
||||||
|
|
||||||
|
// a temp value for use with the rest
|
||||||
|
var existing imagev1.ImageRepository
|
||||||
|
copyName(&existing, &repo)
|
||||||
|
err = imageRepositoryType.upsertAndWait(imageRepositoryAdapter{&existing}, func() error {
|
||||||
|
existing.Spec = repo.Spec
|
||||||
|
existing.Labels = repo.Labels
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
return err
|
||||||
|
}
|
||||||
113
cmd/flux/create_image_updateauto.go
Normal file
113
cmd/flux/create_image_updateauto.go
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
corev1 "k8s.io/api/core/v1"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
|
autov1 "github.com/fluxcd/image-automation-controller/api/v1alpha1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var createImageUpdateCmd = &cobra.Command{
|
||||||
|
Use: "update <name>",
|
||||||
|
Short: "Create or update an ImageUpdateAutomation object",
|
||||||
|
Long: `The create image update command generates an ImageUpdateAutomation resource.
|
||||||
|
An ImageUpdateAutomation object specifies an automated update to images
|
||||||
|
mentioned in YAMLs in a git repository.`,
|
||||||
|
RunE: createImageUpdateRun,
|
||||||
|
}
|
||||||
|
|
||||||
|
type imageUpdateFlags struct {
|
||||||
|
// git checkout spec
|
||||||
|
gitRepoRef string
|
||||||
|
branch string
|
||||||
|
// commit spec
|
||||||
|
commitTemplate string
|
||||||
|
authorName string
|
||||||
|
authorEmail string
|
||||||
|
}
|
||||||
|
|
||||||
|
var imageUpdateArgs = imageUpdateFlags{}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
flags := createImageUpdateCmd.Flags()
|
||||||
|
flags.StringVar(&imageUpdateArgs.gitRepoRef, "git-repo-ref", "", "the name of a GitRepository resource with details of the upstream git repository")
|
||||||
|
flags.StringVar(&imageUpdateArgs.branch, "branch", "", "the branch to push commits to")
|
||||||
|
flags.StringVar(&imageUpdateArgs.commitTemplate, "commit-template", "", "a template for commit messages")
|
||||||
|
flags.StringVar(&imageUpdateArgs.authorName, "author-name", "", "the name to use for commit author")
|
||||||
|
flags.StringVar(&imageUpdateArgs.authorEmail, "author-email", "", "the email to use for commit author")
|
||||||
|
|
||||||
|
createImageCmd.AddCommand(createImageUpdateCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func createImageUpdateRun(cmd *cobra.Command, args []string) error {
|
||||||
|
if len(args) < 1 {
|
||||||
|
return fmt.Errorf("ImageUpdateAutomation name is required")
|
||||||
|
}
|
||||||
|
objectName := args[0]
|
||||||
|
|
||||||
|
if imageUpdateArgs.gitRepoRef == "" {
|
||||||
|
return fmt.Errorf("a reference to a GitRepository is required (--git-repo-ref)")
|
||||||
|
}
|
||||||
|
|
||||||
|
labels, err := parseLabels()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var update = autov1.ImageUpdateAutomation{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: objectName,
|
||||||
|
Namespace: namespace,
|
||||||
|
Labels: labels,
|
||||||
|
},
|
||||||
|
Spec: autov1.ImageUpdateAutomationSpec{
|
||||||
|
Checkout: autov1.GitCheckoutSpec{
|
||||||
|
GitRepositoryRef: corev1.LocalObjectReference{
|
||||||
|
Name: imageUpdateArgs.gitRepoRef,
|
||||||
|
},
|
||||||
|
Branch: imageUpdateArgs.branch,
|
||||||
|
},
|
||||||
|
Interval: metav1.Duration{Duration: interval},
|
||||||
|
Update: autov1.UpdateStrategy{
|
||||||
|
Setters: &autov1.SettersStrategy{},
|
||||||
|
},
|
||||||
|
Commit: autov1.CommitSpec{
|
||||||
|
AuthorName: imageUpdateArgs.authorName,
|
||||||
|
AuthorEmail: imageUpdateArgs.authorEmail,
|
||||||
|
MessageTemplate: imageUpdateArgs.commitTemplate,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
if export {
|
||||||
|
return printExport(exportImageUpdate(&update))
|
||||||
|
}
|
||||||
|
|
||||||
|
var existing autov1.ImageUpdateAutomation
|
||||||
|
copyName(&existing, &update)
|
||||||
|
err = imageUpdateAutomationType.upsertAndWait(imageUpdateAutomationAdapter{&existing}, func() error {
|
||||||
|
existing.Spec = update.Spec
|
||||||
|
existing.Labels = update.Labels
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
return err
|
||||||
|
}
|
||||||
52
cmd/flux/create_secret.go
Normal file
52
cmd/flux/create_secret.go
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
corev1 "k8s.io/api/core/v1"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"sigs.k8s.io/yaml"
|
||||||
|
)
|
||||||
|
|
||||||
|
var createSecretCmd = &cobra.Command{
|
||||||
|
Use: "secret",
|
||||||
|
Short: "Create or update Kubernetes secrets",
|
||||||
|
Long: "The create source sub-commands generate Kubernetes secrets specific to Flux.",
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
createCmd.AddCommand(createSecretCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func exportSecret(secret corev1.Secret) error {
|
||||||
|
secret.TypeMeta = metav1.TypeMeta{
|
||||||
|
APIVersion: "v1",
|
||||||
|
Kind: "Secret",
|
||||||
|
}
|
||||||
|
|
||||||
|
data, err := yaml.Marshal(secret)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("---")
|
||||||
|
fmt.Println(resourceToString(data))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
173
cmd/flux/create_secret_git.go
Normal file
173
cmd/flux/create_secret_git.go
Normal file
@@ -0,0 +1,173 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"crypto/elliptic"
|
||||||
|
"fmt"
|
||||||
|
"net/url"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
corev1 "k8s.io/api/core/v1"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
|
"github.com/fluxcd/flux2/internal/flags"
|
||||||
|
"github.com/fluxcd/flux2/internal/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
var createSecretGitCmd = &cobra.Command{
|
||||||
|
Use: "git [name]",
|
||||||
|
Short: "Create or update a Kubernetes secret for Git authentication",
|
||||||
|
Long: `
|
||||||
|
The create secret git command generates a Kubernetes secret with Git credentials.
|
||||||
|
For Git over SSH, the host and SSH keys are automatically generated and stored in the secret.
|
||||||
|
For Git over HTTP/S, the provided basic authentication credentials are stored in the secret.`,
|
||||||
|
Example: ` # Create a Git SSH authentication secret using an ECDSA P-521 curve public key
|
||||||
|
|
||||||
|
flux create secret git podinfo-auth \
|
||||||
|
--url=ssh://git@github.com/stefanprodan/podinfo \
|
||||||
|
--ssh-key-algorithm=ecdsa \
|
||||||
|
--ssh-ecdsa-curve=p521
|
||||||
|
|
||||||
|
# Create a secret for a Git repository using basic authentication
|
||||||
|
flux create secret git podinfo-auth \
|
||||||
|
--url=https://github.com/stefanprodan/podinfo \
|
||||||
|
--username=username \
|
||||||
|
--password=password
|
||||||
|
|
||||||
|
# Create a Git SSH secret on disk and print the deploy key
|
||||||
|
flux create secret git podinfo-auth \
|
||||||
|
--url=ssh://git@github.com/stefanprodan/podinfo \
|
||||||
|
--export > podinfo-auth.yaml
|
||||||
|
|
||||||
|
yq read podinfo-auth.yaml 'data."identity.pub"' | base64 --decode
|
||||||
|
|
||||||
|
# Create a Git SSH secret on disk and encrypt it with Mozilla SOPS
|
||||||
|
flux create secret git podinfo-auth \
|
||||||
|
--namespace=apps \
|
||||||
|
--url=ssh://git@github.com/stefanprodan/podinfo \
|
||||||
|
--export > podinfo-auth.yaml
|
||||||
|
|
||||||
|
sops --encrypt --encrypted-regex '^(data|stringData)$' \
|
||||||
|
--in-place podinfo-auth.yaml
|
||||||
|
`,
|
||||||
|
RunE: createSecretGitCmdRun,
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
secretGitURL string
|
||||||
|
secretGitUsername string
|
||||||
|
secretGitPassword string
|
||||||
|
secretGitKeyAlgorithm flags.PublicKeyAlgorithm = "rsa"
|
||||||
|
secretGitRSABits flags.RSAKeyBits = 2048
|
||||||
|
secretGitECDSACurve = flags.ECDSACurve{Curve: elliptic.P384()}
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
createSecretGitCmd.Flags().StringVar(&secretGitURL, "url", "", "git address, e.g. ssh://git@host/org/repository")
|
||||||
|
createSecretGitCmd.Flags().StringVarP(&secretGitUsername, "username", "u", "", "basic authentication username")
|
||||||
|
createSecretGitCmd.Flags().StringVarP(&secretGitPassword, "password", "p", "", "basic authentication password")
|
||||||
|
createSecretGitCmd.Flags().Var(&secretGitKeyAlgorithm, "ssh-key-algorithm", sourceGitKeyAlgorithm.Description())
|
||||||
|
createSecretGitCmd.Flags().Var(&secretGitRSABits, "ssh-rsa-bits", sourceGitRSABits.Description())
|
||||||
|
createSecretGitCmd.Flags().Var(&secretGitECDSACurve, "ssh-ecdsa-curve", sourceGitECDSACurve.Description())
|
||||||
|
|
||||||
|
createSecretCmd.AddCommand(createSecretGitCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func createSecretGitCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
|
if len(args) < 1 {
|
||||||
|
return fmt.Errorf("secret name is required")
|
||||||
|
}
|
||||||
|
name := args[0]
|
||||||
|
|
||||||
|
if secretGitURL == "" {
|
||||||
|
return fmt.Errorf("url is required")
|
||||||
|
}
|
||||||
|
|
||||||
|
u, err := url.Parse(secretGitURL)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("git URL parse failed: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
secretLabels, err := parseLabels()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
secret := corev1.Secret{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: name,
|
||||||
|
Namespace: namespace,
|
||||||
|
Labels: secretLabels,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
switch u.Scheme {
|
||||||
|
case "ssh":
|
||||||
|
pair, err := generateKeyPair(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
hostKey, err := scanHostKey(ctx, u)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
secret.Data = map[string][]byte{
|
||||||
|
"identity": pair.PrivateKey,
|
||||||
|
"identity.pub": pair.PublicKey,
|
||||||
|
"known_hosts": hostKey,
|
||||||
|
}
|
||||||
|
|
||||||
|
if !export {
|
||||||
|
logger.Generatef("deploy key: %s", string(pair.PublicKey))
|
||||||
|
}
|
||||||
|
case "http", "https":
|
||||||
|
if secretGitUsername == "" || secretGitPassword == "" {
|
||||||
|
return fmt.Errorf("for Git over HTTP/S the username and password are required")
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: add cert data when it's implemented in source-controller
|
||||||
|
secret.Data = map[string][]byte{
|
||||||
|
"username": []byte(secretGitUsername),
|
||||||
|
"password": []byte(secretGitPassword),
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("git URL scheme '%s' not supported, can be: ssh, http and https", u.Scheme)
|
||||||
|
}
|
||||||
|
|
||||||
|
if export {
|
||||||
|
return exportSecret(secret)
|
||||||
|
}
|
||||||
|
|
||||||
|
kubeClient, err := utils.KubeClient(kubeconfig, kubecontext)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := upsertSecret(ctx, kubeClient, secret); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
logger.Actionf("secret '%s' created in '%s' namespace", name, namespace)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -154,6 +154,7 @@ func createSourceBucketCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: secretName,
|
Name: secretName,
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
|
Labels: sourceLabels,
|
||||||
},
|
},
|
||||||
StringData: map[string]string{},
|
StringData: map[string]string{},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,10 +95,11 @@ var (
|
|||||||
sourceGitUsername string
|
sourceGitUsername string
|
||||||
sourceGitPassword string
|
sourceGitPassword string
|
||||||
|
|
||||||
sourceGitKeyAlgorithm flags.PublicKeyAlgorithm = "rsa"
|
sourceGitKeyAlgorithm flags.PublicKeyAlgorithm = "rsa"
|
||||||
sourceGitRSABits flags.RSAKeyBits = 2048
|
sourceGitRSABits flags.RSAKeyBits = 2048
|
||||||
sourceGitECDSACurve = flags.ECDSACurve{Curve: elliptic.P384()}
|
sourceGitECDSACurve = flags.ECDSACurve{Curve: elliptic.P384()}
|
||||||
sourceGitSecretRef string
|
sourceGitSecretRef string
|
||||||
|
sourceGitImplementation string
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -112,6 +113,7 @@ func init() {
|
|||||||
createSourceGitCmd.Flags().Var(&sourceGitRSABits, "ssh-rsa-bits", sourceGitRSABits.Description())
|
createSourceGitCmd.Flags().Var(&sourceGitRSABits, "ssh-rsa-bits", sourceGitRSABits.Description())
|
||||||
createSourceGitCmd.Flags().Var(&sourceGitECDSACurve, "ssh-ecdsa-curve", sourceGitECDSACurve.Description())
|
createSourceGitCmd.Flags().Var(&sourceGitECDSACurve, "ssh-ecdsa-curve", sourceGitECDSACurve.Description())
|
||||||
createSourceGitCmd.Flags().StringVarP(&sourceGitSecretRef, "secret-ref", "", "", "the name of an existing secret containing SSH or basic credentials")
|
createSourceGitCmd.Flags().StringVarP(&sourceGitSecretRef, "secret-ref", "", "", "the name of an existing secret containing SSH or basic credentials")
|
||||||
|
createSourceGitCmd.Flags().StringVar(&sourceGitImplementation, "git-implementation", "", "the git implementation to use, can be 'go-git' or 'libgit2'")
|
||||||
|
|
||||||
createSourceCmd.AddCommand(createSourceGitCmd)
|
createSourceCmd.AddCommand(createSourceGitCmd)
|
||||||
}
|
}
|
||||||
@@ -142,6 +144,10 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !utils.ContainsItemString([]string{sourcev1.GoGitImplementation, sourcev1.LibGit2Implementation, ""}, sourceGitImplementation) {
|
||||||
|
return fmt.Errorf("Invalid git implementation %q", sourceGitImplementation)
|
||||||
|
}
|
||||||
|
|
||||||
gitRepository := sourcev1.GitRepository{
|
gitRepository := sourcev1.GitRepository{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: name,
|
Name: name,
|
||||||
@@ -153,7 +159,8 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
Interval: metav1.Duration{
|
Interval: metav1.Duration{
|
||||||
Duration: interval,
|
Duration: interval,
|
||||||
},
|
},
|
||||||
Reference: &sourcev1.GitRepositoryRef{},
|
Reference: &sourcev1.GitRepositoryRef{},
|
||||||
|
GitImplementation: sourceGitImplementation,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,13 +194,13 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
if sourceGitSecretRef != "" {
|
if sourceGitSecretRef != "" {
|
||||||
withAuth = true
|
withAuth = true
|
||||||
} else if u.Scheme == "ssh" {
|
} else if u.Scheme == "ssh" {
|
||||||
logger.Actionf("generating deploy key pair")
|
logger.Generatef("generating deploy key pair")
|
||||||
pair, err := generateKeyPair(ctx)
|
pair, err := generateKeyPair(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("%s", pair.PublicKey)
|
logger.Successf("deploy key: %s", pair.PublicKey)
|
||||||
prompt := promptui.Prompt{
|
prompt := promptui.Prompt{
|
||||||
Label: "Have you added the deploy key to your repository",
|
Label: "Have you added the deploy key to your repository",
|
||||||
IsConfirm: true,
|
IsConfirm: true,
|
||||||
@@ -207,14 +214,14 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
logger.Successf("collected public key from SSH server:")
|
logger.Successf("collected public key from SSH server:\n%s", hostKey)
|
||||||
fmt.Printf("%s", hostKey)
|
|
||||||
|
|
||||||
logger.Actionf("applying secret with keys")
|
logger.Actionf("applying secret with keys")
|
||||||
secret := corev1.Secret{
|
secret := corev1.Secret{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: name,
|
Name: name,
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
|
Labels: sourceLabels,
|
||||||
},
|
},
|
||||||
StringData: map[string]string{
|
StringData: map[string]string{
|
||||||
"identity": string(pair.PrivateKey),
|
"identity": string(pair.PrivateKey),
|
||||||
@@ -232,6 +239,7 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: name,
|
Name: name,
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
|
Labels: sourceLabels,
|
||||||
},
|
},
|
||||||
StringData: map[string]string{
|
StringData: map[string]string{
|
||||||
"username": sourceGitUsername,
|
"username": sourceGitUsername,
|
||||||
|
|||||||
@@ -151,6 +151,7 @@ func createSourceHelmCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: secretName,
|
Name: secretName,
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
|
Labels: sourceLabels,
|
||||||
},
|
},
|
||||||
StringData: map[string]string{},
|
StringData: map[string]string{},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,8 +55,7 @@ reconcilers scope to the tenant namespaces.`,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
tenantLabel = "toolkit.fluxcd.io/tenant"
|
tenantLabel = "toolkit.fluxcd.io/tenant"
|
||||||
tenantRoleBinding = "gotk-reconciler"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -123,18 +122,20 @@ func createTenantCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
|
|
||||||
roleBinding := rbacv1.RoleBinding{
|
roleBinding := rbacv1.RoleBinding{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: tenantRoleBinding,
|
Name: fmt.Sprintf("%s-reconciler", tenant),
|
||||||
Namespace: ns,
|
Namespace: ns,
|
||||||
Labels: objLabels,
|
Labels: objLabels,
|
||||||
},
|
},
|
||||||
Subjects: []rbacv1.Subject{
|
Subjects: []rbacv1.Subject{
|
||||||
{
|
{
|
||||||
Kind: "User",
|
APIGroup: "rbac.authorization.k8s.io",
|
||||||
Name: fmt.Sprintf("gotk:%s:reconciler", ns),
|
Kind: "User",
|
||||||
|
Name: fmt.Sprintf("gotk:%s:reconciler", ns),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Kind: "ServiceAccount",
|
Kind: "ServiceAccount",
|
||||||
Name: tenant,
|
Name: tenant,
|
||||||
|
Namespace: ns,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
RoleRef: rbacv1.RoleRef{
|
RoleRef: rbacv1.RoleRef{
|
||||||
@@ -290,7 +291,7 @@ func exportTenant(namespace corev1.Namespace, account corev1.ServiceAccount, rol
|
|||||||
fmt.Println(resourceToString(data))
|
fmt.Println(resourceToString(data))
|
||||||
|
|
||||||
account.TypeMeta = metav1.TypeMeta{
|
account.TypeMeta = metav1.TypeMeta{
|
||||||
APIVersion: "",
|
APIVersion: "v1",
|
||||||
Kind: "ServiceAccount",
|
Kind: "ServiceAccount",
|
||||||
}
|
}
|
||||||
data, err = yaml.Marshal(account)
|
data, err = yaml.Marshal(account)
|
||||||
|
|||||||
@@ -17,7 +17,14 @@ limitations under the License.
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/manifoldco/promptui"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
"k8s.io/apimachinery/pkg/types"
|
||||||
|
|
||||||
|
"github.com/fluxcd/flux2/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
var deleteCmd = &cobra.Command{
|
var deleteCmd = &cobra.Command{
|
||||||
@@ -36,3 +43,52 @@ func init() {
|
|||||||
|
|
||||||
rootCmd.AddCommand(deleteCmd)
|
rootCmd.AddCommand(deleteCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type deleteCommand struct {
|
||||||
|
apiType
|
||||||
|
object adapter // for getting the value, and later deleting it
|
||||||
|
}
|
||||||
|
|
||||||
|
func (del deleteCommand) run(cmd *cobra.Command, args []string) error {
|
||||||
|
if len(args) < 1 {
|
||||||
|
return fmt.Errorf("%s name is required", del.humanKind)
|
||||||
|
}
|
||||||
|
name := args[0]
|
||||||
|
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
kubeClient, err := utils.KubeClient(kubeconfig, kubecontext)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
namespacedName := types.NamespacedName{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
|
||||||
|
err = kubeClient.Get(ctx, namespacedName, del.object.asRuntimeObject())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if !deleteSilent {
|
||||||
|
prompt := promptui.Prompt{
|
||||||
|
Label: "Are you sure you want to delete this " + del.humanKind,
|
||||||
|
IsConfirm: true,
|
||||||
|
}
|
||||||
|
if _, err := prompt.Run(); err != nil {
|
||||||
|
return fmt.Errorf("aborting")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Actionf("deleting %s %s in %s namespace", del.humanKind, name, namespace)
|
||||||
|
err = kubeClient.Delete(ctx, del.object.asRuntimeObject())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
logger.Successf("%s deleted", del.humanKind)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
31
cmd/flux/delete_image.go
Normal file
31
cmd/flux/delete_image.go
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
var deleteAutoCmd = &cobra.Command{
|
||||||
|
Use: "auto",
|
||||||
|
Short: "Delete automation objects",
|
||||||
|
Long: "The delete auto sub-commands delete automation objects.",
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
deleteCmd.AddCommand(deleteAutoCmd)
|
||||||
|
}
|
||||||
40
cmd/flux/delete_image_policy.go
Normal file
40
cmd/flux/delete_image_policy.go
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
imagev1 "github.com/fluxcd/image-reflector-controller/api/v1alpha1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var deleteImagePolicyCmd = &cobra.Command{
|
||||||
|
Use: "image-policy [name]",
|
||||||
|
Short: "Delete an ImagePolicy object",
|
||||||
|
Long: "The delete auto image-policy command deletes the given ImagePolicy from the cluster.",
|
||||||
|
Example: ` # Delete an image policy
|
||||||
|
flux delete auto image-policy alpine3.x
|
||||||
|
`,
|
||||||
|
RunE: deleteCommand{
|
||||||
|
apiType: imagePolicyType,
|
||||||
|
object: universalAdapter{&imagev1.ImagePolicy{}},
|
||||||
|
}.run,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
deleteAutoCmd.AddCommand(deleteImagePolicyCmd)
|
||||||
|
}
|
||||||
40
cmd/flux/delete_image_repository.go
Normal file
40
cmd/flux/delete_image_repository.go
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
imagev1 "github.com/fluxcd/image-reflector-controller/api/v1alpha1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var deleteImageRepositoryCmd = &cobra.Command{
|
||||||
|
Use: "image-repository [name]",
|
||||||
|
Short: "Delete an ImageRepository object",
|
||||||
|
Long: "The delete auto image-repository command deletes the given ImageRepository from the cluster.",
|
||||||
|
Example: ` # Delete an image repository
|
||||||
|
flux delete auto image-repository alpine
|
||||||
|
`,
|
||||||
|
RunE: deleteCommand{
|
||||||
|
apiType: imageRepositoryType,
|
||||||
|
object: universalAdapter{&imagev1.ImageRepository{}},
|
||||||
|
}.run,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
deleteAutoCmd.AddCommand(deleteImageRepositoryCmd)
|
||||||
|
}
|
||||||
40
cmd/flux/delete_image_updateauto.go
Normal file
40
cmd/flux/delete_image_updateauto.go
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
autov1 "github.com/fluxcd/image-automation-controller/api/v1alpha1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var deleteImageUpdateCmd = &cobra.Command{
|
||||||
|
Use: "image-update [name]",
|
||||||
|
Short: "Delete an ImageUpdateAutomation object",
|
||||||
|
Long: "The delete auto image-update command deletes the given ImageUpdateAutomation from the cluster.",
|
||||||
|
Example: ` # Delete an image update automation
|
||||||
|
flux delete auto image-update latest-images
|
||||||
|
`,
|
||||||
|
RunE: deleteCommand{
|
||||||
|
apiType: imageUpdateAutomationType,
|
||||||
|
object: universalAdapter{&autov1.ImageUpdateAutomation{}},
|
||||||
|
}.run,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
deleteAutoCmd.AddCommand(deleteImageUpdateCmd)
|
||||||
|
}
|
||||||
@@ -18,8 +18,15 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
"k8s.io/apimachinery/pkg/types"
|
||||||
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
|
"sigs.k8s.io/yaml"
|
||||||
|
|
||||||
|
"github.com/fluxcd/flux2/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
var exportCmd = &cobra.Command{
|
var exportCmd = &cobra.Command{
|
||||||
@@ -38,6 +45,80 @@ func init() {
|
|||||||
rootCmd.AddCommand(exportCmd)
|
rootCmd.AddCommand(exportCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// exportable represents a type that you can fetch from the Kubernetes
|
||||||
|
// API, then tidy up for serialising.
|
||||||
|
type exportable interface {
|
||||||
|
adapter
|
||||||
|
export() interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// exportableList represents a type that has a list of values, each of
|
||||||
|
// which is exportable.
|
||||||
|
type exportableList interface {
|
||||||
|
adapter
|
||||||
|
len() int
|
||||||
|
exportItem(i int) interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
type exportCommand struct {
|
||||||
|
object exportable
|
||||||
|
list exportableList
|
||||||
|
}
|
||||||
|
|
||||||
|
func (export exportCommand) run(cmd *cobra.Command, args []string) error {
|
||||||
|
if !exportAll && len(args) < 1 {
|
||||||
|
return fmt.Errorf("name is required")
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
kubeClient, err := utils.KubeClient(kubeconfig, kubecontext)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if exportAll {
|
||||||
|
err = kubeClient.List(ctx, export.list.asRuntimeObject(), client.InNamespace(namespace))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if export.list.len() == 0 {
|
||||||
|
logger.Failuref("no objects found in %s namespace", namespace)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := 0; i < export.list.len(); i++ {
|
||||||
|
if err = printExport(export.list.exportItem(i)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
name := args[0]
|
||||||
|
namespacedName := types.NamespacedName{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
err = kubeClient.Get(ctx, namespacedName, export.object.asRuntimeObject())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return printExport(export.object.export())
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func printExport(export interface{}) error {
|
||||||
|
data, err := yaml.Marshal(export)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
fmt.Println("---")
|
||||||
|
fmt.Println(resourceToString(data))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func resourceToString(data []byte) string {
|
func resourceToString(data []byte) string {
|
||||||
data = bytes.Replace(data, []byte(" creationTimestamp: null\n"), []byte(""), 1)
|
data = bytes.Replace(data, []byte(" creationTimestamp: null\n"), []byte(""), 1)
|
||||||
data = bytes.Replace(data, []byte("status: {}\n"), []byte(""), 1)
|
data = bytes.Replace(data, []byte("status: {}\n"), []byte(""), 1)
|
||||||
|
|||||||
31
cmd/flux/export_image.go
Normal file
31
cmd/flux/export_image.go
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
var exportImageCmd = &cobra.Command{
|
||||||
|
Use: "image",
|
||||||
|
Short: "Export image automation objects",
|
||||||
|
Long: "The export image sub-commands export image automation objects in YAML format.",
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
exportCmd.AddCommand(exportImageCmd)
|
||||||
|
}
|
||||||
72
cmd/flux/export_image_policy.go
Normal file
72
cmd/flux/export_image_policy.go
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
|
imagev1 "github.com/fluxcd/image-reflector-controller/api/v1alpha1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var exportImagePolicyCmd = &cobra.Command{
|
||||||
|
Use: "policy [name]",
|
||||||
|
Short: "Export ImagePolicy resources in YAML format",
|
||||||
|
Long: "The export image policy command exports one or all ImagePolicy resources in YAML format.",
|
||||||
|
Example: ` # Export all ImagePolicy resources
|
||||||
|
flux export image policy --all > image-policies.yaml
|
||||||
|
|
||||||
|
# Export a specific policy
|
||||||
|
flux export image policy alpine1x > alpine1x.yaml
|
||||||
|
`,
|
||||||
|
RunE: exportCommand{
|
||||||
|
object: imagePolicyAdapter{&imagev1.ImagePolicy{}},
|
||||||
|
list: imagePolicyListAdapter{&imagev1.ImagePolicyList{}},
|
||||||
|
}.run,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
exportImageCmd.AddCommand(exportImagePolicyCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Export returns a ImagePolicy value which has extraneous information
|
||||||
|
// stripped out.
|
||||||
|
func exportImagePolicy(item *imagev1.ImagePolicy) interface{} {
|
||||||
|
gvk := imagev1.GroupVersion.WithKind(imagev1.ImagePolicyKind)
|
||||||
|
export := imagev1.ImagePolicy{
|
||||||
|
TypeMeta: metav1.TypeMeta{
|
||||||
|
Kind: gvk.Kind,
|
||||||
|
APIVersion: gvk.GroupVersion().String(),
|
||||||
|
},
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: item.Name,
|
||||||
|
Namespace: item.Namespace,
|
||||||
|
Labels: item.Labels,
|
||||||
|
Annotations: item.Annotations,
|
||||||
|
},
|
||||||
|
Spec: item.Spec,
|
||||||
|
}
|
||||||
|
return export
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ex imagePolicyAdapter) export() interface{} {
|
||||||
|
return exportImagePolicy(ex.ImagePolicy)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ex imagePolicyListAdapter) exportItem(i int) interface{} {
|
||||||
|
return exportImagePolicy(&ex.ImagePolicyList.Items[i])
|
||||||
|
}
|
||||||
70
cmd/flux/export_image_repository.go
Normal file
70
cmd/flux/export_image_repository.go
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
|
imagev1 "github.com/fluxcd/image-reflector-controller/api/v1alpha1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var exportImageRepositoryCmd = &cobra.Command{
|
||||||
|
Use: "repository [name]",
|
||||||
|
Short: "Export ImageRepository resources in YAML format",
|
||||||
|
Long: "The export image repository command exports one or all ImageRepository resources in YAML format.",
|
||||||
|
Example: ` # Export all ImageRepository resources
|
||||||
|
flux export image repository --all > image-repositories.yaml
|
||||||
|
|
||||||
|
# Export a specific ImageRepository resource
|
||||||
|
flux export image repository alpine > alpine.yaml
|
||||||
|
`,
|
||||||
|
RunE: exportCommand{
|
||||||
|
object: imageRepositoryAdapter{&imagev1.ImageRepository{}},
|
||||||
|
list: imageRepositoryListAdapter{&imagev1.ImageRepositoryList{}},
|
||||||
|
}.run,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
exportImageCmd.AddCommand(exportImageRepositoryCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func exportImageRepository(repo *imagev1.ImageRepository) interface{} {
|
||||||
|
gvk := imagev1.GroupVersion.WithKind(imagev1.ImageRepositoryKind)
|
||||||
|
export := imagev1.ImageRepository{
|
||||||
|
TypeMeta: metav1.TypeMeta{
|
||||||
|
Kind: gvk.Kind,
|
||||||
|
APIVersion: gvk.GroupVersion().String(),
|
||||||
|
},
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: repo.Name,
|
||||||
|
Namespace: repo.Namespace,
|
||||||
|
Labels: repo.Labels,
|
||||||
|
Annotations: repo.Annotations,
|
||||||
|
},
|
||||||
|
Spec: repo.Spec,
|
||||||
|
}
|
||||||
|
return export
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ex imageRepositoryAdapter) export() interface{} {
|
||||||
|
return exportImageRepository(ex.ImageRepository)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ex imageRepositoryListAdapter) exportItem(i int) interface{} {
|
||||||
|
return exportImageRepository(&ex.ImageRepositoryList.Items[i])
|
||||||
|
}
|
||||||
72
cmd/flux/export_image_updateauto.go
Normal file
72
cmd/flux/export_image_updateauto.go
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
|
autov1 "github.com/fluxcd/image-automation-controller/api/v1alpha1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var exportImageUpdateCmd = &cobra.Command{
|
||||||
|
Use: "update [name]",
|
||||||
|
Short: "Export ImageUpdateAutomation resources in YAML format",
|
||||||
|
Long: "The export image update command exports one or all ImageUpdateAutomation resources in YAML format.",
|
||||||
|
Example: ` # Export all ImageUpdateAutomation resources
|
||||||
|
flux export image update --all > updates.yaml
|
||||||
|
|
||||||
|
# Export a specific automation
|
||||||
|
flux export image update latest-images > latest.yaml
|
||||||
|
`,
|
||||||
|
RunE: exportCommand{
|
||||||
|
object: imageUpdateAutomationAdapter{&autov1.ImageUpdateAutomation{}},
|
||||||
|
list: imageUpdateAutomationListAdapter{&autov1.ImageUpdateAutomationList{}},
|
||||||
|
}.run,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
exportImageCmd.AddCommand(exportImageUpdateCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
// exportImageUpdate returns a value which has extraneous information
|
||||||
|
// stripped out.
|
||||||
|
func exportImageUpdate(item *autov1.ImageUpdateAutomation) interface{} {
|
||||||
|
gvk := autov1.GroupVersion.WithKind(autov1.ImageUpdateAutomationKind)
|
||||||
|
export := autov1.ImageUpdateAutomation{
|
||||||
|
TypeMeta: metav1.TypeMeta{
|
||||||
|
Kind: gvk.Kind,
|
||||||
|
APIVersion: gvk.GroupVersion().String(),
|
||||||
|
},
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: item.Name,
|
||||||
|
Namespace: item.Namespace,
|
||||||
|
Labels: item.Labels,
|
||||||
|
Annotations: item.Annotations,
|
||||||
|
},
|
||||||
|
Spec: item.Spec,
|
||||||
|
}
|
||||||
|
return export
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ex imageUpdateAutomationAdapter) export() interface{} {
|
||||||
|
return exportImageUpdate(ex.ImageUpdateAutomation)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ex imageUpdateAutomationListAdapter) exportItem(i int) interface{} {
|
||||||
|
return exportImageUpdate(&ex.ImageUpdateAutomationList.Items[i])
|
||||||
|
}
|
||||||
@@ -17,7 +17,17 @@ limitations under the License.
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
apimeta "k8s.io/apimachinery/pkg/api/meta"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
|
|
||||||
|
"github.com/fluxcd/pkg/apis/meta"
|
||||||
|
|
||||||
|
"github.com/fluxcd/flux2/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
var getCmd = &cobra.Command{
|
var getCmd = &cobra.Command{
|
||||||
@@ -33,3 +43,66 @@ func init() {
|
|||||||
"list the requested object(s) across all namespaces")
|
"list the requested object(s) across all namespaces")
|
||||||
rootCmd.AddCommand(getCmd)
|
rootCmd.AddCommand(getCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type summarisable interface {
|
||||||
|
adapter
|
||||||
|
len() int
|
||||||
|
summariseItem(i int, includeNamespace bool) []string
|
||||||
|
headers(includeNamespace bool) []string
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- these help with implementations of summarisable
|
||||||
|
|
||||||
|
func statusAndMessage(conditions []metav1.Condition) (string, string) {
|
||||||
|
if c := apimeta.FindStatusCondition(conditions, meta.ReadyCondition); c != nil {
|
||||||
|
return string(c.Status), c.Message
|
||||||
|
}
|
||||||
|
return string(metav1.ConditionFalse), "waiting to be reconciled"
|
||||||
|
}
|
||||||
|
|
||||||
|
func nameColumns(item named, includeNamespace bool) []string {
|
||||||
|
if includeNamespace {
|
||||||
|
return []string{item.GetNamespace(), item.GetName()}
|
||||||
|
}
|
||||||
|
return []string{item.GetName()}
|
||||||
|
}
|
||||||
|
|
||||||
|
var namespaceHeader = []string{"Namespace"}
|
||||||
|
|
||||||
|
type getCommand struct {
|
||||||
|
apiType
|
||||||
|
list summarisable
|
||||||
|
}
|
||||||
|
|
||||||
|
func (get getCommand) run(cmd *cobra.Command, args []string) error {
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
kubeClient, err := utils.KubeClient(kubeconfig, kubecontext)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var listOpts []client.ListOption
|
||||||
|
if !allNamespaces {
|
||||||
|
listOpts = append(listOpts, client.InNamespace(namespace))
|
||||||
|
}
|
||||||
|
err = kubeClient.List(ctx, get.list.asRuntimeObject(), listOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if get.list.len() == 0 {
|
||||||
|
logger.Failuref("no %s objects found in %s namespace", get.kind, namespace)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
header := get.list.headers(allNamespaces)
|
||||||
|
var rows [][]string
|
||||||
|
for i := 0; i < get.list.len(); i++ {
|
||||||
|
row := get.list.summariseItem(i, allNamespaces)
|
||||||
|
rows = append(rows, row)
|
||||||
|
}
|
||||||
|
utils.PrintTable(os.Stdout, header, rows)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
31
cmd/flux/get_image.go
Normal file
31
cmd/flux/get_image.go
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
var getImageCmd = &cobra.Command{
|
||||||
|
Use: "image",
|
||||||
|
Short: "Get image automation object status",
|
||||||
|
Long: "The get image sub-commands print the status of image automation objects.",
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
getCmd.AddCommand(getImageCmd)
|
||||||
|
}
|
||||||
57
cmd/flux/get_image_policy.go
Normal file
57
cmd/flux/get_image_policy.go
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
imagev1 "github.com/fluxcd/image-reflector-controller/api/v1alpha1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var getImagePolicyCmd = &cobra.Command{
|
||||||
|
Use: "policy",
|
||||||
|
Short: "Get ImagePolicy status",
|
||||||
|
Long: "The get image policy command prints the status of ImagePolicy objects.",
|
||||||
|
Example: ` # List all image policies and their status
|
||||||
|
flux get image policy
|
||||||
|
|
||||||
|
# List image policies from all namespaces
|
||||||
|
flux get image policy --all-namespaces
|
||||||
|
`,
|
||||||
|
RunE: getCommand{
|
||||||
|
apiType: imagePolicyType,
|
||||||
|
list: &imagePolicyListAdapter{&imagev1.ImagePolicyList{}},
|
||||||
|
}.run,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
getImageCmd.AddCommand(getImagePolicyCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s imagePolicyListAdapter) summariseItem(i int, includeNamespace bool) []string {
|
||||||
|
item := s.Items[i]
|
||||||
|
status, msg := statusAndMessage(item.Status.Conditions)
|
||||||
|
return append(nameColumns(&item, includeNamespace), status, msg, item.Status.LatestImage)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s imagePolicyListAdapter) headers(includeNamespace bool) []string {
|
||||||
|
headers := []string{"Name", "Ready", "Message", "Latest image"}
|
||||||
|
if includeNamespace {
|
||||||
|
return append(namespaceHeader, headers...)
|
||||||
|
}
|
||||||
|
return headers
|
||||||
|
}
|
||||||
66
cmd/flux/get_image_repository.go
Normal file
66
cmd/flux/get_image_repository.go
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
imagev1 "github.com/fluxcd/image-reflector-controller/api/v1alpha1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var getImageRepositoryCmd = &cobra.Command{
|
||||||
|
Use: "repository",
|
||||||
|
Short: "Get ImageRepository status",
|
||||||
|
Long: "The get image repository command prints the status of ImageRepository objects.",
|
||||||
|
Example: ` # List all image repositories and their status
|
||||||
|
flux get image repository
|
||||||
|
|
||||||
|
# List image repositories from all namespaces
|
||||||
|
flux get image repository --all-namespaces
|
||||||
|
`,
|
||||||
|
RunE: getCommand{
|
||||||
|
apiType: imageRepositoryType,
|
||||||
|
list: imageRepositoryListAdapter{&imagev1.ImageRepositoryList{}},
|
||||||
|
}.run,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
getImageCmd.AddCommand(getImageRepositoryCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s imageRepositoryListAdapter) summariseItem(i int, includeNamespace bool) []string {
|
||||||
|
item := s.Items[i]
|
||||||
|
status, msg := statusAndMessage(item.Status.Conditions)
|
||||||
|
var lastScan string
|
||||||
|
if item.Status.LastScanResult != nil {
|
||||||
|
lastScan = item.Status.LastScanResult.ScanTime.Time.Format(time.RFC3339)
|
||||||
|
}
|
||||||
|
return append(nameColumns(&item, includeNamespace),
|
||||||
|
status, msg, lastScan, strings.Title(strconv.FormatBool(item.Spec.Suspend)))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s imageRepositoryListAdapter) headers(includeNamespace bool) []string {
|
||||||
|
headers := []string{"Name", "Ready", "Message", "Last scan", "Suspended"}
|
||||||
|
if includeNamespace {
|
||||||
|
return append(namespaceHeader, headers...)
|
||||||
|
}
|
||||||
|
return headers
|
||||||
|
}
|
||||||
65
cmd/flux/get_image_updateauto.go
Normal file
65
cmd/flux/get_image_updateauto.go
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
autov1 "github.com/fluxcd/image-automation-controller/api/v1alpha1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var getImageUpdateCmd = &cobra.Command{
|
||||||
|
Use: "update",
|
||||||
|
Short: "Get ImageUpdateAutomation status",
|
||||||
|
Long: "The get image update command prints the status of ImageUpdateAutomation objects.",
|
||||||
|
Example: ` # List all image update automation object and their status
|
||||||
|
flux get image update
|
||||||
|
|
||||||
|
# List image update automations from all namespaces
|
||||||
|
flux get image update --all-namespaces
|
||||||
|
`,
|
||||||
|
RunE: getCommand{
|
||||||
|
apiType: imageUpdateAutomationType,
|
||||||
|
list: &imageUpdateAutomationListAdapter{&autov1.ImageUpdateAutomationList{}},
|
||||||
|
}.run,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
getImageCmd.AddCommand(getImageUpdateCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s imageUpdateAutomationListAdapter) summariseItem(i int, includeNamespace bool) []string {
|
||||||
|
item := s.Items[i]
|
||||||
|
status, msg := statusAndMessage(item.Status.Conditions)
|
||||||
|
var lastRun string
|
||||||
|
if item.Status.LastAutomationRunTime != nil {
|
||||||
|
lastRun = item.Status.LastAutomationRunTime.Time.Format(time.RFC3339)
|
||||||
|
}
|
||||||
|
return append(nameColumns(&item, includeNamespace), status, msg, lastRun, strings.Title(strconv.FormatBool(item.Spec.Suspend)))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s imageUpdateAutomationListAdapter) headers(includeNamespace bool) []string {
|
||||||
|
headers := []string{"Name", "Ready", "Message", "Last run", "Suspended"}
|
||||||
|
if includeNamespace {
|
||||||
|
return append(namespaceHeader, headers...)
|
||||||
|
}
|
||||||
|
return headers
|
||||||
|
}
|
||||||
115
cmd/flux/image.go
Normal file
115
cmd/flux/image.go
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
|
|
||||||
|
autov1 "github.com/fluxcd/image-automation-controller/api/v1alpha1"
|
||||||
|
imagev1 "github.com/fluxcd/image-reflector-controller/api/v1alpha1"
|
||||||
|
)
|
||||||
|
|
||||||
|
// These are general-purpose adapters for attaching methods to, for
|
||||||
|
// the various commands. The *List adapters implement len(), since
|
||||||
|
// it's used in at least a couple of commands.
|
||||||
|
|
||||||
|
// imagev1.ImageRepository
|
||||||
|
|
||||||
|
var imageRepositoryType = apiType{
|
||||||
|
kind: imagev1.ImageRepositoryKind,
|
||||||
|
humanKind: "image repository",
|
||||||
|
}
|
||||||
|
|
||||||
|
type imageRepositoryAdapter struct {
|
||||||
|
*imagev1.ImageRepository
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a imageRepositoryAdapter) asRuntimeObject() runtime.Object {
|
||||||
|
return a.ImageRepository
|
||||||
|
}
|
||||||
|
|
||||||
|
// imagev1.ImageRepositoryList
|
||||||
|
|
||||||
|
type imageRepositoryListAdapter struct {
|
||||||
|
*imagev1.ImageRepositoryList
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a imageRepositoryListAdapter) asRuntimeObject() runtime.Object {
|
||||||
|
return a.ImageRepositoryList
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a imageRepositoryListAdapter) len() int {
|
||||||
|
return len(a.ImageRepositoryList.Items)
|
||||||
|
}
|
||||||
|
|
||||||
|
// imagev1.ImagePolicy
|
||||||
|
|
||||||
|
var imagePolicyType = apiType{
|
||||||
|
kind: imagev1.ImagePolicyKind,
|
||||||
|
humanKind: "image policy",
|
||||||
|
}
|
||||||
|
|
||||||
|
type imagePolicyAdapter struct {
|
||||||
|
*imagev1.ImagePolicy
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a imagePolicyAdapter) asRuntimeObject() runtime.Object {
|
||||||
|
return a.ImagePolicy
|
||||||
|
}
|
||||||
|
|
||||||
|
// imagev1.ImagePolicyList
|
||||||
|
|
||||||
|
type imagePolicyListAdapter struct {
|
||||||
|
*imagev1.ImagePolicyList
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a imagePolicyListAdapter) asRuntimeObject() runtime.Object {
|
||||||
|
return a.ImagePolicyList
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a imagePolicyListAdapter) len() int {
|
||||||
|
return len(a.ImagePolicyList.Items)
|
||||||
|
}
|
||||||
|
|
||||||
|
// autov1.ImageUpdateAutomation
|
||||||
|
|
||||||
|
var imageUpdateAutomationType = apiType{
|
||||||
|
kind: autov1.ImageUpdateAutomationKind,
|
||||||
|
humanKind: "image update automation",
|
||||||
|
}
|
||||||
|
|
||||||
|
type imageUpdateAutomationAdapter struct {
|
||||||
|
*autov1.ImageUpdateAutomation
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a imageUpdateAutomationAdapter) asRuntimeObject() runtime.Object {
|
||||||
|
return a.ImageUpdateAutomation
|
||||||
|
}
|
||||||
|
|
||||||
|
// autov1.ImageUpdateAutomationList
|
||||||
|
|
||||||
|
type imageUpdateAutomationListAdapter struct {
|
||||||
|
*autov1.ImageUpdateAutomationList
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a imageUpdateAutomationListAdapter) asRuntimeObject() runtime.Object {
|
||||||
|
return a.ImageUpdateAutomationList
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a imageUpdateAutomationListAdapter) len() int {
|
||||||
|
return len(a.ImageUpdateAutomationList.Items)
|
||||||
|
}
|
||||||
@@ -56,13 +56,15 @@ var (
|
|||||||
installDryRun bool
|
installDryRun bool
|
||||||
installManifestsPath string
|
installManifestsPath string
|
||||||
installVersion string
|
installVersion string
|
||||||
installComponents []string
|
installDefaultComponents []string
|
||||||
|
installExtraComponents []string
|
||||||
installRegistry string
|
installRegistry string
|
||||||
installImagePullSecret string
|
installImagePullSecret string
|
||||||
installWatchAllNamespaces bool
|
installWatchAllNamespaces bool
|
||||||
installNetworkPolicy bool
|
installNetworkPolicy bool
|
||||||
installArch = flags.Arch(defaults.Arch)
|
installArch = flags.Arch(defaults.Arch)
|
||||||
installLogLevel = flags.LogLevel(defaults.LogLevel)
|
installLogLevel = flags.LogLevel(defaults.LogLevel)
|
||||||
|
installClusterDomain string
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -72,8 +74,10 @@ func init() {
|
|||||||
"only print the object that would be applied")
|
"only print the object that would be applied")
|
||||||
installCmd.Flags().StringVarP(&installVersion, "version", "v", defaults.Version,
|
installCmd.Flags().StringVarP(&installVersion, "version", "v", defaults.Version,
|
||||||
"toolkit version")
|
"toolkit version")
|
||||||
installCmd.Flags().StringSliceVar(&installComponents, "components", defaults.Components,
|
installCmd.Flags().StringSliceVar(&installDefaultComponents, "components", defaults.Components,
|
||||||
"list of components, accepts comma-separated values")
|
"list of components, accepts comma-separated values")
|
||||||
|
installCmd.Flags().StringSliceVar(&installExtraComponents, "components-extra", nil,
|
||||||
|
"list of components in addition to those supplied or defaulted, accepts comma-separated values")
|
||||||
installCmd.Flags().StringVar(&installManifestsPath, "manifests", "", "path to the manifest directory")
|
installCmd.Flags().StringVar(&installManifestsPath, "manifests", "", "path to the manifest directory")
|
||||||
installCmd.Flags().MarkHidden("manifests")
|
installCmd.Flags().MarkHidden("manifests")
|
||||||
installCmd.Flags().StringVar(&installRegistry, "registry", defaults.Registry,
|
installCmd.Flags().StringVar(&installRegistry, "registry", defaults.Registry,
|
||||||
@@ -86,6 +90,7 @@ func init() {
|
|||||||
installCmd.Flags().Var(&installLogLevel, "log-level", installLogLevel.Description())
|
installCmd.Flags().Var(&installLogLevel, "log-level", installLogLevel.Description())
|
||||||
installCmd.Flags().BoolVar(&installNetworkPolicy, "network-policy", defaults.NetworkPolicy,
|
installCmd.Flags().BoolVar(&installNetworkPolicy, "network-policy", defaults.NetworkPolicy,
|
||||||
"deny ingress access to the toolkit controllers from other namespaces using network policies")
|
"deny ingress access to the toolkit controllers from other namespaces using network policies")
|
||||||
|
installCmd.Flags().StringVar(&installClusterDomain, "cluster-domain", defaults.ClusterDomain, "internal cluster domain")
|
||||||
rootCmd.AddCommand(installCmd)
|
rootCmd.AddCommand(installCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,11 +108,13 @@ func installCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
logger.Generatef("generating manifests")
|
logger.Generatef("generating manifests")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
components := append(installDefaultComponents, installExtraComponents...)
|
||||||
|
|
||||||
opts := install.Options{
|
opts := install.Options{
|
||||||
BaseURL: installManifestsPath,
|
BaseURL: installManifestsPath,
|
||||||
Version: installVersion,
|
Version: installVersion,
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Components: installComponents,
|
Components: components,
|
||||||
Registry: installRegistry,
|
Registry: installRegistry,
|
||||||
ImagePullSecret: installImagePullSecret,
|
ImagePullSecret: installImagePullSecret,
|
||||||
Arch: installArch.String(),
|
Arch: installArch.String(),
|
||||||
@@ -117,6 +124,7 @@ func installCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
NotificationController: defaults.NotificationController,
|
NotificationController: defaults.NotificationController,
|
||||||
ManifestFile: fmt.Sprintf("%s.yaml", namespace),
|
ManifestFile: fmt.Sprintf("%s.yaml", namespace),
|
||||||
Timeout: timeout,
|
Timeout: timeout,
|
||||||
|
ClusterDomain: installClusterDomain,
|
||||||
}
|
}
|
||||||
|
|
||||||
if installManifestsPath == "" {
|
if installManifestsPath == "" {
|
||||||
@@ -137,7 +145,7 @@ func installCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
} else if installExport {
|
} else if installExport {
|
||||||
fmt.Println("---")
|
fmt.Println("---")
|
||||||
fmt.Println("# GitOps Toolkit revision", installVersion)
|
fmt.Println("# GitOps Toolkit revision", installVersion)
|
||||||
fmt.Println("# Components:", strings.Join(installComponents, ","))
|
fmt.Println("# Components:", strings.Join(components, ","))
|
||||||
fmt.Print(manifest.Content)
|
fmt.Print(manifest.Content)
|
||||||
fmt.Println("---")
|
fmt.Println("---")
|
||||||
return nil
|
return nil
|
||||||
@@ -167,7 +175,7 @@ func installCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
logger.Waitingf("verifying installation")
|
logger.Waitingf("verifying installation")
|
||||||
for _, deployment := range installComponents {
|
for _, deployment := range components {
|
||||||
kubectlArgs = []string{"-n", namespace, "rollout", "status", "deployment", deployment, "--timeout", timeout.String()}
|
kubectlArgs = []string{"-n", namespace, "rollout", "status", "deployment", deployment, "--timeout", timeout.String()}
|
||||||
if _, err := utils.ExecKubectlCommand(ctx, applyOutput, kubeconfig, kubecontext, kubectlArgs...); err != nil {
|
if _, err := utils.ExecKubectlCommand(ctx, applyOutput, kubeconfig, kubecontext, kubectlArgs...); err != nil {
|
||||||
return fmt.Errorf("install failed")
|
return fmt.Errorf("install failed")
|
||||||
|
|||||||
@@ -16,26 +16,31 @@ limitations under the License.
|
|||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
)
|
||||||
|
|
||||||
type printLogger struct{}
|
type stderrLogger struct {
|
||||||
|
stderr io.Writer
|
||||||
func (l printLogger) Actionf(format string, a ...interface{}) {
|
|
||||||
fmt.Println(`►`, fmt.Sprintf(format, a...))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l printLogger) Generatef(format string, a ...interface{}) {
|
func (l stderrLogger) Actionf(format string, a ...interface{}) {
|
||||||
fmt.Println(`✚`, fmt.Sprintf(format, a...))
|
fmt.Fprintln(l.stderr, `►`, fmt.Sprintf(format, a...))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l printLogger) Waitingf(format string, a ...interface{}) {
|
func (l stderrLogger) Generatef(format string, a ...interface{}) {
|
||||||
fmt.Println(`◎`, fmt.Sprintf(format, a...))
|
fmt.Fprintln(l.stderr, `✚`, fmt.Sprintf(format, a...))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l printLogger) Successf(format string, a ...interface{}) {
|
func (l stderrLogger) Waitingf(format string, a ...interface{}) {
|
||||||
fmt.Println(`✔`, fmt.Sprintf(format, a...))
|
fmt.Fprintln(l.stderr, `◎`, fmt.Sprintf(format, a...))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l printLogger) Failuref(format string, a ...interface{}) {
|
func (l stderrLogger) Successf(format string, a ...interface{}) {
|
||||||
fmt.Println(`✗`, fmt.Sprintf(format, a...))
|
fmt.Fprintln(l.stderr, `✔`, fmt.Sprintf(format, a...))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l stderrLogger) Failuref(format string, a ...interface{}) {
|
||||||
|
fmt.Fprintln(l.stderr, `✗`, fmt.Sprintf(format, a...))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ var (
|
|||||||
timeout time.Duration
|
timeout time.Duration
|
||||||
verbose bool
|
verbose bool
|
||||||
pollInterval = 2 * time.Second
|
pollInterval = 2 * time.Second
|
||||||
logger fluxlog.Logger = printLogger{}
|
logger fluxlog.Logger = stderrLogger{stderr: os.Stderr}
|
||||||
defaults = install.MakeDefaultOptions()
|
defaults = install.MakeDefaultOptions()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
64
cmd/flux/object.go
Normal file
64
cmd/flux/object.go
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Most commands need one or both of the kind (e.g.,
|
||||||
|
// `"ImageRepository"`) and a human-palatable name for the kind (e.g.,
|
||||||
|
// `"image repository"`), to be interpolated into output. It's
|
||||||
|
// convenient to package these up ahead of time, then the command
|
||||||
|
// implementation can pick whichever it wants to use.
|
||||||
|
type apiType struct {
|
||||||
|
kind, humanKind string
|
||||||
|
}
|
||||||
|
|
||||||
|
// adapter is an interface for a wrapper or alias from which we can
|
||||||
|
// get a controller-runtime deserialisable value. This is used so that
|
||||||
|
// you can wrap an API type to give it other useful methods, but still
|
||||||
|
// use values of the wrapper with `client.Client`, which only deals
|
||||||
|
// with types that have been added to the schema.
|
||||||
|
type adapter interface {
|
||||||
|
asRuntimeObject() runtime.Object
|
||||||
|
}
|
||||||
|
|
||||||
|
// universalAdapter is an adapter for any runtime.Object. Use this if
|
||||||
|
// there are no other methods needed.
|
||||||
|
type universalAdapter struct {
|
||||||
|
obj runtime.Object
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c universalAdapter) asRuntimeObject() runtime.Object {
|
||||||
|
return c.obj
|
||||||
|
}
|
||||||
|
|
||||||
|
// named is for adapters that have Name and Namespace fields, which
|
||||||
|
// are sometimes handy to get hold of. ObjectMeta implements these, so
|
||||||
|
// they shouldn't need any extra work.
|
||||||
|
type named interface {
|
||||||
|
GetName() string
|
||||||
|
GetNamespace() string
|
||||||
|
SetName(string)
|
||||||
|
SetNamespace(string)
|
||||||
|
}
|
||||||
|
|
||||||
|
func copyName(target, source named) {
|
||||||
|
target.SetName(source.GetName())
|
||||||
|
target.SetNamespace(source.GetNamespace())
|
||||||
|
}
|
||||||
@@ -17,7 +17,20 @@ limitations under the License.
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/fluxcd/pkg/apis/meta"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
apimeta "k8s.io/apimachinery/pkg/api/meta"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/types"
|
||||||
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
|
"k8s.io/client-go/util/retry"
|
||||||
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
|
|
||||||
|
"github.com/fluxcd/flux2/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
var reconcileCmd = &cobra.Command{
|
var reconcileCmd = &cobra.Command{
|
||||||
@@ -29,3 +42,101 @@ var reconcileCmd = &cobra.Command{
|
|||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(reconcileCmd)
|
rootCmd.AddCommand(reconcileCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type reconcileCommand struct {
|
||||||
|
apiType
|
||||||
|
object reconcilable
|
||||||
|
}
|
||||||
|
|
||||||
|
type reconcilable interface {
|
||||||
|
adapter // to be able to load from the cluster
|
||||||
|
suspendable // to tell if it's suspended
|
||||||
|
|
||||||
|
// these are implemented by anything embedding metav1.ObjectMeta
|
||||||
|
GetAnnotations() map[string]string
|
||||||
|
SetAnnotations(map[string]string)
|
||||||
|
|
||||||
|
// this is usually implemented by GOTK types, since it's used for meta.SetResourceCondition
|
||||||
|
GetStatusConditions() *[]metav1.Condition
|
||||||
|
|
||||||
|
lastHandledReconcileRequest() string // what was the last handled reconcile request?
|
||||||
|
successMessage() string // what do you want to tell people when successfully reconciled?
|
||||||
|
}
|
||||||
|
|
||||||
|
func (reconcile reconcileCommand) run(cmd *cobra.Command, args []string) error {
|
||||||
|
if len(args) < 1 {
|
||||||
|
return fmt.Errorf("%s name is required", reconcile.kind)
|
||||||
|
}
|
||||||
|
name := args[0]
|
||||||
|
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
kubeClient, err := utils.KubeClient(kubeconfig, kubecontext)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
namespacedName := types.NamespacedName{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
|
||||||
|
err = kubeClient.Get(ctx, namespacedName, reconcile.object.asRuntimeObject())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if reconcile.object.isSuspended() {
|
||||||
|
return fmt.Errorf("resource is suspended")
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Actionf("annotating %s %s in %s namespace", reconcile.kind, name, namespace)
|
||||||
|
if err := requestReconciliation(ctx, kubeClient, namespacedName, reconcile.object); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
logger.Successf("%s annotated", reconcile.kind)
|
||||||
|
|
||||||
|
lastHandledReconcileAt := reconcile.object.lastHandledReconcileRequest()
|
||||||
|
logger.Waitingf("waiting for %s reconciliation", reconcile.kind)
|
||||||
|
if err := wait.PollImmediate(pollInterval, timeout,
|
||||||
|
reconciliationHandled(ctx, kubeClient, namespacedName, reconcile.object, lastHandledReconcileAt)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
logger.Successf("%s reconciliation completed", reconcile.kind)
|
||||||
|
|
||||||
|
if apimeta.IsStatusConditionFalse(*reconcile.object.GetStatusConditions(), meta.ReadyCondition) {
|
||||||
|
return fmt.Errorf("%s reconciliation failed", reconcile.kind)
|
||||||
|
}
|
||||||
|
logger.Successf(reconcile.object.successMessage())
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func reconciliationHandled(ctx context.Context, kubeClient client.Client,
|
||||||
|
namespacedName types.NamespacedName, obj reconcilable, lastHandledReconcileAt string) wait.ConditionFunc {
|
||||||
|
return func() (bool, error) {
|
||||||
|
err := kubeClient.Get(ctx, namespacedName, obj.asRuntimeObject())
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
return obj.lastHandledReconcileRequest() != lastHandledReconcileAt, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func requestReconciliation(ctx context.Context, kubeClient client.Client,
|
||||||
|
namespacedName types.NamespacedName, obj reconcilable) error {
|
||||||
|
return retry.RetryOnConflict(retry.DefaultBackoff, func() (err error) {
|
||||||
|
if err := kubeClient.Get(ctx, namespacedName, obj.asRuntimeObject()); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if ann := obj.GetAnnotations(); ann == nil {
|
||||||
|
obj.SetAnnotations(map[string]string{
|
||||||
|
meta.ReconcileAtAnnotation: time.Now().Format(time.RFC3339Nano),
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
ann[meta.ReconcileAtAnnotation] = time.Now().Format(time.RFC3339Nano)
|
||||||
|
obj.SetAnnotations(ann)
|
||||||
|
}
|
||||||
|
return kubeClient.Update(ctx, obj.asRuntimeObject())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -64,13 +64,17 @@ func reconcileAlertCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
Name: name,
|
Name: name,
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Actionf("annotating Alert %s in %s namespace", name, namespace)
|
|
||||||
var alert notificationv1.Alert
|
var alert notificationv1.Alert
|
||||||
err = kubeClient.Get(ctx, namespacedName, &alert)
|
err = kubeClient.Get(ctx, namespacedName, &alert)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if alert.Spec.Suspend {
|
||||||
|
return fmt.Errorf("resource is suspended")
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Actionf("annotating Alert %s in %s namespace", name, namespace)
|
||||||
if alert.Annotations == nil {
|
if alert.Annotations == nil {
|
||||||
alert.Annotations = map[string]string{
|
alert.Annotations = map[string]string{
|
||||||
meta.ReconcileAtAnnotation: time.Now().Format(time.RFC3339Nano),
|
meta.ReconcileAtAnnotation: time.Now().Format(time.RFC3339Nano),
|
||||||
@@ -78,6 +82,7 @@ func reconcileAlertCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
} else {
|
} else {
|
||||||
alert.Annotations[meta.ReconcileAtAnnotation] = time.Now().Format(time.RFC3339Nano)
|
alert.Annotations[meta.ReconcileAtAnnotation] = time.Now().Format(time.RFC3339Nano)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := kubeClient.Update(ctx, &alert); err != nil {
|
if err := kubeClient.Update(ctx, &alert); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,6 +86,10 @@ func reconcileHrCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if helmRelease.Spec.Suspend {
|
||||||
|
return fmt.Errorf("resource is suspended")
|
||||||
|
}
|
||||||
|
|
||||||
if syncHrWithSource {
|
if syncHrWithSource {
|
||||||
switch helmRelease.Spec.Chart.Spec.SourceRef.Kind {
|
switch helmRelease.Spec.Chart.Spec.SourceRef.Kind {
|
||||||
case sourcev1.HelmRepositoryKind:
|
case sourcev1.HelmRepositoryKind:
|
||||||
|
|||||||
31
cmd/flux/reconcile_image.go
Normal file
31
cmd/flux/reconcile_image.go
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
var reconcileImageCmd = &cobra.Command{
|
||||||
|
Use: "image",
|
||||||
|
Short: "Reconcile image automation objects",
|
||||||
|
Long: "The reconcile sub-commands trigger a reconciliation of image automation objects.",
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
reconcileCmd.AddCommand(reconcileImageCmd)
|
||||||
|
}
|
||||||
50
cmd/flux/reconcile_image_repository.go
Normal file
50
cmd/flux/reconcile_image_repository.go
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
imagev1 "github.com/fluxcd/image-reflector-controller/api/v1alpha1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var reconcileImageRepositoryCmd = &cobra.Command{
|
||||||
|
Use: "repository [name]",
|
||||||
|
Short: "Reconcile an ImageRepository",
|
||||||
|
Long: `The reconcile image repository command triggers a reconciliation of an ImageRepository resource and waits for it to finish.`,
|
||||||
|
Example: ` # Trigger an scan for an existing image repository
|
||||||
|
flux reconcile image repository alpine
|
||||||
|
`,
|
||||||
|
RunE: reconcileCommand{
|
||||||
|
apiType: imageRepositoryType,
|
||||||
|
object: imageRepositoryAdapter{&imagev1.ImageRepository{}},
|
||||||
|
}.run,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
reconcileImageCmd.AddCommand(reconcileImageRepositoryCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (obj imageRepositoryAdapter) lastHandledReconcileRequest() string {
|
||||||
|
return obj.Status.GetLastHandledReconcileRequest()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (obj imageRepositoryAdapter) successMessage() string {
|
||||||
|
return fmt.Sprintf("scan fetched %d tags", obj.Status.LastScanResult.TagCount)
|
||||||
|
}
|
||||||
62
cmd/flux/reconcile_image_updateauto.go
Normal file
62
cmd/flux/reconcile_image_updateauto.go
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
apimeta "k8s.io/apimachinery/pkg/api/meta"
|
||||||
|
|
||||||
|
autov1 "github.com/fluxcd/image-automation-controller/api/v1alpha1"
|
||||||
|
meta "github.com/fluxcd/pkg/apis/meta"
|
||||||
|
)
|
||||||
|
|
||||||
|
var reconcileImageUpdateCmd = &cobra.Command{
|
||||||
|
Use: "update [name]",
|
||||||
|
Short: "Reconcile an ImageUpdateAutomation",
|
||||||
|
Long: `The reconcile image update command triggers a reconciliation of an ImageUpdateAutomation resource and waits for it to finish.`,
|
||||||
|
Example: ` # Trigger an automation run for an existing image update automation
|
||||||
|
flux reconcile image update latest-images
|
||||||
|
`,
|
||||||
|
RunE: reconcileCommand{
|
||||||
|
apiType: imageUpdateAutomationType,
|
||||||
|
object: imageUpdateAutomationAdapter{&autov1.ImageUpdateAutomation{}},
|
||||||
|
}.run,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
reconcileImageCmd.AddCommand(reconcileImageUpdateCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (obj imageUpdateAutomationAdapter) suspended() bool {
|
||||||
|
return obj.ImageUpdateAutomation.Spec.Suspend
|
||||||
|
}
|
||||||
|
|
||||||
|
func (obj imageUpdateAutomationAdapter) lastHandledReconcileRequest() string {
|
||||||
|
return obj.Status.GetLastHandledReconcileRequest()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (obj imageUpdateAutomationAdapter) successMessage() string {
|
||||||
|
if rc := apimeta.FindStatusCondition(obj.Status.Conditions, meta.ReadyCondition); rc != nil {
|
||||||
|
return rc.Message
|
||||||
|
}
|
||||||
|
if obj.Status.LastAutomationRunTime != nil {
|
||||||
|
return "last run " + obj.Status.LastAutomationRunTime.Time.Format(time.RFC3339)
|
||||||
|
}
|
||||||
|
return "automation not yet run"
|
||||||
|
}
|
||||||
@@ -84,6 +84,10 @@ func reconcileKsCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if kustomization.Spec.Suspend {
|
||||||
|
return fmt.Errorf("resource is suspended")
|
||||||
|
}
|
||||||
|
|
||||||
if syncKsWithSource {
|
if syncKsWithSource {
|
||||||
switch kustomization.Spec.SourceRef.Kind {
|
switch kustomization.Spec.SourceRef.Kind {
|
||||||
case sourcev1.GitRepositoryKind:
|
case sourcev1.GitRepositoryKind:
|
||||||
|
|||||||
@@ -64,13 +64,17 @@ func reconcileReceiverCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
Name: name,
|
Name: name,
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Actionf("annotating Receiver %s in %s namespace", name, namespace)
|
|
||||||
var receiver notificationv1.Receiver
|
var receiver notificationv1.Receiver
|
||||||
err = kubeClient.Get(ctx, namespacedName, &receiver)
|
err = kubeClient.Get(ctx, namespacedName, &receiver)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if receiver.Spec.Suspend {
|
||||||
|
return fmt.Errorf("resource is suspended")
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Actionf("annotating Receiver %s in %s namespace", name, namespace)
|
||||||
if receiver.Annotations == nil {
|
if receiver.Annotations == nil {
|
||||||
receiver.Annotations = map[string]string{
|
receiver.Annotations = map[string]string{
|
||||||
meta.ReconcileAtAnnotation: time.Now().Format(time.RFC3339Nano),
|
meta.ReconcileAtAnnotation: time.Now().Format(time.RFC3339Nano),
|
||||||
|
|||||||
@@ -74,6 +74,10 @@ func reconcileSourceBucketCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if bucket.Spec.Suspend {
|
||||||
|
return fmt.Errorf("resource is suspended")
|
||||||
|
}
|
||||||
|
|
||||||
lastHandledReconcileAt := bucket.Status.LastHandledReconcileAt
|
lastHandledReconcileAt := bucket.Status.LastHandledReconcileAt
|
||||||
logger.Actionf("annotating Bucket source %s in %s namespace", name, namespace)
|
logger.Actionf("annotating Bucket source %s in %s namespace", name, namespace)
|
||||||
if err := requestBucketReconciliation(ctx, kubeClient, namespacedName, &bucket); err != nil {
|
if err := requestBucketReconciliation(ctx, kubeClient, namespacedName, &bucket); err != nil {
|
||||||
|
|||||||
@@ -72,6 +72,10 @@ func reconcileSourceGitCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if repository.Spec.Suspend {
|
||||||
|
return fmt.Errorf("resource is suspended")
|
||||||
|
}
|
||||||
|
|
||||||
logger.Actionf("annotating GitRepository source %s in %s namespace", name, namespace)
|
logger.Actionf("annotating GitRepository source %s in %s namespace", name, namespace)
|
||||||
if err := requestGitRepositoryReconciliation(ctx, kubeClient, namespacedName, &repository); err != nil {
|
if err := requestGitRepositoryReconciliation(ctx, kubeClient, namespacedName, &repository); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -73,6 +73,10 @@ func reconcileSourceHelmCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if repository.Spec.Suspend {
|
||||||
|
return fmt.Errorf("resource is suspended")
|
||||||
|
}
|
||||||
|
|
||||||
logger.Actionf("annotating HelmRepository source %s in %s namespace", name, namespace)
|
logger.Actionf("annotating HelmRepository source %s in %s namespace", name, namespace)
|
||||||
if err := requestHelmRepositoryReconciliation(ctx, kubeClient, namespacedName, &repository); err != nil {
|
if err := requestHelmRepositoryReconciliation(ctx, kubeClient, namespacedName, &repository); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -17,7 +17,14 @@ limitations under the License.
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
"k8s.io/apimachinery/pkg/types"
|
||||||
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
|
|
||||||
|
"github.com/fluxcd/flux2/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
var resumeCmd = &cobra.Command{
|
var resumeCmd = &cobra.Command{
|
||||||
@@ -29,3 +36,56 @@ var resumeCmd = &cobra.Command{
|
|||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(resumeCmd)
|
rootCmd.AddCommand(resumeCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type resumable interface {
|
||||||
|
adapter
|
||||||
|
statusable
|
||||||
|
setUnsuspended()
|
||||||
|
successMessage() string
|
||||||
|
}
|
||||||
|
|
||||||
|
type resumeCommand struct {
|
||||||
|
apiType
|
||||||
|
object resumable
|
||||||
|
}
|
||||||
|
|
||||||
|
func (resume resumeCommand) run(cmd *cobra.Command, args []string) error {
|
||||||
|
if len(args) < 1 {
|
||||||
|
return fmt.Errorf("%s name is required", resume.humanKind)
|
||||||
|
}
|
||||||
|
name := args[0]
|
||||||
|
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
kubeClient, err := utils.KubeClient(kubeconfig, kubecontext)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
namespacedName := types.NamespacedName{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
|
||||||
|
err = kubeClient.Get(ctx, namespacedName, resume.object.asRuntimeObject())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Actionf("resuming %s %s in %s namespace", resume.humanKind, name, namespace)
|
||||||
|
resume.object.setUnsuspended()
|
||||||
|
if err := kubeClient.Update(ctx, resume.object.asRuntimeObject()); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
logger.Successf("%s resumed", resume.humanKind)
|
||||||
|
|
||||||
|
logger.Waitingf("waiting for %s reconciliation", resume.kind)
|
||||||
|
if err := wait.PollImmediate(pollInterval, timeout,
|
||||||
|
isReady(ctx, kubeClient, namespacedName, resume.object)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
logger.Successf("%s reconciliation completed", resume.kind)
|
||||||
|
logger.Successf(resume.object.successMessage())
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
31
cmd/flux/resume_image.go
Normal file
31
cmd/flux/resume_image.go
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
var resumeImageCmd = &cobra.Command{
|
||||||
|
Use: "image",
|
||||||
|
Short: "Resume image automation objects",
|
||||||
|
Long: "The resume image sub-commands resume suspended image automation objects.",
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
resumeCmd.AddCommand(resumeImageCmd)
|
||||||
|
}
|
||||||
48
cmd/flux/resume_image_repository.go
Normal file
48
cmd/flux/resume_image_repository.go
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
imagev1 "github.com/fluxcd/image-reflector-controller/api/v1alpha1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var resumeImageRepositoryCmd = &cobra.Command{
|
||||||
|
Use: "repository [name]",
|
||||||
|
Short: "Resume a suspended ImageRepository",
|
||||||
|
Long: `The resume command marks a previously suspended ImageRepository resource for reconciliation and waits for it to finish.`,
|
||||||
|
Example: ` # Resume reconciliation for an existing ImageRepository
|
||||||
|
flux resume image repository alpine
|
||||||
|
`,
|
||||||
|
RunE: resumeCommand{
|
||||||
|
apiType: imageRepositoryType,
|
||||||
|
object: imageRepositoryAdapter{&imagev1.ImageRepository{}},
|
||||||
|
}.run,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
resumeImageCmd.AddCommand(resumeImageRepositoryCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (obj imageRepositoryAdapter) getObservedGeneration() int64 {
|
||||||
|
return obj.ImageRepository.Status.ObservedGeneration
|
||||||
|
}
|
||||||
|
|
||||||
|
func (obj imageRepositoryAdapter) setUnsuspended() {
|
||||||
|
obj.ImageRepository.Spec.Suspend = false
|
||||||
|
}
|
||||||
48
cmd/flux/resume_image_updateauto.go
Normal file
48
cmd/flux/resume_image_updateauto.go
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
autov1 "github.com/fluxcd/image-automation-controller/api/v1alpha1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var resumeImageUpdateCmd = &cobra.Command{
|
||||||
|
Use: "update [name]",
|
||||||
|
Short: "Resume a suspended ImageUpdateAutomation",
|
||||||
|
Long: `The resume command marks a previously suspended ImageUpdateAutomation resource for reconciliation and waits for it to finish.`,
|
||||||
|
Example: ` # Resume reconciliation for an existing ImageUpdateAutomation
|
||||||
|
flux resume image update latest-images
|
||||||
|
`,
|
||||||
|
RunE: resumeCommand{
|
||||||
|
apiType: imageUpdateAutomationType,
|
||||||
|
object: imageUpdateAutomationAdapter{&autov1.ImageUpdateAutomation{}},
|
||||||
|
}.run,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
resumeImageCmd.AddCommand(resumeImageUpdateCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (obj imageUpdateAutomationAdapter) setUnsuspended() {
|
||||||
|
obj.ImageUpdateAutomation.Spec.Suspend = false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (obj imageUpdateAutomationAdapter) getObservedGeneration() int64 {
|
||||||
|
return obj.ImageUpdateAutomation.Status.ObservedGeneration
|
||||||
|
}
|
||||||
65
cmd/flux/status.go
Normal file
65
cmd/flux/status.go
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
apimeta "k8s.io/apimachinery/pkg/api/meta"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/types"
|
||||||
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
|
|
||||||
|
"github.com/fluxcd/pkg/apis/meta"
|
||||||
|
)
|
||||||
|
|
||||||
|
// statusable is used to see if a resource is considered ready in the usual way
|
||||||
|
type statusable interface {
|
||||||
|
adapter
|
||||||
|
// this is implemented by ObjectMeta
|
||||||
|
GetGeneration() int64
|
||||||
|
getObservedGeneration() int64
|
||||||
|
// this is usually implemented by GOTK API objects because it's used by pkg/apis/meta
|
||||||
|
GetStatusConditions() *[]metav1.Condition
|
||||||
|
}
|
||||||
|
|
||||||
|
func isReady(ctx context.Context, kubeClient client.Client,
|
||||||
|
namespacedName types.NamespacedName, object statusable) wait.ConditionFunc {
|
||||||
|
return func() (bool, error) {
|
||||||
|
err := kubeClient.Get(ctx, namespacedName, object.asRuntimeObject())
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Confirm the state we are observing is for the current generation
|
||||||
|
if object.GetGeneration() != object.getObservedGeneration() {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if c := apimeta.FindStatusCondition(*object.GetStatusConditions(), meta.ReadyCondition); c != nil {
|
||||||
|
switch c.Status {
|
||||||
|
case metav1.ConditionTrue:
|
||||||
|
return true, nil
|
||||||
|
case metav1.ConditionFalse:
|
||||||
|
return false, fmt.Errorf(c.Message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,7 +17,13 @@ limitations under the License.
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
"k8s.io/apimachinery/pkg/types"
|
||||||
|
|
||||||
|
"github.com/fluxcd/flux2/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
var suspendCmd = &cobra.Command{
|
var suspendCmd = &cobra.Command{
|
||||||
@@ -29,3 +35,47 @@ var suspendCmd = &cobra.Command{
|
|||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(suspendCmd)
|
rootCmd.AddCommand(suspendCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type suspendable interface {
|
||||||
|
adapter
|
||||||
|
isSuspended() bool
|
||||||
|
setSuspended()
|
||||||
|
}
|
||||||
|
|
||||||
|
type suspendCommand struct {
|
||||||
|
apiType
|
||||||
|
object suspendable
|
||||||
|
}
|
||||||
|
|
||||||
|
func (suspend suspendCommand) run(cmd *cobra.Command, args []string) error {
|
||||||
|
if len(args) < 1 {
|
||||||
|
return fmt.Errorf("%s name is required", suspend.humanKind)
|
||||||
|
}
|
||||||
|
name := args[0]
|
||||||
|
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
kubeClient, err := utils.KubeClient(kubeconfig, kubecontext)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
namespacedName := types.NamespacedName{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
err = kubeClient.Get(ctx, namespacedName, suspend.object.asRuntimeObject())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Actionf("suspending %s %s in %s namespace", suspend.humanKind, name, namespace)
|
||||||
|
suspend.object.setSuspended()
|
||||||
|
if err := kubeClient.Update(ctx, suspend.object.asRuntimeObject()); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
logger.Successf("%s suspended", suspend.humanKind)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
31
cmd/flux/suspend_image.go
Normal file
31
cmd/flux/suspend_image.go
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
var suspendImageCmd = &cobra.Command{
|
||||||
|
Use: "image",
|
||||||
|
Short: "Suspend image automation objects",
|
||||||
|
Long: "The suspend image sub-commands suspend the reconciliation of an image automation object.",
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
suspendCmd.AddCommand(suspendImageCmd)
|
||||||
|
}
|
||||||
48
cmd/flux/suspend_image_repository.go
Normal file
48
cmd/flux/suspend_image_repository.go
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
imagev1 "github.com/fluxcd/image-reflector-controller/api/v1alpha1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var suspendImageRepositoryCmd = &cobra.Command{
|
||||||
|
Use: "repository [name]",
|
||||||
|
Short: "Suspend reconciliation of an ImageRepository",
|
||||||
|
Long: "The suspend image repository command disables the reconciliation of a ImageRepository resource.",
|
||||||
|
Example: ` # Suspend reconciliation for an existing ImageRepository
|
||||||
|
flux suspend image repository alpine
|
||||||
|
`,
|
||||||
|
RunE: suspendCommand{
|
||||||
|
apiType: imageRepositoryType,
|
||||||
|
object: imageRepositoryAdapter{&imagev1.ImageRepository{}},
|
||||||
|
}.run,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
suspendImageCmd.AddCommand(suspendImageRepositoryCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (obj imageRepositoryAdapter) isSuspended() bool {
|
||||||
|
return obj.ImageRepository.Spec.Suspend
|
||||||
|
}
|
||||||
|
|
||||||
|
func (obj imageRepositoryAdapter) setSuspended() {
|
||||||
|
obj.ImageRepository.Spec.Suspend = true
|
||||||
|
}
|
||||||
48
cmd/flux/suspend_image_updateauto.go
Normal file
48
cmd/flux/suspend_image_updateauto.go
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
autov1 "github.com/fluxcd/image-automation-controller/api/v1alpha1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var suspendImageUpdateCmd = &cobra.Command{
|
||||||
|
Use: "update [name]",
|
||||||
|
Short: "Suspend reconciliation of an ImageUpdateAutomation",
|
||||||
|
Long: "The suspend image update command disables the reconciliation of a ImageUpdateAutomation resource.",
|
||||||
|
Example: ` # Suspend reconciliation for an existing ImageUpdateAutomation
|
||||||
|
flux suspend image update latest-images
|
||||||
|
`,
|
||||||
|
RunE: suspendCommand{
|
||||||
|
apiType: imageUpdateAutomationType,
|
||||||
|
object: imageUpdateAutomationAdapter{&autov1.ImageUpdateAutomation{}},
|
||||||
|
}.run,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
suspendImageCmd.AddCommand(suspendImageUpdateCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (update imageUpdateAutomationAdapter) isSuspended() bool {
|
||||||
|
return update.ImageUpdateAutomation.Spec.Suspend
|
||||||
|
}
|
||||||
|
|
||||||
|
func (update imageUpdateAutomationAdapter) setSuspended() {
|
||||||
|
update.ImageUpdateAutomation.Spec.Suspend = true
|
||||||
|
}
|
||||||
@@ -11,7 +11,9 @@ The bootstrap sub-commands bootstrap the toolkit components on the targeted Git
|
|||||||
```
|
```
|
||||||
--arch arch cluster architecture, available options are: (amd64, arm, arm64) (default amd64)
|
--arch arch cluster architecture, available options are: (amd64, arm, arm64) (default amd64)
|
||||||
--branch string default branch (for GitHub this must match the default branch setting for the organization) (default "main")
|
--branch string default branch (for GitHub this must match the default branch setting for the organization) (default "main")
|
||||||
|
--cluster-domain string internal cluster domain (default "cluster.local")
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller,helm-controller,notification-controller])
|
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller,helm-controller,notification-controller])
|
||||||
|
--components-extra strings list of components in addition to those supplied or defaulted, accepts comma-separated values
|
||||||
-h, --help help for bootstrap
|
-h, --help help for bootstrap
|
||||||
--image-pull-secret string Kubernetes secret name used for pulling the toolkit images from a private registry
|
--image-pull-secret string Kubernetes secret name used for pulling the toolkit images from a private registry
|
||||||
--log-level logLevel log level, available options are: (debug, info, error) (default info)
|
--log-level logLevel log level, available options are: (debug, info, error) (default info)
|
||||||
|
|||||||
@@ -63,7 +63,9 @@ flux bootstrap github [flags]
|
|||||||
```
|
```
|
||||||
--arch arch cluster architecture, available options are: (amd64, arm, arm64) (default amd64)
|
--arch arch cluster architecture, available options are: (amd64, arm, arm64) (default amd64)
|
||||||
--branch string default branch (for GitHub this must match the default branch setting for the organization) (default "main")
|
--branch string default branch (for GitHub this must match the default branch setting for the organization) (default "main")
|
||||||
|
--cluster-domain string internal cluster domain (default "cluster.local")
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller,helm-controller,notification-controller])
|
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller,helm-controller,notification-controller])
|
||||||
|
--components-extra strings list of components in addition to those supplied or defaulted, accepts comma-separated values
|
||||||
--context string kubernetes context to use
|
--context string kubernetes context to use
|
||||||
--image-pull-secret string Kubernetes secret name used for pulling the toolkit images from a private registry
|
--image-pull-secret string Kubernetes secret name used for pulling the toolkit images from a private registry
|
||||||
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
|
|||||||
@@ -59,7 +59,9 @@ flux bootstrap gitlab [flags]
|
|||||||
```
|
```
|
||||||
--arch arch cluster architecture, available options are: (amd64, arm, arm64) (default amd64)
|
--arch arch cluster architecture, available options are: (amd64, arm, arm64) (default amd64)
|
||||||
--branch string default branch (for GitHub this must match the default branch setting for the organization) (default "main")
|
--branch string default branch (for GitHub this must match the default branch setting for the organization) (default "main")
|
||||||
|
--cluster-domain string internal cluster domain (default "cluster.local")
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller,helm-controller,notification-controller])
|
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller,helm-controller,notification-controller])
|
||||||
|
--components-extra strings list of components in addition to those supplied or defaulted, accepts comma-separated values
|
||||||
--context string kubernetes context to use
|
--context string kubernetes context to use
|
||||||
--image-pull-secret string Kubernetes secret name used for pulling the toolkit images from a private registry
|
--image-pull-secret string Kubernetes secret name used for pulling the toolkit images from a private registry
|
||||||
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
|
|||||||
@@ -31,8 +31,10 @@ The create sub-commands generate sources and resources.
|
|||||||
* [flux create alert](flux_create_alert.md) - Create or update a Alert resource
|
* [flux create alert](flux_create_alert.md) - Create or update a Alert resource
|
||||||
* [flux create alert-provider](flux_create_alert-provider.md) - Create or update a Provider resource
|
* [flux create alert-provider](flux_create_alert-provider.md) - Create or update a Provider resource
|
||||||
* [flux create helmrelease](flux_create_helmrelease.md) - Create or update a HelmRelease resource
|
* [flux create helmrelease](flux_create_helmrelease.md) - Create or update a HelmRelease resource
|
||||||
|
* [flux create image](flux_create_image.md) - Create or update resources dealing with image automation
|
||||||
* [flux create kustomization](flux_create_kustomization.md) - Create or update a Kustomization resource
|
* [flux create kustomization](flux_create_kustomization.md) - Create or update a Kustomization resource
|
||||||
* [flux create receiver](flux_create_receiver.md) - Create or update a Receiver resource
|
* [flux create receiver](flux_create_receiver.md) - Create or update a Receiver resource
|
||||||
|
* [flux create secret](flux_create_secret.md) - Create or update Kubernetes secrets
|
||||||
* [flux create source](flux_create_source.md) - Create or update sources
|
* [flux create source](flux_create_source.md) - Create or update sources
|
||||||
* [flux create tenant](flux_create_tenant.md) - Create or update a tenant
|
* [flux create tenant](flux_create_tenant.md) - Create or update a tenant
|
||||||
|
|
||||||
|
|||||||
36
docs/cmd/flux_create_image.md
Normal file
36
docs/cmd/flux_create_image.md
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
## flux create image
|
||||||
|
|
||||||
|
Create or update resources dealing with image automation
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
The create image sub-commands work with image automation objects; that is,
|
||||||
|
object controlling updates to git based on e.g., new container images
|
||||||
|
being available.
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
```
|
||||||
|
-h, --help help for image
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options inherited from parent commands
|
||||||
|
|
||||||
|
```
|
||||||
|
--context string kubernetes context to use
|
||||||
|
--export export in YAML format to stdout
|
||||||
|
--interval duration source sync interval (default 1m0s)
|
||||||
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
|
--label strings set labels on the resource (can specify multiple labels with commas: label1=value1,label2=value2)
|
||||||
|
-n, --namespace string the namespace scope for this operation (default "flux-system")
|
||||||
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
|
--verbose print generated objects
|
||||||
|
```
|
||||||
|
|
||||||
|
### SEE ALSO
|
||||||
|
|
||||||
|
* [flux create](flux_create.md) - Create or update sources and resources
|
||||||
|
* [flux create image policy](flux_create_image_policy.md) - Create or update an ImagePolicy object
|
||||||
|
* [flux create image repository](flux_create_image_repository.md) - Create or update an ImageRepository object
|
||||||
|
* [flux create image update](flux_create_image_update.md) - Create or update an ImageUpdateAutomation object
|
||||||
|
|
||||||
42
docs/cmd/flux_create_image_policy.md
Normal file
42
docs/cmd/flux_create_image_policy.md
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
## flux create image policy
|
||||||
|
|
||||||
|
Create or update an ImagePolicy object
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
The create image policy command generates an ImagePolicy resource.
|
||||||
|
An ImagePolicy object calculates a "latest image" given an image
|
||||||
|
repository and a policy, e.g., semver.
|
||||||
|
|
||||||
|
The image that sorts highest according to the policy is recorded in
|
||||||
|
the status of the object.
|
||||||
|
|
||||||
|
```
|
||||||
|
flux create image policy <name> [flags]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
```
|
||||||
|
-h, --help help for policy
|
||||||
|
--image-ref string the name of an image repository object
|
||||||
|
--semver string a semver range to apply to tags; e.g., '1.x'
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options inherited from parent commands
|
||||||
|
|
||||||
|
```
|
||||||
|
--context string kubernetes context to use
|
||||||
|
--export export in YAML format to stdout
|
||||||
|
--interval duration source sync interval (default 1m0s)
|
||||||
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
|
--label strings set labels on the resource (can specify multiple labels with commas: label1=value1,label2=value2)
|
||||||
|
-n, --namespace string the namespace scope for this operation (default "flux-system")
|
||||||
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
|
--verbose print generated objects
|
||||||
|
```
|
||||||
|
|
||||||
|
### SEE ALSO
|
||||||
|
|
||||||
|
* [flux create image](flux_create_image.md) - Create or update resources dealing with image automation
|
||||||
|
|
||||||
39
docs/cmd/flux_create_image_repository.md
Normal file
39
docs/cmd/flux_create_image_repository.md
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
## flux create image repository
|
||||||
|
|
||||||
|
Create or update an ImageRepository object
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
The create image repository command generates an ImageRepository resource.
|
||||||
|
An ImageRepository object specifies an image repository to scan.
|
||||||
|
|
||||||
|
```
|
||||||
|
flux create image repository <name> [flags]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
```
|
||||||
|
-h, --help help for repository
|
||||||
|
--image string the image repository to scan; e.g., library/alpine
|
||||||
|
--scan-timeout duration a timeout for scanning; this defaults to the interval if not set
|
||||||
|
--secret-ref string the name of a docker-registry secret to use for credentials
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options inherited from parent commands
|
||||||
|
|
||||||
|
```
|
||||||
|
--context string kubernetes context to use
|
||||||
|
--export export in YAML format to stdout
|
||||||
|
--interval duration source sync interval (default 1m0s)
|
||||||
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
|
--label strings set labels on the resource (can specify multiple labels with commas: label1=value1,label2=value2)
|
||||||
|
-n, --namespace string the namespace scope for this operation (default "flux-system")
|
||||||
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
|
--verbose print generated objects
|
||||||
|
```
|
||||||
|
|
||||||
|
### SEE ALSO
|
||||||
|
|
||||||
|
* [flux create image](flux_create_image.md) - Create or update resources dealing with image automation
|
||||||
|
|
||||||
42
docs/cmd/flux_create_image_update.md
Normal file
42
docs/cmd/flux_create_image_update.md
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
## flux create image update
|
||||||
|
|
||||||
|
Create or update an ImageUpdateAutomation object
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
The create image update command generates an ImageUpdateAutomation resource.
|
||||||
|
An ImageUpdateAutomation object specifies an automated update to images
|
||||||
|
mentioned in YAMLs in a git repository.
|
||||||
|
|
||||||
|
```
|
||||||
|
flux create image update <name> [flags]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
```
|
||||||
|
--author-email string the email to use for commit author
|
||||||
|
--author-name string the name to use for commit author
|
||||||
|
--branch string the branch to push commits to
|
||||||
|
--commit-template string a template for commit messages
|
||||||
|
--git-repo-ref string the name of a GitRepository resource with details of the upstream git repository
|
||||||
|
-h, --help help for update
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options inherited from parent commands
|
||||||
|
|
||||||
|
```
|
||||||
|
--context string kubernetes context to use
|
||||||
|
--export export in YAML format to stdout
|
||||||
|
--interval duration source sync interval (default 1m0s)
|
||||||
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
|
--label strings set labels on the resource (can specify multiple labels with commas: label1=value1,label2=value2)
|
||||||
|
-n, --namespace string the namespace scope for this operation (default "flux-system")
|
||||||
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
|
--verbose print generated objects
|
||||||
|
```
|
||||||
|
|
||||||
|
### SEE ALSO
|
||||||
|
|
||||||
|
* [flux create image](flux_create_image.md) - Create or update resources dealing with image automation
|
||||||
|
|
||||||
32
docs/cmd/flux_create_secret.md
Normal file
32
docs/cmd/flux_create_secret.md
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
## flux create secret
|
||||||
|
|
||||||
|
Create or update Kubernetes secrets
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
The create source sub-commands generate Kubernetes secrets specific to Flux.
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
```
|
||||||
|
-h, --help help for secret
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options inherited from parent commands
|
||||||
|
|
||||||
|
```
|
||||||
|
--context string kubernetes context to use
|
||||||
|
--export export in YAML format to stdout
|
||||||
|
--interval duration source sync interval (default 1m0s)
|
||||||
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
|
--label strings set labels on the resource (can specify multiple labels with commas: label1=value1,label2=value2)
|
||||||
|
-n, --namespace string the namespace scope for this operation (default "flux-system")
|
||||||
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
|
--verbose print generated objects
|
||||||
|
```
|
||||||
|
|
||||||
|
### SEE ALSO
|
||||||
|
|
||||||
|
* [flux create](flux_create.md) - Create or update sources and resources
|
||||||
|
* [flux create secret git](flux_create_secret_git.md) - Create or update a Kubernetes secret for Git authentication
|
||||||
|
|
||||||
78
docs/cmd/flux_create_secret_git.md
Normal file
78
docs/cmd/flux_create_secret_git.md
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
## flux create secret git
|
||||||
|
|
||||||
|
Create or update a Kubernetes secret for Git authentication
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
|
||||||
|
The create secret git command generates a Kubernetes secret with Git credentials.
|
||||||
|
For Git over SSH, the host and SSH keys are automatically generated and stored in the secret.
|
||||||
|
For Git over HTTP/S, the provided basic authentication credentials are stored in the secret.
|
||||||
|
|
||||||
|
```
|
||||||
|
flux create secret git [name] [flags]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
```
|
||||||
|
# Create a Git SSH authentication secret using an ECDSA P-521 curve public key
|
||||||
|
|
||||||
|
flux create secret git podinfo-auth \
|
||||||
|
--url=ssh://git@github.com/stefanprodan/podinfo \
|
||||||
|
--ssh-key-algorithm=ecdsa \
|
||||||
|
--ssh-ecdsa-curve=p521
|
||||||
|
|
||||||
|
# Create a secret for a Git repository using basic authentication
|
||||||
|
flux create secret git podinfo-auth \
|
||||||
|
--url=https://github.com/stefanprodan/podinfo \
|
||||||
|
--username=username \
|
||||||
|
--password=password
|
||||||
|
|
||||||
|
# Create a Git SSH secret on disk and print the deploy key
|
||||||
|
flux create secret git podinfo-auth \
|
||||||
|
--url=ssh://git@github.com/stefanprodan/podinfo \
|
||||||
|
--export > podinfo-auth.yaml
|
||||||
|
|
||||||
|
yq read podinfo-auth.yaml 'data."identity.pub"' | base64 --decode
|
||||||
|
|
||||||
|
# Create a Git SSH secret on disk and encrypt it with Mozilla SOPS
|
||||||
|
flux create secret git podinfo-auth \
|
||||||
|
--namespace=apps \
|
||||||
|
--url=ssh://git@github.com/stefanprodan/podinfo \
|
||||||
|
--export > podinfo-auth.yaml
|
||||||
|
|
||||||
|
sops --encrypt --encrypted-regex '^(data|stringData)$' \
|
||||||
|
--in-place podinfo-auth.yaml
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
```
|
||||||
|
-h, --help help for git
|
||||||
|
-p, --password string basic authentication password
|
||||||
|
--ssh-ecdsa-curve ecdsaCurve SSH ECDSA public key curve (p256, p384, p521) (default p384)
|
||||||
|
--ssh-key-algorithm publicKeyAlgorithm SSH public key algorithm (rsa, ecdsa, ed25519) (default rsa)
|
||||||
|
--ssh-rsa-bits rsaKeyBits SSH RSA public key bit size (multiplies of 8) (default 2048)
|
||||||
|
--url string git address, e.g. ssh://git@host/org/repository
|
||||||
|
-u, --username string basic authentication username
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options inherited from parent commands
|
||||||
|
|
||||||
|
```
|
||||||
|
--context string kubernetes context to use
|
||||||
|
--export export in YAML format to stdout
|
||||||
|
--interval duration source sync interval (default 1m0s)
|
||||||
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
|
--label strings set labels on the resource (can specify multiple labels with commas: label1=value1,label2=value2)
|
||||||
|
-n, --namespace string the namespace scope for this operation (default "flux-system")
|
||||||
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
|
--verbose print generated objects
|
||||||
|
```
|
||||||
|
|
||||||
|
### SEE ALSO
|
||||||
|
|
||||||
|
* [flux create secret](flux_create_secret.md) - Create or update Kubernetes secrets
|
||||||
|
|
||||||
@@ -56,6 +56,7 @@ flux create source git [name] [flags]
|
|||||||
|
|
||||||
```
|
```
|
||||||
--branch string git branch (default "master")
|
--branch string git branch (default "master")
|
||||||
|
--git-implementation string the git implementation to use, can be 'go-git' or 'libgit2'
|
||||||
-h, --help help for git
|
-h, --help help for git
|
||||||
-p, --password string basic authentication password
|
-p, --password string basic authentication password
|
||||||
--secret-ref string the name of an existing secret containing SSH or basic credentials
|
--secret-ref string the name of an existing secret containing SSH or basic credentials
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ The delete sub-commands delete sources and resources.
|
|||||||
* [flux](flux.md) - Command line utility for assembling Kubernetes CD pipelines
|
* [flux](flux.md) - Command line utility for assembling Kubernetes CD pipelines
|
||||||
* [flux delete alert](flux_delete_alert.md) - Delete a Alert resource
|
* [flux delete alert](flux_delete_alert.md) - Delete a Alert resource
|
||||||
* [flux delete alert-provider](flux_delete_alert-provider.md) - Delete a Provider resource
|
* [flux delete alert-provider](flux_delete_alert-provider.md) - Delete a Provider resource
|
||||||
|
* [flux delete auto](flux_delete_auto.md) - Delete automation objects
|
||||||
* [flux delete helmrelease](flux_delete_helmrelease.md) - Delete a HelmRelease resource
|
* [flux delete helmrelease](flux_delete_helmrelease.md) - Delete a HelmRelease resource
|
||||||
* [flux delete kustomization](flux_delete_kustomization.md) - Delete a Kustomization resource
|
* [flux delete kustomization](flux_delete_kustomization.md) - Delete a Kustomization resource
|
||||||
* [flux delete receiver](flux_delete_receiver.md) - Delete a Receiver resource
|
* [flux delete receiver](flux_delete_receiver.md) - Delete a Receiver resource
|
||||||
|
|||||||
32
docs/cmd/flux_delete_auto.md
Normal file
32
docs/cmd/flux_delete_auto.md
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
## flux delete auto
|
||||||
|
|
||||||
|
Delete automation objects
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
The delete auto sub-commands delete automation objects.
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
```
|
||||||
|
-h, --help help for auto
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options inherited from parent commands
|
||||||
|
|
||||||
|
```
|
||||||
|
--context string kubernetes context to use
|
||||||
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
|
-n, --namespace string the namespace scope for this operation (default "flux-system")
|
||||||
|
-s, --silent delete resource without asking for confirmation
|
||||||
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
|
--verbose print generated objects
|
||||||
|
```
|
||||||
|
|
||||||
|
### SEE ALSO
|
||||||
|
|
||||||
|
* [flux delete](flux_delete.md) - Delete sources and resources
|
||||||
|
* [flux delete auto image-policy](flux_delete_auto_image-policy.md) - Delete an ImagePolicy object
|
||||||
|
* [flux delete auto image-repository](flux_delete_auto_image-repository.md) - Delete an ImageRepository object
|
||||||
|
* [flux delete auto image-update](flux_delete_auto_image-update.md) - Delete an ImageUpdateAutomation object
|
||||||
|
|
||||||
41
docs/cmd/flux_delete_auto_image-policy.md
Normal file
41
docs/cmd/flux_delete_auto_image-policy.md
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
## flux delete auto image-policy
|
||||||
|
|
||||||
|
Delete an ImagePolicy object
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
The delete auto image-policy command deletes the given ImagePolicy from the cluster.
|
||||||
|
|
||||||
|
```
|
||||||
|
flux delete auto image-policy [name] [flags]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
```
|
||||||
|
# Delete an image policy
|
||||||
|
flux delete auto image-policy alpine3.x
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
```
|
||||||
|
-h, --help help for image-policy
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options inherited from parent commands
|
||||||
|
|
||||||
|
```
|
||||||
|
--context string kubernetes context to use
|
||||||
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
|
-n, --namespace string the namespace scope for this operation (default "flux-system")
|
||||||
|
-s, --silent delete resource without asking for confirmation
|
||||||
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
|
--verbose print generated objects
|
||||||
|
```
|
||||||
|
|
||||||
|
### SEE ALSO
|
||||||
|
|
||||||
|
* [flux delete auto](flux_delete_auto.md) - Delete automation objects
|
||||||
|
|
||||||
41
docs/cmd/flux_delete_auto_image-repository.md
Normal file
41
docs/cmd/flux_delete_auto_image-repository.md
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
## flux delete auto image-repository
|
||||||
|
|
||||||
|
Delete an ImageRepository object
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
The delete auto image-repository command deletes the given ImageRepository from the cluster.
|
||||||
|
|
||||||
|
```
|
||||||
|
flux delete auto image-repository [name] [flags]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
```
|
||||||
|
# Delete an image repository
|
||||||
|
flux delete auto image-repository alpine
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
```
|
||||||
|
-h, --help help for image-repository
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options inherited from parent commands
|
||||||
|
|
||||||
|
```
|
||||||
|
--context string kubernetes context to use
|
||||||
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
|
-n, --namespace string the namespace scope for this operation (default "flux-system")
|
||||||
|
-s, --silent delete resource without asking for confirmation
|
||||||
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
|
--verbose print generated objects
|
||||||
|
```
|
||||||
|
|
||||||
|
### SEE ALSO
|
||||||
|
|
||||||
|
* [flux delete auto](flux_delete_auto.md) - Delete automation objects
|
||||||
|
|
||||||
41
docs/cmd/flux_delete_auto_image-update.md
Normal file
41
docs/cmd/flux_delete_auto_image-update.md
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
## flux delete auto image-update
|
||||||
|
|
||||||
|
Delete an ImageUpdateAutomation object
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
The delete auto image-update command deletes the given ImageUpdateAutomation from the cluster.
|
||||||
|
|
||||||
|
```
|
||||||
|
flux delete auto image-update [name] [flags]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
```
|
||||||
|
# Delete an image update automation
|
||||||
|
flux delete auto image-update latest-images
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
```
|
||||||
|
-h, --help help for image-update
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options inherited from parent commands
|
||||||
|
|
||||||
|
```
|
||||||
|
--context string kubernetes context to use
|
||||||
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
|
-n, --namespace string the namespace scope for this operation (default "flux-system")
|
||||||
|
-s, --silent delete resource without asking for confirmation
|
||||||
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
|
--verbose print generated objects
|
||||||
|
```
|
||||||
|
|
||||||
|
### SEE ALSO
|
||||||
|
|
||||||
|
* [flux delete auto](flux_delete_auto.md) - Delete automation objects
|
||||||
|
|
||||||
@@ -29,6 +29,7 @@ The export sub-commands export resources in YAML format.
|
|||||||
* [flux export alert](flux_export_alert.md) - Export Alert resources in YAML format
|
* [flux export alert](flux_export_alert.md) - Export Alert resources in YAML format
|
||||||
* [flux export alert-provider](flux_export_alert-provider.md) - Export Provider resources in YAML format
|
* [flux export alert-provider](flux_export_alert-provider.md) - Export Provider resources in YAML format
|
||||||
* [flux export helmrelease](flux_export_helmrelease.md) - Export HelmRelease resources in YAML format
|
* [flux export helmrelease](flux_export_helmrelease.md) - Export HelmRelease resources in YAML format
|
||||||
|
* [flux export image](flux_export_image.md) - Export image automation objects
|
||||||
* [flux export kustomization](flux_export_kustomization.md) - Export Kustomization resources in YAML format
|
* [flux export kustomization](flux_export_kustomization.md) - Export Kustomization resources in YAML format
|
||||||
* [flux export receiver](flux_export_receiver.md) - Export Receiver resources in YAML format
|
* [flux export receiver](flux_export_receiver.md) - Export Receiver resources in YAML format
|
||||||
* [flux export source](flux_export_source.md) - Export sources
|
* [flux export source](flux_export_source.md) - Export sources
|
||||||
|
|||||||
32
docs/cmd/flux_export_image.md
Normal file
32
docs/cmd/flux_export_image.md
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
## flux export image
|
||||||
|
|
||||||
|
Export image automation objects
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
The export image sub-commands export image automation objects in YAML format.
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
```
|
||||||
|
-h, --help help for image
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options inherited from parent commands
|
||||||
|
|
||||||
|
```
|
||||||
|
--all select all resources
|
||||||
|
--context string kubernetes context to use
|
||||||
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
|
-n, --namespace string the namespace scope for this operation (default "flux-system")
|
||||||
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
|
--verbose print generated objects
|
||||||
|
```
|
||||||
|
|
||||||
|
### SEE ALSO
|
||||||
|
|
||||||
|
* [flux export](flux_export.md) - Export resources in YAML format
|
||||||
|
* [flux export image policy](flux_export_image_policy.md) - Export ImagePolicy resources in YAML format
|
||||||
|
* [flux export image repository](flux_export_image_repository.md) - Export ImageRepository resources in YAML format
|
||||||
|
* [flux export image update](flux_export_image_update.md) - Export ImageUpdateAutomation resources in YAML format
|
||||||
|
|
||||||
44
docs/cmd/flux_export_image_policy.md
Normal file
44
docs/cmd/flux_export_image_policy.md
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
## flux export image policy
|
||||||
|
|
||||||
|
Export ImagePolicy resources in YAML format
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
The export image policy command exports one or all ImagePolicy resources in YAML format.
|
||||||
|
|
||||||
|
```
|
||||||
|
flux export image policy [name] [flags]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
```
|
||||||
|
# Export all ImagePolicy resources
|
||||||
|
flux export image policy --all > image-policies.yaml
|
||||||
|
|
||||||
|
# Export a specific policy
|
||||||
|
flux export image policy alpine1x > alpine1x.yaml
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
```
|
||||||
|
-h, --help help for policy
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options inherited from parent commands
|
||||||
|
|
||||||
|
```
|
||||||
|
--all select all resources
|
||||||
|
--context string kubernetes context to use
|
||||||
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
|
-n, --namespace string the namespace scope for this operation (default "flux-system")
|
||||||
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
|
--verbose print generated objects
|
||||||
|
```
|
||||||
|
|
||||||
|
### SEE ALSO
|
||||||
|
|
||||||
|
* [flux export image](flux_export_image.md) - Export image automation objects
|
||||||
|
|
||||||
44
docs/cmd/flux_export_image_repository.md
Normal file
44
docs/cmd/flux_export_image_repository.md
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
## flux export image repository
|
||||||
|
|
||||||
|
Export ImageRepository resources in YAML format
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
The export image repository command exports one or all ImageRepository resources in YAML format.
|
||||||
|
|
||||||
|
```
|
||||||
|
flux export image repository [name] [flags]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
```
|
||||||
|
# Export all ImageRepository resources
|
||||||
|
flux export image repository --all > image-repositories.yaml
|
||||||
|
|
||||||
|
# Export a specific ImageRepository resource
|
||||||
|
flux export image repository alpine > alpine.yaml
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
```
|
||||||
|
-h, --help help for repository
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options inherited from parent commands
|
||||||
|
|
||||||
|
```
|
||||||
|
--all select all resources
|
||||||
|
--context string kubernetes context to use
|
||||||
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
|
-n, --namespace string the namespace scope for this operation (default "flux-system")
|
||||||
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
|
--verbose print generated objects
|
||||||
|
```
|
||||||
|
|
||||||
|
### SEE ALSO
|
||||||
|
|
||||||
|
* [flux export image](flux_export_image.md) - Export image automation objects
|
||||||
|
|
||||||
44
docs/cmd/flux_export_image_update.md
Normal file
44
docs/cmd/flux_export_image_update.md
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
## flux export image update
|
||||||
|
|
||||||
|
Export ImageUpdateAutomation resources in YAML format
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
The export image update command exports one or all ImageUpdateAutomation resources in YAML format.
|
||||||
|
|
||||||
|
```
|
||||||
|
flux export image update [name] [flags]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
```
|
||||||
|
# Export all ImageUpdateAutomation resources
|
||||||
|
flux export image update --all > updates.yaml
|
||||||
|
|
||||||
|
# Export a specific automation
|
||||||
|
flux export image update latest-images > latest.yaml
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
```
|
||||||
|
-h, --help help for update
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options inherited from parent commands
|
||||||
|
|
||||||
|
```
|
||||||
|
--all select all resources
|
||||||
|
--context string kubernetes context to use
|
||||||
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
|
-n, --namespace string the namespace scope for this operation (default "flux-system")
|
||||||
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
|
--verbose print generated objects
|
||||||
|
```
|
||||||
|
|
||||||
|
### SEE ALSO
|
||||||
|
|
||||||
|
* [flux export image](flux_export_image.md) - Export image automation objects
|
||||||
|
|
||||||
@@ -29,6 +29,7 @@ The get sub-commands print the statuses of sources and resources.
|
|||||||
* [flux get alert-providers](flux_get_alert-providers.md) - Get Provider statuses
|
* [flux get alert-providers](flux_get_alert-providers.md) - Get Provider statuses
|
||||||
* [flux get alerts](flux_get_alerts.md) - Get Alert statuses
|
* [flux get alerts](flux_get_alerts.md) - Get Alert statuses
|
||||||
* [flux get helmreleases](flux_get_helmreleases.md) - Get HelmRelease statuses
|
* [flux get helmreleases](flux_get_helmreleases.md) - Get HelmRelease statuses
|
||||||
|
* [flux get image](flux_get_image.md) - Get image automation object status
|
||||||
* [flux get kustomizations](flux_get_kustomizations.md) - Get Kustomization statuses
|
* [flux get kustomizations](flux_get_kustomizations.md) - Get Kustomization statuses
|
||||||
* [flux get receivers](flux_get_receivers.md) - Get Receiver statuses
|
* [flux get receivers](flux_get_receivers.md) - Get Receiver statuses
|
||||||
* [flux get sources](flux_get_sources.md) - Get source statuses
|
* [flux get sources](flux_get_sources.md) - Get source statuses
|
||||||
|
|||||||
32
docs/cmd/flux_get_image.md
Normal file
32
docs/cmd/flux_get_image.md
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
## flux get image
|
||||||
|
|
||||||
|
Get image automation object status
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
The get image sub-commands print the status of image automation objects.
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
```
|
||||||
|
-h, --help help for image
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options inherited from parent commands
|
||||||
|
|
||||||
|
```
|
||||||
|
-A, --all-namespaces list the requested object(s) across all namespaces
|
||||||
|
--context string kubernetes context to use
|
||||||
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
|
-n, --namespace string the namespace scope for this operation (default "flux-system")
|
||||||
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
|
--verbose print generated objects
|
||||||
|
```
|
||||||
|
|
||||||
|
### SEE ALSO
|
||||||
|
|
||||||
|
* [flux get](flux_get.md) - Get sources and resources
|
||||||
|
* [flux get image policy](flux_get_image_policy.md) - Get ImagePolicy status
|
||||||
|
* [flux get image repository](flux_get_image_repository.md) - Get ImageRepository status
|
||||||
|
* [flux get image update](flux_get_image_update.md) - Get ImageUpdateAutomation status
|
||||||
|
|
||||||
44
docs/cmd/flux_get_image_policy.md
Normal file
44
docs/cmd/flux_get_image_policy.md
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
## flux get image policy
|
||||||
|
|
||||||
|
Get ImagePolicy status
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
The get image policy command prints the status of ImagePolicy objects.
|
||||||
|
|
||||||
|
```
|
||||||
|
flux get image policy [flags]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
```
|
||||||
|
# List all image policies and their status
|
||||||
|
flux get image policy
|
||||||
|
|
||||||
|
# List image policies from all namespaces
|
||||||
|
flux get image policy --all-namespaces
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
```
|
||||||
|
-h, --help help for policy
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options inherited from parent commands
|
||||||
|
|
||||||
|
```
|
||||||
|
-A, --all-namespaces list the requested object(s) across all namespaces
|
||||||
|
--context string kubernetes context to use
|
||||||
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
|
-n, --namespace string the namespace scope for this operation (default "flux-system")
|
||||||
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
|
--verbose print generated objects
|
||||||
|
```
|
||||||
|
|
||||||
|
### SEE ALSO
|
||||||
|
|
||||||
|
* [flux get image](flux_get_image.md) - Get image automation object status
|
||||||
|
|
||||||
44
docs/cmd/flux_get_image_repository.md
Normal file
44
docs/cmd/flux_get_image_repository.md
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
## flux get image repository
|
||||||
|
|
||||||
|
Get ImageRepository status
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
The get image repository command prints the status of ImageRepository objects.
|
||||||
|
|
||||||
|
```
|
||||||
|
flux get image repository [flags]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
```
|
||||||
|
# List all image repositories and their status
|
||||||
|
flux get image repository
|
||||||
|
|
||||||
|
# List image repositories from all namespaces
|
||||||
|
flux get image repository --all-namespaces
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
```
|
||||||
|
-h, --help help for repository
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options inherited from parent commands
|
||||||
|
|
||||||
|
```
|
||||||
|
-A, --all-namespaces list the requested object(s) across all namespaces
|
||||||
|
--context string kubernetes context to use
|
||||||
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
|
-n, --namespace string the namespace scope for this operation (default "flux-system")
|
||||||
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
|
--verbose print generated objects
|
||||||
|
```
|
||||||
|
|
||||||
|
### SEE ALSO
|
||||||
|
|
||||||
|
* [flux get image](flux_get_image.md) - Get image automation object status
|
||||||
|
|
||||||
44
docs/cmd/flux_get_image_update.md
Normal file
44
docs/cmd/flux_get_image_update.md
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
## flux get image update
|
||||||
|
|
||||||
|
Get ImageUpdateAutomation status
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
The get image update command prints the status of ImageUpdateAutomation objects.
|
||||||
|
|
||||||
|
```
|
||||||
|
flux get image update [flags]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
```
|
||||||
|
# List all image update automation object and their status
|
||||||
|
flux get image update
|
||||||
|
|
||||||
|
# List image update automations from all namespaces
|
||||||
|
flux get image update --all-namespaces
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
```
|
||||||
|
-h, --help help for update
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options inherited from parent commands
|
||||||
|
|
||||||
|
```
|
||||||
|
-A, --all-namespaces list the requested object(s) across all namespaces
|
||||||
|
--context string kubernetes context to use
|
||||||
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
|
-n, --namespace string the namespace scope for this operation (default "flux-system")
|
||||||
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
|
--verbose print generated objects
|
||||||
|
```
|
||||||
|
|
||||||
|
### SEE ALSO
|
||||||
|
|
||||||
|
* [flux get image](flux_get_image.md) - Get image automation object status
|
||||||
|
|
||||||
@@ -32,7 +32,9 @@ flux install [flags]
|
|||||||
|
|
||||||
```
|
```
|
||||||
--arch arch cluster architecture, available options are: (amd64, arm, arm64) (default amd64)
|
--arch arch cluster architecture, available options are: (amd64, arm, arm64) (default amd64)
|
||||||
|
--cluster-domain string internal cluster domain (default "cluster.local")
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller,helm-controller,notification-controller])
|
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller,helm-controller,notification-controller])
|
||||||
|
--components-extra strings list of components in addition to those supplied or defaulted, accepts comma-separated values
|
||||||
--dry-run only print the object that would be applied
|
--dry-run only print the object that would be applied
|
||||||
--export write the install manifests to stdout and exit
|
--export write the install manifests to stdout and exit
|
||||||
-h, --help help for install
|
-h, --help help for install
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user