Compare commits
1306 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ff7df54899 | ||
|
|
b75ce95086 | ||
|
|
a86d94745a | ||
|
|
c13de6089a | ||
|
|
3cb748a47e | ||
|
|
3e6e93fab4 | ||
|
|
5832811930 | ||
|
|
6f0ea04ff3 | ||
|
|
26ea167524 | ||
|
|
1393e7a62b | ||
|
|
7e1fd499ca | ||
|
|
309fd86b45 | ||
|
|
e14357f694 | ||
|
|
29f0adc587 | ||
|
|
3ab578747d | ||
|
|
2c3cb1a664 | ||
|
|
99a0c47277 | ||
|
|
c5b2c6709a | ||
|
|
8354ac937c | ||
|
|
aa5ad65286 | ||
|
|
05adb44416 | ||
|
|
adf5a5278f | ||
|
|
bb04ca36b2 | ||
|
|
fc94b1af7a | ||
|
|
d9886035c8 | ||
|
|
0e122863dd | ||
|
|
3089f67946 | ||
|
|
3654e221a9 | ||
|
|
a26dd05c49 | ||
|
|
6c844369be | ||
|
|
a03574f8c3 | ||
|
|
43c6a1531a | ||
|
|
aed7341b34 | ||
|
|
8731f00347 | ||
|
|
75a18b4548 | ||
|
|
716b41e91b | ||
|
|
e72214e266 | ||
|
|
46f9fc194c | ||
|
|
6c5f27be02 | ||
|
|
e96652bdaa | ||
|
|
b7007a35d7 | ||
|
|
e4dc56b59d | ||
|
|
b05059a9c4 | ||
|
|
121783976a | ||
|
|
5a9424d0b1 | ||
|
|
e2a3800664 | ||
|
|
56815a3624 | ||
|
|
ca6e0ff36e | ||
|
|
4c60d1657d | ||
|
|
cdd90cfa75 | ||
|
|
05b053e2e9 | ||
|
|
46c75c1af2 | ||
|
|
80cf5fa729 | ||
|
|
789aa322f1 | ||
|
|
f03c24565f | ||
|
|
b6a95be5d0 | ||
|
|
0f9e8ed3f7 | ||
|
|
50af0ba93c | ||
|
|
923a5882de | ||
|
|
83dc3e6093 | ||
|
|
43edb62f87 | ||
|
|
21e5acc0e0 | ||
|
|
be1ce74dc5 | ||
|
|
31771f3575 | ||
|
|
ffcd7d8059 | ||
|
|
4bc4aa1397 | ||
|
|
04faba95cd | ||
|
|
f712dadab5 | ||
|
|
58b3150ce3 | ||
|
|
e7225db397 | ||
|
|
8ec5492d87 | ||
|
|
c2c64a70c4 | ||
|
|
4621576f40 | ||
|
|
3b609e9b03 | ||
|
|
4f2ebd78be | ||
|
|
88dacebc94 | ||
|
|
92e7d1ad1e | ||
|
|
d5d8c340c8 | ||
|
|
b8a85b809a | ||
|
|
61be0775af | ||
|
|
404ffa5a91 | ||
|
|
f2de7e04b8 | ||
|
|
8b3e3b1dd7 | ||
|
|
81e91ac3f5 | ||
|
|
b9bde94d08 | ||
|
|
37746023c1 | ||
|
|
d3e529b8a4 | ||
|
|
eb69083ef5 | ||
|
|
96aac387c9 | ||
|
|
870f18c621 | ||
|
|
57b33e29f7 | ||
|
|
94b7917679 | ||
|
|
98fa0c4271 | ||
|
|
8282907bce | ||
|
|
323f4f5e5f | ||
|
|
744b3ebd0a | ||
|
|
3fdba35993 | ||
|
|
ebdf9ed379 | ||
|
|
a572274c5c | ||
|
|
6a6bba8669 | ||
|
|
1d1d4bbf4b | ||
|
|
d9bb4c631e | ||
|
|
722962c138 | ||
|
|
c98ff6ae87 | ||
|
|
cbef6a4cad | ||
|
|
f887a2c029 | ||
|
|
078cfe92c2 | ||
|
|
80ef184b60 | ||
|
|
f2475988bd | ||
|
|
45526108e0 | ||
|
|
414c0bbbdc | ||
|
|
6873a710d9 | ||
|
|
8a44006384 | ||
|
|
1b6061066a | ||
|
|
3a8a5982c6 | ||
|
|
ccff578492 | ||
|
|
e2402e3d84 | ||
|
|
f13b1629cf | ||
|
|
72a97bb70a | ||
|
|
67b393ce09 | ||
|
|
48e89b95bb | ||
|
|
2159ed62d0 | ||
|
|
8bb65719cd | ||
|
|
4352915945 | ||
|
|
ebd145f7f7 | ||
|
|
cd52a0eef3 | ||
|
|
69e4a86fe2 | ||
|
|
52d89a2ee1 | ||
|
|
5c60e792d9 | ||
|
|
77c9611784 | ||
|
|
66780bbf54 | ||
|
|
a8932e677e | ||
|
|
e12988a8f9 | ||
|
|
6ee4abe79e | ||
|
|
948e050d60 | ||
|
|
87feb45751 | ||
|
|
77aa81a064 | ||
|
|
a4a1db0915 | ||
|
|
57b9610af7 | ||
|
|
c3384c6499 | ||
|
|
5389859260 | ||
|
|
84c585cf61 | ||
|
|
ca496d393d | ||
|
|
3d4ca831dc | ||
|
|
7ace8de753 | ||
|
|
928d3e2185 | ||
|
|
cbf2b90320 | ||
|
|
69dce73e51 | ||
|
|
75d4f87dec | ||
|
|
4f7d89e825 | ||
|
|
da87e16321 | ||
|
|
f7aa3e7e1b | ||
|
|
deacfd6c03 | ||
|
|
3e8d1ae1d5 | ||
|
|
08f5ca39b0 | ||
|
|
31da363495 | ||
|
|
2ecd99d317 | ||
|
|
59c3d84182 | ||
|
|
641d5378f8 | ||
|
|
08512e5c43 | ||
|
|
8f7f7b23e8 | ||
|
|
2eb6ba5a48 | ||
|
|
03df386f9e | ||
|
|
5e741da69c | ||
|
|
3bea028cc9 | ||
|
|
10475b24c4 | ||
|
|
a5238e867c | ||
|
|
0e747790f9 | ||
|
|
2b4d6150d4 | ||
|
|
e22ad96164 | ||
|
|
f54907e66e | ||
|
|
fb713e9632 | ||
|
|
0b659e3f09 | ||
|
|
4c99117c7c | ||
|
|
83c3e8c2fc | ||
|
|
92277225df | ||
|
|
622ed88a11 | ||
|
|
d9414f25d5 | ||
|
|
5249d17a95 | ||
|
|
25283d357e | ||
|
|
e926321094 | ||
|
|
9c1542c3f3 | ||
|
|
25d06a53bc | ||
|
|
4d904e8216 | ||
|
|
0beab87f5b | ||
|
|
b9ceceada4 | ||
|
|
ac7ccf7b94 | ||
|
|
5aa9ae511f | ||
|
|
dd81ed896b | ||
|
|
e6bbed162d | ||
|
|
3ee8747fdc | ||
|
|
0651064999 | ||
|
|
4661e4519d | ||
|
|
19caeb178f | ||
|
|
d8235ea21b | ||
|
|
5067df179e | ||
|
|
50a1e32da3 | ||
|
|
fb85cafcc5 | ||
|
|
d06a2936cc | ||
|
|
7c77a9723a | ||
|
|
8a3e5790f5 | ||
|
|
dd093a775a | ||
|
|
a096bd2d71 | ||
|
|
2eddcde609 | ||
|
|
1849e1768a | ||
|
|
bbe62d029c | ||
|
|
68a89d3cd4 | ||
|
|
b16f1fc260 | ||
|
|
64f39e160b | ||
|
|
3a76c26822 | ||
|
|
9d9fff5796 | ||
|
|
0a92c61b09 | ||
|
|
546be76f55 | ||
|
|
d770f3f53f | ||
|
|
254cc131ae | ||
|
|
70509ffcb4 | ||
|
|
4cc2326c7f | ||
|
|
0133caaec4 | ||
|
|
7ae4f28920 | ||
|
|
b1eb0270e9 | ||
|
|
03b6de1169 | ||
|
|
9d3f75d111 | ||
|
|
5c41924b2f | ||
|
|
7cf7cf2f1e | ||
|
|
2679731bde | ||
|
|
ad73370cd7 | ||
|
|
18acae57bd | ||
|
|
b427356eca | ||
|
|
2e6ca16a4a | ||
|
|
e98f1142a6 | ||
|
|
06fa8f75c9 | ||
|
|
8cbd4e8172 | ||
|
|
83c7994266 | ||
|
|
43843581b6 | ||
|
|
7e03d64e8a | ||
|
|
c6f4d71187 | ||
|
|
69c3b90fea | ||
|
|
75309b4c93 | ||
|
|
433f13a7ed | ||
|
|
8896a1e73e | ||
|
|
54758b1692 | ||
|
|
375e00c79c | ||
|
|
e2454d91f1 | ||
|
|
6894f6f3bf | ||
|
|
d45501a129 | ||
|
|
def92e14ee | ||
|
|
11708d4189 | ||
|
|
2bc64bf419 | ||
|
|
3a3bdc62c8 | ||
|
|
72294b2a56 | ||
|
|
94940a20ef | ||
|
|
219ff2ef7d | ||
|
|
bc2de741b8 | ||
|
|
5eabd4e898 | ||
|
|
e8d6d5fe5c | ||
|
|
55bd93ff79 | ||
|
|
b34b2d779b | ||
|
|
103ed2be65 | ||
|
|
cc32c1be07 | ||
|
|
a3ba9817a3 | ||
|
|
6d5f1b17ad | ||
|
|
0d5d5fce46 | ||
|
|
375edffd15 | ||
|
|
d1982e64b2 | ||
|
|
cec8b5336c | ||
|
|
8f78263455 | ||
|
|
cb96bca6aa | ||
|
|
c18d0b9217 | ||
|
|
d1970185b9 | ||
|
|
794d3ee2f5 | ||
|
|
daeef98dfb | ||
|
|
4146df1f02 | ||
|
|
78f4dfa48d | ||
|
|
8b68d7d7e2 | ||
|
|
ba1bba17ad | ||
|
|
70f2b5028f | ||
|
|
4f4f0d70a4 | ||
|
|
9607b07e65 | ||
|
|
3570fab0f9 | ||
|
|
dd0f17d7a5 | ||
|
|
2290880389 | ||
|
|
351d287d88 | ||
|
|
eba6706f15 | ||
|
|
7f425efa6b | ||
|
|
d40685ab62 | ||
|
|
f795e3eeb8 | ||
|
|
d3944c0204 | ||
|
|
4086ab15fa | ||
|
|
446a367094 | ||
|
|
bd250c9871 | ||
|
|
91b3788362 | ||
|
|
658dbb9ea8 | ||
|
|
1257b9cbc8 | ||
|
|
0ae39d5a0a | ||
|
|
d8911e0c77 | ||
|
|
1be006a45f | ||
|
|
b95e75ddb4 | ||
|
|
15a5f75fe7 | ||
|
|
b01e27f50f | ||
|
|
b1a9583262 | ||
|
|
dd5e6377f8 | ||
|
|
fcb73554c9 | ||
|
|
5c4b3d1080 | ||
|
|
c98cd10621 | ||
|
|
e4af8ddcc8 | ||
|
|
b5ce02b8cf | ||
|
|
cd42b3fb44 | ||
|
|
6dedb767c3 | ||
|
|
4de3268f3b | ||
|
|
a72ff06d79 | ||
|
|
cf239deb3d | ||
|
|
8735229745 | ||
|
|
3f081ba2d9 | ||
|
|
3f613341cb | ||
|
|
4305b8a77d | ||
|
|
fab91d44c3 | ||
|
|
34484734d8 | ||
|
|
10c58bb007 | ||
|
|
1c1fd62a91 | ||
|
|
637ac1e3fe | ||
|
|
f52387e849 | ||
|
|
9efc4986f9 | ||
|
|
fdc366ec1c | ||
|
|
d455db444c | ||
|
|
17418c9858 | ||
|
|
5da7eb7d0d | ||
|
|
9da977ee7a | ||
|
|
8e4b2ead9b | ||
|
|
fd364828a1 | ||
|
|
afa58d8c08 | ||
|
|
179062876e | ||
|
|
a796f3609f | ||
|
|
b7c6db74d2 | ||
|
|
4f7b040405 | ||
|
|
34ca29830e | ||
|
|
78f1b634fa | ||
|
|
044bc64ad9 | ||
|
|
091f439498 | ||
|
|
a17b0a1ce0 | ||
|
|
354cd5e177 | ||
|
|
4e8f1221f7 | ||
|
|
6b179aa7d9 | ||
|
|
f748114dfa | ||
|
|
5de83f015a | ||
|
|
a6620e478a | ||
|
|
c7fcffdd8e | ||
|
|
160f59a984 | ||
|
|
d38d487c2a | ||
|
|
db28907543 | ||
|
|
c4261399b5 | ||
|
|
b4edb46269 | ||
|
|
a20ed0e630 | ||
|
|
cea869e285 | ||
|
|
e12db14d1e | ||
|
|
296bf3cc6c | ||
|
|
1789aa180d | ||
|
|
bd255800db | ||
|
|
1355962b3c | ||
|
|
bb0114e379 | ||
|
|
f9622a5b9e | ||
|
|
3a74fcd75c | ||
|
|
7265276cc2 | ||
|
|
b98027b528 | ||
|
|
b6ae7d2cdd | ||
|
|
aa887c61c3 | ||
|
|
700cef0989 | ||
|
|
3ed3e553e7 | ||
|
|
d68158ddc9 | ||
|
|
9f83a69242 | ||
|
|
bf69dbd43d | ||
|
|
465ea5ccfd | ||
|
|
92ef39e2ad | ||
|
|
0404790df9 | ||
|
|
f880e93df4 | ||
|
|
4697b1101d | ||
|
|
50ff2accd2 | ||
|
|
c7d876eb8f | ||
|
|
eda392dfcd | ||
|
|
3b91e14f6d | ||
|
|
17e3c57d7e | ||
|
|
1c744a0f97 | ||
|
|
99bdb20aeb | ||
|
|
fbe7050cb8 | ||
|
|
12ea028aa9 | ||
|
|
ea62cb5fc9 | ||
|
|
d27c2164b2 | ||
|
|
ef8f5cb87d | ||
|
|
378a2c2a0e | ||
|
|
2597ad0f73 | ||
|
|
0df34bed59 | ||
|
|
be65cf8052 | ||
|
|
8922753591 | ||
|
|
87e11ed653 | ||
|
|
ab34771b3d | ||
|
|
e733c4f55a | ||
|
|
37b60666c4 | ||
|
|
734d736bdf | ||
|
|
8ca65059f7 | ||
|
|
086f174463 | ||
|
|
48fd70fc09 | ||
|
|
606266e976 | ||
|
|
f7006a8172 | ||
|
|
653dcc8d78 | ||
|
|
8df140c713 | ||
|
|
089af9cc90 | ||
|
|
695fb55b13 | ||
|
|
ec21eedd56 | ||
|
|
5ba3774fd5 | ||
|
|
12a2100fcf | ||
|
|
68074d3543 | ||
|
|
18849e36c7 | ||
|
|
671fe274da | ||
|
|
af1d9102b9 | ||
|
|
9dc10ef7d1 | ||
|
|
86a3cf20e7 | ||
|
|
27a42ecd8e | ||
|
|
ae7a59fbb4 | ||
|
|
598dfc32e8 | ||
|
|
a40d124e23 | ||
|
|
9df3fcab18 | ||
|
|
b6ce969d1b | ||
|
|
6a37649ee6 | ||
|
|
8926095660 | ||
|
|
bd34870334 | ||
|
|
a56ce1f867 | ||
|
|
dab5bbd393 | ||
|
|
15ebfd7eb6 | ||
|
|
5ab8dd2557 | ||
|
|
9164914d16 | ||
|
|
c9e0bc0807 | ||
|
|
61439adf9b | ||
|
|
e4d7450643 | ||
|
|
0fbcfded57 | ||
|
|
fb3a434f95 | ||
|
|
4f66da84d6 | ||
|
|
b67e8aafab | ||
|
|
0b4f1d30a6 | ||
|
|
c494e6bf7e | ||
|
|
b8c57c7901 | ||
|
|
6aed4631e7 | ||
|
|
5df9118365 | ||
|
|
4a4af94d6c | ||
|
|
baa54fb84a | ||
|
|
cb6470f817 | ||
|
|
1a904e138f | ||
|
|
3b482529ff | ||
|
|
67997437db | ||
|
|
a5541eddca | ||
|
|
203157e525 | ||
|
|
655c2261ba | ||
|
|
45e446eb00 | ||
|
|
68abe37648 | ||
|
|
df6a0a3762 | ||
|
|
c35bae577f | ||
|
|
3567941eda | ||
|
|
3c95fe6380 | ||
|
|
d07f0d003c | ||
|
|
86774309db | ||
|
|
427f23e32d | ||
|
|
70cddde16c | ||
|
|
e86789b643 | ||
|
|
f52fec66bd | ||
|
|
f4926d1e45 | ||
|
|
2774c1a5cd | ||
|
|
8274bc0ea3 | ||
|
|
e9531e4d57 | ||
|
|
3a8aad7e5c | ||
|
|
ef079c5b58 | ||
|
|
50332aa2ee | ||
|
|
b47f3a57dc | ||
|
|
9a928744cc | ||
|
|
328d403507 | ||
|
|
76ffd76bd3 | ||
|
|
951589e652 | ||
|
|
7bb0704401 | ||
|
|
3aa45e72e7 | ||
|
|
67691e92e3 | ||
|
|
43388ec67b | ||
|
|
2fe3934491 | ||
|
|
f60ba95b4c | ||
|
|
4ecf541748 | ||
|
|
7994829765 | ||
|
|
ce14951436 | ||
|
|
a5ce8221a3 | ||
|
|
e6344ef18e | ||
|
|
99e60634ad | ||
|
|
6c656b7366 | ||
|
|
fc3a09b5ad | ||
|
|
b1484f2f24 | ||
|
|
7dcf884e38 | ||
|
|
b6d349da8c | ||
|
|
40ce3d50c2 | ||
|
|
68046067c5 | ||
|
|
e3b12a8a24 | ||
|
|
f123b9d3cb | ||
|
|
f4ce89ae26 | ||
|
|
ea451e7e49 | ||
|
|
d434575047 | ||
|
|
e627634184 | ||
|
|
e0dd12505f | ||
|
|
5a67f94380 | ||
|
|
5f9dd7a5a5 | ||
|
|
bce0da2806 | ||
|
|
a58c40f2d7 | ||
|
|
65d5cadf29 | ||
|
|
1ea5d4d2e3 | ||
|
|
719ef3c44c | ||
|
|
f4adfc3029 | ||
|
|
d8d08091cc | ||
|
|
de4b3ef3dc | ||
|
|
7bd6aedb73 | ||
|
|
fffe40fbd4 | ||
|
|
74feda73af | ||
|
|
8b5583930e | ||
|
|
466fdae70e | ||
|
|
054a62fb30 | ||
|
|
c694b570e0 | ||
|
|
4204ec1d43 | ||
|
|
6d4e37ccb2 | ||
|
|
eef06c993e | ||
|
|
58362fbbb9 | ||
|
|
b872e595ae | ||
|
|
18c3f79319 | ||
|
|
8f0cd35d7a | ||
|
|
c8bcf19f32 | ||
|
|
5bee3047ac | ||
|
|
0d2f6bf02d | ||
|
|
7481c6beb0 | ||
|
|
4ece12348b | ||
|
|
e65a5beaae | ||
|
|
ef576128e3 | ||
|
|
7f0bc2ada2 | ||
|
|
96c373d045 | ||
|
|
22648cae3b | ||
|
|
f57ce14754 | ||
|
|
1d3a381389 | ||
|
|
9055e753a9 | ||
|
|
6390812cbb | ||
|
|
fa46f05423 | ||
|
|
6b0ffe0b13 | ||
|
|
e724d90202 | ||
|
|
6129943685 | ||
|
|
d4e37cbda5 | ||
|
|
cccfb3a560 | ||
|
|
d0403038ed | ||
|
|
a5a7d7970f | ||
|
|
62b9377f15 | ||
|
|
ec2c71f9ef | ||
|
|
b54fd2c6b3 | ||
|
|
e5066c3712 | ||
|
|
fd1c038303 | ||
|
|
64e7a857b8 | ||
|
|
7da24932ab | ||
|
|
1a2ea8407b | ||
|
|
32f94bab97 | ||
|
|
dea4a67639 | ||
|
|
236ffd1767 | ||
|
|
1b2ffad2f1 | ||
|
|
4750d0d81c | ||
|
|
63a210a0b2 | ||
|
|
465eaa24d3 | ||
|
|
c23e8c7ee1 | ||
|
|
974f01cb46 | ||
|
|
16fa9b2753 | ||
|
|
9deab1c415 | ||
|
|
7c01eeb115 | ||
|
|
998f0c7d53 | ||
|
|
bd41406aaa | ||
|
|
f17801753d | ||
|
|
92891fd340 | ||
|
|
aa122455f7 | ||
|
|
880e70c19c | ||
|
|
968f249562 | ||
|
|
bb9f476be2 | ||
|
|
276f43fdeb | ||
|
|
150d1c2a5a | ||
|
|
1bf3814701 | ||
|
|
166181c745 | ||
|
|
bfff977d41 | ||
|
|
787d755261 | ||
|
|
acf7173959 | ||
|
|
e6132e36ba | ||
|
|
585b97c462 | ||
|
|
3dfd0bc2e1 | ||
|
|
10ff99542f | ||
|
|
2449030ab8 | ||
|
|
3e85901f40 | ||
|
|
73b1576f81 | ||
|
|
cdb5b7c9a2 | ||
|
|
d9331b0c91 | ||
|
|
b6a8163dd9 | ||
|
|
185252ba48 | ||
|
|
043d37921b | ||
|
|
02fb8d9958 | ||
|
|
cfa6c0a178 | ||
|
|
e8b52bf2fc | ||
|
|
85fbb780bf | ||
|
|
bd9f9bf518 | ||
|
|
077860fff1 | ||
|
|
d29a4ee4d2 | ||
|
|
6d2e34e9b2 | ||
|
|
0b6969537b | ||
|
|
dc6b0d0f0d | ||
|
|
b4dbb178fe | ||
|
|
4cf5290989 | ||
|
|
6ffd2222c2 | ||
|
|
e7725911a7 | ||
|
|
0c1664cd01 | ||
|
|
0239307d8e | ||
|
|
9f10b6be1b | ||
|
|
01f613b39e | ||
|
|
b775d11a70 | ||
|
|
022576697f | ||
|
|
065d0b2c06 | ||
|
|
ed4718205a | ||
|
|
a29d0c536d | ||
|
|
eaeb8ca5c1 | ||
|
|
2092c14aca | ||
|
|
69f38b8c77 | ||
|
|
d2cdd02a57 | ||
|
|
095c8323a1 | ||
|
|
accb4c915e | ||
|
|
242809f61d | ||
|
|
c4907cf6c6 | ||
|
|
a4b9191fa3 | ||
|
|
5fd3d0bd41 | ||
|
|
ba6da23323 | ||
|
|
0328bb14ce | ||
|
|
2b7a0f3fd4 | ||
|
|
527886bea0 | ||
|
|
98078a0c65 | ||
|
|
ca660b7ba5 | ||
|
|
ed93e93b81 | ||
|
|
80419f00db | ||
|
|
01946facb3 | ||
|
|
08c1bd7653 | ||
|
|
ebf9188c6a | ||
|
|
382c6d5885 | ||
|
|
384c60a988 | ||
|
|
0078147587 | ||
|
|
d79bedf2bc | ||
|
|
14b31b321c | ||
|
|
309b9b52f8 | ||
|
|
5d063e7390 | ||
|
|
e7ba9b5624 | ||
|
|
81f6fa598f | ||
|
|
d9eabcdbf7 | ||
|
|
bb3562427b | ||
|
|
8a5bba80bf | ||
|
|
ff2833c4d1 | ||
|
|
45ba845f23 | ||
|
|
771a14fcf6 | ||
|
|
c8ff861d00 | ||
|
|
0f05ce3605 | ||
|
|
38a3f3ba11 | ||
|
|
659a19cd80 | ||
|
|
baaa466c0f | ||
|
|
168c65bb6e | ||
|
|
6003d11156 | ||
|
|
1f16b6d639 | ||
|
|
54bb4b2efd | ||
|
|
f54770c21a | ||
|
|
1244a62deb | ||
|
|
2fe55bcdde | ||
|
|
9943690855 | ||
|
|
89c46a6379 | ||
|
|
a0d4530cc0 | ||
|
|
6db84269af | ||
|
|
2cd3c32ca7 | ||
|
|
9740fecc35 | ||
|
|
433492791b | ||
|
|
7d3c63ad74 | ||
|
|
a6538b117e | ||
|
|
d54e7559a5 | ||
|
|
bb9eca7232 | ||
|
|
b5027d8f3f | ||
|
|
00a134e23f | ||
|
|
aab3452773 | ||
|
|
5903dfc627 | ||
|
|
a5272b2b39 | ||
|
|
771fc20bb2 | ||
|
|
b5f48bee78 | ||
|
|
ff78af5808 | ||
|
|
7eab649abc | ||
|
|
1b5db157b1 | ||
|
|
0fa9aebf7a | ||
|
|
9fb9965ffe | ||
|
|
02c9f29499 | ||
|
|
c6243ad002 | ||
|
|
f4650c7a84 | ||
|
|
6df691598e | ||
|
|
26964b7f88 | ||
|
|
71712ae1c3 | ||
|
|
0b6c979e47 | ||
|
|
cc2cbc2519 | ||
|
|
8043ae961a | ||
|
|
b1d1d30cdb | ||
|
|
28d606cb0e | ||
|
|
e9c5b6e917 | ||
|
|
68f96235fc | ||
|
|
12f22ddeba | ||
|
|
9db5c644a6 | ||
|
|
ef6a1fb09b | ||
|
|
99002f92f4 | ||
|
|
298d6a1a15 | ||
|
|
5a21f50230 | ||
|
|
5263dabd22 | ||
|
|
9b649f6c72 | ||
|
|
b903cd5b68 | ||
|
|
890b5c5202 | ||
|
|
a14e88d04d | ||
|
|
58e09b4c68 | ||
|
|
631201d541 | ||
|
|
0fbeb6d2cd | ||
|
|
11f8e2ffde | ||
|
|
055eb4a61a | ||
|
|
30c1c5c3d3 | ||
|
|
e034ec3207 | ||
|
|
8edc4bd24b | ||
|
|
6e1672f73c | ||
|
|
5e1f6f7317 | ||
|
|
386780ba12 | ||
|
|
e785971ba8 | ||
|
|
daaae07649 | ||
|
|
6cd567dc66 | ||
|
|
a541a7ee85 | ||
|
|
43572bba04 | ||
|
|
2a3a4456c1 | ||
|
|
15f8e6369b | ||
|
|
cfad9a19eb | ||
|
|
e4c3136433 | ||
|
|
73b8a26850 | ||
|
|
aa533b28fb | ||
|
|
9d70e09a57 | ||
|
|
17e18985e6 | ||
|
|
7c39aaf463 | ||
|
|
bae5c125e8 | ||
|
|
1c84fa0d97 | ||
|
|
6f583f9f0e | ||
|
|
217574b75c | ||
|
|
1378530aeb | ||
|
|
0b10ed4d88 | ||
|
|
a2887f5776 | ||
|
|
0f1d27f1e6 | ||
|
|
850ab0942b | ||
|
|
f5ae8f44b4 | ||
|
|
7f98cfd506 | ||
|
|
bc45a79b92 | ||
|
|
5003cf674d | ||
|
|
bc9cbc387c | ||
|
|
60a1e78869 | ||
|
|
37f5587085 | ||
|
|
fa6e3d3706 | ||
|
|
bb8bc875b4 | ||
|
|
b3dca737be | ||
|
|
9094f85487 | ||
|
|
1256bbfbaf | ||
|
|
24fe74f2f6 | ||
|
|
908f501e03 | ||
|
|
35507c7854 | ||
|
|
eb7102ecac | ||
|
|
ade6bfcbca | ||
|
|
fa98403aa8 | ||
|
|
3f0cb1637c | ||
|
|
42011d028e | ||
|
|
307bb0dea1 | ||
|
|
ec2a8347d4 | ||
|
|
e99b1c3ed8 | ||
|
|
99825f2663 | ||
|
|
afffdfbc5c | ||
|
|
cd874acfd5 | ||
|
|
34edbf469e | ||
|
|
d9ed30e436 | ||
|
|
30008de400 | ||
|
|
a5fa731545 | ||
|
|
493ee3c956 | ||
|
|
3dd574ee51 | ||
|
|
5416c19b2e | ||
|
|
2f31d80c7a | ||
|
|
27d1833854 | ||
|
|
84ed716908 | ||
|
|
6c9c9c7578 | ||
|
|
cc7b7b0689 | ||
|
|
5df8e05d1a | ||
|
|
b3b224b0ca | ||
|
|
75ab28ee5d | ||
|
|
aa9ea2b4ab | ||
|
|
1e6be99c36 | ||
|
|
49fb396bf8 | ||
|
|
e055c9ddc1 | ||
|
|
c708e390a7 | ||
|
|
d5ad26c934 | ||
|
|
144b7cd922 | ||
|
|
9e86fbb311 | ||
|
|
b528428d02 | ||
|
|
b3d7730e79 | ||
|
|
f2ba567ca4 | ||
|
|
8342f77087 | ||
|
|
7cade1b98f | ||
|
|
ee4c1fb36c | ||
|
|
dbc4e537fe | ||
|
|
e28990b96c | ||
|
|
408cf92c04 | ||
|
|
425af2e0dc | ||
|
|
22df860eca | ||
|
|
f395044d65 | ||
|
|
afe0ddcd84 | ||
|
|
2c0323684c | ||
|
|
6d5ffdea57 | ||
|
|
648af6e645 | ||
|
|
e1895a4e21 | ||
|
|
d5f45800ae | ||
|
|
51f9d249ff | ||
|
|
6f525356cb | ||
|
|
5008f9064e | ||
|
|
cff96ed7ca | ||
|
|
4e8a600f34 | ||
|
|
4fd5684277 | ||
|
|
06bf469ba7 | ||
|
|
b8a215230c | ||
|
|
2460cfcf1c | ||
|
|
364242c857 | ||
|
|
29e2900f59 | ||
|
|
61e1fb770e | ||
|
|
2d3fcbdea3 | ||
|
|
47e15cee3d | ||
|
|
adeb3e3f42 | ||
|
|
fb1278285b | ||
|
|
e371610849 | ||
|
|
424de63bd1 | ||
|
|
832c925d39 | ||
|
|
378f118d51 | ||
|
|
d651777122 | ||
|
|
65d8ebabb8 | ||
|
|
9195ed9a1b | ||
|
|
5df8f7313c | ||
|
|
25ed6ca0a4 | ||
|
|
9f972995bd | ||
|
|
29c46a9892 | ||
|
|
ef579fe596 | ||
|
|
5b268f62a3 | ||
|
|
1f1c8286a5 | ||
|
|
5401e1ace4 | ||
|
|
69294ef56d | ||
|
|
a685ed8029 | ||
|
|
68d0be3818 | ||
|
|
84e2cb4c1f | ||
|
|
263c664acd | ||
|
|
b12c4c22fb | ||
|
|
9f39fadb9e | ||
|
|
4c29a1ca27 | ||
|
|
f4db124d50 | ||
|
|
8f8c7cccc6 | ||
|
|
e2097c28bd | ||
|
|
871eb444fc | ||
|
|
bc5fbb9fa5 | ||
|
|
3e9749c6b1 | ||
|
|
eaf08fbe90 | ||
|
|
df411cdb88 | ||
|
|
a83c26a864 | ||
|
|
6aa853491c | ||
|
|
3af1d7a5b8 | ||
|
|
c7c57f6717 | ||
|
|
cbb97768d1 | ||
|
|
2bb40d335b | ||
|
|
1b581d6f51 | ||
|
|
c219eb2883 | ||
|
|
65a2c87b5a | ||
|
|
13aa523c37 | ||
|
|
584f0eea58 | ||
|
|
b5ebdb16b2 | ||
|
|
a18f84c27b | ||
|
|
eb86505375 | ||
|
|
984f1c8669 | ||
|
|
c7378edabc | ||
|
|
ac6c6e3a30 | ||
|
|
1bca31f32c | ||
|
|
28d099a6b2 | ||
|
|
6a2b53fbf5 | ||
|
|
7568f301b8 | ||
|
|
6add511447 | ||
|
|
a7586e69fd | ||
|
|
77db369213 | ||
|
|
2eb6a0513e | ||
|
|
38468c72db | ||
|
|
5f759200c6 | ||
|
|
81f68157fa | ||
|
|
0f3e8abf06 | ||
|
|
fcadd5312d | ||
|
|
6e32820910 | ||
|
|
8499269bab | ||
|
|
72122120cb | ||
|
|
2bbcb95f4f | ||
|
|
19982fa4a6 | ||
|
|
41cf38c6a7 | ||
|
|
16e74647eb | ||
|
|
53cdcbc4ee | ||
|
|
eb2535e066 | ||
|
|
f5c29a7a72 | ||
|
|
e243df93f1 | ||
|
|
388642d9dd | ||
|
|
9e1db06936 | ||
|
|
a260403334 | ||
|
|
6396b25886 | ||
|
|
ca480164b7 | ||
|
|
714f9df3cf | ||
|
|
6a7f1e7d48 | ||
|
|
bcdce02b78 | ||
|
|
2f0835b655 | ||
|
|
36bafa23df | ||
|
|
db611549f2 | ||
|
|
5d4cdcc207 | ||
|
|
a3b9c094b6 | ||
|
|
f82174adae | ||
|
|
c7080d2834 | ||
|
|
381127d413 | ||
|
|
f6fa468acb | ||
|
|
9228130f92 | ||
|
|
207c50ceac | ||
|
|
c3255a6e1e | ||
|
|
5e1c93a167 | ||
|
|
43c33a0cc3 | ||
|
|
f5117329e4 | ||
|
|
f7c62d12a5 | ||
|
|
fe5f181706 | ||
|
|
cc09b29a2e | ||
|
|
406601eead | ||
|
|
341d860c51 | ||
|
|
8214bb8e33 | ||
|
|
884e3c678c | ||
|
|
3b249dfe69 | ||
|
|
d236a9af57 | ||
|
|
ad9b0ae067 | ||
|
|
31f166cd02 | ||
|
|
5685ebc3a5 | ||
|
|
46bcf5da33 | ||
|
|
1784d15f36 | ||
|
|
cafce536bb | ||
|
|
d03280a12f | ||
|
|
b30ef523f8 | ||
|
|
a6a303629a | ||
|
|
61e79ef793 | ||
|
|
f632abd8fa | ||
|
|
c3911fe490 | ||
|
|
505701e1c6 | ||
|
|
67643e7487 | ||
|
|
a962c17adb | ||
|
|
479b4b5859 | ||
|
|
57f8cf85ca | ||
|
|
dd2c20b225 | ||
|
|
9da427a515 | ||
|
|
604773e866 | ||
|
|
1331f5260a | ||
|
|
65d0f3569c | ||
|
|
ba522877ec | ||
|
|
4b63ccf140 | ||
|
|
4fcf93306a | ||
|
|
96d8ec2016 | ||
|
|
3697a5e348 | ||
|
|
084c587c0e | ||
|
|
dcb505045e | ||
|
|
0aeb3128ed | ||
|
|
c61cfcbd18 | ||
|
|
eba2dd36e0 | ||
|
|
2a75754561 | ||
|
|
d03944893d | ||
|
|
884c6ebd37 | ||
|
|
331ac3f031 | ||
|
|
ccc84a8367 | ||
|
|
daeb41c31b | ||
|
|
17bda9c110 | ||
|
|
febedaad8f | ||
|
|
d1357dff1f | ||
|
|
102552427f | ||
|
|
f33898265d | ||
|
|
57bdaf939a | ||
|
|
981fed111b | ||
|
|
3a4a2002d4 | ||
|
|
b8d4af5538 | ||
|
|
0646538cef | ||
|
|
70a87247e2 | ||
|
|
61129c6b6a | ||
|
|
c158f95130 | ||
|
|
ad90d37f14 | ||
|
|
73ba754481 | ||
|
|
7dcfbdbb29 | ||
|
|
f453507fcc | ||
|
|
c5465de000 | ||
|
|
352b864636 | ||
|
|
c034befbb5 | ||
|
|
572cdf40fc | ||
|
|
0c0d353e9c | ||
|
|
bcc90afba2 | ||
|
|
a919703011 | ||
|
|
3300a45c39 | ||
|
|
f1cfae8f26 | ||
|
|
62763961be | ||
|
|
f1dab2279d | ||
|
|
ea337cf839 | ||
|
|
27277136f8 | ||
|
|
dd0b807fe4 | ||
|
|
ed09dd57b6 | ||
|
|
58b4c980c1 | ||
|
|
dd5165dcbf | ||
|
|
6da22613fe | ||
|
|
d0926776a5 | ||
|
|
14dc39e8d2 | ||
|
|
f0f2a79384 | ||
|
|
7b6f875920 | ||
|
|
52cec044b8 | ||
|
|
07dd59892f | ||
|
|
ffeaa683c5 | ||
|
|
1301bf7c15 | ||
|
|
69387fd2a4 | ||
|
|
12a0ebe3ba | ||
|
|
3de81827eb | ||
|
|
a7362b60e7 | ||
|
|
5d4bb3a43f | ||
|
|
d02d507812 | ||
|
|
554de7ba6f | ||
|
|
5d9ccc973d | ||
|
|
53ffb8aa00 | ||
|
|
c4da4a81aa | ||
|
|
b824ea8858 | ||
|
|
22e26efec1 | ||
|
|
679490e8f4 | ||
|
|
15f17ed36d | ||
|
|
c8265fb80c | ||
|
|
3883e92631 | ||
|
|
aa9bc4ce8b | ||
|
|
37c14e8088 | ||
|
|
439fbafc01 | ||
|
|
1b8e980519 | ||
|
|
567acb6291 | ||
|
|
996bfe87ff | ||
|
|
3c1793b6c5 | ||
|
|
1a7f253767 | ||
|
|
f188e59b21 | ||
|
|
5ea4e814f5 | ||
|
|
008b3b8408 | ||
|
|
7ae3dee900 | ||
|
|
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 | ||
|
|
b981bae1db | ||
|
|
d2df9ccf33 | ||
|
|
5e51f51449 | ||
|
|
2c044a27e4 | ||
|
|
d274a1115e | ||
|
|
bfae2899f3 | ||
|
|
5352a7e13a | ||
|
|
c49f9ef26a | ||
|
|
4a7376c5f5 | ||
|
|
567ce7f987 | ||
|
|
26bc0a8100 | ||
|
|
e7ff319685 | ||
|
|
072138deff | ||
|
|
dd8dc90c1e | ||
|
|
8f1da33375 | ||
|
|
c02fbc2794 | ||
|
|
371db07108 | ||
|
|
99f5dbf16b | ||
|
|
0db06c8962 | ||
|
|
a8e5876b2e | ||
|
|
8273851b73 | ||
|
|
c2967240bb | ||
|
|
282a6270c8 | ||
|
|
1b299fad90 | ||
|
|
aa8dced7ad | ||
|
|
050ba951b0 | ||
|
|
5e47c16099 | ||
|
|
902db4c732 | ||
|
|
86462fbee6 | ||
|
|
48bed79439 | ||
|
|
26b61c2b6b | ||
|
|
3b2253ddc0 | ||
|
|
5ddcb39129 | ||
|
|
59adef5bcc | ||
|
|
875aefc8dd | ||
|
|
0dbc9d213e | ||
|
|
9f4c53e321 | ||
|
|
3c8716f6ac | ||
|
|
1a7f31ae2e | ||
|
|
64ad69acfe | ||
|
|
9f47b55aa9 | ||
|
|
53a1db0703 | ||
|
|
2a789ec705 | ||
|
|
3047b25193 | ||
|
|
f66399cdc0 | ||
|
|
37fb0f632b | ||
|
|
e5dd0c7ff8 | ||
|
|
51392cd54c | ||
|
|
02bcb4ff3c | ||
|
|
d84297a5b5 | ||
|
|
c3876e30a9 | ||
|
|
10711ed780 | ||
|
|
de4e266e33 | ||
|
|
15442969f8 | ||
|
|
bed48ada82 | ||
|
|
a66004f567 | ||
|
|
72a4e3b3b8 | ||
|
|
16761e4fca | ||
|
|
ba34a6d401 | ||
|
|
23912e4091 | ||
|
|
17468cb5f5 | ||
|
|
5ea7aa0a75 | ||
|
|
7792cd6a10 | ||
|
|
237d186207 | ||
|
|
c41487598e | ||
|
|
2c0aa3c3af | ||
|
|
cedb33b2b9 | ||
|
|
06a3aa2c60 | ||
|
|
3fadc94711 | ||
|
|
61d02bf5e4 | ||
|
|
a62976461e | ||
|
|
d7a893acf9 | ||
|
|
0c67e75fb6 | ||
|
|
e6b84c4cfc | ||
|
|
5d2e793386 | ||
|
|
f0517906b7 | ||
|
|
16fa167931 | ||
|
|
b036999b8c | ||
|
|
1911766b7b | ||
|
|
9f7835d818 | ||
|
|
1df45e4857 | ||
|
|
47a1743965 | ||
|
|
d5844bbdaa | ||
|
|
128c87ab33 | ||
|
|
f4adcae79a | ||
|
|
ba4df070cf | ||
|
|
ce4ecfb388 | ||
|
|
e6006e0833 | ||
|
|
d500cc0bd1 | ||
|
|
71995b4f83 | ||
|
|
932c91d022 | ||
|
|
107e7424d1 | ||
|
|
c93181c0ad | ||
|
|
050fca6767 | ||
|
|
71827b4a1a | ||
|
|
1d0315bf5e | ||
|
|
b2b64e7283 | ||
|
|
fe0e2edd37 | ||
|
|
e5bb3d5645 | ||
|
|
b88a99347b | ||
|
|
344a909d19 | ||
|
|
3cbe3aab25 | ||
|
|
9e3a4b1810 | ||
|
|
e855bbaa29 | ||
|
|
78d7dca985 | ||
|
|
9da7ded976 | ||
|
|
427b107d0e | ||
|
|
1cab68e385 | ||
|
|
07e4fa8abd | ||
|
|
77b86c78a4 | ||
|
|
e4c701864a | ||
|
|
0275f28490 | ||
|
|
300c3dd578 | ||
|
|
fb81870803 | ||
|
|
bb6a61a313 | ||
|
|
976d917a57 | ||
|
|
7e13cc2ca8 | ||
|
|
704296df4e | ||
|
|
65244e3b8d | ||
|
|
3cf54a4cce | ||
|
|
031c09d8dc | ||
|
|
5209d9cf75 | ||
|
|
815dad18f4 | ||
|
|
4319382da3 | ||
|
|
5e96cec95b | ||
|
|
071982097a | ||
|
|
56024de6cc | ||
|
|
845d4acd8e | ||
|
|
b0029e9255 | ||
|
|
23bc44a350 | ||
|
|
0bf52f4746 | ||
|
|
345707e6cc | ||
|
|
e2752e4508 | ||
|
|
9916a53761 | ||
|
|
4581c99a81 | ||
|
|
c3fdc41a91 | ||
|
|
edf2f51aa1 | ||
|
|
de944d0095 | ||
|
|
49ffc972f8 | ||
|
|
2d8e5b2420 | ||
|
|
7c48975198 | ||
|
|
9bc250d027 | ||
|
|
41d4e7e15b | ||
|
|
b0d2a38ff6 | ||
|
|
bd4d4d927e | ||
|
|
db17cacbf4 | ||
|
|
0c5961df98 | ||
|
|
0e67b76b57 | ||
|
|
f72b323ab5 | ||
|
|
927c21a60f | ||
|
|
624a9ba8eb | ||
|
|
8509283ac2 | ||
|
|
aa9ba27f40 | ||
|
|
06434464bb | ||
|
|
3e7bfc72a2 | ||
|
|
8dfbc35e60 |
84
.github/ISSUE_TEMPLATE/bug_report.yaml
vendored
Normal file
84
.github/ISSUE_TEMPLATE/bug_report.yaml
vendored
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
description: Create a report to help us improve Flux
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
## Support
|
||||||
|
Find out more about your support options and getting help at: https://fluxcd.io/support/
|
||||||
|
- type: textarea
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
attributes:
|
||||||
|
label: Describe the bug
|
||||||
|
description: A clear description of what the bug is.
|
||||||
|
- type: textarea
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
attributes:
|
||||||
|
label: Steps to reproduce
|
||||||
|
description: |
|
||||||
|
Steps to reproduce the problem.
|
||||||
|
placeholder: |
|
||||||
|
For example:
|
||||||
|
1. Install Flux with the additional image automation controllers
|
||||||
|
2. Run command '...'
|
||||||
|
3. See error
|
||||||
|
- type: textarea
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
attributes:
|
||||||
|
label: Expected behavior
|
||||||
|
description: A brief description of what you expected to happen.
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Screenshots and recordings
|
||||||
|
description: |
|
||||||
|
If applicable, add screenshots to help explain your problem. You can also record an asciinema session: https://asciinema.org/
|
||||||
|
- type: input
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
attributes:
|
||||||
|
label: OS / Distro
|
||||||
|
description: The OS / distro you are executing `flux` on. If not applicable, write `N/A`.
|
||||||
|
placeholder: e.g. Windows 10, Ubuntu 20.04, Arch Linux, macOS 10.15...
|
||||||
|
- type: input
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
attributes:
|
||||||
|
label: Flux version
|
||||||
|
description: Run `flux version --client`. If not applicable, write `N/A`.
|
||||||
|
placeholder: e.g. v0.20.1
|
||||||
|
- type: textarea
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
attributes:
|
||||||
|
label: Flux check
|
||||||
|
description: Run `flux check`. If not applicable, write `N/A`.
|
||||||
|
placeholder: |
|
||||||
|
For example:
|
||||||
|
► checking prerequisites
|
||||||
|
✔ Kubernetes 1.21.1 >=1.19.0-0
|
||||||
|
► checking controllers
|
||||||
|
✔ all checks passed
|
||||||
|
- type: input
|
||||||
|
attributes:
|
||||||
|
label: Git provider
|
||||||
|
description: If applicable, add the Git provider you are having problems with, e.g. GitHub (Enterprise), GitLab, etc.
|
||||||
|
- type: input
|
||||||
|
attributes:
|
||||||
|
label: Container Registry provider
|
||||||
|
description: If applicable, add the Container Registry provider you are having problems with, e.g. DockerHub, GitHub Packages, Quay.io, etc.
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Additional context
|
||||||
|
description: Add any other context about the problem here. This can be logs (e.g. output from `flux logs`), environment specific caveats, etc.
|
||||||
|
- type: checkboxes
|
||||||
|
id: terms
|
||||||
|
attributes:
|
||||||
|
label: Code of Conduct
|
||||||
|
description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/fluxcd/.github/blob/main/CODE_OF_CONDUCT.md)
|
||||||
|
options:
|
||||||
|
- label: I agree to follow this project's Code of Conduct
|
||||||
|
required: true
|
||||||
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
blank_issues_enabled: true
|
||||||
|
contact_links:
|
||||||
|
- name: Ask a question
|
||||||
|
url: https://github.com/fluxcd/flux2/discussions
|
||||||
|
about: Please ask and answer questions here.
|
||||||
16
.github/aur/flux-bin/.SRCINFO.template
vendored
Normal file
16
.github/aur/flux-bin/.SRCINFO.template
vendored
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
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
|
||||||
|
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
|
||||||
45
.github/aur/flux-bin/PKGBUILD.template
vendored
Normal file
45
.github/aur/flux-bin/PKGBUILD.template
vendored
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
# 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=('bash-completion: auto-completion for flux in Bash',
|
||||||
|
'zsh-completions: auto-completion for flux in ZSH')
|
||||||
|
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}
|
||||||
|
)
|
||||||
|
_srcname=flux
|
||||||
|
|
||||||
|
package() {
|
||||||
|
install -Dm755 ${_srcname} "${pkgdir}/usr/bin/${_srcname}"
|
||||||
|
|
||||||
|
"${pkgdir}/usr/bin/${_srcname}" completion bash | install -Dm644 /dev/stdin "${pkgdir}/usr/share/bash-completion/completions/${_srcname}"
|
||||||
|
"${pkgdir}/usr/bin/${_srcname}" completion fish | install -Dm644 /dev/stdin "${pkgdir}/usr/share/fish/vendor_completions.d/${_srcname}.fish"
|
||||||
|
"${pkgdir}/usr/bin/${_srcname}" completion zsh | install -Dm644 /dev/stdin "${pkgdir}/usr/share/zsh/site-functions/_${_srcname}"
|
||||||
|
}
|
||||||
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
|
||||||
18
.github/aur/flux-go/.SRCINFO.template
vendored
Normal file
18
.github/aur/flux-go/.SRCINFO.template
vendored
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
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
|
||||||
|
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
|
||||||
50
.github/aur/flux-go/PKGBUILD.template
vendored
Normal file
50
.github/aur/flux-go/PKGBUILD.template
vendored
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
# 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>=1.16', 'kustomize>=3.0')
|
||||||
|
optdepends=('bash-completion: auto-completion for flux in Bash',
|
||||||
|
'zsh-completions: auto-completion for flux in ZSH')
|
||||||
|
source=(
|
||||||
|
"${pkgname}-${pkgver}.tar.gz::https://github.com/fluxcd/flux2/archive/v${pkgver}.tar.gz"
|
||||||
|
)
|
||||||
|
sha256sums=(
|
||||||
|
${SHA256SUM}
|
||||||
|
)
|
||||||
|
_srcname=flux
|
||||||
|
|
||||||
|
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 -mod=readonly -modcacherw"
|
||||||
|
./manifests/scripts/bundle.sh "${PWD}/manifests" "${PWD}/cmd/flux/manifests"
|
||||||
|
go build -ldflags "-linkmode=external -X main.VERSION=${pkgver}" -o ${_srcname} ./cmd/flux
|
||||||
|
}
|
||||||
|
|
||||||
|
check() {
|
||||||
|
cd "flux2-${pkgver}"
|
||||||
|
make test
|
||||||
|
}
|
||||||
|
|
||||||
|
package() {
|
||||||
|
cd "flux2-${pkgver}"
|
||||||
|
install -Dm755 ${_srcname} "${pkgdir}/usr/bin/${_srcname}"
|
||||||
|
install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
|
||||||
|
|
||||||
|
"${pkgdir}/usr/bin/${_srcname}" completion bash | install -Dm644 /dev/stdin "${pkgdir}/usr/share/bash-completion/completions/${_srcname}"
|
||||||
|
"${pkgdir}/usr/bin/${_srcname}" completion fish | install -Dm644 /dev/stdin "${pkgdir}/usr/share/fish/vendor_completions.d/${_srcname}.fish"
|
||||||
|
"${pkgdir}/usr/bin/${_srcname}" completion zsh | install -Dm644 /dev/stdin "${pkgdir}/usr/share/zsh/site-functions/_${_srcname}"
|
||||||
|
}
|
||||||
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
|
||||||
18
.github/aur/flux-scm/.SRCINFO.template
vendored
Normal file
18
.github/aur/flux-scm/.SRCINFO.template
vendored
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
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
|
||||||
|
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
|
||||||
52
.github/aur/flux-scm/PKGBUILD.template
vendored
Normal file
52
.github/aur/flux-scm/PKGBUILD.template
vendored
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
# 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>=1.16', 'kustomize>=3.0')
|
||||||
|
optdepends=('bash-completion: auto-completion for flux in Bash',
|
||||||
|
'zsh-completions: auto-completion for flux in ZSH')
|
||||||
|
source=(
|
||||||
|
"git+https://github.com/fluxcd/flux2.git"
|
||||||
|
)
|
||||||
|
md5sums=('SKIP')
|
||||||
|
_srcname=flux
|
||||||
|
|
||||||
|
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 -mod=readonly -modcacherw"
|
||||||
|
make cmd/flux/manifests
|
||||||
|
go build -ldflags "-linkmode=external -X main.VERSION=${pkgver}" -o ${_srcname} ./cmd/flux
|
||||||
|
}
|
||||||
|
|
||||||
|
check() {
|
||||||
|
cd "flux2"
|
||||||
|
make test
|
||||||
|
}
|
||||||
|
|
||||||
|
package() {
|
||||||
|
cd "flux2"
|
||||||
|
install -Dm755 ${_srcname} "${pkgdir}/usr/bin/${_srcname}"
|
||||||
|
install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
|
||||||
|
|
||||||
|
"${pkgdir}/usr/bin/${_srcname}" completion bash | install -Dm644 /dev/stdin "${pkgdir}/usr/share/bash-completion/completions/${_srcname}"
|
||||||
|
"${pkgdir}/usr/bin/${_srcname}" completion fish | install -Dm644 /dev/stdin "${pkgdir}/usr/share/fish/vendor_completions.d/${_srcname}.fish"
|
||||||
|
"${pkgdir}/usr/bin/${_srcname}" completion zsh | install -Dm644 /dev/stdin "${pkgdir}/usr/share/zsh/site-functions/_${_srcname}"
|
||||||
|
}
|
||||||
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
|
||||||
5
.github/kind/config.yaml
vendored
Normal file
5
.github/kind/config.yaml
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
kind: Cluster
|
||||||
|
apiVersion: kind.x-k8s.io/v1alpha4
|
||||||
|
networking:
|
||||||
|
disableDefaultCNI: true # disable kindnet
|
||||||
|
podSubnet: 192.168.0.0/16 # set to Calico's default subnet
|
||||||
72
.github/runners/README.md
vendored
Normal file
72
.github/runners/README.md
vendored
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
# Flux ARM64 GitHub runners
|
||||||
|
|
||||||
|
The Flux ARM64 end-to-end tests run on Equinix instances provisioned with Docker and GitHub self-hosted runners.
|
||||||
|
|
||||||
|
## Current instances
|
||||||
|
|
||||||
|
| Runner | Instance | Region |
|
||||||
|
|---------------|---------------------|--------|
|
||||||
|
| equinix-arm-1 | flux-equinix-arm-01 | AMS1 |
|
||||||
|
| equinix-arm-2 | flux-equinix-arm-01 | AMS1 |
|
||||||
|
| equinix-arm-3 | flux-equinix-arm-01 | AMS1 |
|
||||||
|
| equinix-arm-4 | flux-equinix-arm-02 | DFW2 |
|
||||||
|
| equinix-arm-5 | flux-equinix-arm-02 | DFW2 |
|
||||||
|
| equinix-arm-6 | flux-equinix-arm-02 | DFW2 |
|
||||||
|
|
||||||
|
## Instance setup
|
||||||
|
|
||||||
|
In order to add a new runner to the GitHub Actions pool,
|
||||||
|
first create a server on Equinix with the following configuration:
|
||||||
|
- Type: c2.large.arm
|
||||||
|
- OS: Ubuntu 20.04
|
||||||
|
|
||||||
|
### Install prerequisites
|
||||||
|
|
||||||
|
- SSH into a newly created instance
|
||||||
|
```shell
|
||||||
|
ssh root@<instance-public-IP>
|
||||||
|
```
|
||||||
|
|
||||||
|
- Create the ubuntu user
|
||||||
|
```shell
|
||||||
|
adduser ubuntu
|
||||||
|
usermod -aG sudo ubuntu
|
||||||
|
su - ubuntu
|
||||||
|
```
|
||||||
|
|
||||||
|
- Create the prerequisites dir
|
||||||
|
```shell
|
||||||
|
mkdir -p prereq && cd prereq
|
||||||
|
```
|
||||||
|
|
||||||
|
- Download the prerequisites script
|
||||||
|
```shell
|
||||||
|
curl -sL https://raw.githubusercontent.com/fluxcd/flux2/main/.github/runners/prereq.sh > prereq.sh \
|
||||||
|
&& chmod +x ./prereq.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
- Install the prerequisites
|
||||||
|
```shell
|
||||||
|
sudo ./prereq.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
### Install runners
|
||||||
|
|
||||||
|
- Retrieve the GitHub runner token from the repository [settings page](https://github.com/fluxcd/flux2/settings/actions/runners/new?arch=arm64&os=linux)
|
||||||
|
|
||||||
|
- Create 3 directories `runner1`, `runner2`, `runner3`
|
||||||
|
|
||||||
|
- In each dir run:
|
||||||
|
```shell
|
||||||
|
curl -sL https://raw.githubusercontent.com/fluxcd/flux2/main/.github/runners/runner-setup.sh > runner-setup.sh \
|
||||||
|
&& chmod +x ./runner-setup.sh
|
||||||
|
|
||||||
|
./runner-setup.sh equinix-arm-<NUMBER> <TOKEN>
|
||||||
|
```
|
||||||
|
|
||||||
|
- Reboot the instance
|
||||||
|
```shell
|
||||||
|
sudo reboot
|
||||||
|
```
|
||||||
|
|
||||||
|
- Navigate to the GitHub repository [runners page](https://github.com/fluxcd/flux2/settings/actions/runners) and check the runner status
|
||||||
61
.github/runners/prereq.sh
vendored
Executable file
61
.github/runners/prereq.sh
vendored
Executable file
@@ -0,0 +1,61 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Copyright 2021 The Flux authors. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
# This script installs the prerequisites for running Flux end-to-end tests with Docker and GitHub self-hosted runners.
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
KIND_VERSION=0.11.1
|
||||||
|
KUBECTL_VERSION=1.21.2
|
||||||
|
KUSTOMIZE_VERSION=4.1.3
|
||||||
|
GITHUB_RUNNER_VERSION=2.285.1
|
||||||
|
PACKAGES="apt-transport-https ca-certificates software-properties-common build-essential libssl-dev gnupg lsb-release jq"
|
||||||
|
|
||||||
|
# install prerequisites
|
||||||
|
apt-get update \
|
||||||
|
&& apt-get install -y -q ${PACKAGES} \
|
||||||
|
&& apt-get clean \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# install docker
|
||||||
|
curl -fsSL https://get.docker.com -o get-docker.sh \
|
||||||
|
&& chmod +x get-docker.sh
|
||||||
|
./get-docker.sh
|
||||||
|
systemctl enable docker.service
|
||||||
|
systemctl enable containerd.service
|
||||||
|
usermod -aG docker ubuntu
|
||||||
|
|
||||||
|
# install kind
|
||||||
|
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v${KIND_VERSION}/kind-linux-arm64
|
||||||
|
install -o root -g root -m 0755 kind /usr/local/bin/kind
|
||||||
|
|
||||||
|
# install kubectl
|
||||||
|
curl -LO "https://dl.k8s.io/release/v${KUBECTL_VERSION}/bin/linux/arm64/kubectl"
|
||||||
|
install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
|
||||||
|
|
||||||
|
# install kustomize
|
||||||
|
curl -Lo ./kustomize.tar.gz https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv${KUSTOMIZE_VERSION}/kustomize_v${KUSTOMIZE_VERSION}_linux_arm64.tar.gz \
|
||||||
|
&& tar -zxvf kustomize.tar.gz \
|
||||||
|
&& rm kustomize.tar.gz
|
||||||
|
install -o root -g root -m 0755 kustomize /usr/local/bin/kustomize
|
||||||
|
|
||||||
|
# download runner
|
||||||
|
curl -o actions-runner-linux-arm64.tar.gz -L https://github.com/actions/runner/releases/download/v${GITHUB_RUNNER_VERSION}/actions-runner-linux-arm64-${GITHUB_RUNNER_VERSION}.tar.gz \
|
||||||
|
&& tar xzf actions-runner-linux-arm64.tar.gz \
|
||||||
|
&& rm actions-runner-linux-arm64.tar.gz
|
||||||
|
|
||||||
|
# install runner dependencies
|
||||||
|
./bin/installdependencies.sh
|
||||||
37
.github/runners/runner-setup.sh
vendored
Executable file
37
.github/runners/runner-setup.sh
vendored
Executable file
@@ -0,0 +1,37 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Copyright 2021 The Flux authors. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
# This script installs a GitHub self-hosted ARM64 runner for running Flux end-to-end tests.
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
RUNNER_NAME=$1
|
||||||
|
REPOSITORY_TOKEN=$2
|
||||||
|
REPOSITORY_URL=${3:-https://github.com/fluxcd/flux2}
|
||||||
|
|
||||||
|
GITHUB_RUNNER_VERSION=2.285.1
|
||||||
|
|
||||||
|
# download runner
|
||||||
|
curl -o actions-runner-linux-arm64.tar.gz -L https://github.com/actions/runner/releases/download/v${GITHUB_RUNNER_VERSION}/actions-runner-linux-arm64-${GITHUB_RUNNER_VERSION}.tar.gz \
|
||||||
|
&& tar xzf actions-runner-linux-arm64.tar.gz \
|
||||||
|
&& rm actions-runner-linux-arm64.tar.gz
|
||||||
|
|
||||||
|
# register runner with GitHub
|
||||||
|
./config.sh --unattended --url ${REPOSITORY_URL} --token ${REPOSITORY_TOKEN} --name ${RUNNER_NAME}
|
||||||
|
|
||||||
|
# start runner
|
||||||
|
sudo ./svc.sh install
|
||||||
|
sudo ./svc.sh start
|
||||||
129
.github/workflows/bootstrap.yaml
vendored
129
.github/workflows/bootstrap.yaml
vendored
@@ -2,12 +2,14 @@ name: bootstrap
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches: [ main ]
|
||||||
- '*'
|
pull_request:
|
||||||
|
branches: [ main ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
github:
|
github:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
@@ -15,64 +17,111 @@ jobs:
|
|||||||
uses: actions/cache@v1
|
uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
path: ~/go/pkg/mod
|
path: ~/go/pkg/mod
|
||||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
key: ${{ runner.os }}-go1.16-${{ hashFiles('**/go.sum') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-go-
|
${{ runner.os }}-go1.16-
|
||||||
- name: Setup Go
|
- name: Setup Go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: 1.14.x
|
go-version: 1.16.x
|
||||||
- name: Setup Kubernetes
|
- name: Setup Kubernetes
|
||||||
uses: engineerd/setup-kind@v0.4.0
|
uses: engineerd/setup-kind@v0.5.0
|
||||||
|
with:
|
||||||
|
version: v0.11.1
|
||||||
|
image: kindest/node:v1.21.1@sha256:69860bda5563ac81e3c0057d654b5253219618a22ec3a346306239bba8cfa1a6
|
||||||
|
- name: Setup Kustomize
|
||||||
|
uses: fluxcd/pkg//actions/kustomize@main
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
make cmd/flux/.manifests.done
|
||||||
|
go build -o /tmp/flux ./cmd/flux
|
||||||
- name: Set outputs
|
- name: Set outputs
|
||||||
id: vars
|
id: vars
|
||||||
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
|
run: |
|
||||||
- name: Build
|
REPOSITORY_NAME=${{ github.event.repository.name }}
|
||||||
run: sudo go build -o ./bin/gotk ./cmd/gotk
|
BRANCH_NAME=${GITHUB_REF##*/}
|
||||||
|
COMMIT_SHA=$(git rev-parse HEAD)
|
||||||
|
PSEUDO_RAND_SUFFIX=$(echo "${BRANCH_NAME}-${COMMIT_SHA}" | shasum | awk '{print $1}')
|
||||||
|
TEST_REPO_NAME="${REPOSITORY_NAME}-${PSEUDO_RAND_SUFFIX}"
|
||||||
|
echo "::set-output name=test_repo_name::$TEST_REPO_NAME"
|
||||||
- name: bootstrap init
|
- name: bootstrap init
|
||||||
run: |
|
run: |
|
||||||
./bin/gotk bootstrap github --manifests ./manifests/install/ \
|
/tmp/flux bootstrap github --manifests ./manifests/install/ \
|
||||||
--owner=fluxcd-testing \
|
--owner=fluxcd-testing \
|
||||||
--repository=gotk-test-${{ steps.vars.outputs.sha_short }} \
|
--repository=${{ steps.vars.outputs.test_repo_name }} \
|
||||||
--branch=main \
|
--branch=main \
|
||||||
--path=test-cluster
|
--path=test-cluster \
|
||||||
|
--team=team-z
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITPROVIDER_BOT_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITPROVIDER_BOT_TOKEN }}
|
||||||
- name: bootstrap no-op
|
- name: bootstrap no-op
|
||||||
run: |
|
run: |
|
||||||
./bin/gotk bootstrap github --manifests ./manifests/install/ \
|
/tmp/flux bootstrap github --manifests ./manifests/install/ \
|
||||||
--owner=fluxcd-testing \
|
--owner=fluxcd-testing \
|
||||||
--repository=gotk-test-${{ steps.vars.outputs.sha_short }} \
|
--repository=${{ steps.vars.outputs.test_repo_name }} \
|
||||||
--branch=main \
|
|
||||||
--path=test-cluster
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITPROVIDER_BOT_TOKEN }}
|
|
||||||
- name: uninstall
|
|
||||||
run: |
|
|
||||||
./bin/gotk suspend kustomization gotk-system
|
|
||||||
./bin/gotk uninstall --resources --crds -s
|
|
||||||
- name: bootstrap reinstall
|
|
||||||
run: |
|
|
||||||
./bin/gotk bootstrap github --manifests ./manifests/install/ \
|
|
||||||
--owner=fluxcd-testing \
|
|
||||||
--repository=gotk-test-${{ steps.vars.outputs.sha_short }} \
|
|
||||||
--branch=main \
|
|
||||||
--path=test-cluster
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITPROVIDER_BOT_TOKEN }}
|
|
||||||
- name: delete repository
|
|
||||||
run: |
|
|
||||||
./bin/gotk bootstrap github --manifests ./manifests/install/ \
|
|
||||||
--owner=fluxcd-testing \
|
|
||||||
--repository=gotk-test-${{ steps.vars.outputs.sha_short }} \
|
|
||||||
--branch=main \
|
--branch=main \
|
||||||
--path=test-cluster \
|
--path=test-cluster \
|
||||||
--delete
|
--team=team-z
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITPROVIDER_BOT_TOKEN }}
|
||||||
|
- name: bootstrap customize
|
||||||
|
run: |
|
||||||
|
make setup-bootstrap-patch
|
||||||
|
/tmp/flux bootstrap github --manifests ./manifests/install/ \
|
||||||
|
--owner=fluxcd-testing \
|
||||||
|
--repository=${{ steps.vars.outputs.test_repo_name }} \
|
||||||
|
--branch=main \
|
||||||
|
--path=test-cluster \
|
||||||
|
--team=team-z
|
||||||
|
if [ $(kubectl get deployments.apps source-controller -o jsonpath='{.spec.template.spec.securityContext.runAsUser}') != "10000" ]; then
|
||||||
|
echo "Bootstrap not customized as controller is not running as user 10000" && exit 1
|
||||||
|
fi
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITPROVIDER_BOT_TOKEN }}
|
||||||
|
GITHUB_REPO_NAME: ${{ steps.vars.outputs.test_repo_name }}
|
||||||
|
GITHUB_ORG_NAME: fluxcd-testing
|
||||||
|
- name: libgit2
|
||||||
|
run: |
|
||||||
|
/tmp/flux create source git test-libgit2 \
|
||||||
|
--url=ssh://git@github.com/fluxcd-testing/${{ steps.vars.outputs.test_repo_name }} \
|
||||||
|
--git-implementation=libgit2 \
|
||||||
|
--secret-ref=flux-system \
|
||||||
|
--branch=main
|
||||||
|
- name: uninstall
|
||||||
|
run: |
|
||||||
|
/tmp/flux uninstall -s --keep-namespace
|
||||||
|
kubectl delete ns flux-system --timeout=10m --wait=true
|
||||||
|
- name: test image automation
|
||||||
|
run: |
|
||||||
|
make setup-image-automation
|
||||||
|
/tmp/flux bootstrap github --manifests ./manifests/install/ \
|
||||||
|
--owner=fluxcd-testing \
|
||||||
|
--repository=${{ steps.vars.outputs.test_repo_name }} \
|
||||||
|
--branch=main \
|
||||||
|
--path=test-cluster \
|
||||||
|
--read-write-key
|
||||||
|
/tmp/flux reconcile image repository podinfo
|
||||||
|
/tmp/flux reconcile image update flux-system
|
||||||
|
/tmp/flux get images all
|
||||||
|
/tmp/flux get images policy podinfo | grep "5.2.1"
|
||||||
|
/tmp/flux get image update flux-system | grep commit
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITPROVIDER_BOT_TOKEN }}
|
||||||
|
GITHUB_REPO_NAME: ${{ steps.vars.outputs.test_repo_name }}
|
||||||
|
GITHUB_ORG_NAME: fluxcd-testing
|
||||||
|
- name: delete repository
|
||||||
|
run: |
|
||||||
|
curl \
|
||||||
|
-X DELETE \
|
||||||
|
-H "Accept: application/vnd.github.v3+json" \
|
||||||
|
-H "Authorization: token ${GITHUB_TOKEN}" \
|
||||||
|
--fail --silent \
|
||||||
|
https://api.github.com/repos/fluxcd-testing/${{ steps.vars.outputs.test_repo_name }}
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITPROVIDER_BOT_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITPROVIDER_BOT_TOKEN }}
|
||||||
- name: Debug failure
|
- name: Debug failure
|
||||||
if: failure()
|
if: failure()
|
||||||
run: |
|
run: |
|
||||||
kubectl -n gotk-system get all
|
kubectl -n flux-system get all
|
||||||
kubectl -n gotk-system logs deploy/source-controller
|
kubectl -n flux-system logs deploy/source-controller
|
||||||
kubectl -n gotk-system logs deploy/kustomize-controller
|
kubectl -n flux-system logs deploy/kustomize-controller
|
||||||
|
|||||||
65
.github/workflows/docs.yaml
vendored
65
.github/workflows/docs.yaml
vendored
@@ -1,65 +0,0 @@
|
|||||||
name: Publish docs via GitHub Pages
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- docs*
|
|
||||||
- main
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
name: Deploy docs
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout master
|
|
||||||
uses: actions/checkout@v1
|
|
||||||
- name: Copy assets
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
run: |
|
|
||||||
controller_version() {
|
|
||||||
sed -n "s/.*$1\/archive\/\(.*\).zip.*/\1/p;n" manifests/bases/$1/kustomization.yaml
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
# source-controller CRDs
|
|
||||||
SOURCE_VER=$(controller_version source-controller)
|
|
||||||
curl -# -Lf "https://raw.githubusercontent.com/fluxcd/source-controller/$SOURCE_VER/docs/api/source.md" > docs/components/source/api.md
|
|
||||||
curl -# -Lf "https://raw.githubusercontent.com/fluxcd/source-controller/$SOURCE_VER/docs/spec/v1beta1/gitrepositories.md" > docs/components/source/gitrepositories.md
|
|
||||||
curl -# -Lf "https://raw.githubusercontent.com/fluxcd/source-controller/$SOURCE_VER/docs/spec/v1beta1/helmrepositories.md" > docs/components/source/helmrepositories.md
|
|
||||||
curl -# -Lf "https://raw.githubusercontent.com/fluxcd/source-controller/$SOURCE_VER/docs/spec/v1beta1/helmcharts.md" > docs/components/source/helmcharts.md
|
|
||||||
curl -# -Lf "https://raw.githubusercontent.com/fluxcd/source-controller/$SOURCE_VER/docs/spec/v1beta1/buckets.md" > docs/components/source/buckets.md
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
# kustomize-controller CRDs
|
|
||||||
KUSTOMIZE_VER=$(controller_version kustomize-controller)
|
|
||||||
curl -# -Lf "https://raw.githubusercontent.com/fluxcd/kustomize-controller/$KUSTOMIZE_VER/docs/api/kustomize.md" > docs/components/kustomize/api.md
|
|
||||||
curl -# -Lf "https://raw.githubusercontent.com/fluxcd/kustomize-controller/$KUSTOMIZE_VER/docs/spec/v1beta1/kustomization.md" > docs/components/kustomize/kustomization.md
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
# helm-controller CRDs
|
|
||||||
HELM_VER=$(controller_version helm-controller)
|
|
||||||
curl -# -Lf "https://raw.githubusercontent.com/fluxcd/helm-controller/$HELM_VER/docs/api/helmrelease.md" > docs/components/helm/api.md
|
|
||||||
curl -# -Lf "https://raw.githubusercontent.com/fluxcd/helm-controller/$HELM_VER/docs/spec/v2beta1/helmreleases.md" > docs/components/helm/helmreleases.md
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
# notification-controller CRDs
|
|
||||||
NOTIFICATION_VER=$(controller_version notification-controller)
|
|
||||||
curl -# -Lf "https://raw.githubusercontent.com/fluxcd/notification-controller/$NOTIFICATION_VER/docs/api/notification.md" > docs/components/notification/api.md
|
|
||||||
curl -# -Lf "https://raw.githubusercontent.com/fluxcd/notification-controller/$NOTIFICATION_VER/docs/spec/v1beta1/event.md" > docs/components/notification/event.md
|
|
||||||
curl -# -Lf "https://raw.githubusercontent.com/fluxcd/notification-controller/$NOTIFICATION_VER/docs/spec/v1beta1/alert.md" > docs/components/notification/alert.md
|
|
||||||
curl -# -Lf "https://raw.githubusercontent.com/fluxcd/notification-controller/$NOTIFICATION_VER/docs/spec/v1beta1/provider.md" > docs/components/notification/provider.md
|
|
||||||
curl -# -Lf "https://raw.githubusercontent.com/fluxcd/notification-controller/$NOTIFICATION_VER/docs/spec/v1beta1/receiver.md" > docs/components/notification/receiver.md
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
# install script
|
|
||||||
cp install/gotk.sh docs/install.sh
|
|
||||||
}
|
|
||||||
- name: Deploy docs
|
|
||||||
uses: mhausenblas/mkdocs-deploy-gh-pages@master
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
CUSTOM_DOMAIN: toolkit.fluxcd.io
|
|
||||||
37
.github/workflows/e2e-arm64.yaml
vendored
Normal file
37
.github/workflows/e2e-arm64.yaml
vendored
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
name: e2e-arm64
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
branches: [ main, update-components, equinix-runners ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
# Hosted on Equinix
|
||||||
|
# Docs: https://github.com/fluxcd/flux2/tree/main/.github/runners
|
||||||
|
runs-on: [self-hosted, Linux, ARM64, equinix]
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Setup Go
|
||||||
|
uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: 1.16.x
|
||||||
|
- name: Prepare
|
||||||
|
id: prep
|
||||||
|
run: |
|
||||||
|
echo ::set-output name=CLUSTER::arm64-${GITHUB_SHA:0:7}-$(date +%s)
|
||||||
|
echo ::set-output name=CONTEXT::kind-arm64-${GITHUB_SHA:0:7}-$(date +%s)
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
make build
|
||||||
|
- name: Setup Kubernetes Kind
|
||||||
|
run: |
|
||||||
|
kind create cluster --name ${{ steps.prep.outputs.CLUSTER }} --kubeconfig=/tmp/${{ steps.prep.outputs.CLUSTER }}
|
||||||
|
- name: Run e2e tests
|
||||||
|
run: TEST_KUBECONFIG=/tmp/${{ steps.prep.outputs.CLUSTER }} make e2e
|
||||||
|
- name: Cleanup
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
kind delete cluster --name ${{ steps.prep.outputs.CLUSTER }}
|
||||||
|
rm /tmp/${{ steps.prep.outputs.CLUSTER }}
|
||||||
66
.github/workflows/e2e-azure.yaml
vendored
Normal file
66
.github/workflows/e2e-azure.yaml
vendored
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
name: e2e-azure
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 6 * * *'
|
||||||
|
push:
|
||||||
|
branches: [ azure* ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
e2e:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Restore Go cache
|
||||||
|
uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
path: ~/go/pkg/mod
|
||||||
|
key: ${{ runner.os }}-go1.16-${{ hashFiles('**/go.sum') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-go1.16-
|
||||||
|
- name: Setup Go
|
||||||
|
uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: 1.16.x
|
||||||
|
- name: Install libgit2
|
||||||
|
run: |
|
||||||
|
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 648ACFD622F3D138
|
||||||
|
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 0E98404D386FA1D9
|
||||||
|
echo "deb http://deb.debian.org/debian unstable main" | sudo tee -a /etc/apt/sources.list
|
||||||
|
echo "deb-src http://deb.debian.org/debian unstable main" | sudo tee -a /etc/apt/sources.list
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y --allow-downgrades libgit2-dev/unstable zlib1g-dev/unstable libssh2-1-dev/unstable libpcre3-dev/unstable
|
||||||
|
- name: Setup Flux CLI
|
||||||
|
run: |
|
||||||
|
make build
|
||||||
|
mkdir -p $HOME/.local/bin
|
||||||
|
mv ./bin/flux $HOME/.local/bin
|
||||||
|
- name: Setup SOPS
|
||||||
|
run: |
|
||||||
|
wget https://github.com/mozilla/sops/releases/download/v3.7.1/sops-v3.7.1.linux
|
||||||
|
chmod +x sops-v3.7.1.linux
|
||||||
|
mkdir -p $HOME/.local/bin
|
||||||
|
mv sops-v3.7.1.linux $HOME/.local/bin/sops
|
||||||
|
- name: Setup Terraform
|
||||||
|
uses: hashicorp/setup-terraform@v1
|
||||||
|
with:
|
||||||
|
terraform_version: 1.0.7
|
||||||
|
terraform_wrapper: false
|
||||||
|
- name: Setup Azure CLI
|
||||||
|
run: |
|
||||||
|
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
|
||||||
|
- name: Run Azure e2e tests
|
||||||
|
env:
|
||||||
|
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }}
|
||||||
|
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
|
||||||
|
ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }}
|
||||||
|
ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }}
|
||||||
|
run: |
|
||||||
|
echo $HOME
|
||||||
|
echo $PATH
|
||||||
|
ls $HOME/.local/bin
|
||||||
|
az login --service-principal -u ${ARM_CLIENT_ID} -p ${ARM_CLIENT_SECRET} -t ${ARM_TENANT_ID}
|
||||||
|
cd ./tests/azure
|
||||||
|
go test -v -coverprofile cover.out -timeout 60m .
|
||||||
208
.github/workflows/e2e.yaml
vendored
208
.github/workflows/e2e.yaml
vendored
@@ -1,10 +1,10 @@
|
|||||||
name: e2e
|
name: e2e
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
|
||||||
push:
|
push:
|
||||||
branches:
|
branches: [ main, e2e* ]
|
||||||
- main
|
pull_request:
|
||||||
|
branches: [ main ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
kind:
|
kind:
|
||||||
@@ -16,19 +16,33 @@ jobs:
|
|||||||
uses: actions/cache@v1
|
uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
path: ~/go/pkg/mod
|
path: ~/go/pkg/mod
|
||||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
key: ${{ runner.os }}-go1.16-${{ hashFiles('**/go.sum') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-go-
|
${{ runner.os }}-go1.16-
|
||||||
- name: Setup Go
|
- name: Setup Go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: 1.15.x
|
go-version: 1.16.x
|
||||||
- name: Setup Kubernetes
|
- name: Setup Kubernetes
|
||||||
uses: engineerd/setup-kind@v0.4.0
|
uses: engineerd/setup-kind@v0.5.0
|
||||||
with:
|
with:
|
||||||
image: kindest/node:v1.16.9
|
version: v0.11.1
|
||||||
- name: Run test
|
image: kindest/node:v1.19.11@sha256:07db187ae84b4b7de440a73886f008cf903fcf5764ba8106a9fd5243d6f32729
|
||||||
|
config: .github/kind/config.yaml # disable KIND-net
|
||||||
|
- name: Setup envtest
|
||||||
|
uses: fluxcd/pkg/actions/envtest@main
|
||||||
|
with:
|
||||||
|
version: "1.21.x"
|
||||||
|
- name: Setup Calico for network policy
|
||||||
|
run: |
|
||||||
|
kubectl apply -f https://docs.projectcalico.org/v3.20/manifests/calico.yaml
|
||||||
|
kubectl -n kube-system set env daemonset/calico-node FELIX_IGNORELOOSERPF=true
|
||||||
|
- name: Setup Kustomize
|
||||||
|
uses: fluxcd/pkg//actions/kustomize@main
|
||||||
|
- name: Run tests
|
||||||
run: make test
|
run: make test
|
||||||
|
- name: Run e2e tests
|
||||||
|
run: TEST_KUBECONFIG=$HOME/.kube/config make e2e
|
||||||
- name: Check if working tree is dirty
|
- name: Check if working tree is dirty
|
||||||
run: |
|
run: |
|
||||||
if [[ $(git diff --stat) != '' ]]; then
|
if [[ $(git diff --stat) != '' ]]; then
|
||||||
@@ -37,116 +51,166 @@ jobs:
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
- name: Build
|
- name: Build
|
||||||
run: sudo go build -o ./bin/gotk ./cmd/gotk
|
|
||||||
- name: gotk check --pre
|
|
||||||
run: |
|
run: |
|
||||||
./bin/gotk check --pre
|
go build -o /tmp/flux ./cmd/flux
|
||||||
- name: gotk install --manifests
|
- name: flux check --pre
|
||||||
run: |
|
run: |
|
||||||
./bin/gotk install --manifests ./manifests/install/
|
/tmp/flux check --pre
|
||||||
- name: gotk create source git
|
- name: flux install --manifests
|
||||||
run: |
|
run: |
|
||||||
./bin/gotk create source git podinfo \
|
/tmp/flux install --manifests ./manifests/install/
|
||||||
|
- name: flux create secret
|
||||||
|
run: |
|
||||||
|
/tmp/flux create secret git git-ssh-test \
|
||||||
|
--url ssh://git@github.com/stefanprodan/podinfo
|
||||||
|
/tmp/flux create secret git git-https-test \
|
||||||
|
--url https://github.com/stefanprodan/podinfo \
|
||||||
|
--username=test --password=test
|
||||||
|
/tmp/flux create secret helm helm-test \
|
||||||
|
--username=test --password=test
|
||||||
|
- name: flux create source git
|
||||||
|
run: |
|
||||||
|
/tmp/flux create source git podinfo \
|
||||||
--url https://github.com/stefanprodan/podinfo \
|
--url https://github.com/stefanprodan/podinfo \
|
||||||
--tag-semver=">=3.2.3"
|
--tag-semver=">=3.2.3"
|
||||||
- name: gotk create source git export apply
|
- name: flux create source git export apply
|
||||||
run: |
|
run: |
|
||||||
./bin/gotk create source git podinfo-export \
|
/tmp/flux create source git podinfo-export \
|
||||||
--url https://github.com/stefanprodan/podinfo \
|
--url https://github.com/stefanprodan/podinfo \
|
||||||
--tag-semver=">=3.2.3" \
|
--tag-semver=">=3.2.3" \
|
||||||
--export | kubectl apply -f -
|
--export | kubectl apply -f -
|
||||||
./bin/gotk delete source git podinfo-export --silent
|
/tmp/flux delete source git podinfo-export --silent
|
||||||
- name: gotk get sources git
|
- name: flux create source git libgit2 semver
|
||||||
run: |
|
run: |
|
||||||
./bin/gotk get sources git
|
/tmp/flux create source git podinfo-libgit2 \
|
||||||
- name: gotk get sources git --all-namespaces
|
--url https://github.com/stefanprodan/podinfo \
|
||||||
|
--tag-semver=">=3.2.3" \
|
||||||
|
--git-implementation=libgit2
|
||||||
|
/tmp/flux delete source git podinfo-libgit2 --silent
|
||||||
|
- name: flux get sources git
|
||||||
run: |
|
run: |
|
||||||
./bin/gotk get sources git --all-namespaces
|
/tmp/flux get sources git
|
||||||
- name: gotk create kustomization
|
- name: flux get sources git --all-namespaces
|
||||||
run: |
|
run: |
|
||||||
./bin/gotk create kustomization podinfo \
|
/tmp/flux get sources git --all-namespaces
|
||||||
|
- name: flux create kustomization
|
||||||
|
run: |
|
||||||
|
/tmp/flux create kustomization podinfo \
|
||||||
--source=podinfo \
|
--source=podinfo \
|
||||||
--path="./deploy/overlays/dev" \
|
--path="./deploy/overlays/dev" \
|
||||||
--prune=true \
|
--prune=true \
|
||||||
--interval=5m \
|
--interval=5m \
|
||||||
--validation=client \
|
|
||||||
--health-check="Deployment/frontend.dev" \
|
--health-check="Deployment/frontend.dev" \
|
||||||
--health-check="Deployment/backend.dev" \
|
--health-check="Deployment/backend.dev" \
|
||||||
--health-check-timeout=3m
|
--health-check-timeout=3m
|
||||||
- name: gotk reconcile kustomization --with-source
|
- name: flux trace
|
||||||
run: |
|
run: |
|
||||||
./bin/gotk reconcile kustomization podinfo --with-source
|
/tmp/flux trace frontend \
|
||||||
- name: gotk get kustomizations
|
--kind=deployment \
|
||||||
|
--api-version=apps/v1 \
|
||||||
|
--namespace=dev
|
||||||
|
- name: flux reconcile kustomization --with-source
|
||||||
run: |
|
run: |
|
||||||
./bin/gotk get kustomizations
|
/tmp/flux reconcile kustomization podinfo --with-source
|
||||||
- name: gotk get kustomizations --all-namespaces
|
- name: flux get kustomizations
|
||||||
run: |
|
run: |
|
||||||
./bin/gotk get kustomizations --all-namespaces
|
/tmp/flux get kustomizations
|
||||||
- name: gotk suspend kustomization
|
- name: flux get kustomizations --all-namespaces
|
||||||
run: |
|
run: |
|
||||||
./bin/gotk suspend kustomization podinfo
|
/tmp/flux get kustomizations --all-namespaces
|
||||||
- name: gotk resume kustomization
|
- name: flux suspend kustomization
|
||||||
run: |
|
run: |
|
||||||
./bin/gotk resume kustomization podinfo
|
/tmp/flux suspend kustomization podinfo
|
||||||
- name: gotk export
|
- name: flux resume kustomization
|
||||||
run: |
|
run: |
|
||||||
./bin/gotk export source git --all
|
/tmp/flux resume kustomization podinfo
|
||||||
./bin/gotk export kustomization --all
|
- name: flux export
|
||||||
- name: gotk delete kustomization
|
|
||||||
run: |
|
run: |
|
||||||
./bin/gotk delete kustomization podinfo --silent
|
/tmp/flux export source git --all
|
||||||
- name: gotk create source helm
|
/tmp/flux export kustomization --all
|
||||||
|
- name: flux delete kustomization
|
||||||
run: |
|
run: |
|
||||||
./bin/gotk create source helm podinfo \
|
/tmp/flux delete kustomization podinfo --silent
|
||||||
|
- name: flux create source helm
|
||||||
|
run: |
|
||||||
|
/tmp/flux create source helm podinfo \
|
||||||
--url https://stefanprodan.github.io/podinfo
|
--url https://stefanprodan.github.io/podinfo
|
||||||
- name: gotk create helmrelease --source=HelmRepository/podinfo
|
- name: flux create helmrelease --source=HelmRepository/podinfo
|
||||||
run: |
|
run: |
|
||||||
./bin/gotk create hr podinfo-helm \
|
/tmp/flux create hr podinfo-helm \
|
||||||
--target-namespace=default \
|
--target-namespace=default \
|
||||||
--source=HelmRepository/podinfo \
|
--source=HelmRepository/podinfo.flux-system \
|
||||||
--chart=podinfo \
|
--chart=podinfo \
|
||||||
--chart-version=">4.0.0 <5.0.0"
|
--chart-version=">4.0.0 <5.0.0"
|
||||||
- name: gotk create helmrelease --source=GitRepository/podinfo
|
- name: flux create helmrelease --source=GitRepository/podinfo
|
||||||
run: |
|
run: |
|
||||||
./bin/gotk create hr podinfo-git \
|
/tmp/flux create hr podinfo-git \
|
||||||
--target-namespace=default \
|
--target-namespace=default \
|
||||||
--source=GitRepository/podinfo \
|
--source=GitRepository/podinfo \
|
||||||
--chart=./charts/podinfo
|
--chart=./charts/podinfo
|
||||||
- name: gotk reconcile helmrelease --with-source
|
- name: flux reconcile helmrelease --with-source
|
||||||
run: |
|
run: |
|
||||||
./bin/gotk reconcile helmrelease podinfo-git --with-source
|
/tmp/flux reconcile helmrelease podinfo-git --with-source
|
||||||
- name: gotk get helmreleases
|
- name: flux get helmreleases
|
||||||
run: |
|
run: |
|
||||||
./bin/gotk get helmreleases
|
/tmp/flux get helmreleases
|
||||||
- name: gotk get helmreleases --all-namespaces
|
- name: flux get helmreleases --all-namespaces
|
||||||
run: |
|
run: |
|
||||||
./bin/gotk get helmreleases --all-namespaces
|
/tmp/flux get helmreleases --all-namespaces
|
||||||
- name: gotk export helmrelease
|
- name: flux export helmrelease
|
||||||
run: |
|
run: |
|
||||||
./bin/gotk export hr --all
|
/tmp/flux export hr --all
|
||||||
- name: gotk delete helmrelease podinfo-helm
|
- name: flux delete helmrelease podinfo-helm
|
||||||
run: |
|
run: |
|
||||||
./bin/gotk delete hr podinfo-helm --silent
|
/tmp/flux delete hr podinfo-helm --silent
|
||||||
- name: gotk delete helmrelease podinfo-git
|
- name: flux delete helmrelease podinfo-git
|
||||||
run: |
|
run: |
|
||||||
./bin/gotk delete hr podinfo-git --silent
|
/tmp/flux delete hr podinfo-git --silent
|
||||||
- name: gotk delete source helm
|
- name: flux delete source helm
|
||||||
run: |
|
run: |
|
||||||
./bin/gotk delete source helm podinfo --silent
|
/tmp/flux delete source helm podinfo --silent
|
||||||
- name: gotk delete source git
|
- name: flux delete source git
|
||||||
run: |
|
run: |
|
||||||
./bin/gotk delete source git podinfo --silent
|
/tmp/flux delete source git podinfo --silent
|
||||||
- name: gotk check
|
- name: flux create tenant
|
||||||
run: |
|
run: |
|
||||||
./bin/gotk check
|
/tmp/flux create tenant dev-team --with-namespace=apps
|
||||||
- name: gotk uninstall
|
/tmp/flux -n apps create source helm podinfo \
|
||||||
|
--url https://stefanprodan.github.io/podinfo
|
||||||
|
/tmp/flux -n apps create hr podinfo-helm \
|
||||||
|
--source=HelmRepository/podinfo \
|
||||||
|
--chart=podinfo \
|
||||||
|
--chart-version="5.0.x" \
|
||||||
|
--service-account=dev-team
|
||||||
|
- name: flux2-kustomize-helm-example
|
||||||
run: |
|
run: |
|
||||||
./bin/gotk uninstall --crds --silent
|
/tmp/flux create source git flux-system \
|
||||||
|
--url=https://github.com/fluxcd/flux2-kustomize-helm-example \
|
||||||
|
--branch=main \
|
||||||
|
--recurse-submodules
|
||||||
|
/tmp/flux create kustomization flux-system \
|
||||||
|
--source=flux-system \
|
||||||
|
--path=./clusters/staging
|
||||||
|
kubectl -n flux-system wait kustomization/infrastructure --for=condition=ready --timeout=5m
|
||||||
|
kubectl -n flux-system wait kustomization/apps --for=condition=ready --timeout=5m
|
||||||
|
kubectl -n nginx wait helmrelease/nginx --for=condition=ready --timeout=5m
|
||||||
|
kubectl -n redis wait helmrelease/redis --for=condition=ready --timeout=5m
|
||||||
|
kubectl -n podinfo wait helmrelease/podinfo --for=condition=ready --timeout=5m
|
||||||
|
- name: flux tree
|
||||||
|
run: |
|
||||||
|
/tmp/flux tree kustomization flux-system | grep Service/podinfo
|
||||||
|
- name: flux check
|
||||||
|
run: |
|
||||||
|
/tmp/flux check
|
||||||
|
- name: flux uninstall
|
||||||
|
run: |
|
||||||
|
/tmp/flux uninstall --silent
|
||||||
- name: Debug failure
|
- name: Debug failure
|
||||||
if: failure()
|
if: failure()
|
||||||
run: |
|
run: |
|
||||||
kubectl version --client --short
|
kubectl version --client --short
|
||||||
kubectl -n gotk-system get all
|
kubectl -n flux-system get all
|
||||||
kubectl -n gotk-system get kustomizations -oyaml
|
kubectl -n flux-system describe pods
|
||||||
kubectl -n gotk-system logs deploy/source-controller
|
kubectl -n flux-system get kustomizations -oyaml
|
||||||
kubectl -n gotk-system logs deploy/kustomize-controller
|
kubectl -n flux-system logs deploy/source-controller
|
||||||
|
kubectl -n flux-system logs deploy/kustomize-controller
|
||||||
|
|||||||
25
.github/workflows/fossa.yml
vendored
25
.github/workflows/fossa.yml
vendored
@@ -1,25 +0,0 @@
|
|||||||
name: FOSSA
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [main]
|
|
||||||
pull_request:
|
|
||||||
branches: [main]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: "^1.14.x"
|
|
||||||
- name: Add GOPATH to GITHUB_ENV
|
|
||||||
run: echo "GOPATH=$(go env GOPATH)" >>"$GITHUB_ENV"
|
|
||||||
- name: Add GOPATH to GITHUB_PATH
|
|
||||||
run: echo "$GOPATH/bin" >>"$GITHUB_PATH"
|
|
||||||
- name: Run FOSSA scan and upload build data
|
|
||||||
uses: fossa-contrib/fossa-action@v1
|
|
||||||
with:
|
|
||||||
# FOSSA Push-Only API Token
|
|
||||||
fossa-api-key: 5ee8bf422db1471e0bcf2bcb289185de
|
|
||||||
github-token: ${{ github.token }}
|
|
||||||
@@ -2,9 +2,9 @@ name: rebase
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
types: [opened]
|
types: [ opened ]
|
||||||
issue_comment:
|
issue_comment:
|
||||||
types: [created]
|
types: [ created ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
rebase:
|
rebase:
|
||||||
88
.github/workflows/release.yaml
vendored
88
.github/workflows/release.yaml
vendored
@@ -2,8 +2,7 @@ name: release
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags: [ 'v*' ]
|
||||||
- '*'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
goreleaser:
|
goreleaser:
|
||||||
@@ -16,7 +15,27 @@ jobs:
|
|||||||
- name: Setup Go
|
- name: Setup Go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: 1.15.x
|
go-version: 1.16.x
|
||||||
|
- name: Setup QEMU
|
||||||
|
uses: docker/setup-qemu-action@v1
|
||||||
|
with:
|
||||||
|
platforms: all
|
||||||
|
- name: Setup Docker Buildx
|
||||||
|
id: buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
with:
|
||||||
|
buildkitd-flags: "--debug"
|
||||||
|
- name: Login to GitHub Container Registry
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: fluxcdbot
|
||||||
|
password: ${{ secrets.GHCR_TOKEN }}
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
username: fluxcdbot
|
||||||
|
password: ${{ secrets.DOCKER_FLUXCD_PASSWORD }}
|
||||||
- name: Download release notes utility
|
- name: Download release notes utility
|
||||||
env:
|
env:
|
||||||
GH_REL_URL: https://github.com/buchanae/github-release-notes/releases/download/0.2.0/github-release-notes-linux-amd64-0.2.0.tar.gz
|
GH_REL_URL: https://github.com/buchanae/github-release-notes/releases/download/0.2.0/github-release-notes-linux-amd64-0.2.0.tar.gz
|
||||||
@@ -29,54 +48,24 @@ jobs:
|
|||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
- name: Setup Kustomize
|
- name: Setup Kustomize
|
||||||
uses: fluxcd/pkg//actions/kustomize@main
|
uses: fluxcd/pkg//actions/kustomize@main
|
||||||
- name: Generate manifests tarball
|
- name: Generate manifests
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ./output
|
make cmd/flux/.manifests.done
|
||||||
files=""
|
./manifests/scripts/bundle.sh "" ./output manifests.tar.gz
|
||||||
|
kustomize build ./manifests/install > ./output/install.yaml
|
||||||
# build controllers
|
- name: Build CRDs
|
||||||
for controller in ./manifests/bases/*/; do
|
run: |
|
||||||
output_path="./output/$(basename $controller).yaml"
|
kustomize build manifests/crds > all-crds.yaml
|
||||||
echo "building $controller to $output_path"
|
# Pinned to commit before https://github.com/fluxcd/pkg/pull/189 due to
|
||||||
|
# introduction faulty behavior.
|
||||||
kustomize build $controller > $output_path
|
- name: Generate OpenAPI JSON schemas from CRDs
|
||||||
files+=" $(basename $output_path)"
|
uses: fluxcd/pkg//actions/crdjsonschema@49e26aa2ee9e734c3233c560253fd9542afe18ae
|
||||||
done
|
|
||||||
|
|
||||||
# build rbac
|
|
||||||
rbac_path="./manifests/rbac"
|
|
||||||
rbac_output_path="./output/rbac.yaml"
|
|
||||||
echo "building $rbac_path to $rbac_output_path"
|
|
||||||
kustomize build $rbac_path > $rbac_output_path
|
|
||||||
files+=" $(basename $rbac_output_path)"
|
|
||||||
|
|
||||||
# build policies
|
|
||||||
policies_path="./manifests/policies"
|
|
||||||
policies_output_path="./output/policies.yaml"
|
|
||||||
echo "building $policies_path to $policies_output_path"
|
|
||||||
kustomize build $policies_path > $policies_output_path
|
|
||||||
files+=" $(basename $policies_output_path)"
|
|
||||||
|
|
||||||
# create tarball
|
|
||||||
cd ./output && tar -cvzf manifests.tar.gz $files
|
|
||||||
- name: Create release
|
|
||||||
id: create_release
|
|
||||||
uses: actions/create-release@latest
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ github.ref }}
|
crd: all-crds.yaml
|
||||||
release_name: ${{ github.ref }}
|
output: schemas
|
||||||
- name: Upload artifacts
|
- name: Archive the OpenAPI JSON schemas
|
||||||
id: upload-release-asset
|
run: |
|
||||||
uses: actions/upload-release-asset@v1
|
tar -czvf ./output/crd-schemas.tar.gz -C schemas .
|
||||||
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 +74,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 }}
|
||||||
|
|||||||
60
.github/workflows/scan.yaml
vendored
Normal file
60
.github/workflows/scan.yaml
vendored
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
name: Scan
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ main ]
|
||||||
|
schedule:
|
||||||
|
- cron: '18 10 * * 3'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
fossa:
|
||||||
|
name: FOSSA
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Run FOSSA scan and upload build data
|
||||||
|
uses: fossa-contrib/fossa-action@v1
|
||||||
|
with:
|
||||||
|
# FOSSA Push-Only API Token
|
||||||
|
fossa-api-key: 5ee8bf422db1471e0bcf2bcb289185de
|
||||||
|
github-token: ${{ github.token }}
|
||||||
|
|
||||||
|
snyk:
|
||||||
|
name: Snyk
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Setup Kustomize
|
||||||
|
uses: fluxcd/pkg//actions/kustomize@main
|
||||||
|
- name: Build manifests
|
||||||
|
run: |
|
||||||
|
make cmd/flux/.manifests.done
|
||||||
|
- name: Run Snyk to check for vulnerabilities
|
||||||
|
uses: snyk/actions/golang@master
|
||||||
|
continue-on-error: true
|
||||||
|
env:
|
||||||
|
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
|
||||||
|
with:
|
||||||
|
args: --sarif-file-output=snyk.sarif
|
||||||
|
- name: Upload result to GitHub Code Scanning
|
||||||
|
uses: github/codeql-action/upload-sarif@v1
|
||||||
|
with:
|
||||||
|
sarif_file: snyk.sarif
|
||||||
|
|
||||||
|
codeql:
|
||||||
|
name: CodeQL
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Initialize CodeQL
|
||||||
|
uses: github/codeql-action/init@v1
|
||||||
|
with:
|
||||||
|
languages: go
|
||||||
|
- name: Autobuild
|
||||||
|
uses: github/codeql-action/autobuild@v1
|
||||||
|
- name: Perform CodeQL Analysis
|
||||||
|
uses: github/codeql-action/analyze@v1
|
||||||
94
.github/workflows/update.yaml
vendored
Normal file
94
.github/workflows/update.yaml
vendored
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
name: Update Components
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
schedule:
|
||||||
|
- cron: "0 * * * *"
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update-components:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Setup Go
|
||||||
|
uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: 1.16.x
|
||||||
|
- name: Update component versions
|
||||||
|
id: update
|
||||||
|
run: |
|
||||||
|
PR_BODY=""
|
||||||
|
|
||||||
|
bump_version() {
|
||||||
|
local LATEST_VERSION=$(curl -s https://api.github.com/repos/fluxcd/$1/releases | jq -r 'sort_by(.published_at) | .[-1] | .tag_name')
|
||||||
|
local CTRL_VERSION=$(sed -n "s/.*$1\/releases\/download\/\(.*\)\/.*/\1/p;n" manifests/bases/$1/kustomization.yaml)
|
||||||
|
local CRD_VERSION=$(sed -n "s/.*$1\/releases\/download\/\(.*\)\/.*/\1/p" manifests/crds/kustomization.yaml)
|
||||||
|
local MOD_VERSION=$(go list -m -f '{{ .Version }}' "github.com/fluxcd/$1/api")
|
||||||
|
|
||||||
|
local changed=false
|
||||||
|
|
||||||
|
if [[ "${CTRL_VERSION}" != "${LATEST_VERSION}" ]]; then
|
||||||
|
sed -i "s/\($1\/releases\/download\/\)v.*\(\/.*\)/\1${LATEST_VERSION}\2/g" "manifests/bases/$1/kustomization.yaml"
|
||||||
|
changed=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${CRD_VERSION}" != "${LATEST_VERSION}" ]]; then
|
||||||
|
sed -i "s/\($1\/releases\/download\/\)v.*\(\/.*\)/\1${LATEST_VERSION}\2/g" "manifests/crds/kustomization.yaml"
|
||||||
|
changed=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${MOD_VERSION}" != "${LATEST_VERSION}" ]]; then
|
||||||
|
go mod edit -require="github.com/fluxcd/$1/api@${LATEST_VERSION}"
|
||||||
|
rm go.sum
|
||||||
|
go mod tidy
|
||||||
|
changed=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$changed" == true ]]; then
|
||||||
|
PR_BODY="$PR_BODY- $1 to ${LATEST_VERSION}%0A https://github.com/fluxcd/$1/blob/${LATEST_VERSION}/CHANGELOG.md%0A"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
# bump controller versions
|
||||||
|
bump_version helm-controller
|
||||||
|
bump_version kustomize-controller
|
||||||
|
bump_version source-controller
|
||||||
|
bump_version notification-controller
|
||||||
|
bump_version image-reflector-controller
|
||||||
|
bump_version image-automation-controller
|
||||||
|
|
||||||
|
# diff change
|
||||||
|
git diff
|
||||||
|
|
||||||
|
# export PR_BODY for PR and commit
|
||||||
|
echo "::set-output name=pr_body::$PR_BODY"
|
||||||
|
}
|
||||||
|
|
||||||
|
- name: Create Pull Request
|
||||||
|
id: cpr
|
||||||
|
uses: peter-evans/create-pull-request@v3
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.BOT_GITHUB_TOKEN }}
|
||||||
|
commit-message: |
|
||||||
|
Update toolkit components
|
||||||
|
|
||||||
|
${{ steps.update.outputs.pr_body }}
|
||||||
|
committer: GitHub <noreply@github.com>
|
||||||
|
author: fluxcdbot <fluxcdbot@users.noreply.github.com>
|
||||||
|
signoff: true
|
||||||
|
branch: update-components
|
||||||
|
title: Update toolkit components
|
||||||
|
body: |
|
||||||
|
${{ steps.update.outputs.pr_body }}
|
||||||
|
labels: |
|
||||||
|
area/build
|
||||||
|
reviewers: ${{ secrets.ASSIGNEES }}
|
||||||
|
|
||||||
|
- name: Check output
|
||||||
|
run: |
|
||||||
|
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
|
||||||
|
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
|
||||||
74
.github/workflows/update.yml
vendored
74
.github/workflows/update.yml
vendored
@@ -1,74 +0,0 @@
|
|||||||
name: Update Components
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
schedule:
|
|
||||||
- cron: "0 * * * *"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
update-components:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Check out code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Update component versions
|
|
||||||
id: update
|
|
||||||
run: |
|
|
||||||
PR_BODY=""
|
|
||||||
|
|
||||||
bump_version() {
|
|
||||||
local RELEASE_VERSION=$(curl -s https://api.github.com/repos/fluxcd/$1/releases | jq -r 'sort_by(.published_at) | .[-1] | .tag_name')
|
|
||||||
local CURRENT_VERSION=$(sed -n "s/.*$1\/archive\/\(.*\).zip.*/\1/p;n" manifests/bases/$1/kustomization.yaml)
|
|
||||||
|
|
||||||
if [[ "${RELEASE_VERSION}" != "${CURRENT_VERSION}" ]]; then
|
|
||||||
# bump kustomize
|
|
||||||
sed -i "s/\($1\/archive\/\)v.*\(.zip\/\/$1-\).*\(\/config.*\)/\1${RELEASE_VERSION}\2${RELEASE_VERSION/v}\3/g" "manifests/bases/$1/kustomization.yaml"
|
|
||||||
|
|
||||||
if [[ ! -z $(go list -m all | grep "github.com/fluxcd/$1/api" | awk '{print $2}') ]]; then
|
|
||||||
# bump go mod
|
|
||||||
go mod edit -require="github.com/fluxcd/$1/api@${RELEASE_VERSION}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
PR_BODY="$PR_BODY- $1 to ${RELEASE_VERSION}%0A"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
# bump controller versions
|
|
||||||
bump_version helm-controller
|
|
||||||
bump_version kustomize-controller
|
|
||||||
bump_version source-controller
|
|
||||||
bump_version notification-controller
|
|
||||||
|
|
||||||
# add missing and remove unused modules
|
|
||||||
go mod tidy
|
|
||||||
|
|
||||||
# diff change
|
|
||||||
git diff
|
|
||||||
|
|
||||||
# export PR_BODY for PR
|
|
||||||
echo "::set-output name=pr_body::$PR_BODY"
|
|
||||||
}
|
|
||||||
|
|
||||||
- name: Create Pull Request
|
|
||||||
id: cpr
|
|
||||||
uses: peter-evans/create-pull-request@v3
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.BOT_GITHUB_TOKEN }}
|
|
||||||
commit-message: Update toolkit components
|
|
||||||
committer: GitHub <noreply@github.com>
|
|
||||||
author: fluxcdbot <fluxcdbot@users.noreply.github.com>
|
|
||||||
title: Update toolkit components
|
|
||||||
body: |
|
|
||||||
${{ steps.update.outputs.pr_body }}
|
|
||||||
|
|
||||||
Auto-generated by [create-pull-request][1]
|
|
||||||
|
|
||||||
[1]: https://github.com/peter-evans/create-pull-request
|
|
||||||
branch: update-components
|
|
||||||
reviewers: ${{ secrets.ASSIGNEES }}
|
|
||||||
|
|
||||||
- name: Check output
|
|
||||||
run: |
|
|
||||||
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
|
|
||||||
10
.gitignore
vendored
10
.gitignore
vendored
@@ -11,7 +11,15 @@
|
|||||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||||
*.out
|
*.out
|
||||||
|
|
||||||
|
# Release
|
||||||
|
dist/
|
||||||
|
|
||||||
# Dependency directories (remove the comment below to include it)
|
# Dependency directories (remove the comment below to include it)
|
||||||
# vendor/
|
# vendor/
|
||||||
bin/
|
bin/
|
||||||
output/
|
output/
|
||||||
|
cmd/flux/manifests/
|
||||||
|
cmd/flux/.manifests.done
|
||||||
|
|
||||||
|
# Docs
|
||||||
|
site/
|
||||||
|
|||||||
141
.goreleaser.yml
141
.goreleaser.yml
@@ -1,35 +1,146 @@
|
|||||||
|
project_name: flux
|
||||||
builds:
|
builds:
|
||||||
- main: ./cmd/gotk
|
- <<: &build_defaults
|
||||||
ldflags:
|
binary: flux
|
||||||
- -s -w -X main.VERSION={{ .Version }}
|
main: ./cmd/flux
|
||||||
binary: gotk
|
ldflags:
|
||||||
|
- -s -w -X main.VERSION={{ .Version }}
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=0
|
||||||
|
id: linux
|
||||||
goos:
|
goos:
|
||||||
- darwin
|
|
||||||
- linux
|
- linux
|
||||||
- windows
|
|
||||||
goarch:
|
goarch:
|
||||||
- amd64
|
- amd64
|
||||||
- arm64
|
- arm64
|
||||||
- arm
|
- arm
|
||||||
goarm:
|
goarm:
|
||||||
- 7
|
- 7
|
||||||
env:
|
- <<: *build_defaults
|
||||||
- CGO_ENABLED=0
|
id: darwin
|
||||||
|
goos:
|
||||||
|
- darwin
|
||||||
|
goarch:
|
||||||
|
- amd64
|
||||||
|
- arm64
|
||||||
|
- <<: *build_defaults
|
||||||
|
id: windows
|
||||||
|
goos:
|
||||||
|
- windows
|
||||||
archives:
|
archives:
|
||||||
- name_template: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
|
- name_template: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
|
||||||
|
id: nix
|
||||||
|
builds: [linux, darwin]
|
||||||
|
format: tar.gz
|
||||||
|
files:
|
||||||
|
- none*
|
||||||
|
- name_template: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
|
||||||
|
id: windows
|
||||||
|
builds: [windows]
|
||||||
|
format: zip
|
||||||
files:
|
files:
|
||||||
- none*
|
- none*
|
||||||
brews:
|
brews:
|
||||||
- name: gotk
|
- name: flux
|
||||||
tap:
|
tap:
|
||||||
owner: fluxcd
|
owner: fluxcd
|
||||||
name: homebrew-tap
|
name: homebrew-tap
|
||||||
token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}"
|
token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}"
|
||||||
folder: Formula
|
folder: Formula
|
||||||
homepage: "https://toolkit.fluxcd.io/"
|
homepage: "https://fluxcd.io/"
|
||||||
description: "GitOps Toolkit CLI"
|
description: "Flux CLI"
|
||||||
dependencies:
|
install: |
|
||||||
- name: kubectl
|
bin.install "flux"
|
||||||
type: optional
|
|
||||||
|
bash_output = Utils.safe_popen_read(bin/"flux", "completion", "bash")
|
||||||
|
(bash_completion/"flux").write bash_output
|
||||||
|
|
||||||
|
zsh_output = Utils.safe_popen_read(bin/"flux", "completion", "zsh")
|
||||||
|
(zsh_completion/"_flux").write zsh_output
|
||||||
|
|
||||||
|
fish_output = Utils.safe_popen_read(bin/"flux", "completion", "fish")
|
||||||
|
(fish_completion/"flux.fish").write fish_output
|
||||||
test: |
|
test: |
|
||||||
system "#{bin}/gotk --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/crd-schemas.tar.gz
|
||||||
|
- glob: ./output/manifests.tar.gz
|
||||||
|
- glob: ./output/install.yaml
|
||||||
|
dockers:
|
||||||
|
- image_templates:
|
||||||
|
- 'fluxcd/flux-cli:{{ .Tag }}-amd64'
|
||||||
|
- 'ghcr.io/fluxcd/flux-cli:{{ .Tag }}-amd64'
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
use_buildx: true
|
||||||
|
goos: linux
|
||||||
|
goarch: amd64
|
||||||
|
build_flag_templates:
|
||||||
|
- "--pull"
|
||||||
|
- "--build-arg=ARCH=linux/amd64"
|
||||||
|
- "--label=org.opencontainers.image.created={{ .Date }}"
|
||||||
|
- "--label=org.opencontainers.image.name={{ .ProjectName }}"
|
||||||
|
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"
|
||||||
|
- "--label=org.opencontainers.image.version={{ .Version }}"
|
||||||
|
- "--label=org.opencontainers.image.source={{ .GitURL }}"
|
||||||
|
- "--platform=linux/amd64"
|
||||||
|
- image_templates:
|
||||||
|
- 'fluxcd/flux-cli:{{ .Tag }}-arm64'
|
||||||
|
- 'ghcr.io/fluxcd/flux-cli:{{ .Tag }}-arm64'
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
use_buildx: true
|
||||||
|
goos: linux
|
||||||
|
goarch: arm64
|
||||||
|
build_flag_templates:
|
||||||
|
- "--pull"
|
||||||
|
- "--build-arg=ARCH=linux/arm64"
|
||||||
|
- "--label=org.opencontainers.image.created={{ .Date }}"
|
||||||
|
- "--label=org.opencontainers.image.name={{ .ProjectName }}"
|
||||||
|
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"
|
||||||
|
- "--label=org.opencontainers.image.version={{ .Version }}"
|
||||||
|
- "--label=org.opencontainers.image.source={{ .GitURL }}"
|
||||||
|
- "--platform=linux/arm64"
|
||||||
|
- image_templates:
|
||||||
|
- 'fluxcd/flux-cli:{{ .Tag }}-arm'
|
||||||
|
- 'ghcr.io/fluxcd/flux-cli:{{ .Tag }}-arm'
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
use_buildx: true
|
||||||
|
goos: linux
|
||||||
|
goarch: arm
|
||||||
|
goarm: 7
|
||||||
|
build_flag_templates:
|
||||||
|
- "--pull"
|
||||||
|
- "--build-arg=ARCH=linux/arm"
|
||||||
|
- "--label=org.opencontainers.image.created={{ .Date }}"
|
||||||
|
- "--label=org.opencontainers.image.name={{ .ProjectName }}"
|
||||||
|
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"
|
||||||
|
- "--label=org.opencontainers.image.version={{ .Version }}"
|
||||||
|
- "--label=org.opencontainers.image.source={{ .GitURL }}"
|
||||||
|
- "--platform=linux/arm/v7"
|
||||||
|
docker_manifests:
|
||||||
|
- name_template: 'fluxcd/flux-cli:{{ .Tag }}'
|
||||||
|
image_templates:
|
||||||
|
- 'fluxcd/flux-cli:{{ .Tag }}-amd64'
|
||||||
|
- 'fluxcd/flux-cli:{{ .Tag }}-arm64'
|
||||||
|
- 'fluxcd/flux-cli:{{ .Tag }}-arm'
|
||||||
|
- name_template: 'ghcr.io/fluxcd/flux-cli:{{ .Tag }}'
|
||||||
|
image_templates:
|
||||||
|
- 'ghcr.io/fluxcd/flux-cli:{{ .Tag }}-amd64'
|
||||||
|
- 'ghcr.io/fluxcd/flux-cli:{{ .Tag }}-arm64'
|
||||||
|
- 'ghcr.io/fluxcd/flux-cli:{{ .Tag }}-arm'
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
# Contributing
|
# Contributing
|
||||||
|
|
||||||
The GitOps Toolkit is [Apache 2.0 licensed](https://github.com/fluxcd/toolkit/blob/master/LICENSE)
|
Flux is [Apache 2.0 licensed](https://github.com/fluxcd/flux2/blob/main/LICENSE) and
|
||||||
and accepts contributions via GitHub pull requests. This document outlines
|
accepts contributions via GitHub pull requests. This document outlines
|
||||||
some of the conventions on to make it easier to get your contribution accepted.
|
some of the conventions on to make it easier to get your contribution
|
||||||
|
accepted.
|
||||||
|
|
||||||
We gratefully welcome improvements to issues and documentation as well as to
|
We gratefully welcome improvements to issues and documentation as well as to
|
||||||
code.
|
code.
|
||||||
@@ -12,18 +13,27 @@ code.
|
|||||||
By contributing to this project you agree to the Developer Certificate of
|
By contributing to this project you agree to the Developer Certificate of
|
||||||
Origin (DCO). This document was created by the Linux Kernel community and is a
|
Origin (DCO). This document was created by the Linux Kernel community and is a
|
||||||
simple statement that you, as a contributor, have the legal right to make the
|
simple statement that you, as a contributor, have the legal right to make the
|
||||||
contribution. No action from you is required, but it's a good idea to see the
|
contribution.
|
||||||
[DCO](DCO) file for details before you start contributing code to FluxCD
|
|
||||||
organization.
|
We require all commits to be signed. By signing off with your signature, you
|
||||||
|
certify that you wrote the patch or otherwise have the right to contribute the
|
||||||
|
material by the rules of the [DCO](DCO):
|
||||||
|
|
||||||
|
`Signed-off-by: Jane Doe <jane.doe@example.com>`
|
||||||
|
|
||||||
|
The signature must contain your real name
|
||||||
|
(sorry, no pseudonyms or anonymous contributions)
|
||||||
|
If your `user.name` and `user.email` are configured in your Git config,
|
||||||
|
you can sign your commit automatically with `git commit -s`.
|
||||||
|
|
||||||
## Communications
|
## Communications
|
||||||
|
|
||||||
For realtime communications we use Slack: To join the conversation, simply
|
For realtime communications we use Slack: To join the conversation, simply
|
||||||
join the [CNCF](https://slack.cncf.io/) Slack workspace and use the
|
join the [CNCF](https://slack.cncf.io/) Slack workspace and use the
|
||||||
[#flux-dev](https://cloud-native.slack.com/messages/flux-dev/) channel.
|
[#flux-contributors](https://cloud-native.slack.com/messages/flux-contributors/) channel.
|
||||||
|
|
||||||
To discuss ideas and specifications we use [Github
|
To discuss ideas and specifications we use [Github
|
||||||
Discussions](https://github.com/fluxcd/toolkit/discussions).
|
Discussions](https://github.com/fluxcd/flux2/discussions).
|
||||||
|
|
||||||
For announcements we use a mailing list as well. Simply subscribe to
|
For announcements we use a mailing list as well. Simply subscribe to
|
||||||
[flux-dev on cncf.io](https://lists.cncf.io/g/cncf-flux-dev)
|
[flux-dev on cncf.io](https://lists.cncf.io/g/cncf-flux-dev)
|
||||||
@@ -31,34 +41,67 @@ to join the conversation (there you can also add calendar invites
|
|||||||
to your Google calendar for our [Flux
|
to your Google calendar for our [Flux
|
||||||
meeting](https://docs.google.com/document/d/1l_M0om0qUEN_NNiGgpqJ2tvsF2iioHkaARDeh6b70B0/view)).
|
meeting](https://docs.google.com/document/d/1l_M0om0qUEN_NNiGgpqJ2tvsF2iioHkaARDeh6b70B0/view)).
|
||||||
|
|
||||||
## Understanding the GitOps Toolkit
|
## Understanding Flux and the GitOps Toolkit
|
||||||
|
|
||||||
If you are entirely new to the GitOps Toolkit,
|
If you are entirely new to Flux and the GitOps Toolkit,
|
||||||
you might want to take a look at the [introductory talk and demo](https://www.youtube.com/watch?v=qQBtSkgl7tI).
|
you might want to take a look at the [introductory talk and demo](https://www.youtube.com/watch?v=qQBtSkgl7tI).
|
||||||
|
|
||||||
This project is composed of:
|
This project is composed of:
|
||||||
|
|
||||||
- [/f/toolkit](https://github.com/fluxcd/toolkit): The GitOps Toolkit CLI
|
- [flux2](https://github.com/fluxcd/flux2): The Flux CLI
|
||||||
- [/f/source-manager](https://github.com/fluxcd/source-controller): Kubernetes operator for managing sources
|
- [source-manager](https://github.com/fluxcd/source-controller): Kubernetes operator for managing sources (Git and Helm repositories, S3-compatible Buckets)
|
||||||
- [/f/kustomize-controller](https://github.com/fluxcd/kustomize-controller): Kubernetes operator for building GitOps pipelines with Kustomize
|
- [kustomize-controller](https://github.com/fluxcd/kustomize-controller): Kubernetes operator for building GitOps pipelines with Kustomize
|
||||||
- [/f/helm-controller](https://github.com/fluxcd/helm-controller): Kubernetes operator for building GitOps pipelines with Helm
|
- [helm-controller](https://github.com/fluxcd/helm-controller): Kubernetes operator for building GitOps pipelines with Helm
|
||||||
- [/f/notification-controller](https://github.com/fluxcd/notification-controller): Kubernetes operator for handling inbound and outbound events
|
- [notification-controller](https://github.com/fluxcd/notification-controller): Kubernetes operator for handling inbound and outbound events
|
||||||
|
- [image-reflector-controller](https://github.com/fluxcd/image-reflector-controller): Kubernetes operator for scanning container registries
|
||||||
|
- [image-automation-controller](https://github.com/fluxcd/image-automation-controller): Kubernetes operator for patches container image tags in Git
|
||||||
|
|
||||||
### Understanding the code
|
### Understanding the code
|
||||||
|
|
||||||
To get started with developing controllers, you might want to review
|
To get started with developing controllers, you might want to review
|
||||||
[our guide](https://toolkit.fluxcd.io/dev-guides/source-watcher/) which
|
[our guide](https://fluxcd.io/docs/gitops-toolkit/source-watcher/) which
|
||||||
walks you through writing a short and concise controller that watches out
|
walks you through writing a short and concise controller that watches out
|
||||||
for source changes.
|
for source changes.
|
||||||
|
|
||||||
### How to run the test suite
|
## How to run the test suite
|
||||||
|
|
||||||
You can run the unit tests by simply doing
|
Prerequisites:
|
||||||
|
|
||||||
|
* go >= 1.16
|
||||||
|
* kubectl >= 1.19
|
||||||
|
* kustomize >= 4.0
|
||||||
|
|
||||||
|
Install the [controller-runtime/envtest](https://github.com/kubernetes-sigs/controller-runtime/tree/master/tools/setup-envtest) binaries with:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make install-envtest
|
||||||
|
```
|
||||||
|
|
||||||
|
Then you can run the unit tests with:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
make test
|
make test
|
||||||
```
|
```
|
||||||
|
|
||||||
|
After [installing Kubernetes kind](https://kind.sigs.k8s.io/docs/user/quick-start#installation) on your machine,
|
||||||
|
create a cluster for testing with:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make setup-kind
|
||||||
|
```
|
||||||
|
|
||||||
|
Then you can run the end-to-end tests with:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make e2e
|
||||||
|
```
|
||||||
|
|
||||||
|
Teardown the e2e environment with:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make cleanup-kind
|
||||||
|
```
|
||||||
|
|
||||||
## Acceptance policy
|
## Acceptance policy
|
||||||
|
|
||||||
These things will make a PR more likely to be accepted:
|
These things will make a PR more likely to be accepted:
|
||||||
|
|||||||
23
Dockerfile
Normal file
23
Dockerfile
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
FROM alpine:3.14 as builder
|
||||||
|
|
||||||
|
RUN apk add --no-cache ca-certificates curl
|
||||||
|
|
||||||
|
ARG ARCH=linux/amd64
|
||||||
|
ARG KUBECTL_VER=1.22.2
|
||||||
|
|
||||||
|
RUN curl -sL https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VER}/bin/${ARCH}/kubectl \
|
||||||
|
-o /usr/local/bin/kubectl && chmod +x /usr/local/bin/kubectl && \
|
||||||
|
kubectl version --client=true
|
||||||
|
|
||||||
|
FROM alpine:3.14 as flux-cli
|
||||||
|
|
||||||
|
# Create minimal nsswitch.conf file to prioritize the usage of /etc/hosts over DNS queries.
|
||||||
|
# https://github.com/gliderlabs/docker-alpine/issues/367#issuecomment-354316460
|
||||||
|
RUN [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf
|
||||||
|
|
||||||
|
RUN apk add --no-cache ca-certificates
|
||||||
|
|
||||||
|
COPY --from=builder /usr/local/bin/kubectl /usr/local/bin/
|
||||||
|
COPY --chmod=755 flux /usr/local/bin/
|
||||||
|
|
||||||
|
ENTRYPOINT [ "flux" ]
|
||||||
12
MAINTAINERS
12
MAINTAINERS
@@ -2,7 +2,19 @@ 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, NexHealth <aurel.canciu@nexhealth.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)
|
||||||
|
Max Jonas Werner, D2iQ <max@e13.dev> (github: @makkes, slack: max)
|
||||||
|
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)
|
||||||
|
Sunny, Weaveworks <sunny@weave.works> (github: @darkowlzz, slack: darkowlzz)
|
||||||
|
|||||||
78
Makefile
78
Makefile
@@ -1,4 +1,17 @@
|
|||||||
VERSION?=$(shell grep 'VERSION' cmd/gotk/main.go | awk '{ print $$4 }' | tr -d '"')
|
VERSION?=$(shell grep 'VERSION' cmd/flux/main.go | awk '{ print $$4 }' | head -n 1 | tr -d '"')
|
||||||
|
EMBEDDED_MANIFESTS_TARGET=cmd/flux/.manifests.done
|
||||||
|
TEST_KUBECONFIG?=/tmp/flux-e2e-test-kubeconfig
|
||||||
|
ENVTEST_BIN_VERSION?=latest
|
||||||
|
KUBEBUILDER_ASSETS?=$(shell $(SETUP_ENVTEST) use -i $(ENVTEST_BIN_VERSION) -p path)
|
||||||
|
|
||||||
|
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
|
||||||
|
ifeq (,$(shell go env GOBIN))
|
||||||
|
GOBIN=$(shell go env GOPATH)/bin
|
||||||
|
else
|
||||||
|
GOBIN=$(shell go env GOBIN)
|
||||||
|
endif
|
||||||
|
|
||||||
|
rwildcard=$(foreach d,$(wildcard $(addsuffix *,$(1))),$(call rwildcard,$(d)/,$(2)) $(filter $(subst *,%,$(2)),$(d)))
|
||||||
|
|
||||||
all: test build
|
all: test build
|
||||||
|
|
||||||
@@ -11,18 +24,61 @@ fmt:
|
|||||||
vet:
|
vet:
|
||||||
go vet ./...
|
go vet ./...
|
||||||
|
|
||||||
test: tidy fmt vet docs
|
setup-kind:
|
||||||
go test ./... -coverprofile cover.out
|
kind create cluster --name=flux-e2e-test --kubeconfig=$(TEST_KUBECONFIG) --config=.github/kind/config.yaml
|
||||||
|
kubectl --kubeconfig=$(TEST_KUBECONFIG) apply -f https://docs.projectcalico.org/v3.16/manifests/calico.yaml
|
||||||
|
kubectl --kubeconfig=$(TEST_KUBECONFIG) -n kube-system set env daemonset/calico-node FELIX_IGNORELOOSERPF=true
|
||||||
|
|
||||||
build:
|
cleanup-kind:
|
||||||
CGO_ENABLED=0 go build -o ./bin/gotk ./cmd/gotk
|
kind delete cluster --name=flux-e2e-test
|
||||||
|
rm $(TEST_KUBECONFIG)
|
||||||
|
|
||||||
|
test: $(EMBEDDED_MANIFESTS_TARGET) tidy fmt vet install-envtest
|
||||||
|
KUBEBUILDER_ASSETS="$(KUBEBUILDER_ASSETS)" go test ./... -coverprofile cover.out --tags=unit
|
||||||
|
|
||||||
|
e2e: $(EMBEDDED_MANIFESTS_TARGET) tidy fmt vet
|
||||||
|
TEST_KUBECONFIG=$(TEST_KUBECONFIG) go test ./cmd/flux/... -coverprofile e2e.cover.out --tags=e2e -v -failfast
|
||||||
|
|
||||||
|
test-with-kind: install-envtest
|
||||||
|
make setup-kind
|
||||||
|
make e2e
|
||||||
|
make cleanup-kind
|
||||||
|
|
||||||
|
$(EMBEDDED_MANIFESTS_TARGET): $(call rwildcard,manifests/,*.yaml *.json)
|
||||||
|
./manifests/scripts/bundle.sh
|
||||||
|
touch $@
|
||||||
|
|
||||||
|
build: $(EMBEDDED_MANIFESTS_TARGET)
|
||||||
|
CGO_ENABLED=0 go build -ldflags="-s -w -X main.VERSION=$(VERSION)" -o ./bin/flux ./cmd/flux
|
||||||
|
|
||||||
|
.PHONY: install
|
||||||
install:
|
install:
|
||||||
go install cmd/gotk
|
CGO_ENABLED=0 go install ./cmd/flux
|
||||||
|
|
||||||
.PHONY: docs
|
|
||||||
docs:
|
|
||||||
mkdir -p ./docs/cmd && go run ./cmd/gotk/ docgen
|
|
||||||
|
|
||||||
install-dev:
|
install-dev:
|
||||||
CGO_ENABLED=0 go build -o /usr/local/bin ./cmd/gotk
|
CGO_ENABLED=0 go build -o /usr/local/bin ./cmd/flux
|
||||||
|
|
||||||
|
install-envtest: setup-envtest
|
||||||
|
$(SETUP_ENVTEST) use $(ENVTEST_BIN_VERSION)
|
||||||
|
|
||||||
|
setup-bootstrap-patch:
|
||||||
|
go run ./tests/bootstrap/main.go
|
||||||
|
|
||||||
|
setup-image-automation:
|
||||||
|
cd tests/image-automation && go run main.go
|
||||||
|
|
||||||
|
# Find or download setup-envtest
|
||||||
|
setup-envtest:
|
||||||
|
ifeq (, $(shell which setup-envtest))
|
||||||
|
@{ \
|
||||||
|
set -e ;\
|
||||||
|
SETUP_ENVTEST_TMP_DIR=$$(mktemp -d) ;\
|
||||||
|
cd $$SETUP_ENVTEST_TMP_DIR ;\
|
||||||
|
go mod init tmp ;\
|
||||||
|
go get sigs.k8s.io/controller-runtime/tools/setup-envtest@latest ;\
|
||||||
|
rm -rf $$SETUP_ENVTEST_TMP_DIR ;\
|
||||||
|
}
|
||||||
|
SETUP_ENVTEST=$(GOBIN)/setup-envtest
|
||||||
|
else
|
||||||
|
SETUP_ENVTEST=$(shell which setup-envtest)
|
||||||
|
endif
|
||||||
|
|||||||
149
README.md
149
README.md
@@ -1,94 +1,97 @@
|
|||||||
# GitOps Toolkit
|
# Flux version 2
|
||||||
|
|
||||||
[](https://github.com/fluxcd/toolkit/actions)
|
[](https://bestpractices.coreinfrastructure.org/projects/4782)
|
||||||
[](https://goreportcard.com/report/github.com/fluxcd/toolkit)
|
[](https://github.com/fluxcd/flux2/actions)
|
||||||
[](https://github.com/fluxcd/toolkit/blob/main/LICENSE)
|
[](https://goreportcard.com/report/github.com/fluxcd/flux2)
|
||||||
[](https://github.com/fluxcd/toolkit/releases)
|
[](https://github.com/fluxcd/flux2/blob/main/LICENSE)
|
||||||

|
[](https://github.com/fluxcd/flux2/releases)
|
||||||
|
|
||||||
The GitOps Toolkit is a set of composable APIs and specialized tools
|
Flux is a tool for keeping Kubernetes clusters in sync with sources of
|
||||||
that can be used to build a Continuous Delivery platform on top of Kubernetes.
|
configuration (like Git repositories), and automating updates to
|
||||||
|
configuration when there is new code to deploy.
|
||||||
|
|
||||||
These tools are build with Kubernetes controller-runtime libraries, and they
|
Flux version 2 ("v2") is built from the ground up to use Kubernetes'
|
||||||
can be dynamically configured with Kubernetes custom resources either by
|
API extension system, and to integrate with Prometheus and other core
|
||||||
cluster admins or by other automated tools.
|
components of the Kubernetes ecosystem. In version 2, Flux supports
|
||||||
The GitOps Toolkit components interact with each other via Kubernetes
|
multi-tenancy and support for syncing an arbitrary number of Git
|
||||||
events and are responsible for the reconciliation of their designated API objects.
|
repositories, among other long-requested features.
|
||||||
|
|
||||||
## `gotk` installation
|
Flux v2 is constructed with the [GitOps Toolkit](#gitops-toolkit), a
|
||||||
|
set of composable APIs and specialized tools for building Continuous
|
||||||
|
Delivery on top of Kubernetes.
|
||||||
|
|
||||||
With Homebrew:
|
Flux is a Cloud Native Computing Foundation ([CNCF](https://www.cncf.io/)) project.
|
||||||
|
|
||||||
```sh
|
## Quickstart and documentation
|
||||||
brew tap fluxcd/tap
|
|
||||||
brew install gotk
|
|
||||||
```
|
|
||||||
|
|
||||||
With Bash:
|
To get started check out this [guide](https://fluxcd.io/docs/get-started/)
|
||||||
|
on how to bootstrap Flux on Kubernetes and deploy a sample application in a GitOps manner.
|
||||||
|
|
||||||
```sh
|
For more comprehensive documentation, see the following guides:
|
||||||
curl -s https://toolkit.fluxcd.io/install.sh | sudo bash
|
- [Ways of structuring your repositories](https://fluxcd.io/docs/guides/repository-structure/)
|
||||||
|
- [Manage Helm Releases](https://fluxcd.io/docs/guides/helmreleases/)
|
||||||
|
- [Automate image updates to Git](https://fluxcd.io/docs/guides/image-update/)
|
||||||
|
- [Manage Kubernetes secrets with Mozilla SOPS](https://fluxcd.io/docs/guides/mozilla-sops/)
|
||||||
|
|
||||||
# enable completions in ~/.bash_profile
|
If you need help, please refer to our **[Support page](https://fluxcd.io/support/)**.
|
||||||
. <(gotk completion bash)
|
|
||||||
```
|
|
||||||
|
|
||||||
Binaries for macOS, Windows and Linux AMD64/ARM are available to download on the
|
## GitOps Toolkit
|
||||||
[release page](https://github.com/fluxcd/toolkit/releases).
|
|
||||||
|
|
||||||
Verify that your cluster satisfies the prerequisites with:
|
The GitOps Toolkit is the set of APIs and controllers that make up the
|
||||||
|
runtime for Flux v2. The APIs comprise Kubernetes custom resources,
|
||||||
|
which can be created and updated by a cluster user, or by other
|
||||||
|
automation tooling.
|
||||||
|
|
||||||
```sh
|

|
||||||
gotk check --pre
|
|
||||||
```
|
|
||||||
|
|
||||||
## Get started
|
You can use the toolkit to extend Flux, or to build your own systems
|
||||||
|
for continuous delivery -- see [the developer
|
||||||
|
guides](https://fluxcd.io/docs/gitops-toolkit/source-watcher/).
|
||||||
|
|
||||||
To get started with the GitOps Toolkit, start [browsing the documentation](https://toolkit.fluxcd.io)
|
### Components
|
||||||
or get started with one of the following guides:
|
|
||||||
|
|
||||||
- [Get started with GitOps Toolkit (deep dive)](https://toolkit.fluxcd.io/get-started/)
|
|
||||||
- [Installation](https://toolkit.fluxcd.io/guides/installation/)
|
|
||||||
- [Manage Helm Releases](https://toolkit.fluxcd.io/guides/helmreleases/)
|
|
||||||
- [Setup Notifications](https://toolkit.fluxcd.io/guides/notifications/)
|
|
||||||
- [Setup Webhook Receivers](https://toolkit.fluxcd.io/guides/webhook-receivers/)
|
|
||||||
|
|
||||||
## Components
|
|
||||||
|
|
||||||
- [Toolkit CLI](https://toolkit.fluxcd.io/cmd/gotk/)
|
|
||||||
- [Source Controller](https://toolkit.fluxcd.io/components/source/controller/)
|
|
||||||
- [GitRepository CRD](https://toolkit.fluxcd.io/components/source/gitrepositories/)
|
|
||||||
- [HelmRepository CRD](https://toolkit.fluxcd.io/components/source/helmrepositories/)
|
|
||||||
- [HelmChart CRD](https://toolkit.fluxcd.io/components/source/helmcharts/)
|
|
||||||
- [Bucket CRD](https://toolkit.fluxcd.io/components/source/buckets/)
|
|
||||||
- [Kustomize Controller](https://toolkit.fluxcd.io/components/kustomize/controller/)
|
|
||||||
- [Kustomization CRD](https://toolkit.fluxcd.io/components/kustomize/kustomization/)
|
|
||||||
- [Helm Controller](https://toolkit.fluxcd.io/components/helm/controller/)
|
|
||||||
- [HelmRelease CRD](https://toolkit.fluxcd.io/components/helm/helmreleases/)
|
|
||||||
- [Notification Controller](https://toolkit.fluxcd.io/components/notification/controller/)
|
|
||||||
- [Provider CRD](https://toolkit.fluxcd.io/components/notification/provider/)
|
|
||||||
- [Alert CRD](https://toolkit.fluxcd.io/components/notification/alert/)
|
|
||||||
- [Receiver CRD](https://toolkit.fluxcd.io/components/notification/receiver/)
|
|
||||||
|
|
||||||
|
- [Source Controller](https://fluxcd.io/docs/components/source/)
|
||||||
|
- [GitRepository CRD](https://fluxcd.io/docs/components/source/gitrepositories/)
|
||||||
|
- [HelmRepository CRD](https://fluxcd.io/docs/components/source/helmrepositories/)
|
||||||
|
- [HelmChart CRD](https://fluxcd.io/docs/components/source/helmcharts/)
|
||||||
|
- [Bucket CRD](https://fluxcd.io/docs/components/source/buckets/)
|
||||||
|
- [Kustomize Controller](https://fluxcd.io/docs/components/kustomize/)
|
||||||
|
- [Kustomization CRD](https://fluxcd.io/docs/components/kustomize/kustomization/)
|
||||||
|
- [Helm Controller](https://fluxcd.io/docs/components/helm/)
|
||||||
|
- [HelmRelease CRD](https://fluxcd.io/docs/components/helm/helmreleases/)
|
||||||
|
- [Notification Controller](https://fluxcd.io/docs/components/notification/)
|
||||||
|
- [Provider CRD](https://fluxcd.io/docs/components/notification/provider/)
|
||||||
|
- [Alert CRD](https://fluxcd.io/docs/components/notification/alert/)
|
||||||
|
- [Receiver CRD](https://fluxcd.io/docs/components/notification/receiver/)
|
||||||
|
- [Image Automation Controllers](https://fluxcd.io/docs/components/image/)
|
||||||
|
- [ImageRepository CRD](https://fluxcd.io/docs/components/image/imagerepositories/)
|
||||||
|
- [ImagePolicy CRD](https://fluxcd.io/docs/components/image/imagepolicies/)
|
||||||
|
- [ImageUpdateAutomation CRD](https://fluxcd.io/docs/components/image/imageupdateautomations/)
|
||||||
|
|
||||||
## Community
|
## Community
|
||||||
|
|
||||||
The GitOps Toolkit is always looking for new contributors and there are a multitude of ways to get involved. Depending on what you want to do, some of the following bits might be your first steps:
|
Need help or want to contribute? Please see the links below. The Flux project is always looking for
|
||||||
|
new contributors and there are a multitude of ways to get involved.
|
||||||
|
|
||||||
- Join our upcoming dev meetings ([meeting access and agenda](https://docs.google.com/document/d/1l_M0om0qUEN_NNiGgpqJ2tvsF2iioHkaARDeh6b70B0/view))
|
- Getting Started?
|
||||||
- Talk to us in the #flux channel on [CNCF Slack](https://slack.cncf.io/)
|
- Look at our [Get Started guide](https://fluxcd.io/docs/get-started/) and give us feedback
|
||||||
- Join the [planning discussions](https://github.com/fluxcd/toolkit/discussions)
|
- Need help?
|
||||||
- And if you are completely new to the GitOps Toolkit, take a look at our [Get Started guide](https://toolkit.fluxcd.io/get-started/) and give us feedback
|
- First: Ask questions on our [GH Discussions page](https://github.com/fluxcd/flux2/discussions)
|
||||||
- To be part of the conversation about Flux's development, [join the flux-dev mailing list](https://lists.cncf.io/g/cncf-flux-dev).
|
- Second: Talk to us in the #flux channel on [CNCF Slack](https://slack.cncf.io/)
|
||||||
- Check out [how to contribute](CONTRIBUTING.md) to the project
|
- Please follow our [Support Guidelines](https://fluxcd.io/support/)
|
||||||
|
(in short: be nice, be respectful of volunteers' time, understand that maintainers and
|
||||||
|
contributors cannot respond to all DMs, and keep discussions in the public #flux channel as much as possible).
|
||||||
|
- Have feature proposals or want to contribute?
|
||||||
|
- Propose features on our [GH Discussions page](https://github.com/fluxcd/flux2/discussions)
|
||||||
|
- Join our upcoming dev meetings ([meeting access and agenda](https://docs.google.com/document/d/1l_M0om0qUEN_NNiGgpqJ2tvsF2iioHkaARDeh6b70B0/view))
|
||||||
|
- [Join the flux-dev mailing list](https://lists.cncf.io/g/cncf-flux-dev).
|
||||||
|
- Check out [how to contribute](CONTRIBUTING.md) to the project
|
||||||
|
|
||||||
## Featured Talks
|
### Events
|
||||||
- 12 Oct 2020 - [Rawkode Live: Introduction to GitOps Toolkit with Stefan Prodan](https://youtu.be/HqTzuOBP0eY)
|
|
||||||
- 4 Sep 2020 - [KubeCon/CloudNativeCon 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)
|
|
||||||
- 7 May 2020 - [GitOps Days - Community Special: GitOps Toolkit Experimentation with Stefan Prodan](https://youtu.be/WHzxunv4DKk?t=6521)
|
|
||||||
|
|
||||||
### Upcoming Meetups
|
Check out our **[events calendar](https://fluxcd.io/#calendar)**,
|
||||||
- 19 Oct 2020 - [The Power of GitOps with Flux & GitOps Toolkit - Part 1](https://www.meetup.com/GitOps-Community/events/273640196/)
|
both with upcoming talks, events and meetings you can attend.
|
||||||
- 2 Nov 2020 - [The Power of GitOps with Flux & GitOps Toolkit - Part 2](https://www.meetup.com/GitOps-Community/events/273934676/)
|
Or view the **[resources section](https://fluxcd.io/resources)**
|
||||||
|
with past events videos you can watch.
|
||||||
|
|
||||||
We are looking forward to seeing you with us!
|
We look forward to seeing you with us!
|
||||||
|
|||||||
104
action/README.md
Normal file
104
action/README.md
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
# Flux GitHub Action
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- name: Setup Flux CLI
|
||||||
|
uses: fluxcd/flux2/action@main
|
||||||
|
- name: Run Flux commands
|
||||||
|
run: flux -v
|
||||||
|
```
|
||||||
|
|
||||||
|
The latest stable version of the `flux` binary is downloaded from
|
||||||
|
GitHub [releases](https://github.com/fluxcd/flux2/releases)
|
||||||
|
and placed at `/usr/local/bin/flux`.
|
||||||
|
|
||||||
|
Note that this action can only be used on GitHub **Linux** runners.
|
||||||
|
You can change the arch (defaults to `amd64`) with:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- name: Setup Flux CLI
|
||||||
|
uses: fluxcd/flux2/action@main
|
||||||
|
with:
|
||||||
|
arch: arm64 # can be amd64, arm64 or arm
|
||||||
|
```
|
||||||
|
|
||||||
|
You can download a specific version with:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- name: Setup Flux CLI
|
||||||
|
uses: fluxcd/flux2/action@main
|
||||||
|
with:
|
||||||
|
version: 0.8.0
|
||||||
|
```
|
||||||
|
|
||||||
|
### Automate Flux updates
|
||||||
|
|
||||||
|
Example workflow for updating Flux's components generated with `flux bootstrap --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 \
|
||||||
|
--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
|
||||||
|
name: e2e
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- '*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
kubernetes:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Setup Flux CLI
|
||||||
|
uses: fluxcd/flux2/action@main
|
||||||
|
- name: Setup Kubernetes Kind
|
||||||
|
uses: engineerd/setup-kind@v0.5.0
|
||||||
|
- name: Install Flux in Kubernetes Kind
|
||||||
|
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)
|
||||||
43
action/action.yml
Normal file
43
action/action.yml
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
name: Setup Flux CLI
|
||||||
|
description: A GitHub Action for running Flux commands
|
||||||
|
author: Stefan Prodan
|
||||||
|
branding:
|
||||||
|
color: blue
|
||||||
|
icon: command
|
||||||
|
inputs:
|
||||||
|
version:
|
||||||
|
description: "Flux version e.g. 0.8.0 (defaults to latest stable release)"
|
||||||
|
required: false
|
||||||
|
arch:
|
||||||
|
description: "arch can be amd64, arm64 or arm"
|
||||||
|
required: true
|
||||||
|
default: "amd64"
|
||||||
|
runs:
|
||||||
|
using: composite
|
||||||
|
steps:
|
||||||
|
- name: "Download flux binary to tmp"
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
ARCH=${{ inputs.arch }}
|
||||||
|
VERSION=${{ inputs.version }}
|
||||||
|
|
||||||
|
if [ -z $VERSION ]; then
|
||||||
|
VERSION=$(curl https://api.github.com/repos/fluxcd/flux2/releases/latest -sL | grep tag_name | sed -E 's/.*"([^"]+)".*/\1/' | cut -c 2-)
|
||||||
|
fi
|
||||||
|
|
||||||
|
BIN_URL="https://github.com/fluxcd/flux2/releases/download/v${VERSION}/flux_${VERSION}_linux_${ARCH}.tar.gz"
|
||||||
|
curl -sL ${BIN_URL} -o /tmp/flux.tar.gz
|
||||||
|
mkdir -p /tmp/flux
|
||||||
|
tar -C /tmp/flux/ -zxvf /tmp/flux.tar.gz
|
||||||
|
- name: "Add flux binary to /usr/local/bin"
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
sudo cp /tmp/flux/flux /usr/local/bin
|
||||||
|
- name: "Cleanup tmp"
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
rm -rf /tmp/flux/ /tmp/flux.tar.gz
|
||||||
|
- name: "Verify correct installation of binary"
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
flux -v
|
||||||
56
cmd/flux/alert.go
Normal file
56
cmd/flux/alert.go
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2021 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 (
|
||||||
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
|
|
||||||
|
notificationv1 "github.com/fluxcd/notification-controller/api/v1beta1"
|
||||||
|
)
|
||||||
|
|
||||||
|
// notificationv1.Alert
|
||||||
|
|
||||||
|
var alertType = apiType{
|
||||||
|
kind: notificationv1.AlertKind,
|
||||||
|
humanKind: "alert",
|
||||||
|
}
|
||||||
|
|
||||||
|
type alertAdapter struct {
|
||||||
|
*notificationv1.Alert
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a alertAdapter) asClientObject() client.Object {
|
||||||
|
return a.Alert
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a alertAdapter) deepCopyClientObject() client.Object {
|
||||||
|
return a.Alert.DeepCopy()
|
||||||
|
}
|
||||||
|
|
||||||
|
// notificationv1.Alert
|
||||||
|
|
||||||
|
type alertListAdapter struct {
|
||||||
|
*notificationv1.AlertList
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a alertListAdapter) asClientList() client.ObjectList {
|
||||||
|
return a.AlertList
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a alertListAdapter) len() int {
|
||||||
|
return len(a.AlertList.Items)
|
||||||
|
}
|
||||||
56
cmd/flux/alert_provider.go
Normal file
56
cmd/flux/alert_provider.go
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2021 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 (
|
||||||
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
|
|
||||||
|
notificationv1 "github.com/fluxcd/notification-controller/api/v1beta1"
|
||||||
|
)
|
||||||
|
|
||||||
|
// notificationv1.Provider
|
||||||
|
|
||||||
|
var alertProviderType = apiType{
|
||||||
|
kind: notificationv1.ProviderKind,
|
||||||
|
humanKind: "alert provider",
|
||||||
|
}
|
||||||
|
|
||||||
|
type alertProviderAdapter struct {
|
||||||
|
*notificationv1.Provider
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a alertProviderAdapter) asClientObject() client.Object {
|
||||||
|
return a.Provider
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a alertProviderAdapter) deepCopyClientObject() client.Object {
|
||||||
|
return a.Provider.DeepCopy()
|
||||||
|
}
|
||||||
|
|
||||||
|
// notificationv1.Provider
|
||||||
|
|
||||||
|
type alertProviderListAdapter struct {
|
||||||
|
*notificationv1.ProviderList
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a alertProviderListAdapter) asClientList() client.ObjectList {
|
||||||
|
return a.ProviderList
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a alertProviderListAdapter) len() int {
|
||||||
|
return len(a.ProviderList.Items)
|
||||||
|
}
|
||||||
192
cmd/flux/bootstrap.go
Normal file
192
cmd/flux/bootstrap.go
Normal file
@@ -0,0 +1,192 @@
|
|||||||
|
/*
|
||||||
|
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 (
|
||||||
|
"crypto/elliptic"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
"github.com/fluxcd/flux2/internal/flags"
|
||||||
|
"github.com/fluxcd/flux2/internal/utils"
|
||||||
|
"github.com/fluxcd/flux2/pkg/manifestgen/sourcesecret"
|
||||||
|
)
|
||||||
|
|
||||||
|
var bootstrapCmd = &cobra.Command{
|
||||||
|
Use: "bootstrap",
|
||||||
|
Short: "Bootstrap toolkit components",
|
||||||
|
Long: "The bootstrap sub-commands bootstrap the toolkit components on the targeted Git provider.",
|
||||||
|
}
|
||||||
|
|
||||||
|
type bootstrapFlags struct {
|
||||||
|
version string
|
||||||
|
arch flags.Arch
|
||||||
|
logLevel flags.LogLevel
|
||||||
|
|
||||||
|
branch string
|
||||||
|
recurseSubmodules bool
|
||||||
|
manifestsPath string
|
||||||
|
|
||||||
|
defaultComponents []string
|
||||||
|
extraComponents []string
|
||||||
|
requiredComponents []string
|
||||||
|
|
||||||
|
registry string
|
||||||
|
imagePullSecret string
|
||||||
|
|
||||||
|
secretName string
|
||||||
|
tokenAuth bool
|
||||||
|
keyAlgorithm flags.PublicKeyAlgorithm
|
||||||
|
keyRSABits flags.RSAKeyBits
|
||||||
|
keyECDSACurve flags.ECDSACurve
|
||||||
|
sshHostname string
|
||||||
|
caFile string
|
||||||
|
privateKeyFile string
|
||||||
|
|
||||||
|
watchAllNamespaces bool
|
||||||
|
networkPolicy bool
|
||||||
|
clusterDomain string
|
||||||
|
tolerationKeys []string
|
||||||
|
|
||||||
|
authorName string
|
||||||
|
authorEmail string
|
||||||
|
|
||||||
|
gpgKeyRingPath string
|
||||||
|
gpgPassphrase string
|
||||||
|
gpgKeyID string
|
||||||
|
|
||||||
|
commitMessageAppendix string
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
bootstrapDefaultBranch = "main"
|
||||||
|
)
|
||||||
|
|
||||||
|
var bootstrapArgs = NewBootstrapFlags()
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
bootstrapCmd.PersistentFlags().StringVarP(&bootstrapArgs.version, "version", "v", "",
|
||||||
|
"toolkit version, when specified the manifests are downloaded from https://github.com/fluxcd/flux2/releases")
|
||||||
|
|
||||||
|
bootstrapCmd.PersistentFlags().StringSliceVar(&bootstrapArgs.defaultComponents, "components", rootArgs.defaults.Components,
|
||||||
|
"list of components, accepts comma-separated values")
|
||||||
|
bootstrapCmd.PersistentFlags().StringSliceVar(&bootstrapArgs.extraComponents, "components-extra", nil,
|
||||||
|
"list of components in addition to those supplied or defaulted, accepts comma-separated values")
|
||||||
|
|
||||||
|
bootstrapCmd.PersistentFlags().StringVar(&bootstrapArgs.registry, "registry", "ghcr.io/fluxcd",
|
||||||
|
"container registry where the toolkit images are published")
|
||||||
|
bootstrapCmd.PersistentFlags().StringVar(&bootstrapArgs.imagePullSecret, "image-pull-secret", "",
|
||||||
|
"Kubernetes secret name used for pulling the toolkit images from a private registry")
|
||||||
|
|
||||||
|
bootstrapCmd.PersistentFlags().StringVar(&bootstrapArgs.branch, "branch", bootstrapDefaultBranch, "Git branch")
|
||||||
|
bootstrapCmd.PersistentFlags().BoolVar(&bootstrapArgs.recurseSubmodules, "recurse-submodules", false,
|
||||||
|
"when enabled, configures the GitRepository source to initialize and include Git submodules in the artifact it produces")
|
||||||
|
|
||||||
|
bootstrapCmd.PersistentFlags().StringVar(&bootstrapArgs.manifestsPath, "manifests", "", "path to the manifest directory")
|
||||||
|
|
||||||
|
bootstrapCmd.PersistentFlags().BoolVar(&bootstrapArgs.watchAllNamespaces, "watch-all-namespaces", true,
|
||||||
|
"watch for custom resources in all namespaces, if set to false it will only watch the namespace where the toolkit is installed")
|
||||||
|
bootstrapCmd.PersistentFlags().BoolVar(&bootstrapArgs.networkPolicy, "network-policy", true,
|
||||||
|
"deny ingress access to the toolkit controllers from other namespaces using network policies")
|
||||||
|
bootstrapCmd.PersistentFlags().BoolVar(&bootstrapArgs.tokenAuth, "token-auth", false,
|
||||||
|
"when enabled, the personal access token will be used instead of SSH deploy key")
|
||||||
|
bootstrapCmd.PersistentFlags().Var(&bootstrapArgs.logLevel, "log-level", bootstrapArgs.logLevel.Description())
|
||||||
|
bootstrapCmd.PersistentFlags().StringVar(&bootstrapArgs.clusterDomain, "cluster-domain", rootArgs.defaults.ClusterDomain, "internal cluster domain")
|
||||||
|
bootstrapCmd.PersistentFlags().StringSliceVar(&bootstrapArgs.tolerationKeys, "toleration-keys", nil,
|
||||||
|
"list of toleration keys used to schedule the components pods onto nodes with matching taints")
|
||||||
|
|
||||||
|
bootstrapCmd.PersistentFlags().StringVar(&bootstrapArgs.secretName, "secret-name", rootArgs.defaults.Namespace, "name of the secret the sync credentials can be found in or stored to")
|
||||||
|
bootstrapCmd.PersistentFlags().Var(&bootstrapArgs.keyAlgorithm, "ssh-key-algorithm", bootstrapArgs.keyAlgorithm.Description())
|
||||||
|
bootstrapCmd.PersistentFlags().Var(&bootstrapArgs.keyRSABits, "ssh-rsa-bits", bootstrapArgs.keyRSABits.Description())
|
||||||
|
bootstrapCmd.PersistentFlags().Var(&bootstrapArgs.keyECDSACurve, "ssh-ecdsa-curve", bootstrapArgs.keyECDSACurve.Description())
|
||||||
|
bootstrapCmd.PersistentFlags().StringVar(&bootstrapArgs.sshHostname, "ssh-hostname", "", "SSH hostname, to be used when the SSH host differs from the HTTPS one")
|
||||||
|
bootstrapCmd.PersistentFlags().StringVar(&bootstrapArgs.caFile, "ca-file", "", "path to TLS CA file used for validating self-signed certificates")
|
||||||
|
bootstrapCmd.PersistentFlags().StringVar(&bootstrapArgs.privateKeyFile, "private-key-file", "", "path to a private key file used for authenticating to the Git SSH server")
|
||||||
|
|
||||||
|
bootstrapCmd.PersistentFlags().StringVar(&bootstrapArgs.authorName, "author-name", "Flux", "author name for Git commits")
|
||||||
|
bootstrapCmd.PersistentFlags().StringVar(&bootstrapArgs.authorEmail, "author-email", "", "author email for Git commits")
|
||||||
|
|
||||||
|
bootstrapCmd.PersistentFlags().StringVar(&bootstrapArgs.gpgKeyRingPath, "gpg-key-ring", "", "path to GPG key ring for signing commits")
|
||||||
|
bootstrapCmd.PersistentFlags().StringVar(&bootstrapArgs.gpgPassphrase, "gpg-passphrase", "", "passphrase for decrypting GPG private key")
|
||||||
|
bootstrapCmd.PersistentFlags().StringVar(&bootstrapArgs.gpgKeyID, "gpg-key-id", "", "key id for selecting a particular key")
|
||||||
|
|
||||||
|
bootstrapCmd.PersistentFlags().StringVar(&bootstrapArgs.commitMessageAppendix, "commit-message-appendix", "", "string to add to the commit messages, e.g. '[ci skip]'")
|
||||||
|
|
||||||
|
bootstrapCmd.PersistentFlags().Var(&bootstrapArgs.arch, "arch", bootstrapArgs.arch.Description())
|
||||||
|
bootstrapCmd.PersistentFlags().MarkDeprecated("arch", "multi-arch container image is now available for AMD64, ARMv7 and ARM64")
|
||||||
|
bootstrapCmd.PersistentFlags().MarkHidden("manifests")
|
||||||
|
|
||||||
|
rootCmd.AddCommand(bootstrapCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewBootstrapFlags() bootstrapFlags {
|
||||||
|
return bootstrapFlags{
|
||||||
|
logLevel: flags.LogLevel(rootArgs.defaults.LogLevel),
|
||||||
|
requiredComponents: []string{"source-controller", "kustomize-controller"},
|
||||||
|
keyAlgorithm: flags.PublicKeyAlgorithm(sourcesecret.ECDSAPrivateKeyAlgorithm),
|
||||||
|
keyRSABits: 2048,
|
||||||
|
keyECDSACurve: flags.ECDSACurve{Curve: elliptic.P384()},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func bootstrapComponents() []string {
|
||||||
|
return append(bootstrapArgs.defaultComponents, bootstrapArgs.extraComponents...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func buildEmbeddedManifestBase() (string, error) {
|
||||||
|
if !isEmbeddedVersion(bootstrapArgs.version) {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
tmpBaseDir, err := os.MkdirTemp("", "flux-manifests-")
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
if err := writeEmbeddedManifests(tmpBaseDir); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return tmpBaseDir, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func bootstrapValidate() error {
|
||||||
|
components := bootstrapComponents()
|
||||||
|
for _, component := range bootstrapArgs.requiredComponents {
|
||||||
|
if !utils.ContainsItemString(components, component) {
|
||||||
|
return fmt.Errorf("component %s is required", component)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := utils.ValidateComponents(components); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func mapTeamSlice(s []string, defaultPermission string) map[string]string {
|
||||||
|
m := make(map[string]string, len(s))
|
||||||
|
for _, v := range s {
|
||||||
|
m[v] = defaultPermission
|
||||||
|
if s := strings.Split(v, ":"); len(s) == 2 {
|
||||||
|
m[s[0]] = s[1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return m
|
||||||
|
}
|
||||||
279
cmd/flux/bootstrap_bitbucket_server.go
Normal file
279
cmd/flux/bootstrap_bitbucket_server.go
Normal file
@@ -0,0 +1,279 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2021 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"
|
||||||
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/go-git/go-git/v5/plumbing/transport/http"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
"github.com/fluxcd/flux2/internal/bootstrap"
|
||||||
|
"github.com/fluxcd/flux2/internal/bootstrap/git/gogit"
|
||||||
|
"github.com/fluxcd/flux2/internal/bootstrap/provider"
|
||||||
|
"github.com/fluxcd/flux2/internal/flags"
|
||||||
|
"github.com/fluxcd/flux2/internal/utils"
|
||||||
|
"github.com/fluxcd/flux2/pkg/manifestgen/install"
|
||||||
|
"github.com/fluxcd/flux2/pkg/manifestgen/sourcesecret"
|
||||||
|
"github.com/fluxcd/flux2/pkg/manifestgen/sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
var bootstrapBServerCmd = &cobra.Command{
|
||||||
|
Use: "bitbucket-server",
|
||||||
|
Short: "Bootstrap toolkit components in a Bitbucket Server repository",
|
||||||
|
Long: `The bootstrap bitbucket-server command creates the Bitbucket Server repository if it doesn't exists and
|
||||||
|
commits the toolkit components manifests to the master branch.
|
||||||
|
Then it configures the target cluster to synchronize with the repository.
|
||||||
|
If the toolkit components are present on the cluster,
|
||||||
|
the bootstrap command will perform an upgrade if needed.`,
|
||||||
|
Example: ` # Create a Bitbucket Server API token and export it as an env var
|
||||||
|
export BITBUCKET_TOKEN=<my-token>
|
||||||
|
|
||||||
|
# Run bootstrap for a private repository using HTTPS token authentication
|
||||||
|
flux bootstrap bitbucket-server --owner=<project> --username=<user> --repository=<repository name> --hostname=<domain> --token-auth
|
||||||
|
|
||||||
|
# Run bootstrap for a private repository using SSH authentication
|
||||||
|
flux bootstrap bitbucket-server --owner=<project> --username=<user> --repository=<repository name> --hostname=<domain>
|
||||||
|
|
||||||
|
# Run bootstrap for a repository path
|
||||||
|
flux bootstrap bitbucket-server --owner=<project> --username=<user> --repository=<repository name> --path=dev-cluster --hostname=<domain>
|
||||||
|
|
||||||
|
# Run bootstrap for a public repository on a personal account
|
||||||
|
flux bootstrap bitbucket-server --owner=<user> --repository=<repository name> --private=false --personal --hostname=<domain> --token-auth
|
||||||
|
|
||||||
|
# Run bootstrap for a an existing repository with a branch named main
|
||||||
|
flux bootstrap bitbucket-server --owner=<project> --username=<user> --repository=<repository name> --branch=main --hostname=<domain> --token-auth`,
|
||||||
|
RunE: bootstrapBServerCmdRun,
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
bServerDefaultPermission = "push"
|
||||||
|
bServerTokenEnvVar = "BITBUCKET_TOKEN"
|
||||||
|
)
|
||||||
|
|
||||||
|
type bServerFlags struct {
|
||||||
|
owner string
|
||||||
|
repository string
|
||||||
|
interval time.Duration
|
||||||
|
personal bool
|
||||||
|
username string
|
||||||
|
private bool
|
||||||
|
hostname string
|
||||||
|
path flags.SafeRelativePath
|
||||||
|
teams []string
|
||||||
|
readWriteKey bool
|
||||||
|
reconcile bool
|
||||||
|
}
|
||||||
|
|
||||||
|
var bServerArgs bServerFlags
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
bootstrapBServerCmd.Flags().StringVar(&bServerArgs.owner, "owner", "", "Bitbucket Server user or project name")
|
||||||
|
bootstrapBServerCmd.Flags().StringVar(&bServerArgs.repository, "repository", "", "Bitbucket Server repository name")
|
||||||
|
bootstrapBServerCmd.Flags().StringSliceVar(&bServerArgs.teams, "group", []string{}, "Bitbucket Server groups to be given write access (also accepts comma-separated values)")
|
||||||
|
bootstrapBServerCmd.Flags().BoolVar(&bServerArgs.personal, "personal", false, "if true, the owner is assumed to be a Bitbucket Server user; otherwise a group")
|
||||||
|
bootstrapBServerCmd.Flags().StringVarP(&bServerArgs.username, "username", "u", "git", "authentication username")
|
||||||
|
bootstrapBServerCmd.Flags().BoolVar(&bServerArgs.private, "private", true, "if true, the repository is setup or configured as private")
|
||||||
|
bootstrapBServerCmd.Flags().DurationVar(&bServerArgs.interval, "interval", time.Minute, "sync interval")
|
||||||
|
bootstrapBServerCmd.Flags().StringVar(&bServerArgs.hostname, "hostname", "", "Bitbucket Server hostname")
|
||||||
|
bootstrapBServerCmd.Flags().Var(&bServerArgs.path, "path", "path relative to the repository root, when specified the cluster sync will be scoped to this path")
|
||||||
|
bootstrapBServerCmd.Flags().BoolVar(&bServerArgs.readWriteKey, "read-write-key", false, "if true, the deploy key is configured with read/write permissions")
|
||||||
|
bootstrapBServerCmd.Flags().BoolVar(&bServerArgs.reconcile, "reconcile", false, "if true, the configured options are also reconciled if the repository already exists")
|
||||||
|
|
||||||
|
bootstrapCmd.AddCommand(bootstrapBServerCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func bootstrapBServerCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
|
bitbucketToken := os.Getenv(bServerTokenEnvVar)
|
||||||
|
if bitbucketToken == "" {
|
||||||
|
var err error
|
||||||
|
bitbucketToken, err = readPasswordFromStdin("Please enter your Bitbucket personal access token (PAT): ")
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("could not read token: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if bServerArgs.hostname == "" {
|
||||||
|
return fmt.Errorf("invalid hostname %q", bServerArgs.hostname)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := bootstrapValidate(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Manifest base
|
||||||
|
if ver, err := getVersion(bootstrapArgs.version); err == nil {
|
||||||
|
bootstrapArgs.version = ver
|
||||||
|
}
|
||||||
|
manifestsBase, err := buildEmbeddedManifestBase()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer os.RemoveAll(manifestsBase)
|
||||||
|
|
||||||
|
user := bServerArgs.username
|
||||||
|
if bServerArgs.personal {
|
||||||
|
user = bServerArgs.owner
|
||||||
|
}
|
||||||
|
|
||||||
|
var caBundle []byte
|
||||||
|
if bootstrapArgs.caFile != "" {
|
||||||
|
var err error
|
||||||
|
caBundle, err = os.ReadFile(bootstrapArgs.caFile)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to read TLS CA file: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build Bitbucket Server provider
|
||||||
|
providerCfg := provider.Config{
|
||||||
|
Provider: provider.GitProviderStash,
|
||||||
|
Hostname: bServerArgs.hostname,
|
||||||
|
Username: user,
|
||||||
|
Token: bitbucketToken,
|
||||||
|
CaBundle: caBundle,
|
||||||
|
}
|
||||||
|
|
||||||
|
providerClient, err := provider.BuildGitProvider(providerCfg)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lazy go-git repository
|
||||||
|
tmpDir, err := os.MkdirTemp("", "flux-bootstrap-")
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to create temporary working dir: %w", err)
|
||||||
|
}
|
||||||
|
defer os.RemoveAll(tmpDir)
|
||||||
|
gitClient := gogit.New(tmpDir, &http.BasicAuth{
|
||||||
|
Username: user,
|
||||||
|
Password: bitbucketToken,
|
||||||
|
})
|
||||||
|
|
||||||
|
// Install manifest config
|
||||||
|
installOptions := install.Options{
|
||||||
|
BaseURL: rootArgs.defaults.BaseURL,
|
||||||
|
Version: bootstrapArgs.version,
|
||||||
|
Namespace: rootArgs.namespace,
|
||||||
|
Components: bootstrapComponents(),
|
||||||
|
Registry: bootstrapArgs.registry,
|
||||||
|
ImagePullSecret: bootstrapArgs.imagePullSecret,
|
||||||
|
WatchAllNamespaces: bootstrapArgs.watchAllNamespaces,
|
||||||
|
NetworkPolicy: bootstrapArgs.networkPolicy,
|
||||||
|
LogLevel: bootstrapArgs.logLevel.String(),
|
||||||
|
NotificationController: rootArgs.defaults.NotificationController,
|
||||||
|
ManifestFile: rootArgs.defaults.ManifestFile,
|
||||||
|
Timeout: rootArgs.timeout,
|
||||||
|
TargetPath: bServerArgs.path.ToSlash(),
|
||||||
|
ClusterDomain: bootstrapArgs.clusterDomain,
|
||||||
|
TolerationKeys: bootstrapArgs.tolerationKeys,
|
||||||
|
}
|
||||||
|
if customBaseURL := bootstrapArgs.manifestsPath; customBaseURL != "" {
|
||||||
|
installOptions.BaseURL = customBaseURL
|
||||||
|
}
|
||||||
|
|
||||||
|
// Source generation and secret config
|
||||||
|
secretOpts := sourcesecret.Options{
|
||||||
|
Name: bootstrapArgs.secretName,
|
||||||
|
Namespace: rootArgs.namespace,
|
||||||
|
TargetPath: bServerArgs.path.String(),
|
||||||
|
ManifestFile: sourcesecret.MakeDefaultOptions().ManifestFile,
|
||||||
|
}
|
||||||
|
if bootstrapArgs.tokenAuth {
|
||||||
|
if bServerArgs.personal {
|
||||||
|
secretOpts.Username = bServerArgs.owner
|
||||||
|
} else {
|
||||||
|
secretOpts.Username = bServerArgs.username
|
||||||
|
}
|
||||||
|
secretOpts.Password = bitbucketToken
|
||||||
|
|
||||||
|
if bootstrapArgs.caFile != "" {
|
||||||
|
secretOpts.CAFilePath = bootstrapArgs.caFile
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
secretOpts.PrivateKeyAlgorithm = sourcesecret.PrivateKeyAlgorithm(bootstrapArgs.keyAlgorithm)
|
||||||
|
secretOpts.RSAKeyBits = int(bootstrapArgs.keyRSABits)
|
||||||
|
secretOpts.ECDSACurve = bootstrapArgs.keyECDSACurve.Curve
|
||||||
|
secretOpts.SSHHostname = bServerArgs.hostname
|
||||||
|
|
||||||
|
if bootstrapArgs.privateKeyFile != "" {
|
||||||
|
secretOpts.PrivateKeyPath = bootstrapArgs.privateKeyFile
|
||||||
|
}
|
||||||
|
if bootstrapArgs.sshHostname != "" {
|
||||||
|
secretOpts.SSHHostname = bootstrapArgs.sshHostname
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sync manifest config
|
||||||
|
syncOpts := sync.Options{
|
||||||
|
Interval: bServerArgs.interval,
|
||||||
|
Name: rootArgs.namespace,
|
||||||
|
Namespace: rootArgs.namespace,
|
||||||
|
Branch: bootstrapArgs.branch,
|
||||||
|
Secret: bootstrapArgs.secretName,
|
||||||
|
TargetPath: bServerArgs.path.ToSlash(),
|
||||||
|
ManifestFile: sync.MakeDefaultOptions().ManifestFile,
|
||||||
|
GitImplementation: sourceGitArgs.gitImplementation.String(),
|
||||||
|
RecurseSubmodules: bootstrapArgs.recurseSubmodules,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bootstrap config
|
||||||
|
bootstrapOpts := []bootstrap.GitProviderOption{
|
||||||
|
bootstrap.WithProviderRepository(bServerArgs.owner, bServerArgs.repository, bServerArgs.personal),
|
||||||
|
bootstrap.WithBranch(bootstrapArgs.branch),
|
||||||
|
bootstrap.WithBootstrapTransportType("https"),
|
||||||
|
bootstrap.WithAuthor(bootstrapArgs.authorName, bootstrapArgs.authorEmail),
|
||||||
|
bootstrap.WithCommitMessageAppendix(bootstrapArgs.commitMessageAppendix),
|
||||||
|
bootstrap.WithProviderTeamPermissions(mapTeamSlice(bServerArgs.teams, bServerDefaultPermission)),
|
||||||
|
bootstrap.WithReadWriteKeyPermissions(bServerArgs.readWriteKey),
|
||||||
|
bootstrap.WithKubeconfig(rootArgs.kubeconfig, rootArgs.kubecontext),
|
||||||
|
bootstrap.WithLogger(logger),
|
||||||
|
bootstrap.WithCABundle(caBundle),
|
||||||
|
}
|
||||||
|
if bootstrapArgs.sshHostname != "" {
|
||||||
|
bootstrapOpts = append(bootstrapOpts, bootstrap.WithSSHHostname(bootstrapArgs.sshHostname))
|
||||||
|
}
|
||||||
|
if bootstrapArgs.tokenAuth {
|
||||||
|
bootstrapOpts = append(bootstrapOpts, bootstrap.WithSyncTransportType("https"))
|
||||||
|
}
|
||||||
|
if !bServerArgs.private {
|
||||||
|
bootstrapOpts = append(bootstrapOpts, bootstrap.WithProviderRepositoryConfig("", "", "public"))
|
||||||
|
}
|
||||||
|
if bServerArgs.reconcile {
|
||||||
|
bootstrapOpts = append(bootstrapOpts, bootstrap.WithReconcile())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup bootstrapper with constructed configs
|
||||||
|
b, err := bootstrap.NewGitProviderBootstrapper(gitClient, providerClient, kubeClient, bootstrapOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run
|
||||||
|
return bootstrap.Run(ctx, b, manifestsBase, installOptions, secretOpts, syncOpts, rootArgs.pollInterval, rootArgs.timeout)
|
||||||
|
}
|
||||||
280
cmd/flux/bootstrap_git.go
Normal file
280
cmd/flux/bootstrap_git.go
Normal file
@@ -0,0 +1,280 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2021 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"
|
||||||
|
"net/url"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/go-git/go-git/v5/plumbing/transport"
|
||||||
|
"github.com/go-git/go-git/v5/plumbing/transport/http"
|
||||||
|
"github.com/go-git/go-git/v5/plumbing/transport/ssh"
|
||||||
|
"github.com/manifoldco/promptui"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
corev1 "k8s.io/api/core/v1"
|
||||||
|
|
||||||
|
"github.com/fluxcd/flux2/internal/bootstrap"
|
||||||
|
"github.com/fluxcd/flux2/internal/bootstrap/git/gogit"
|
||||||
|
"github.com/fluxcd/flux2/internal/flags"
|
||||||
|
"github.com/fluxcd/flux2/internal/utils"
|
||||||
|
"github.com/fluxcd/flux2/pkg/manifestgen/install"
|
||||||
|
"github.com/fluxcd/flux2/pkg/manifestgen/sourcesecret"
|
||||||
|
"github.com/fluxcd/flux2/pkg/manifestgen/sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
var bootstrapGitCmd = &cobra.Command{
|
||||||
|
Use: "git",
|
||||||
|
Short: "Bootstrap toolkit components in a Git repository",
|
||||||
|
Long: `The bootstrap git command commits the toolkit components manifests to the
|
||||||
|
branch of a Git repository. It then configures the target cluster to synchronize with
|
||||||
|
the repository. If the toolkit components are present on the cluster, the bootstrap
|
||||||
|
command will perform an upgrade if needed.`,
|
||||||
|
Example: ` # Run bootstrap for a Git repository and authenticate with your SSH agent
|
||||||
|
flux bootstrap git --url=ssh://git@example.com/repository.git
|
||||||
|
|
||||||
|
# Run bootstrap for a Git repository and authenticate using a password
|
||||||
|
flux bootstrap git --url=https://example.com/repository.git --password=<password>
|
||||||
|
|
||||||
|
# Run bootstrap for a Git repository with a passwordless private key
|
||||||
|
flux bootstrap git --url=ssh://git@example.com/repository.git --private-key-file=<path/to/private.key>
|
||||||
|
|
||||||
|
# Run bootstrap for a Git repository with a private key and password
|
||||||
|
flux bootstrap git --url=ssh://git@example.com/repository.git --private-key-file=<path/to/private.key> --password=<password>
|
||||||
|
`,
|
||||||
|
RunE: bootstrapGitCmdRun,
|
||||||
|
}
|
||||||
|
|
||||||
|
type gitFlags struct {
|
||||||
|
url string
|
||||||
|
interval time.Duration
|
||||||
|
path flags.SafeRelativePath
|
||||||
|
username string
|
||||||
|
password string
|
||||||
|
silent bool
|
||||||
|
}
|
||||||
|
|
||||||
|
var gitArgs gitFlags
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
bootstrapGitCmd.Flags().StringVar(&gitArgs.url, "url", "", "Git repository URL")
|
||||||
|
bootstrapGitCmd.Flags().DurationVar(&gitArgs.interval, "interval", time.Minute, "sync interval")
|
||||||
|
bootstrapGitCmd.Flags().Var(&gitArgs.path, "path", "path relative to the repository root, when specified the cluster sync will be scoped to this path")
|
||||||
|
bootstrapGitCmd.Flags().StringVarP(&gitArgs.username, "username", "u", "git", "basic authentication username")
|
||||||
|
bootstrapGitCmd.Flags().StringVarP(&gitArgs.password, "password", "p", "", "basic authentication password")
|
||||||
|
bootstrapGitCmd.Flags().BoolVarP(&gitArgs.silent, "silent", "s", false, "assumes the deploy key is already setup, skips confirmation")
|
||||||
|
|
||||||
|
bootstrapCmd.AddCommand(bootstrapGitCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func bootstrapGitCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
|
if err := bootstrapValidate(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
repositoryURL, err := url.Parse(gitArgs.url)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
gitAuth, err := transportForURL(repositoryURL)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Manifest base
|
||||||
|
if ver, err := getVersion(bootstrapArgs.version); err == nil {
|
||||||
|
bootstrapArgs.version = ver
|
||||||
|
}
|
||||||
|
manifestsBase, err := buildEmbeddedManifestBase()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer os.RemoveAll(manifestsBase)
|
||||||
|
|
||||||
|
// Lazy go-git repository
|
||||||
|
tmpDir, err := os.MkdirTemp("", "flux-bootstrap-")
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to create temporary working dir: %w", err)
|
||||||
|
}
|
||||||
|
defer os.RemoveAll(tmpDir)
|
||||||
|
gitClient := gogit.New(tmpDir, gitAuth)
|
||||||
|
|
||||||
|
// Install manifest config
|
||||||
|
installOptions := install.Options{
|
||||||
|
BaseURL: rootArgs.defaults.BaseURL,
|
||||||
|
Version: bootstrapArgs.version,
|
||||||
|
Namespace: rootArgs.namespace,
|
||||||
|
Components: bootstrapComponents(),
|
||||||
|
Registry: bootstrapArgs.registry,
|
||||||
|
ImagePullSecret: bootstrapArgs.imagePullSecret,
|
||||||
|
WatchAllNamespaces: bootstrapArgs.watchAllNamespaces,
|
||||||
|
NetworkPolicy: bootstrapArgs.networkPolicy,
|
||||||
|
LogLevel: bootstrapArgs.logLevel.String(),
|
||||||
|
NotificationController: rootArgs.defaults.NotificationController,
|
||||||
|
ManifestFile: rootArgs.defaults.ManifestFile,
|
||||||
|
Timeout: rootArgs.timeout,
|
||||||
|
TargetPath: gitArgs.path.ToSlash(),
|
||||||
|
ClusterDomain: bootstrapArgs.clusterDomain,
|
||||||
|
TolerationKeys: bootstrapArgs.tolerationKeys,
|
||||||
|
}
|
||||||
|
if customBaseURL := bootstrapArgs.manifestsPath; customBaseURL != "" {
|
||||||
|
installOptions.BaseURL = customBaseURL
|
||||||
|
}
|
||||||
|
|
||||||
|
// Source generation and secret config
|
||||||
|
secretOpts := sourcesecret.Options{
|
||||||
|
Name: bootstrapArgs.secretName,
|
||||||
|
Namespace: rootArgs.namespace,
|
||||||
|
TargetPath: gitArgs.path.String(),
|
||||||
|
ManifestFile: sourcesecret.MakeDefaultOptions().ManifestFile,
|
||||||
|
}
|
||||||
|
if bootstrapArgs.tokenAuth {
|
||||||
|
secretOpts.Username = gitArgs.username
|
||||||
|
secretOpts.Password = gitArgs.password
|
||||||
|
|
||||||
|
if bootstrapArgs.caFile != "" {
|
||||||
|
secretOpts.CAFilePath = bootstrapArgs.caFile
|
||||||
|
}
|
||||||
|
|
||||||
|
// Configure repository URL to match auth config for sync.
|
||||||
|
repositoryURL.User = nil
|
||||||
|
repositoryURL.Scheme = "https"
|
||||||
|
repositoryURL.Host = repositoryURL.Hostname()
|
||||||
|
} else {
|
||||||
|
secretOpts.PrivateKeyAlgorithm = sourcesecret.PrivateKeyAlgorithm(bootstrapArgs.keyAlgorithm)
|
||||||
|
secretOpts.Password = gitArgs.password
|
||||||
|
secretOpts.RSAKeyBits = int(bootstrapArgs.keyRSABits)
|
||||||
|
secretOpts.ECDSACurve = bootstrapArgs.keyECDSACurve.Curve
|
||||||
|
|
||||||
|
// Configure repository URL to match auth config for sync
|
||||||
|
|
||||||
|
// Override existing user when user is not already set
|
||||||
|
// or when a username was passed in
|
||||||
|
if repositoryURL.User == nil || gitArgs.username != "git" {
|
||||||
|
repositoryURL.User = url.User(gitArgs.username)
|
||||||
|
}
|
||||||
|
|
||||||
|
repositoryURL.Scheme = "ssh"
|
||||||
|
if bootstrapArgs.sshHostname != "" {
|
||||||
|
repositoryURL.Host = bootstrapArgs.sshHostname
|
||||||
|
}
|
||||||
|
if bootstrapArgs.privateKeyFile != "" {
|
||||||
|
secretOpts.PrivateKeyPath = bootstrapArgs.privateKeyFile
|
||||||
|
}
|
||||||
|
|
||||||
|
// Configure last as it depends on the config above.
|
||||||
|
secretOpts.SSHHostname = repositoryURL.Host
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sync manifest config
|
||||||
|
syncOpts := sync.Options{
|
||||||
|
Interval: gitArgs.interval,
|
||||||
|
Name: rootArgs.namespace,
|
||||||
|
Namespace: rootArgs.namespace,
|
||||||
|
URL: repositoryURL.String(),
|
||||||
|
Branch: bootstrapArgs.branch,
|
||||||
|
Secret: bootstrapArgs.secretName,
|
||||||
|
TargetPath: gitArgs.path.ToSlash(),
|
||||||
|
ManifestFile: sync.MakeDefaultOptions().ManifestFile,
|
||||||
|
GitImplementation: sourceGitArgs.gitImplementation.String(),
|
||||||
|
RecurseSubmodules: bootstrapArgs.recurseSubmodules,
|
||||||
|
}
|
||||||
|
|
||||||
|
var caBundle []byte
|
||||||
|
if bootstrapArgs.caFile != "" {
|
||||||
|
var err error
|
||||||
|
caBundle, err = os.ReadFile(bootstrapArgs.caFile)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to read TLS CA file: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bootstrap config
|
||||||
|
bootstrapOpts := []bootstrap.GitOption{
|
||||||
|
bootstrap.WithRepositoryURL(gitArgs.url),
|
||||||
|
bootstrap.WithBranch(bootstrapArgs.branch),
|
||||||
|
bootstrap.WithAuthor(bootstrapArgs.authorName, bootstrapArgs.authorEmail),
|
||||||
|
bootstrap.WithCommitMessageAppendix(bootstrapArgs.commitMessageAppendix),
|
||||||
|
bootstrap.WithKubeconfig(rootArgs.kubeconfig, rootArgs.kubecontext),
|
||||||
|
bootstrap.WithPostGenerateSecretFunc(promptPublicKey),
|
||||||
|
bootstrap.WithLogger(logger),
|
||||||
|
bootstrap.WithCABundle(caBundle),
|
||||||
|
bootstrap.WithGitCommitSigning(bootstrapArgs.gpgKeyRingPath, bootstrapArgs.gpgPassphrase, bootstrapArgs.gpgKeyID),
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup bootstrapper with constructed configs
|
||||||
|
b, err := bootstrap.NewPlainGitProvider(gitClient, kubeClient, bootstrapOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run
|
||||||
|
return bootstrap.Run(ctx, b, manifestsBase, installOptions, secretOpts, syncOpts, rootArgs.pollInterval, rootArgs.timeout)
|
||||||
|
}
|
||||||
|
|
||||||
|
// transportForURL constructs a transport.AuthMethod based on the scheme
|
||||||
|
// of the given URL and the configured flags. If the protocol equals
|
||||||
|
// "ssh" but no private key is configured, authentication using the local
|
||||||
|
// SSH-agent is attempted.
|
||||||
|
func transportForURL(u *url.URL) (transport.AuthMethod, error) {
|
||||||
|
switch u.Scheme {
|
||||||
|
case "https":
|
||||||
|
return &http.BasicAuth{
|
||||||
|
Username: gitArgs.username,
|
||||||
|
Password: gitArgs.password,
|
||||||
|
}, nil
|
||||||
|
case "ssh":
|
||||||
|
if bootstrapArgs.privateKeyFile != "" {
|
||||||
|
return ssh.NewPublicKeysFromFile(u.User.Username(), bootstrapArgs.privateKeyFile, gitArgs.password)
|
||||||
|
}
|
||||||
|
return nil, nil
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("scheme %q is not supported", u.Scheme)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func promptPublicKey(ctx context.Context, secret corev1.Secret, _ sourcesecret.Options) error {
|
||||||
|
ppk, ok := secret.StringData[sourcesecret.PublicKeySecretKey]
|
||||||
|
if !ok {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Successf("public key: %s", strings.TrimSpace(ppk))
|
||||||
|
|
||||||
|
if !gitArgs.silent {
|
||||||
|
prompt := promptui.Prompt{
|
||||||
|
Label: "Please give the key access to your repository",
|
||||||
|
IsConfirm: true,
|
||||||
|
}
|
||||||
|
_, err := prompt.Run()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("aborting")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
268
cmd/flux/bootstrap_github.go
Normal file
268
cmd/flux/bootstrap_github.go
Normal file
@@ -0,0 +1,268 @@
|
|||||||
|
/*
|
||||||
|
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"
|
||||||
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/go-git/go-git/v5/plumbing/transport/http"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
"github.com/fluxcd/flux2/internal/bootstrap"
|
||||||
|
"github.com/fluxcd/flux2/internal/bootstrap/git/gogit"
|
||||||
|
"github.com/fluxcd/flux2/internal/bootstrap/provider"
|
||||||
|
"github.com/fluxcd/flux2/internal/flags"
|
||||||
|
"github.com/fluxcd/flux2/internal/utils"
|
||||||
|
"github.com/fluxcd/flux2/pkg/manifestgen/install"
|
||||||
|
"github.com/fluxcd/flux2/pkg/manifestgen/sourcesecret"
|
||||||
|
"github.com/fluxcd/flux2/pkg/manifestgen/sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
var bootstrapGitHubCmd = &cobra.Command{
|
||||||
|
Use: "github",
|
||||||
|
Short: "Bootstrap toolkit components in a GitHub repository",
|
||||||
|
Long: `The bootstrap github command creates the GitHub repository if it doesn't exists and
|
||||||
|
commits the toolkit components manifests to the main branch.
|
||||||
|
Then it configures the target cluster to synchronize with the repository.
|
||||||
|
If the toolkit components are present on the cluster,
|
||||||
|
the bootstrap command will perform an upgrade if needed.`,
|
||||||
|
Example: ` # Create a GitHub personal access token and export it as an env var
|
||||||
|
export GITHUB_TOKEN=<my-token>
|
||||||
|
|
||||||
|
# Run bootstrap for a private repository owned by a GitHub organization
|
||||||
|
flux bootstrap github --owner=<organization> --repository=<repository name>
|
||||||
|
|
||||||
|
# Run bootstrap for a private repository and assign organization teams to it
|
||||||
|
flux bootstrap github --owner=<organization> --repository=<repository name> --team=<team1 slug> --team=<team2 slug>
|
||||||
|
|
||||||
|
# Run bootstrap for a private repository and assign organization teams with their access level(e.g maintain, admin) to it
|
||||||
|
flux bootstrap github --owner=<organization> --repository=<repository name> --team=<team1 slug>:<access-level>
|
||||||
|
|
||||||
|
# Run bootstrap for a repository path
|
||||||
|
flux bootstrap github --owner=<organization> --repository=<repository name> --path=dev-cluster
|
||||||
|
|
||||||
|
# Run bootstrap for a public repository on a personal account
|
||||||
|
flux bootstrap github --owner=<user> --repository=<repository name> --private=false --personal=true
|
||||||
|
|
||||||
|
# Run bootstrap for a private repository hosted on GitHub Enterprise using SSH auth
|
||||||
|
flux bootstrap github --owner=<organization> --repository=<repository name> --hostname=<domain> --ssh-hostname=<domain>
|
||||||
|
|
||||||
|
# Run bootstrap for a private repository hosted on GitHub Enterprise using HTTPS auth
|
||||||
|
flux bootstrap github --owner=<organization> --repository=<repository name> --hostname=<domain> --token-auth
|
||||||
|
|
||||||
|
# Run bootstrap for an existing repository with a branch named main
|
||||||
|
flux bootstrap github --owner=<organization> --repository=<repository name> --branch=main`,
|
||||||
|
RunE: bootstrapGitHubCmdRun,
|
||||||
|
}
|
||||||
|
|
||||||
|
type githubFlags struct {
|
||||||
|
owner string
|
||||||
|
repository string
|
||||||
|
interval time.Duration
|
||||||
|
personal bool
|
||||||
|
private bool
|
||||||
|
hostname string
|
||||||
|
path flags.SafeRelativePath
|
||||||
|
teams []string
|
||||||
|
readWriteKey bool
|
||||||
|
reconcile bool
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
ghDefaultPermission = "maintain"
|
||||||
|
ghDefaultDomain = "github.com"
|
||||||
|
ghTokenEnvVar = "GITHUB_TOKEN"
|
||||||
|
)
|
||||||
|
|
||||||
|
var githubArgs githubFlags
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
bootstrapGitHubCmd.Flags().StringVar(&githubArgs.owner, "owner", "", "GitHub user or organization name")
|
||||||
|
bootstrapGitHubCmd.Flags().StringVar(&githubArgs.repository, "repository", "", "GitHub repository name")
|
||||||
|
bootstrapGitHubCmd.Flags().StringSliceVar(&githubArgs.teams, "team", []string{}, "GitHub team and the access to be given to it(team:maintain). Defaults to maintainer access if no access level is specified (also accepts comma-separated values)")
|
||||||
|
bootstrapGitHubCmd.Flags().BoolVar(&githubArgs.personal, "personal", false, "if true, the owner is assumed to be a GitHub user; otherwise an org")
|
||||||
|
bootstrapGitHubCmd.Flags().BoolVar(&githubArgs.private, "private", true, "if true, the repository is setup or configured as private")
|
||||||
|
bootstrapGitHubCmd.Flags().DurationVar(&githubArgs.interval, "interval", time.Minute, "sync interval")
|
||||||
|
bootstrapGitHubCmd.Flags().StringVar(&githubArgs.hostname, "hostname", ghDefaultDomain, "GitHub hostname")
|
||||||
|
bootstrapGitHubCmd.Flags().Var(&githubArgs.path, "path", "path relative to the repository root, when specified the cluster sync will be scoped to this path")
|
||||||
|
bootstrapGitHubCmd.Flags().BoolVar(&githubArgs.readWriteKey, "read-write-key", false, "if true, the deploy key is configured with read/write permissions")
|
||||||
|
bootstrapGitHubCmd.Flags().BoolVar(&githubArgs.reconcile, "reconcile", false, "if true, the configured options are also reconciled if the repository already exists")
|
||||||
|
|
||||||
|
bootstrapCmd.AddCommand(bootstrapGitHubCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func bootstrapGitHubCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
|
ghToken := os.Getenv(ghTokenEnvVar)
|
||||||
|
if ghToken == "" {
|
||||||
|
var err error
|
||||||
|
ghToken, err = readPasswordFromStdin("Please enter your GitHub personal access token (PAT): ")
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("could not read token: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := bootstrapValidate(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Manifest base
|
||||||
|
if ver, err := getVersion(bootstrapArgs.version); err == nil {
|
||||||
|
bootstrapArgs.version = ver
|
||||||
|
}
|
||||||
|
manifestsBase, err := buildEmbeddedManifestBase()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer os.RemoveAll(manifestsBase)
|
||||||
|
|
||||||
|
var caBundle []byte
|
||||||
|
if bootstrapArgs.caFile != "" {
|
||||||
|
var err error
|
||||||
|
caBundle, err = os.ReadFile(bootstrapArgs.caFile)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to read TLS CA file: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Build GitHub provider
|
||||||
|
providerCfg := provider.Config{
|
||||||
|
Provider: provider.GitProviderGitHub,
|
||||||
|
Hostname: githubArgs.hostname,
|
||||||
|
Token: ghToken,
|
||||||
|
CaBundle: caBundle,
|
||||||
|
}
|
||||||
|
providerClient, err := provider.BuildGitProvider(providerCfg)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lazy go-git repository
|
||||||
|
tmpDir, err := os.MkdirTemp("", "flux-bootstrap-")
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to create temporary working dir: %w", err)
|
||||||
|
}
|
||||||
|
defer os.RemoveAll(tmpDir)
|
||||||
|
gitClient := gogit.New(tmpDir, &http.BasicAuth{
|
||||||
|
Username: githubArgs.owner,
|
||||||
|
Password: ghToken,
|
||||||
|
})
|
||||||
|
|
||||||
|
// Install manifest config
|
||||||
|
installOptions := install.Options{
|
||||||
|
BaseURL: rootArgs.defaults.BaseURL,
|
||||||
|
Version: bootstrapArgs.version,
|
||||||
|
Namespace: rootArgs.namespace,
|
||||||
|
Components: bootstrapComponents(),
|
||||||
|
Registry: bootstrapArgs.registry,
|
||||||
|
ImagePullSecret: bootstrapArgs.imagePullSecret,
|
||||||
|
WatchAllNamespaces: bootstrapArgs.watchAllNamespaces,
|
||||||
|
NetworkPolicy: bootstrapArgs.networkPolicy,
|
||||||
|
LogLevel: bootstrapArgs.logLevel.String(),
|
||||||
|
NotificationController: rootArgs.defaults.NotificationController,
|
||||||
|
ManifestFile: rootArgs.defaults.ManifestFile,
|
||||||
|
Timeout: rootArgs.timeout,
|
||||||
|
TargetPath: githubArgs.path.ToSlash(),
|
||||||
|
ClusterDomain: bootstrapArgs.clusterDomain,
|
||||||
|
TolerationKeys: bootstrapArgs.tolerationKeys,
|
||||||
|
}
|
||||||
|
if customBaseURL := bootstrapArgs.manifestsPath; customBaseURL != "" {
|
||||||
|
installOptions.BaseURL = customBaseURL
|
||||||
|
}
|
||||||
|
|
||||||
|
// Source generation and secret config
|
||||||
|
secretOpts := sourcesecret.Options{
|
||||||
|
Name: bootstrapArgs.secretName,
|
||||||
|
Namespace: rootArgs.namespace,
|
||||||
|
TargetPath: githubArgs.path.ToSlash(),
|
||||||
|
ManifestFile: sourcesecret.MakeDefaultOptions().ManifestFile,
|
||||||
|
}
|
||||||
|
if bootstrapArgs.tokenAuth {
|
||||||
|
secretOpts.Username = "git"
|
||||||
|
secretOpts.Password = ghToken
|
||||||
|
|
||||||
|
if bootstrapArgs.caFile != "" {
|
||||||
|
secretOpts.CAFilePath = bootstrapArgs.caFile
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
secretOpts.PrivateKeyAlgorithm = sourcesecret.PrivateKeyAlgorithm(bootstrapArgs.keyAlgorithm)
|
||||||
|
secretOpts.RSAKeyBits = int(bootstrapArgs.keyRSABits)
|
||||||
|
secretOpts.ECDSACurve = bootstrapArgs.keyECDSACurve.Curve
|
||||||
|
secretOpts.SSHHostname = githubArgs.hostname
|
||||||
|
|
||||||
|
if bootstrapArgs.sshHostname != "" {
|
||||||
|
secretOpts.SSHHostname = bootstrapArgs.sshHostname
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sync manifest config
|
||||||
|
syncOpts := sync.Options{
|
||||||
|
Interval: githubArgs.interval,
|
||||||
|
Name: rootArgs.namespace,
|
||||||
|
Namespace: rootArgs.namespace,
|
||||||
|
Branch: bootstrapArgs.branch,
|
||||||
|
Secret: bootstrapArgs.secretName,
|
||||||
|
TargetPath: githubArgs.path.ToSlash(),
|
||||||
|
ManifestFile: sync.MakeDefaultOptions().ManifestFile,
|
||||||
|
GitImplementation: sourceGitArgs.gitImplementation.String(),
|
||||||
|
RecurseSubmodules: bootstrapArgs.recurseSubmodules,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bootstrap config
|
||||||
|
bootstrapOpts := []bootstrap.GitProviderOption{
|
||||||
|
bootstrap.WithProviderRepository(githubArgs.owner, githubArgs.repository, githubArgs.personal),
|
||||||
|
bootstrap.WithBranch(bootstrapArgs.branch),
|
||||||
|
bootstrap.WithBootstrapTransportType("https"),
|
||||||
|
bootstrap.WithAuthor(bootstrapArgs.authorName, bootstrapArgs.authorEmail),
|
||||||
|
bootstrap.WithCommitMessageAppendix(bootstrapArgs.commitMessageAppendix),
|
||||||
|
bootstrap.WithProviderTeamPermissions(mapTeamSlice(githubArgs.teams, ghDefaultPermission)),
|
||||||
|
bootstrap.WithReadWriteKeyPermissions(githubArgs.readWriteKey),
|
||||||
|
bootstrap.WithKubeconfig(rootArgs.kubeconfig, rootArgs.kubecontext),
|
||||||
|
bootstrap.WithLogger(logger),
|
||||||
|
bootstrap.WithCABundle(caBundle),
|
||||||
|
}
|
||||||
|
if bootstrapArgs.sshHostname != "" {
|
||||||
|
bootstrapOpts = append(bootstrapOpts, bootstrap.WithSSHHostname(bootstrapArgs.sshHostname))
|
||||||
|
}
|
||||||
|
if bootstrapArgs.tokenAuth {
|
||||||
|
bootstrapOpts = append(bootstrapOpts, bootstrap.WithSyncTransportType("https"))
|
||||||
|
}
|
||||||
|
if !githubArgs.private {
|
||||||
|
bootstrapOpts = append(bootstrapOpts, bootstrap.WithProviderRepositoryConfig("", "", "public"))
|
||||||
|
}
|
||||||
|
if githubArgs.reconcile {
|
||||||
|
bootstrapOpts = append(bootstrapOpts, bootstrap.WithReconcile())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup bootstrapper with constructed configs
|
||||||
|
b, err := bootstrap.NewGitProviderBootstrapper(gitClient, providerClient, kubeClient, bootstrapOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run
|
||||||
|
return bootstrap.Run(ctx, b, manifestsBase, installOptions, secretOpts, syncOpts, rootArgs.pollInterval, rootArgs.timeout)
|
||||||
|
}
|
||||||
282
cmd/flux/bootstrap_gitlab.go
Normal file
282
cmd/flux/bootstrap_gitlab.go
Normal file
@@ -0,0 +1,282 @@
|
|||||||
|
/*
|
||||||
|
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"
|
||||||
|
"os"
|
||||||
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/go-git/go-git/v5/plumbing/transport/http"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
"github.com/fluxcd/flux2/internal/bootstrap"
|
||||||
|
"github.com/fluxcd/flux2/internal/bootstrap/git/gogit"
|
||||||
|
"github.com/fluxcd/flux2/internal/bootstrap/provider"
|
||||||
|
"github.com/fluxcd/flux2/internal/flags"
|
||||||
|
"github.com/fluxcd/flux2/internal/utils"
|
||||||
|
"github.com/fluxcd/flux2/pkg/manifestgen/install"
|
||||||
|
"github.com/fluxcd/flux2/pkg/manifestgen/sourcesecret"
|
||||||
|
"github.com/fluxcd/flux2/pkg/manifestgen/sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
var bootstrapGitLabCmd = &cobra.Command{
|
||||||
|
Use: "gitlab",
|
||||||
|
Short: "Bootstrap toolkit components in a GitLab repository",
|
||||||
|
Long: `The bootstrap gitlab command creates the GitLab repository if it doesn't exists and
|
||||||
|
commits the toolkit components manifests to the master branch.
|
||||||
|
Then it configures the target cluster to synchronize with the repository.
|
||||||
|
If the toolkit components are present on the cluster,
|
||||||
|
the bootstrap command will perform an upgrade if needed.`,
|
||||||
|
Example: ` # Create a GitLab API token and export it as an env var
|
||||||
|
export GITLAB_TOKEN=<my-token>
|
||||||
|
|
||||||
|
# Run bootstrap for a private repository using HTTPS token authentication
|
||||||
|
flux bootstrap gitlab --owner=<group> --repository=<repository name> --token-auth
|
||||||
|
|
||||||
|
# Run bootstrap for a private repository using SSH authentication
|
||||||
|
flux bootstrap gitlab --owner=<group> --repository=<repository name>
|
||||||
|
|
||||||
|
# Run bootstrap for a repository path
|
||||||
|
flux bootstrap gitlab --owner=<group> --repository=<repository name> --path=dev-cluster
|
||||||
|
|
||||||
|
# Run bootstrap for a public repository on a personal account
|
||||||
|
flux bootstrap gitlab --owner=<user> --repository=<repository name> --private=false --personal --token-auth
|
||||||
|
|
||||||
|
# Run bootstrap for a private repository hosted on a GitLab server
|
||||||
|
flux bootstrap gitlab --owner=<group> --repository=<repository name> --hostname=<domain> --token-auth
|
||||||
|
|
||||||
|
# Run bootstrap for a an existing repository with a branch named main
|
||||||
|
flux bootstrap gitlab --owner=<organization> --repository=<repository name> --branch=main --token-auth`,
|
||||||
|
RunE: bootstrapGitLabCmdRun,
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
glDefaultPermission = "maintain"
|
||||||
|
glDefaultDomain = "gitlab.com"
|
||||||
|
glTokenEnvVar = "GITLAB_TOKEN"
|
||||||
|
gitlabProjectRegex = `\A[[:alnum:]\x{00A9}-\x{1f9ff}_][[:alnum:]\p{Pd}\x{00A9}-\x{1f9ff}_\.]*\z`
|
||||||
|
)
|
||||||
|
|
||||||
|
type gitlabFlags struct {
|
||||||
|
owner string
|
||||||
|
repository string
|
||||||
|
interval time.Duration
|
||||||
|
personal bool
|
||||||
|
private bool
|
||||||
|
hostname string
|
||||||
|
path flags.SafeRelativePath
|
||||||
|
teams []string
|
||||||
|
readWriteKey bool
|
||||||
|
reconcile bool
|
||||||
|
}
|
||||||
|
|
||||||
|
var gitlabArgs gitlabFlags
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
bootstrapGitLabCmd.Flags().StringVar(&gitlabArgs.owner, "owner", "", "GitLab user or group name")
|
||||||
|
bootstrapGitLabCmd.Flags().StringVar(&gitlabArgs.repository, "repository", "", "GitLab repository name")
|
||||||
|
bootstrapGitLabCmd.Flags().StringSliceVar(&gitlabArgs.teams, "team", []string{}, "GitLab teams to be given maintainer access (also accepts comma-separated values)")
|
||||||
|
bootstrapGitLabCmd.Flags().BoolVar(&gitlabArgs.personal, "personal", false, "if true, the owner is assumed to be a GitLab user; otherwise a group")
|
||||||
|
bootstrapGitLabCmd.Flags().BoolVar(&gitlabArgs.private, "private", true, "if true, the repository is setup or configured as private")
|
||||||
|
bootstrapGitLabCmd.Flags().DurationVar(&gitlabArgs.interval, "interval", time.Minute, "sync interval")
|
||||||
|
bootstrapGitLabCmd.Flags().StringVar(&gitlabArgs.hostname, "hostname", glDefaultDomain, "GitLab hostname")
|
||||||
|
bootstrapGitLabCmd.Flags().Var(&gitlabArgs.path, "path", "path relative to the repository root, when specified the cluster sync will be scoped to this path")
|
||||||
|
bootstrapGitLabCmd.Flags().BoolVar(&gitlabArgs.readWriteKey, "read-write-key", false, "if true, the deploy key is configured with read/write permissions")
|
||||||
|
bootstrapGitLabCmd.Flags().BoolVar(&gitlabArgs.reconcile, "reconcile", false, "if true, the configured options are also reconciled if the repository already exists")
|
||||||
|
|
||||||
|
bootstrapCmd.AddCommand(bootstrapGitLabCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func bootstrapGitLabCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
|
glToken := os.Getenv(glTokenEnvVar)
|
||||||
|
if glToken == "" {
|
||||||
|
var err error
|
||||||
|
glToken, err = readPasswordFromStdin("Please enter your GitLab personal access token (PAT): ")
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("could not read token: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if projectNameIsValid, err := regexp.MatchString(gitlabProjectRegex, gitlabArgs.repository); err != nil || !projectNameIsValid {
|
||||||
|
if err == nil {
|
||||||
|
err = fmt.Errorf("%s is an invalid project name for gitlab.\nIt can contain only letters, digits, emojis, '_', '.', dash, space. It must start with letter, digit, emoji or '_'.", gitlabArgs.repository)
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := bootstrapValidate(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Manifest base
|
||||||
|
if ver, err := getVersion(bootstrapArgs.version); err == nil {
|
||||||
|
bootstrapArgs.version = ver
|
||||||
|
}
|
||||||
|
manifestsBase, err := buildEmbeddedManifestBase()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer os.RemoveAll(manifestsBase)
|
||||||
|
|
||||||
|
var caBundle []byte
|
||||||
|
if bootstrapArgs.caFile != "" {
|
||||||
|
var err error
|
||||||
|
caBundle, err = os.ReadFile(bootstrapArgs.caFile)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to read TLS CA file: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build GitLab provider
|
||||||
|
providerCfg := provider.Config{
|
||||||
|
Provider: provider.GitProviderGitLab,
|
||||||
|
Hostname: gitlabArgs.hostname,
|
||||||
|
Token: glToken,
|
||||||
|
CaBundle: caBundle,
|
||||||
|
}
|
||||||
|
// Workaround for: https://github.com/fluxcd/go-git-providers/issues/55
|
||||||
|
if hostname := providerCfg.Hostname; hostname != glDefaultDomain &&
|
||||||
|
!strings.HasPrefix(hostname, "https://") &&
|
||||||
|
!strings.HasPrefix(hostname, "http://") {
|
||||||
|
providerCfg.Hostname = "https://" + providerCfg.Hostname
|
||||||
|
}
|
||||||
|
providerClient, err := provider.BuildGitProvider(providerCfg)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lazy go-git repository
|
||||||
|
tmpDir, err := os.MkdirTemp("", "flux-bootstrap-")
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to create temporary working dir: %w", err)
|
||||||
|
}
|
||||||
|
defer os.RemoveAll(tmpDir)
|
||||||
|
gitClient := gogit.New(tmpDir, &http.BasicAuth{
|
||||||
|
Username: gitlabArgs.owner,
|
||||||
|
Password: glToken,
|
||||||
|
})
|
||||||
|
|
||||||
|
// Install manifest config
|
||||||
|
installOptions := install.Options{
|
||||||
|
BaseURL: rootArgs.defaults.BaseURL,
|
||||||
|
Version: bootstrapArgs.version,
|
||||||
|
Namespace: rootArgs.namespace,
|
||||||
|
Components: bootstrapComponents(),
|
||||||
|
Registry: bootstrapArgs.registry,
|
||||||
|
ImagePullSecret: bootstrapArgs.imagePullSecret,
|
||||||
|
WatchAllNamespaces: bootstrapArgs.watchAllNamespaces,
|
||||||
|
NetworkPolicy: bootstrapArgs.networkPolicy,
|
||||||
|
LogLevel: bootstrapArgs.logLevel.String(),
|
||||||
|
NotificationController: rootArgs.defaults.NotificationController,
|
||||||
|
ManifestFile: rootArgs.defaults.ManifestFile,
|
||||||
|
Timeout: rootArgs.timeout,
|
||||||
|
TargetPath: gitlabArgs.path.ToSlash(),
|
||||||
|
ClusterDomain: bootstrapArgs.clusterDomain,
|
||||||
|
TolerationKeys: bootstrapArgs.tolerationKeys,
|
||||||
|
}
|
||||||
|
if customBaseURL := bootstrapArgs.manifestsPath; customBaseURL != "" {
|
||||||
|
installOptions.BaseURL = customBaseURL
|
||||||
|
}
|
||||||
|
|
||||||
|
// Source generation and secret config
|
||||||
|
secretOpts := sourcesecret.Options{
|
||||||
|
Name: bootstrapArgs.secretName,
|
||||||
|
Namespace: rootArgs.namespace,
|
||||||
|
TargetPath: gitlabArgs.path.String(),
|
||||||
|
ManifestFile: sourcesecret.MakeDefaultOptions().ManifestFile,
|
||||||
|
}
|
||||||
|
if bootstrapArgs.tokenAuth {
|
||||||
|
secretOpts.Username = "git"
|
||||||
|
secretOpts.Password = glToken
|
||||||
|
|
||||||
|
if bootstrapArgs.caFile != "" {
|
||||||
|
secretOpts.CAFilePath = bootstrapArgs.caFile
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
secretOpts.PrivateKeyAlgorithm = sourcesecret.PrivateKeyAlgorithm(bootstrapArgs.keyAlgorithm)
|
||||||
|
secretOpts.RSAKeyBits = int(bootstrapArgs.keyRSABits)
|
||||||
|
secretOpts.ECDSACurve = bootstrapArgs.keyECDSACurve.Curve
|
||||||
|
secretOpts.SSHHostname = gitlabArgs.hostname
|
||||||
|
|
||||||
|
if bootstrapArgs.privateKeyFile != "" {
|
||||||
|
secretOpts.PrivateKeyPath = bootstrapArgs.privateKeyFile
|
||||||
|
}
|
||||||
|
if bootstrapArgs.sshHostname != "" {
|
||||||
|
secretOpts.SSHHostname = bootstrapArgs.sshHostname
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sync manifest config
|
||||||
|
syncOpts := sync.Options{
|
||||||
|
Interval: gitlabArgs.interval,
|
||||||
|
Name: rootArgs.namespace,
|
||||||
|
Namespace: rootArgs.namespace,
|
||||||
|
Branch: bootstrapArgs.branch,
|
||||||
|
Secret: bootstrapArgs.secretName,
|
||||||
|
TargetPath: gitlabArgs.path.ToSlash(),
|
||||||
|
ManifestFile: sync.MakeDefaultOptions().ManifestFile,
|
||||||
|
GitImplementation: sourceGitArgs.gitImplementation.String(),
|
||||||
|
RecurseSubmodules: bootstrapArgs.recurseSubmodules,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bootstrap config
|
||||||
|
bootstrapOpts := []bootstrap.GitProviderOption{
|
||||||
|
bootstrap.WithProviderRepository(gitlabArgs.owner, gitlabArgs.repository, gitlabArgs.personal),
|
||||||
|
bootstrap.WithBranch(bootstrapArgs.branch),
|
||||||
|
bootstrap.WithBootstrapTransportType("https"),
|
||||||
|
bootstrap.WithAuthor(bootstrapArgs.authorName, bootstrapArgs.authorEmail),
|
||||||
|
bootstrap.WithCommitMessageAppendix(bootstrapArgs.commitMessageAppendix),
|
||||||
|
bootstrap.WithProviderTeamPermissions(mapTeamSlice(gitlabArgs.teams, glDefaultPermission)),
|
||||||
|
bootstrap.WithReadWriteKeyPermissions(gitlabArgs.readWriteKey),
|
||||||
|
bootstrap.WithKubeconfig(rootArgs.kubeconfig, rootArgs.kubecontext),
|
||||||
|
bootstrap.WithLogger(logger),
|
||||||
|
bootstrap.WithCABundle(caBundle),
|
||||||
|
}
|
||||||
|
if bootstrapArgs.sshHostname != "" {
|
||||||
|
bootstrapOpts = append(bootstrapOpts, bootstrap.WithSSHHostname(bootstrapArgs.sshHostname))
|
||||||
|
}
|
||||||
|
if bootstrapArgs.tokenAuth {
|
||||||
|
bootstrapOpts = append(bootstrapOpts, bootstrap.WithSyncTransportType("https"))
|
||||||
|
}
|
||||||
|
if !gitlabArgs.private {
|
||||||
|
bootstrapOpts = append(bootstrapOpts, bootstrap.WithProviderRepositoryConfig("", "", "public"))
|
||||||
|
}
|
||||||
|
if gitlabArgs.reconcile {
|
||||||
|
bootstrapOpts = append(bootstrapOpts, bootstrap.WithReconcile())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup bootstrapper with constructed configs
|
||||||
|
b, err := bootstrap.NewGitProviderBootstrapper(gitClient, providerClient, kubeClient, bootstrapOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run
|
||||||
|
return bootstrap.Run(ctx, b, manifestsBase, installOptions, secretOpts, syncOpts, rootArgs.pollInterval, rootArgs.timeout)
|
||||||
|
}
|
||||||
210
cmd/flux/check.go
Normal file
210
cmd/flux/check.go
Normal file
@@ -0,0 +1,210 @@
|
|||||||
|
/*
|
||||||
|
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"
|
||||||
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/Masterminds/semver/v3"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
v1 "k8s.io/api/apps/v1"
|
||||||
|
"k8s.io/client-go/kubernetes"
|
||||||
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
|
|
||||||
|
"github.com/fluxcd/pkg/version"
|
||||||
|
|
||||||
|
"github.com/fluxcd/flux2/internal/utils"
|
||||||
|
"github.com/fluxcd/flux2/pkg/manifestgen"
|
||||||
|
"github.com/fluxcd/flux2/pkg/manifestgen/install"
|
||||||
|
"github.com/fluxcd/flux2/pkg/status"
|
||||||
|
)
|
||||||
|
|
||||||
|
var checkCmd = &cobra.Command{
|
||||||
|
Use: "check",
|
||||||
|
Short: "Check requirements and installation",
|
||||||
|
Long: `The check command will perform a series of checks to validate that
|
||||||
|
the local environment is configured correctly and if the installed components are healthy.`,
|
||||||
|
Example: ` # Run pre-installation checks
|
||||||
|
flux check --pre
|
||||||
|
|
||||||
|
# Run installation checks
|
||||||
|
flux check`,
|
||||||
|
RunE: runCheckCmd,
|
||||||
|
}
|
||||||
|
|
||||||
|
type checkFlags struct {
|
||||||
|
pre bool
|
||||||
|
components []string
|
||||||
|
extraComponents []string
|
||||||
|
pollInterval time.Duration
|
||||||
|
}
|
||||||
|
|
||||||
|
var kubernetesConstraints = []string{
|
||||||
|
">=1.19.0-0",
|
||||||
|
">=1.16.11-0 <=1.16.15-0",
|
||||||
|
">=1.17.7-0 <=1.17.17-0",
|
||||||
|
">=1.18.4-0 <=1.18.20-0",
|
||||||
|
}
|
||||||
|
|
||||||
|
var checkArgs checkFlags
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
checkCmd.Flags().BoolVarP(&checkArgs.pre, "pre", "", false,
|
||||||
|
"only run pre-installation checks")
|
||||||
|
checkCmd.Flags().StringSliceVar(&checkArgs.components, "components", rootArgs.defaults.Components,
|
||||||
|
"list of components, accepts comma-separated values")
|
||||||
|
checkCmd.Flags().StringSliceVar(&checkArgs.extraComponents, "components-extra", nil,
|
||||||
|
"list of components in addition to those supplied or defaulted, accepts comma-separated values")
|
||||||
|
checkCmd.Flags().DurationVar(&checkArgs.pollInterval, "poll-interval", 5*time.Second,
|
||||||
|
"how often the health checker should poll the cluster for the latest state of the resources.")
|
||||||
|
rootCmd.AddCommand(checkCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func runCheckCmd(cmd *cobra.Command, args []string) error {
|
||||||
|
logger.Actionf("checking prerequisites")
|
||||||
|
checkFailed := false
|
||||||
|
|
||||||
|
fluxCheck()
|
||||||
|
|
||||||
|
if !kubernetesCheck(kubernetesConstraints) {
|
||||||
|
checkFailed = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if checkArgs.pre {
|
||||||
|
if checkFailed {
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
logger.Successf("prerequisites checks passed")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Actionf("checking controllers")
|
||||||
|
if !componentsCheck() {
|
||||||
|
checkFailed = true
|
||||||
|
}
|
||||||
|
if checkFailed {
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
logger.Successf("all checks passed")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func fluxCheck() {
|
||||||
|
curSv, err := version.ParseVersion(VERSION)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// Exclude development builds.
|
||||||
|
if curSv.Prerelease() != "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
latest, err := install.GetLatestVersion()
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
latestSv, err := version.ParseVersion(latest)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if latestSv.GreaterThan(curSv) {
|
||||||
|
logger.Failuref("flux %s <%s (new version is available, please upgrade)", curSv, latestSv)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func kubernetesCheck(constraints []string) bool {
|
||||||
|
cfg, err := utils.KubeConfig(rootArgs.kubeconfig, rootArgs.kubecontext)
|
||||||
|
if err != nil {
|
||||||
|
logger.Failuref("Kubernetes client initialization failed: %s", err.Error())
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
clientSet, err := kubernetes.NewForConfig(cfg)
|
||||||
|
if err != nil {
|
||||||
|
logger.Failuref("Kubernetes client initialization failed: %s", err.Error())
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
kv, err := clientSet.Discovery().ServerVersion()
|
||||||
|
if err != nil {
|
||||||
|
logger.Failuref("Kubernetes API call failed: %s", err.Error())
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
v, err := version.ParseVersion(kv.String())
|
||||||
|
if err != nil {
|
||||||
|
logger.Failuref("Kubernetes version can't be determined")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
var valid bool
|
||||||
|
var vrange string
|
||||||
|
for _, constraint := range constraints {
|
||||||
|
c, _ := semver.NewConstraint(constraint)
|
||||||
|
if c.Check(v) {
|
||||||
|
valid = true
|
||||||
|
vrange = constraint
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !valid {
|
||||||
|
logger.Failuref("Kubernetes version %s does not match %s", v.Original(), constraints[0])
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Successf("Kubernetes %s %s", v.String(), vrange)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func componentsCheck() bool {
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
kubeConfig, err := utils.KubeConfig(rootArgs.kubeconfig, rootArgs.kubecontext)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
statusChecker, err := status.NewStatusChecker(kubeConfig, checkArgs.pollInterval, rootArgs.timeout, logger)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
ok := true
|
||||||
|
selector := client.MatchingLabels{manifestgen.PartOfLabelKey: manifestgen.PartOfLabelValue}
|
||||||
|
var list v1.DeploymentList
|
||||||
|
if err := kubeClient.List(ctx, &list, client.InNamespace(rootArgs.namespace), selector); err == nil {
|
||||||
|
for _, d := range list.Items {
|
||||||
|
if ref, err := buildComponentObjectRefs(d.Name); err == nil {
|
||||||
|
if err := statusChecker.Assess(ref...); err != nil {
|
||||||
|
ok = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, c := range d.Spec.Template.Spec.Containers {
|
||||||
|
logger.Actionf(c.Image)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ok
|
||||||
|
}
|
||||||
51
cmd/flux/check_test.go
Normal file
51
cmd/flux/check_test.go
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
// +build e2e
|
||||||
|
|
||||||
|
/*
|
||||||
|
Copyright 2021 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"
|
||||||
|
"encoding/json"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/fluxcd/flux2/internal/utils"
|
||||||
|
"k8s.io/apimachinery/pkg/version"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestCheckPre(t *testing.T) {
|
||||||
|
jsonOutput, err := utils.ExecKubectlCommand(context.TODO(), utils.ModeCapture, rootArgs.kubeconfig, rootArgs.kubecontext, "version", "--output", "json")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error running utils.ExecKubectlCommand: %v", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
var versions map[string]version.Info
|
||||||
|
if err := json.Unmarshal([]byte(jsonOutput), &versions); err != nil {
|
||||||
|
t.Fatalf("Error unmarshalling: %v", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
serverVersion := strings.TrimPrefix(versions["serverVersion"].GitVersion, "v")
|
||||||
|
|
||||||
|
cmd := cmdTestCase{
|
||||||
|
args: "check --pre",
|
||||||
|
assert: assertGoldenTemplateFile("testdata/check/check_pre.golden", map[string]string{
|
||||||
|
"serverVersion": serverVersion,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
cmd.runTestCmd(t)
|
||||||
|
}
|
||||||
116
cmd/flux/completion.go
Normal file
116
cmd/flux/completion.go
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
/*
|
||||||
|
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"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/fluxcd/flux2/internal/utils"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
"k8s.io/apimachinery/pkg/api/meta"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
"k8s.io/client-go/discovery"
|
||||||
|
memory "k8s.io/client-go/discovery/cached"
|
||||||
|
"k8s.io/client-go/dynamic"
|
||||||
|
"k8s.io/client-go/restmapper"
|
||||||
|
)
|
||||||
|
|
||||||
|
var completionCmd = &cobra.Command{
|
||||||
|
Use: "completion",
|
||||||
|
Short: "Generates completion scripts for various shells",
|
||||||
|
Long: "The completion sub-command generates completion scripts for various shells",
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
rootCmd.AddCommand(completionCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func contextsCompletionFunc(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||||
|
rawConfig, err := utils.ClientConfig(rootArgs.kubeconfig, rootArgs.kubecontext).RawConfig()
|
||||||
|
if err != nil {
|
||||||
|
return completionError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var comps []string
|
||||||
|
|
||||||
|
for name := range rawConfig.Contexts {
|
||||||
|
if strings.HasPrefix(name, toComplete) {
|
||||||
|
comps = append(comps, name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return comps, cobra.ShellCompDirectiveNoFileComp
|
||||||
|
}
|
||||||
|
|
||||||
|
func resourceNamesCompletionFunc(gvk schema.GroupVersionKind) func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||||
|
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
cfg, err := utils.KubeConfig(rootArgs.kubeconfig, rootArgs.kubecontext)
|
||||||
|
if err != nil {
|
||||||
|
return completionError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
dc, err := discovery.NewDiscoveryClientForConfig(cfg)
|
||||||
|
if err != nil {
|
||||||
|
return completionError(err)
|
||||||
|
}
|
||||||
|
mapper := restmapper.NewDeferredDiscoveryRESTMapper(memory.NewMemCacheClient(dc))
|
||||||
|
|
||||||
|
mapping, err := mapper.RESTMapping(gvk.GroupKind(), gvk.Version)
|
||||||
|
if err != nil {
|
||||||
|
return completionError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
client, err := dynamic.NewForConfig(cfg)
|
||||||
|
if err != nil {
|
||||||
|
return completionError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var dr dynamic.ResourceInterface
|
||||||
|
if mapping.Scope.Name() == meta.RESTScopeNameNamespace {
|
||||||
|
dr = client.Resource(mapping.Resource).Namespace(rootArgs.namespace)
|
||||||
|
} else {
|
||||||
|
dr = client.Resource(mapping.Resource)
|
||||||
|
}
|
||||||
|
|
||||||
|
list, err := dr.List(ctx, metav1.ListOptions{})
|
||||||
|
if err != nil {
|
||||||
|
return completionError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var comps []string
|
||||||
|
|
||||||
|
for _, item := range list.Items {
|
||||||
|
name := item.GetName()
|
||||||
|
|
||||||
|
if strings.HasPrefix(name, toComplete) {
|
||||||
|
comps = append(comps, name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return comps, cobra.ShellCompDirectiveNoFileComp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func completionError(err error) ([]string, cobra.ShellCompDirective) {
|
||||||
|
cobra.CompError(err.Error())
|
||||||
|
return nil, cobra.ShellCompDirectiveError
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2020 The Flux CD contributors.
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -27,13 +27,12 @@ var completionBashCmd = &cobra.Command{
|
|||||||
Short: "Generates bash completion scripts",
|
Short: "Generates bash completion scripts",
|
||||||
Example: `To load completion run
|
Example: `To load completion run
|
||||||
|
|
||||||
. <(gotk completion bash)
|
. <(flux completion bash)
|
||||||
|
|
||||||
To configure your bash shell to load completions for each session add to your bashrc
|
To configure your bash shell to load completions for each session add to your bashrc
|
||||||
|
|
||||||
# ~/.bashrc or ~/.profile
|
# ~/.bashrc or ~/.profile
|
||||||
command -v gotk >/dev/null && . <(gotk completion bash)
|
command -v flux >/dev/null && . <(flux completion bash)`,
|
||||||
`,
|
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
rootCmd.GenBashCompletion(os.Stdout)
|
rootCmd.GenBashCompletion(os.Stdout)
|
||||||
},
|
},
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2020 The Flux CD contributors.
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -25,16 +25,11 @@ import (
|
|||||||
var completionFishCmd = &cobra.Command{
|
var completionFishCmd = &cobra.Command{
|
||||||
Use: "fish",
|
Use: "fish",
|
||||||
Short: "Generates fish completion scripts",
|
Short: "Generates fish completion scripts",
|
||||||
Example: `To load completion run
|
Example: `To configure your fish shell to load completions for each session write this script to your completions dir:
|
||||||
|
|
||||||
. <(gotk completion fish)
|
flux completion fish > ~/.config/fish/completions/flux.fish
|
||||||
|
|
||||||
To configure your fish shell to load completions for each session write this script to your completions dir:
|
See http://fishshell.com/docs/current/index.html#completion-own for more details`,
|
||||||
|
|
||||||
gotk completion fish > ~/.config/fish/completions/gotk
|
|
||||||
|
|
||||||
See http://fishshell.com/docs/current/index.html#completion-own for more details
|
|
||||||
`,
|
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
rootCmd.GenFishCompletion(os.Stdout, true)
|
rootCmd.GenFishCompletion(os.Stdout, true)
|
||||||
},
|
},
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2020 The Flux CD contributors.
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -27,20 +27,19 @@ var completionPowerShellCmd = &cobra.Command{
|
|||||||
Short: "Generates powershell completion scripts",
|
Short: "Generates powershell completion scripts",
|
||||||
Example: `To load completion run
|
Example: `To load completion run
|
||||||
|
|
||||||
. <(gotk completion powershell)
|
. <(flux completion powershell)
|
||||||
|
|
||||||
To configure your powershell shell to load completions for each session add to your powershell profile
|
To configure your powershell shell to load completions for each session add to your powershell profile
|
||||||
|
|
||||||
Windows:
|
Windows:
|
||||||
|
|
||||||
cd "$env:USERPROFILE\Documents\WindowsPowerShell\Modules"
|
cd "$env:USERPROFILE\Documents\WindowsPowerShell\Modules"
|
||||||
gotk completion >> gotk-completion.ps1
|
flux completion >> flux-completion.ps1
|
||||||
|
|
||||||
Linux:
|
Linux:
|
||||||
|
|
||||||
cd "${XDG_CONFIG_HOME:-"$HOME/.config/"}/powershell/modules"
|
cd "${XDG_CONFIG_HOME:-"$HOME/.config/"}/powershell/modules"
|
||||||
gotk completion >> gotk-completions.ps1
|
flux completion >> flux-completions.ps1`,
|
||||||
`,
|
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
rootCmd.GenPowerShellCompletion(os.Stdout)
|
rootCmd.GenPowerShellCompletion(os.Stdout)
|
||||||
},
|
},
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2020 The Flux CD contributors.
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@@ -27,23 +28,24 @@ var completionZshCmd = &cobra.Command{
|
|||||||
Short: "Generates zsh completion scripts",
|
Short: "Generates zsh completion scripts",
|
||||||
Example: `To load completion run
|
Example: `To load completion run
|
||||||
|
|
||||||
. <(gotk completion zsh) && compdef _gotk gotk
|
. <(flux completion zsh)
|
||||||
|
|
||||||
To configure your zsh shell to load completions for each session add to your zshrc
|
To configure your zsh shell to load completions for each session add to your zshrc
|
||||||
|
|
||||||
# ~/.zshrc or ~/.profile
|
# ~/.zshrc or ~/.profile
|
||||||
command -v gotk >/dev/null && . <(gotk completion zsh) && compdef _gotk gotk
|
command -v flux >/dev/null && . <(flux completion zsh)
|
||||||
|
|
||||||
or write a cached file in one of the completion directories in your ${fpath}:
|
or write a cached file in one of the completion directories in your ${fpath}:
|
||||||
|
|
||||||
echo "${fpath// /\n}" | grep -i completion
|
echo "${fpath// /\n}" | grep -i completion
|
||||||
gotk completions zsh > _gotk
|
flux completion zsh > _flux
|
||||||
|
|
||||||
mv _gotk ~/.oh-my-zsh/completions # oh-my-zsh
|
mv _flux ~/.oh-my-zsh/completions # oh-my-zsh
|
||||||
mv _gotk ~/.zprezto/modules/completion/external/src/ # zprezto
|
mv _flux ~/.zprezto/modules/completion/external/src/ # zprezto`,
|
||||||
`,
|
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
rootCmd.GenZshCompletion(os.Stdout)
|
rootCmd.GenZshCompletion(os.Stdout)
|
||||||
|
// Cobra doesn't source zsh completion file, explicitly doing it here
|
||||||
|
fmt.Println("compdef _flux flux")
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
152
cmd/flux/create.go
Normal file
152
cmd/flux/create.go
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
/*
|
||||||
|
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"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"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{
|
||||||
|
Use: "create",
|
||||||
|
Short: "Create or update sources and resources",
|
||||||
|
Long: "The create sub-commands generate sources and resources.",
|
||||||
|
}
|
||||||
|
|
||||||
|
type createFlags struct {
|
||||||
|
interval time.Duration
|
||||||
|
export bool
|
||||||
|
labels []string
|
||||||
|
}
|
||||||
|
|
||||||
|
var createArgs createFlags
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
createCmd.PersistentFlags().DurationVarP(&createArgs.interval, "interval", "", time.Minute, "source sync interval")
|
||||||
|
createCmd.PersistentFlags().BoolVar(&createArgs.export, "export", false, "export in YAML format to stdout")
|
||||||
|
createCmd.PersistentFlags().StringSliceVar(&createArgs.labels, "label", nil,
|
||||||
|
"set labels on the resource (can specify multiple labels with commas: label1=value1,label2=value2)")
|
||||||
|
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.asClientObject(), 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(), rootArgs.timeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.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(rootArgs.pollInterval, rootArgs.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) {
|
||||||
|
result := make(map[string]string)
|
||||||
|
for _, label := range createArgs.labels {
|
||||||
|
// validate key value pair
|
||||||
|
parts := strings.Split(label, "=")
|
||||||
|
if len(parts) != 2 {
|
||||||
|
return nil, fmt.Errorf("invalid label format '%s', must be key=value", label)
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate label name
|
||||||
|
if errors := validation.IsQualifiedName(parts[0]); len(errors) > 0 {
|
||||||
|
return nil, fmt.Errorf("invalid label '%s': %v", parts[0], errors)
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate label value
|
||||||
|
if errors := validation.IsValidLabelValue(parts[1]); len(errors) > 0 {
|
||||||
|
return nil, fmt.Errorf("invalid label value '%s': %v", parts[1], errors)
|
||||||
|
}
|
||||||
|
|
||||||
|
result[parts[0]] = parts[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2020 The Flux CD contributors.
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -20,18 +20,18 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/fluxcd/pkg/apis/meta"
|
|
||||||
"github.com/fluxcd/toolkit/internal/utils"
|
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
corev1 "k8s.io/api/core/v1"
|
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
|
apimeta "k8s.io/apimachinery/pkg/api/meta"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
|
|
||||||
notificationv1 "github.com/fluxcd/notification-controller/api/v1beta1"
|
notificationv1 "github.com/fluxcd/notification-controller/api/v1beta1"
|
||||||
|
"github.com/fluxcd/pkg/apis/meta"
|
||||||
|
|
||||||
|
"github.com/fluxcd/flux2/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
var createAlertCmd = &cobra.Command{
|
var createAlertCmd = &cobra.Command{
|
||||||
@@ -39,25 +39,26 @@ var createAlertCmd = &cobra.Command{
|
|||||||
Short: "Create or update a Alert resource",
|
Short: "Create or update a Alert resource",
|
||||||
Long: "The create alert command generates a Alert resource.",
|
Long: "The create alert command generates a Alert resource.",
|
||||||
Example: ` # Create an Alert for kustomization events
|
Example: ` # Create an Alert for kustomization events
|
||||||
gotk create alert \
|
flux create alert \
|
||||||
--event-severity info \
|
--event-severity info \
|
||||||
--event-source Kustomization/gotk-system \
|
--event-source Kustomization/flux-system \
|
||||||
--provider-ref slack \
|
--provider-ref slack \
|
||||||
gotk-system
|
flux-system`,
|
||||||
`,
|
|
||||||
RunE: createAlertCmdRun,
|
RunE: createAlertCmdRun,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
type alertFlags struct {
|
||||||
aProviderRef string
|
providerRef string
|
||||||
aEventSeverity string
|
eventSeverity string
|
||||||
aEventSources []string
|
eventSources []string
|
||||||
)
|
}
|
||||||
|
|
||||||
|
var alertArgs alertFlags
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
createAlertCmd.Flags().StringVar(&aProviderRef, "provider-ref", "", "reference to provider")
|
createAlertCmd.Flags().StringVar(&alertArgs.providerRef, "provider-ref", "", "reference to provider")
|
||||||
createAlertCmd.Flags().StringVar(&aEventSeverity, "event-severity", "", "severity of events to send alerts for")
|
createAlertCmd.Flags().StringVar(&alertArgs.eventSeverity, "event-severity", "", "severity of events to send alerts for")
|
||||||
createAlertCmd.Flags().StringArrayVar(&aEventSources, "event-source", []string{}, "sources that should generate alerts (<kind>/<name>)")
|
createAlertCmd.Flags().StringSliceVar(&alertArgs.eventSources, "event-source", []string{}, "sources that should generate alerts (<kind>/<name>), also accepts comma-separated values")
|
||||||
createCmd.AddCommand(createAlertCmd)
|
createCmd.AddCommand(createAlertCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,20 +68,21 @@ func createAlertCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
name := args[0]
|
name := args[0]
|
||||||
|
|
||||||
if aProviderRef == "" {
|
if alertArgs.providerRef == "" {
|
||||||
return fmt.Errorf("provider ref is required")
|
return fmt.Errorf("provider ref is required")
|
||||||
}
|
}
|
||||||
|
|
||||||
eventSources := []notificationv1.CrossNamespaceObjectReference{}
|
eventSources := []notificationv1.CrossNamespaceObjectReference{}
|
||||||
for _, eventSource := range aEventSources {
|
for _, eventSource := range alertArgs.eventSources {
|
||||||
kind, name := utils.ParseObjectKindName(eventSource)
|
kind, name, namespace := utils.ParseObjectKindNameNamespace(eventSource)
|
||||||
if kind == "" {
|
if kind == "" {
|
||||||
return fmt.Errorf("invalid event source '%s', must be in format <kind>/<name>", eventSource)
|
return fmt.Errorf("invalid event source '%s', must be in format <kind>/<name>", eventSource)
|
||||||
}
|
}
|
||||||
|
|
||||||
eventSources = append(eventSources, notificationv1.CrossNamespaceObjectReference{
|
eventSources = append(eventSources, notificationv1.CrossNamespaceObjectReference{
|
||||||
Kind: kind,
|
Kind: kind,
|
||||||
Name: name,
|
Name: name,
|
||||||
|
Namespace: namespace,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,34 +95,34 @@ func createAlertCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !export {
|
if !createArgs.export {
|
||||||
logger.Generatef("generating Alert")
|
logger.Generatef("generating Alert")
|
||||||
}
|
}
|
||||||
|
|
||||||
alert := notificationv1.Alert{
|
alert := notificationv1.Alert{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: name,
|
Name: name,
|
||||||
Namespace: namespace,
|
Namespace: rootArgs.namespace,
|
||||||
Labels: sourceLabels,
|
Labels: sourceLabels,
|
||||||
},
|
},
|
||||||
Spec: notificationv1.AlertSpec{
|
Spec: notificationv1.AlertSpec{
|
||||||
ProviderRef: corev1.LocalObjectReference{
|
ProviderRef: meta.LocalObjectReference{
|
||||||
Name: aProviderRef,
|
Name: alertArgs.providerRef,
|
||||||
},
|
},
|
||||||
EventSeverity: aEventSeverity,
|
EventSeverity: alertArgs.eventSeverity,
|
||||||
EventSources: eventSources,
|
EventSources: eventSources,
|
||||||
Suspend: false,
|
Suspend: false,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if export {
|
if createArgs.export {
|
||||||
return exportAlert(alert)
|
return printExport(exportAlert(&alert))
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
kubeClient, err := utils.KubeClient(kubeconfig)
|
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -132,7 +134,7 @@ func createAlertCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
logger.Waitingf("waiting for Alert reconciliation")
|
logger.Waitingf("waiting for Alert reconciliation")
|
||||||
if err := wait.PollImmediate(pollInterval, timeout,
|
if err := wait.PollImmediate(rootArgs.pollInterval, rootArgs.timeout,
|
||||||
isAlertReady(ctx, kubeClient, namespacedName, &alert)); err != nil {
|
isAlertReady(ctx, kubeClient, namespacedName, &alert)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -179,11 +181,11 @@ func isAlertReady(ctx context.Context, kubeClient client.Client,
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if c := meta.GetCondition(alert.Status.Conditions, meta.ReadyCondition); c != nil {
|
if c := apimeta.FindStatusCondition(alert.Status.Conditions, meta.ReadyCondition); c != nil {
|
||||||
switch c.Status {
|
switch c.Status {
|
||||||
case corev1.ConditionTrue:
|
case metav1.ConditionTrue:
|
||||||
return true, nil
|
return true, nil
|
||||||
case corev1.ConditionFalse:
|
case metav1.ConditionFalse:
|
||||||
return false, fmt.Errorf(c.Message)
|
return false, fmt.Errorf(c.Message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2020 The Flux CD contributors.
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -21,8 +21,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
corev1 "k8s.io/api/core/v1"
|
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
|
apimeta "k8s.io/apimachinery/pkg/api/meta"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
@@ -30,7 +30,8 @@ import (
|
|||||||
|
|
||||||
notificationv1 "github.com/fluxcd/notification-controller/api/v1beta1"
|
notificationv1 "github.com/fluxcd/notification-controller/api/v1beta1"
|
||||||
"github.com/fluxcd/pkg/apis/meta"
|
"github.com/fluxcd/pkg/apis/meta"
|
||||||
"github.com/fluxcd/toolkit/internal/utils"
|
|
||||||
|
"github.com/fluxcd/flux2/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
var createAlertProviderCmd = &cobra.Command{
|
var createAlertProviderCmd = &cobra.Command{
|
||||||
@@ -38,35 +39,36 @@ var createAlertProviderCmd = &cobra.Command{
|
|||||||
Short: "Create or update a Provider resource",
|
Short: "Create or update a Provider resource",
|
||||||
Long: "The create alert-provider command generates a Provider resource.",
|
Long: "The create alert-provider command generates a Provider resource.",
|
||||||
Example: ` # Create a Provider for a Slack channel
|
Example: ` # Create a Provider for a Slack channel
|
||||||
gotk create alert-provider slack \
|
flux create alert-provider slack \
|
||||||
--type slack \
|
--type slack \
|
||||||
--channel general \
|
--channel general \
|
||||||
--address https://hooks.slack.com/services/YOUR/SLACK/WEBHOOK \
|
--address https://hooks.slack.com/services/YOUR/SLACK/WEBHOOK \
|
||||||
--secret-ref webhook-url
|
--secret-ref webhook-url
|
||||||
|
|
||||||
# Create a Provider for a Github repository
|
# Create a Provider for a Github repository
|
||||||
gotk create alert-provider github-podinfo \
|
flux create alert-provider github-podinfo \
|
||||||
--type github \
|
--type github \
|
||||||
--address https://github.com/stefanprodan/podinfo \
|
--address https://github.com/stefanprodan/podinfo \
|
||||||
--secret-ref github-token
|
--secret-ref github-token`,
|
||||||
`,
|
|
||||||
RunE: createAlertProviderCmdRun,
|
RunE: createAlertProviderCmdRun,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
type alertProviderFlags struct {
|
||||||
apType string
|
alertType string
|
||||||
apChannel string
|
channel string
|
||||||
apUsername string
|
username string
|
||||||
apAddress string
|
address string
|
||||||
apSecretRef string
|
secretRef string
|
||||||
)
|
}
|
||||||
|
|
||||||
|
var alertProviderArgs alertProviderFlags
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
createAlertProviderCmd.Flags().StringVar(&apType, "type", "", "type of provider")
|
createAlertProviderCmd.Flags().StringVar(&alertProviderArgs.alertType, "type", "", "type of provider")
|
||||||
createAlertProviderCmd.Flags().StringVar(&apChannel, "channel", "", "channel to send messages to in the case of a chat provider")
|
createAlertProviderCmd.Flags().StringVar(&alertProviderArgs.channel, "channel", "", "channel to send messages to in the case of a chat provider")
|
||||||
createAlertProviderCmd.Flags().StringVar(&apUsername, "username", "", "bot username used by the provider")
|
createAlertProviderCmd.Flags().StringVar(&alertProviderArgs.username, "username", "", "bot username used by the provider")
|
||||||
createAlertProviderCmd.Flags().StringVar(&apAddress, "address", "", "path to either the git repository, chat provider or webhook")
|
createAlertProviderCmd.Flags().StringVar(&alertProviderArgs.address, "address", "", "path to either the git repository, chat provider or webhook")
|
||||||
createAlertProviderCmd.Flags().StringVar(&apSecretRef, "secret-ref", "", "name of secret containing authentication token")
|
createAlertProviderCmd.Flags().StringVar(&alertProviderArgs.secretRef, "secret-ref", "", "name of secret containing authentication token")
|
||||||
createCmd.AddCommand(createAlertProviderCmd)
|
createCmd.AddCommand(createAlertProviderCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +78,7 @@ func createAlertProviderCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
name := args[0]
|
name := args[0]
|
||||||
|
|
||||||
if apType == "" {
|
if alertProviderArgs.alertType == "" {
|
||||||
return fmt.Errorf("Provider type is required")
|
return fmt.Errorf("Provider type is required")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,38 +87,38 @@ func createAlertProviderCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !export {
|
if !createArgs.export {
|
||||||
logger.Generatef("generating Provider")
|
logger.Generatef("generating Provider")
|
||||||
}
|
}
|
||||||
|
|
||||||
provider := notificationv1.Provider{
|
provider := notificationv1.Provider{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: name,
|
Name: name,
|
||||||
Namespace: namespace,
|
Namespace: rootArgs.namespace,
|
||||||
Labels: sourceLabels,
|
Labels: sourceLabels,
|
||||||
},
|
},
|
||||||
Spec: notificationv1.ProviderSpec{
|
Spec: notificationv1.ProviderSpec{
|
||||||
Type: apType,
|
Type: alertProviderArgs.alertType,
|
||||||
Channel: apChannel,
|
Channel: alertProviderArgs.channel,
|
||||||
Username: apUsername,
|
Username: alertProviderArgs.username,
|
||||||
Address: apAddress,
|
Address: alertProviderArgs.address,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if apSecretRef != "" {
|
if alertProviderArgs.secretRef != "" {
|
||||||
provider.Spec.SecretRef = &corev1.LocalObjectReference{
|
provider.Spec.SecretRef = &meta.LocalObjectReference{
|
||||||
Name: apSecretRef,
|
Name: alertProviderArgs.secretRef,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if export {
|
if createArgs.export {
|
||||||
return exportAlertProvider(provider)
|
return printExport(exportAlertProvider(&provider))
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
kubeClient, err := utils.KubeClient(kubeconfig)
|
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -128,7 +130,7 @@ func createAlertProviderCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
logger.Waitingf("waiting for Provider reconciliation")
|
logger.Waitingf("waiting for Provider reconciliation")
|
||||||
if err := wait.PollImmediate(pollInterval, timeout,
|
if err := wait.PollImmediate(rootArgs.pollInterval, rootArgs.timeout,
|
||||||
isAlertProviderReady(ctx, kubeClient, namespacedName, &provider)); err != nil {
|
isAlertProviderReady(ctx, kubeClient, namespacedName, &provider)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -177,11 +179,11 @@ func isAlertProviderReady(ctx context.Context, kubeClient client.Client,
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if c := meta.GetCondition(provider.Status.Conditions, meta.ReadyCondition); c != nil {
|
if c := apimeta.FindStatusCondition(provider.Status.Conditions, meta.ReadyCondition); c != nil {
|
||||||
switch c.Status {
|
switch c.Status {
|
||||||
case corev1.ConditionTrue:
|
case metav1.ConditionTrue:
|
||||||
return true, nil
|
return true, nil
|
||||||
case corev1.ConditionFalse:
|
case metav1.ConditionFalse:
|
||||||
return false, fmt.Errorf(c.Message)
|
return false, fmt.Errorf(c.Message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
321
cmd/flux/create_helmrelease.go
Normal file
321
cmd/flux/create_helmrelease.go
Normal file
@@ -0,0 +1,321 @@
|
|||||||
|
/*
|
||||||
|
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"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/fluxcd/flux2/internal/flags"
|
||||||
|
"github.com/fluxcd/flux2/internal/utils"
|
||||||
|
"github.com/fluxcd/pkg/apis/meta"
|
||||||
|
"github.com/fluxcd/pkg/runtime/transform"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
|
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"
|
||||||
|
"sigs.k8s.io/yaml"
|
||||||
|
|
||||||
|
helmv2 "github.com/fluxcd/helm-controller/api/v2beta1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var createHelmReleaseCmd = &cobra.Command{
|
||||||
|
Use: "helmrelease [name]",
|
||||||
|
Aliases: []string{"hr"},
|
||||||
|
Short: "Create or update a HelmRelease resource",
|
||||||
|
Long: "The helmrelease create command generates a HelmRelease resource for a given HelmRepository source.",
|
||||||
|
Example: ` # Create a HelmRelease with a chart from a HelmRepository source
|
||||||
|
flux create hr podinfo \
|
||||||
|
--interval=10m \
|
||||||
|
--source=HelmRepository/podinfo \
|
||||||
|
--chart=podinfo \
|
||||||
|
--chart-version=">4.0.0"
|
||||||
|
|
||||||
|
# Create a HelmRelease with a chart from a GitRepository source
|
||||||
|
flux create hr podinfo \
|
||||||
|
--interval=10m \
|
||||||
|
--source=GitRepository/podinfo \
|
||||||
|
--chart=./charts/podinfo
|
||||||
|
|
||||||
|
# Create a HelmRelease with a chart from a Bucket source
|
||||||
|
flux create hr podinfo \
|
||||||
|
--interval=10m \
|
||||||
|
--source=Bucket/podinfo \
|
||||||
|
--chart=./charts/podinfo
|
||||||
|
|
||||||
|
# Create a HelmRelease with values from local YAML files
|
||||||
|
flux create hr podinfo \
|
||||||
|
--source=HelmRepository/podinfo \
|
||||||
|
--chart=podinfo \
|
||||||
|
--values=./my-values1.yaml \
|
||||||
|
--values=./my-values2.yaml
|
||||||
|
|
||||||
|
# Create a HelmRelease with values from a Kubernetes secret
|
||||||
|
kubectl -n app create secret generic my-secret-values \
|
||||||
|
--from-file=values.yaml=/path/to/my-secret-values.yaml
|
||||||
|
flux -n app create hr podinfo \
|
||||||
|
--source=HelmRepository/podinfo \
|
||||||
|
--chart=podinfo \
|
||||||
|
--values-from=Secret/my-secret-values
|
||||||
|
|
||||||
|
# Create a HelmRelease with a custom release name
|
||||||
|
flux create hr podinfo \
|
||||||
|
--release-name=podinfo-dev
|
||||||
|
--source=HelmRepository/podinfo \
|
||||||
|
--chart=podinfo \
|
||||||
|
|
||||||
|
# Create a HelmRelease targeting another namespace than the resource
|
||||||
|
flux create hr podinfo \
|
||||||
|
--target-namespace=test \
|
||||||
|
--create-target-namespace=true \
|
||||||
|
--source=HelmRepository/podinfo \
|
||||||
|
--chart=podinfo
|
||||||
|
|
||||||
|
# Create a HelmRelease using a source from a different namespace
|
||||||
|
flux create hr podinfo \
|
||||||
|
--namespace=default \
|
||||||
|
--source=HelmRepository/podinfo.flux-system \
|
||||||
|
--chart=podinfo
|
||||||
|
|
||||||
|
# Create a HelmRelease definition on disk without applying it on the cluster
|
||||||
|
flux create hr podinfo \
|
||||||
|
--source=HelmRepository/podinfo \
|
||||||
|
--chart=podinfo \
|
||||||
|
--values=./values.yaml \
|
||||||
|
--export > podinfo-release.yaml`,
|
||||||
|
RunE: createHelmReleaseCmdRun,
|
||||||
|
}
|
||||||
|
|
||||||
|
type helmReleaseFlags struct {
|
||||||
|
name string
|
||||||
|
source flags.HelmChartSource
|
||||||
|
dependsOn []string
|
||||||
|
chart string
|
||||||
|
chartVersion string
|
||||||
|
targetNamespace string
|
||||||
|
createNamespace bool
|
||||||
|
valuesFiles []string
|
||||||
|
valuesFrom flags.HelmReleaseValuesFrom
|
||||||
|
saName string
|
||||||
|
crds flags.CRDsPolicy
|
||||||
|
}
|
||||||
|
|
||||||
|
var helmReleaseArgs helmReleaseFlags
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
createHelmReleaseCmd.Flags().StringVar(&helmReleaseArgs.name, "release-name", "", "name used for the Helm release, defaults to a composition of '[<target-namespace>-]<HelmRelease-name>'")
|
||||||
|
createHelmReleaseCmd.Flags().Var(&helmReleaseArgs.source, "source", helmReleaseArgs.source.Description())
|
||||||
|
createHelmReleaseCmd.Flags().StringVar(&helmReleaseArgs.chart, "chart", "", "Helm chart name or path")
|
||||||
|
createHelmReleaseCmd.Flags().StringVar(&helmReleaseArgs.chartVersion, "chart-version", "", "Helm chart version, accepts a semver range (ignored for charts from GitRepository sources)")
|
||||||
|
createHelmReleaseCmd.Flags().StringSliceVar(&helmReleaseArgs.dependsOn, "depends-on", nil, "HelmReleases that must be ready before this release can be installed, supported formats '<name>' and '<namespace>/<name>'")
|
||||||
|
createHelmReleaseCmd.Flags().StringVar(&helmReleaseArgs.targetNamespace, "target-namespace", "", "namespace to install this release, defaults to the HelmRelease namespace")
|
||||||
|
createHelmReleaseCmd.Flags().BoolVar(&helmReleaseArgs.createNamespace, "create-target-namespace", false, "create the target namespace if it does not exist")
|
||||||
|
createHelmReleaseCmd.Flags().StringVar(&helmReleaseArgs.saName, "service-account", "", "the name of the service account to impersonate when reconciling this HelmRelease")
|
||||||
|
createHelmReleaseCmd.Flags().StringSliceVar(&helmReleaseArgs.valuesFiles, "values", nil, "local path to values.yaml files, also accepts comma-separated values")
|
||||||
|
createHelmReleaseCmd.Flags().Var(&helmReleaseArgs.valuesFrom, "values-from", helmReleaseArgs.valuesFrom.Description())
|
||||||
|
createHelmReleaseCmd.Flags().Var(&helmReleaseArgs.crds, "crds", helmReleaseArgs.crds.Description())
|
||||||
|
createCmd.AddCommand(createHelmReleaseCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func createHelmReleaseCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
|
if len(args) < 1 {
|
||||||
|
return fmt.Errorf("HelmRelease name is required")
|
||||||
|
}
|
||||||
|
name := args[0]
|
||||||
|
|
||||||
|
if helmReleaseArgs.chart == "" {
|
||||||
|
return fmt.Errorf("chart name or path is required")
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceLabels, err := parseLabels()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if !createArgs.export {
|
||||||
|
logger.Generatef("generating HelmRelease")
|
||||||
|
}
|
||||||
|
|
||||||
|
helmRelease := helmv2.HelmRelease{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: name,
|
||||||
|
Namespace: rootArgs.namespace,
|
||||||
|
Labels: sourceLabels,
|
||||||
|
},
|
||||||
|
Spec: helmv2.HelmReleaseSpec{
|
||||||
|
ReleaseName: helmReleaseArgs.name,
|
||||||
|
DependsOn: utils.MakeDependsOn(helmReleaseArgs.dependsOn),
|
||||||
|
Interval: metav1.Duration{
|
||||||
|
Duration: createArgs.interval,
|
||||||
|
},
|
||||||
|
TargetNamespace: helmReleaseArgs.targetNamespace,
|
||||||
|
|
||||||
|
Chart: helmv2.HelmChartTemplate{
|
||||||
|
Spec: helmv2.HelmChartTemplateSpec{
|
||||||
|
Chart: helmReleaseArgs.chart,
|
||||||
|
Version: helmReleaseArgs.chartVersion,
|
||||||
|
SourceRef: helmv2.CrossNamespaceObjectReference{
|
||||||
|
Kind: helmReleaseArgs.source.Kind,
|
||||||
|
Name: helmReleaseArgs.source.Name,
|
||||||
|
Namespace: helmReleaseArgs.source.Namespace,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Suspend: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
if helmReleaseArgs.createNamespace {
|
||||||
|
if helmRelease.Spec.Install == nil {
|
||||||
|
helmRelease.Spec.Install = &helmv2.Install{}
|
||||||
|
}
|
||||||
|
|
||||||
|
helmRelease.Spec.Install.CreateNamespace = helmReleaseArgs.createNamespace
|
||||||
|
}
|
||||||
|
|
||||||
|
if helmReleaseArgs.saName != "" {
|
||||||
|
helmRelease.Spec.ServiceAccountName = helmReleaseArgs.saName
|
||||||
|
}
|
||||||
|
|
||||||
|
if helmReleaseArgs.crds != "" {
|
||||||
|
if helmRelease.Spec.Install == nil {
|
||||||
|
helmRelease.Spec.Install = &helmv2.Install{}
|
||||||
|
}
|
||||||
|
|
||||||
|
helmRelease.Spec.Install.CRDs = helmv2.Create
|
||||||
|
helmRelease.Spec.Upgrade = &helmv2.Upgrade{CRDs: helmv2.CRDsPolicy(helmReleaseArgs.crds.String())}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(helmReleaseArgs.valuesFiles) > 0 {
|
||||||
|
valuesMap := make(map[string]interface{})
|
||||||
|
for _, v := range helmReleaseArgs.valuesFiles {
|
||||||
|
data, err := os.ReadFile(v)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("reading values from %s failed: %w", v, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
jsonBytes, err := yaml.YAMLToJSON(data)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("converting values to JSON from %s failed: %w", v, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
jsonMap := make(map[string]interface{})
|
||||||
|
if err := json.Unmarshal(jsonBytes, &jsonMap); err != nil {
|
||||||
|
return fmt.Errorf("unmarshaling values from %s failed: %w", v, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
valuesMap = transform.MergeMaps(valuesMap, jsonMap)
|
||||||
|
}
|
||||||
|
|
||||||
|
jsonRaw, err := json.Marshal(valuesMap)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("marshaling values failed: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
helmRelease.Spec.Values = &apiextensionsv1.JSON{Raw: jsonRaw}
|
||||||
|
}
|
||||||
|
|
||||||
|
if helmReleaseArgs.valuesFrom.String() != "" {
|
||||||
|
helmRelease.Spec.ValuesFrom = []helmv2.ValuesReference{{
|
||||||
|
Kind: helmReleaseArgs.valuesFrom.Kind,
|
||||||
|
Name: helmReleaseArgs.valuesFrom.Name,
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
if createArgs.export {
|
||||||
|
return printExport(exportHelmRelease(&helmRelease))
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Actionf("applying HelmRelease")
|
||||||
|
namespacedName, err := upsertHelmRelease(ctx, kubeClient, &helmRelease)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Waitingf("waiting for HelmRelease reconciliation")
|
||||||
|
if err := wait.PollImmediate(rootArgs.pollInterval, rootArgs.timeout,
|
||||||
|
isHelmReleaseReady(ctx, kubeClient, namespacedName, &helmRelease)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
logger.Successf("HelmRelease %s is ready", name)
|
||||||
|
|
||||||
|
logger.Successf("applied revision %s", helmRelease.Status.LastAppliedRevision)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func upsertHelmRelease(ctx context.Context, kubeClient client.Client,
|
||||||
|
helmRelease *helmv2.HelmRelease) (types.NamespacedName, error) {
|
||||||
|
namespacedName := types.NamespacedName{
|
||||||
|
Namespace: helmRelease.GetNamespace(),
|
||||||
|
Name: helmRelease.GetName(),
|
||||||
|
}
|
||||||
|
|
||||||
|
var existing helmv2.HelmRelease
|
||||||
|
err := kubeClient.Get(ctx, namespacedName, &existing)
|
||||||
|
if err != nil {
|
||||||
|
if errors.IsNotFound(err) {
|
||||||
|
if err := kubeClient.Create(ctx, helmRelease); err != nil {
|
||||||
|
return namespacedName, err
|
||||||
|
} else {
|
||||||
|
logger.Successf("HelmRelease created")
|
||||||
|
return namespacedName, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return namespacedName, err
|
||||||
|
}
|
||||||
|
|
||||||
|
existing.Labels = helmRelease.Labels
|
||||||
|
existing.Spec = helmRelease.Spec
|
||||||
|
if err := kubeClient.Update(ctx, &existing); err != nil {
|
||||||
|
return namespacedName, err
|
||||||
|
}
|
||||||
|
helmRelease = &existing
|
||||||
|
logger.Successf("HelmRelease updated")
|
||||||
|
return namespacedName, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func isHelmReleaseReady(ctx context.Context, kubeClient client.Client,
|
||||||
|
namespacedName types.NamespacedName, helmRelease *helmv2.HelmRelease) wait.ConditionFunc {
|
||||||
|
return func() (bool, error) {
|
||||||
|
err := kubeClient.Get(ctx, namespacedName, helmRelease)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Confirm the state we are observing is for the current generation
|
||||||
|
if helmRelease.Generation != helmRelease.Status.ObservedGeneration {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return apimeta.IsStatusConditionTrue(helmRelease.Status.Conditions, meta.ReadyCondition), nil
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2020 The Flux CD contributors.
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -20,16 +20,16 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var getCmd = &cobra.Command{
|
const createImageLong = `The create image sub-commands work with image automation objects; that is,
|
||||||
Use: "get",
|
object controlling updates to git based on e.g., new container images
|
||||||
Short: "Get sources and resources",
|
being available.`
|
||||||
Long: "The get sub-commands print the statuses of sources and resources.",
|
|
||||||
}
|
|
||||||
|
|
||||||
var allNamespaces bool
|
var createImageCmd = &cobra.Command{
|
||||||
|
Use: "image",
|
||||||
|
Short: "Create or update resources dealing with image automation",
|
||||||
|
Long: createImageLong,
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
getCmd.PersistentFlags().BoolVarP(&allNamespaces, "all-namespaces", "A", false,
|
createCmd.AddCommand(createImageCmd)
|
||||||
"list the requested object(s) across all namespaces")
|
|
||||||
rootCmd.AddCommand(getCmd)
|
|
||||||
}
|
}
|
||||||
263
cmd/flux/create_image_policy.go
Normal file
263
cmd/flux/create_image_policy.go
Normal file
@@ -0,0 +1,263 @@
|
|||||||
|
/*
|
||||||
|
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"
|
||||||
|
"regexp/syntax"
|
||||||
|
"strings"
|
||||||
|
"unicode"
|
||||||
|
"unicode/utf8"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
|
"github.com/fluxcd/pkg/apis/meta"
|
||||||
|
|
||||||
|
imagev1 "github.com/fluxcd/image-reflector-controller/api/v1beta1"
|
||||||
|
)
|
||||||
|
|
||||||
|
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.`,
|
||||||
|
Example: ` # Create an ImagePolicy to select the latest stable release
|
||||||
|
flux create image policy podinfo \
|
||||||
|
--image-ref=podinfo \
|
||||||
|
--select-semver=">=1.0.0"
|
||||||
|
|
||||||
|
# Create an ImagePolicy to select the latest main branch build tagged as "${GIT_BRANCH}-${GIT_SHA:0:7}-$(date +%s)"
|
||||||
|
flux create image policy podinfo \
|
||||||
|
--image-ref=podinfo \
|
||||||
|
--select-numeric=asc \
|
||||||
|
--filter-regex='^main-[a-f0-9]+-(?P<ts>[0-9]+)' \
|
||||||
|
--filter-extract='$ts'`,
|
||||||
|
RunE: createImagePolicyRun}
|
||||||
|
|
||||||
|
type imagePolicyFlags struct {
|
||||||
|
imageRef string
|
||||||
|
semver string
|
||||||
|
alpha string
|
||||||
|
numeric string
|
||||||
|
filterRegex string
|
||||||
|
filterExtract string
|
||||||
|
filterNumerical 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, "select-semver", "", "a semver range to apply to tags; e.g., '1.x'")
|
||||||
|
flags.StringVar(&imagePolicyArgs.alpha, "select-alpha", "", "use alphabetical sorting to select image; either \"asc\" meaning select the last, or \"desc\" meaning select the first")
|
||||||
|
flags.StringVar(&imagePolicyArgs.numeric, "select-numeric", "", "use numeric sorting to select image; either \"asc\" meaning select the last, or \"desc\" meaning select the first")
|
||||||
|
flags.StringVar(&imagePolicyArgs.filterRegex, "filter-regex", "", "regular expression pattern used to filter the image tags")
|
||||||
|
flags.StringVar(&imagePolicyArgs.filterExtract, "filter-extract", "", "replacement pattern (using capture groups from --filter-regex) to use for sorting")
|
||||||
|
|
||||||
|
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: rootArgs.namespace,
|
||||||
|
Labels: labels,
|
||||||
|
},
|
||||||
|
Spec: imagev1.ImagePolicySpec{
|
||||||
|
ImageRepositoryRef: meta.NamespacedObjectReference{
|
||||||
|
Name: imagePolicyArgs.imageRef,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case imagePolicyArgs.semver != "" && imagePolicyArgs.alpha != "":
|
||||||
|
case imagePolicyArgs.semver != "" && imagePolicyArgs.numeric != "":
|
||||||
|
case imagePolicyArgs.alpha != "" && imagePolicyArgs.numeric != "":
|
||||||
|
return fmt.Errorf("only one of --select-semver, --select-alpha or --select-numeric can be specified")
|
||||||
|
case imagePolicyArgs.semver != "":
|
||||||
|
policy.Spec.Policy.SemVer = &imagev1.SemVerPolicy{
|
||||||
|
Range: imagePolicyArgs.semver,
|
||||||
|
}
|
||||||
|
case imagePolicyArgs.alpha != "":
|
||||||
|
if imagePolicyArgs.alpha != "desc" && imagePolicyArgs.alpha != "asc" {
|
||||||
|
return fmt.Errorf("--select-alpha must be one of [\"asc\", \"desc\"]")
|
||||||
|
}
|
||||||
|
policy.Spec.Policy.Alphabetical = &imagev1.AlphabeticalPolicy{
|
||||||
|
Order: imagePolicyArgs.alpha,
|
||||||
|
}
|
||||||
|
case imagePolicyArgs.numeric != "":
|
||||||
|
if imagePolicyArgs.numeric != "desc" && imagePolicyArgs.numeric != "asc" {
|
||||||
|
return fmt.Errorf("--select-numeric must be one of [\"asc\", \"desc\"]")
|
||||||
|
}
|
||||||
|
policy.Spec.Policy.Numerical = &imagev1.NumericalPolicy{
|
||||||
|
Order: imagePolicyArgs.numeric,
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("a policy must be provided with either --select-semver or --select-alpha")
|
||||||
|
}
|
||||||
|
|
||||||
|
if imagePolicyArgs.filterRegex != "" {
|
||||||
|
exp, err := syntax.Parse(imagePolicyArgs.filterRegex, syntax.Perl)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("--filter-regex is an invalid regex pattern")
|
||||||
|
}
|
||||||
|
policy.Spec.FilterTags = &imagev1.TagFilter{
|
||||||
|
Pattern: imagePolicyArgs.filterRegex,
|
||||||
|
}
|
||||||
|
|
||||||
|
if imagePolicyArgs.filterExtract != "" {
|
||||||
|
if err := validateExtractStr(imagePolicyArgs.filterExtract, exp.CapNames()); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
policy.Spec.FilterTags.Extract = imagePolicyArgs.filterExtract
|
||||||
|
}
|
||||||
|
} else if imagePolicyArgs.filterExtract != "" {
|
||||||
|
return fmt.Errorf("cannot specify --filter-extract without specifying --filter-regex")
|
||||||
|
}
|
||||||
|
|
||||||
|
if createArgs.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
|
||||||
|
}
|
||||||
|
|
||||||
|
// Performs a dry-run of the extract function in Regexp to validate the template
|
||||||
|
func validateExtractStr(template string, capNames []string) error {
|
||||||
|
for len(template) > 0 {
|
||||||
|
i := strings.Index(template, "$")
|
||||||
|
if i < 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
template = template[i:]
|
||||||
|
if len(template) > 1 && template[1] == '$' {
|
||||||
|
template = template[2:]
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
name, num, rest, ok := extract(template)
|
||||||
|
if !ok {
|
||||||
|
// Malformed extract string, assume user didn't want this
|
||||||
|
template = template[1:]
|
||||||
|
return fmt.Errorf("--filter-extract is malformed")
|
||||||
|
}
|
||||||
|
template = rest
|
||||||
|
if num >= 0 {
|
||||||
|
// we won't worry about numbers as we can't validate these
|
||||||
|
continue
|
||||||
|
} else {
|
||||||
|
found := false
|
||||||
|
for _, capName := range capNames {
|
||||||
|
if name == capName {
|
||||||
|
found = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
return fmt.Errorf("capture group $%s used in --filter-extract not found in --filter-regex", name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// extract method from the regexp package
|
||||||
|
// returns the name or number of the value prepended by $
|
||||||
|
func extract(str string) (name string, num int, rest string, ok bool) {
|
||||||
|
if len(str) < 2 || str[0] != '$' {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
brace := false
|
||||||
|
if str[1] == '{' {
|
||||||
|
brace = true
|
||||||
|
str = str[2:]
|
||||||
|
} else {
|
||||||
|
str = str[1:]
|
||||||
|
}
|
||||||
|
i := 0
|
||||||
|
for i < len(str) {
|
||||||
|
rune, size := utf8.DecodeRuneInString(str[i:])
|
||||||
|
if !unicode.IsLetter(rune) && !unicode.IsDigit(rune) && rune != '_' {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
i += size
|
||||||
|
}
|
||||||
|
if i == 0 {
|
||||||
|
// empty name is not okay
|
||||||
|
return
|
||||||
|
}
|
||||||
|
name = str[:i]
|
||||||
|
if brace {
|
||||||
|
if i >= len(str) || str[i] != '}' {
|
||||||
|
// missing closing brace
|
||||||
|
return
|
||||||
|
}
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse number.
|
||||||
|
num = 0
|
||||||
|
for i := 0; i < len(name); i++ {
|
||||||
|
if name[i] < '0' || '9' < name[i] || num >= 1e8 {
|
||||||
|
num = -1
|
||||||
|
break
|
||||||
|
}
|
||||||
|
num = num*10 + int(name[i]) - '0'
|
||||||
|
}
|
||||||
|
// Disallow leading zeros.
|
||||||
|
if name[0] == '0' && len(name) > 1 {
|
||||||
|
num = -1
|
||||||
|
}
|
||||||
|
|
||||||
|
rest = str[i:]
|
||||||
|
ok = true
|
||||||
|
return
|
||||||
|
}
|
||||||
142
cmd/flux/create_image_repository.go
Normal file
142
cmd/flux/create_image_repository.go
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
/*
|
||||||
|
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"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
|
"github.com/fluxcd/pkg/apis/meta"
|
||||||
|
|
||||||
|
imagev1 "github.com/fluxcd/image-reflector-controller/api/v1beta1"
|
||||||
|
)
|
||||||
|
|
||||||
|
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.`,
|
||||||
|
Example: ` # Create an ImageRepository object to scan the alpine image repository:
|
||||||
|
flux create image repository alpine-repo --image alpine --interval 20m
|
||||||
|
|
||||||
|
# Create an image repository that uses an image pull secret (assumed to
|
||||||
|
# have been created already):
|
||||||
|
flux create image repository myapp-repo \
|
||||||
|
--secret-ref image-pull \
|
||||||
|
--image ghcr.io/example.com/myapp --interval 5m
|
||||||
|
|
||||||
|
# Create a TLS secret for a local image registry using a self-signed
|
||||||
|
# host certificate, and use it to scan an image. ca.pem is a file
|
||||||
|
# containing the CA certificate used to sign the host certificate.
|
||||||
|
flux create secret tls local-registry-cert --ca-file ./ca.pem
|
||||||
|
flux create image repository app-repo \
|
||||||
|
--cert-secret-ref local-registry-cert \
|
||||||
|
--image local-registry:5000/app --interval 5m
|
||||||
|
|
||||||
|
# Create a TLS secret with a client certificate and key, and use it
|
||||||
|
# to scan a private image registry.
|
||||||
|
flux create secret tls client-cert \
|
||||||
|
--cert-file client.crt --key-file client.key
|
||||||
|
flux create image repository app-repo \
|
||||||
|
--cert-secret-ref client-cert \
|
||||||
|
--image registry.example.com/private/app --interval 5m`,
|
||||||
|
RunE: createImageRepositoryRun,
|
||||||
|
}
|
||||||
|
|
||||||
|
type imageRepoFlags struct {
|
||||||
|
image string
|
||||||
|
secretRef string
|
||||||
|
certSecretRef 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")
|
||||||
|
flags.StringVar(&imageRepoArgs.certSecretRef, "cert-ref", "", "the name of a secret to use for TLS certificates")
|
||||||
|
// 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: rootArgs.namespace,
|
||||||
|
Labels: labels,
|
||||||
|
},
|
||||||
|
Spec: imagev1.ImageRepositorySpec{
|
||||||
|
Image: imageRepoArgs.image,
|
||||||
|
Interval: metav1.Duration{Duration: createArgs.interval},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
if imageRepoArgs.timeout != 0 {
|
||||||
|
repo.Spec.Timeout = &metav1.Duration{Duration: imageRepoArgs.timeout}
|
||||||
|
}
|
||||||
|
if imageRepoArgs.secretRef != "" {
|
||||||
|
repo.Spec.SecretRef = &meta.LocalObjectReference{
|
||||||
|
Name: imageRepoArgs.secretRef,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if imageRepoArgs.certSecretRef != "" {
|
||||||
|
repo.Spec.CertSecretRef = &meta.LocalObjectReference{
|
||||||
|
Name: imageRepoArgs.certSecretRef,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if createArgs.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
|
||||||
|
}
|
||||||
165
cmd/flux/create_image_update.go
Normal file
165
cmd/flux/create_image_update.go
Normal file
@@ -0,0 +1,165 @@
|
|||||||
|
/*
|
||||||
|
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"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
|
autov1 "github.com/fluxcd/image-automation-controller/api/v1beta1"
|
||||||
|
sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
|
||||||
|
)
|
||||||
|
|
||||||
|
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.`,
|
||||||
|
Example: ` # Configure image updates for the main repository created by flux bootstrap
|
||||||
|
flux create image update flux-system \
|
||||||
|
--git-repo-ref=flux-system \
|
||||||
|
--git-repo-path="./clusters/my-cluster" \
|
||||||
|
--checkout-branch=main \
|
||||||
|
--author-name=flux \
|
||||||
|
--author-email=flux@example.com \
|
||||||
|
--commit-template="{{range .Updated.Images}}{{println .}}{{end}}"
|
||||||
|
|
||||||
|
# Configure image updates to push changes to a different branch, if the branch doesn't exists it will be created
|
||||||
|
flux create image update flux-system \
|
||||||
|
--git-repo-ref=flux-system \
|
||||||
|
--git-repo-path="./clusters/my-cluster" \
|
||||||
|
--checkout-branch=main \
|
||||||
|
--push-branch=image-updates \
|
||||||
|
--author-name=flux \
|
||||||
|
--author-email=flux@example.com \
|
||||||
|
--commit-template="{{range .Updated.Images}}{{println .}}{{end}}"`,
|
||||||
|
RunE: createImageUpdateRun,
|
||||||
|
}
|
||||||
|
|
||||||
|
type imageUpdateFlags struct {
|
||||||
|
gitRepoRef string
|
||||||
|
gitRepoPath string
|
||||||
|
checkoutBranch string
|
||||||
|
pushBranch string
|
||||||
|
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.gitRepoPath, "git-repo-path", "", "path to the directory containing the manifests to be updated, defaults to the repository root")
|
||||||
|
flags.StringVar(&imageUpdateArgs.checkoutBranch, "checkout-branch", "", "the branch to checkout")
|
||||||
|
flags.StringVar(&imageUpdateArgs.pushBranch, "push-branch", "", "the branch to push commits to, defaults to the checkout branch if not specified")
|
||||||
|
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)")
|
||||||
|
}
|
||||||
|
|
||||||
|
if imageUpdateArgs.checkoutBranch == "" {
|
||||||
|
return fmt.Errorf("the Git repository branch is required (--checkout-branch)")
|
||||||
|
}
|
||||||
|
|
||||||
|
if imageUpdateArgs.authorName == "" {
|
||||||
|
return fmt.Errorf("the author name is required (--author-name)")
|
||||||
|
}
|
||||||
|
|
||||||
|
if imageUpdateArgs.authorEmail == "" {
|
||||||
|
return fmt.Errorf("the author email is required (--author-email)")
|
||||||
|
}
|
||||||
|
|
||||||
|
labels, err := parseLabels()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var update = autov1.ImageUpdateAutomation{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: objectName,
|
||||||
|
Namespace: rootArgs.namespace,
|
||||||
|
Labels: labels,
|
||||||
|
},
|
||||||
|
Spec: autov1.ImageUpdateAutomationSpec{
|
||||||
|
SourceRef: autov1.SourceReference{
|
||||||
|
Kind: sourcev1.GitRepositoryKind,
|
||||||
|
Name: imageUpdateArgs.gitRepoRef,
|
||||||
|
},
|
||||||
|
|
||||||
|
GitSpec: &autov1.GitSpec{
|
||||||
|
Checkout: &autov1.GitCheckoutSpec{
|
||||||
|
Reference: sourcev1.GitRepositoryRef{
|
||||||
|
Branch: imageUpdateArgs.checkoutBranch,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Commit: autov1.CommitSpec{
|
||||||
|
Author: autov1.CommitUser{
|
||||||
|
Name: imageUpdateArgs.authorName,
|
||||||
|
Email: imageUpdateArgs.authorEmail,
|
||||||
|
},
|
||||||
|
MessageTemplate: imageUpdateArgs.commitTemplate,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Interval: metav1.Duration{
|
||||||
|
Duration: createArgs.interval,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
if imageUpdateArgs.pushBranch != "" {
|
||||||
|
update.Spec.GitSpec.Push = &autov1.PushSpec{
|
||||||
|
Branch: imageUpdateArgs.pushBranch,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if imageUpdateArgs.gitRepoPath != "" {
|
||||||
|
update.Spec.Update = &autov1.UpdateStrategy{
|
||||||
|
Path: imageUpdateArgs.gitRepoPath,
|
||||||
|
Strategy: autov1.UpdateStrategySetters,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if createArgs.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
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2020 The Flux CD contributors.
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -23,18 +23,19 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
corev1 "k8s.io/api/core/v1"
|
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
|
apimeta "k8s.io/apimachinery/pkg/api/meta"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
|
|
||||||
helmv2 "github.com/fluxcd/helm-controller/api/v2beta1"
|
helmv2 "github.com/fluxcd/helm-controller/api/v2beta1"
|
||||||
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1beta1"
|
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1beta2"
|
||||||
"github.com/fluxcd/pkg/apis/meta"
|
"github.com/fluxcd/pkg/apis/meta"
|
||||||
"github.com/fluxcd/toolkit/internal/flags"
|
|
||||||
"github.com/fluxcd/toolkit/internal/utils"
|
"github.com/fluxcd/flux2/internal/flags"
|
||||||
|
"github.com/fluxcd/flux2/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
var createKsCmd = &cobra.Command{
|
var createKsCmd = &cobra.Command{
|
||||||
@@ -43,81 +44,98 @@ var createKsCmd = &cobra.Command{
|
|||||||
Short: "Create or update a Kustomization resource",
|
Short: "Create or update a Kustomization resource",
|
||||||
Long: "The kustomization source create command generates a Kustomize resource for a given source.",
|
Long: "The kustomization source create command generates a Kustomize resource for a given source.",
|
||||||
Example: ` # Create a Kustomization resource from a source at a given path
|
Example: ` # Create a Kustomization resource from a source at a given path
|
||||||
gotk create kustomization contour \
|
flux create kustomization contour \
|
||||||
--source=contour \
|
--source=GitRepository/contour \
|
||||||
--path="./examples/contour/" \
|
--path="./examples/contour/" \
|
||||||
--prune=true \
|
--prune=true \
|
||||||
--interval=10m \
|
--interval=10m \
|
||||||
--validation=client \
|
|
||||||
--health-check="Deployment/contour.projectcontour" \
|
--health-check="Deployment/contour.projectcontour" \
|
||||||
--health-check="DaemonSet/envoy.projectcontour" \
|
--health-check="DaemonSet/envoy.projectcontour" \
|
||||||
--health-check-timeout=3m
|
--health-check-timeout=3m
|
||||||
|
|
||||||
# Create a Kustomization resource that depends on the previous one
|
# Create a Kustomization resource that depends on the previous one
|
||||||
gotk create kustomization webapp \
|
flux create kustomization webapp \
|
||||||
--depends-on=contour \
|
--depends-on=contour \
|
||||||
--source=webapp \
|
--source=GitRepository/webapp \
|
||||||
--path="./deploy/overlays/dev" \
|
--path="./deploy/overlays/dev" \
|
||||||
--prune=true \
|
--prune=true \
|
||||||
--interval=5m \
|
--interval=5m
|
||||||
--validation=client
|
|
||||||
|
|
||||||
# Create a Kustomization resource that references a Bucket
|
# Create a Kustomization using a source from a different namespace
|
||||||
gotk create kustomization secrets \
|
flux create kustomization podinfo \
|
||||||
--source=Bucket/secrets \
|
--namespace=default \
|
||||||
|
--source=GitRepository/podinfo.flux-system \
|
||||||
|
--path="./deploy/overlays/dev" \
|
||||||
--prune=true \
|
--prune=true \
|
||||||
--interval=5m
|
--interval=5m
|
||||||
`,
|
|
||||||
|
# Create a Kustomization resource that references a Bucket
|
||||||
|
flux create kustomization secrets \
|
||||||
|
--source=Bucket/secrets \
|
||||||
|
--prune=true \
|
||||||
|
--interval=5m`,
|
||||||
RunE: createKsCmdRun,
|
RunE: createKsCmdRun,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
type kustomizationFlags struct {
|
||||||
ksSource flags.KustomizationSource
|
source flags.KustomizationSource
|
||||||
ksPath string
|
path flags.SafeRelativePath
|
||||||
ksPrune bool
|
prune bool
|
||||||
ksDependsOn []string
|
dependsOn []string
|
||||||
ksValidation string
|
validation string
|
||||||
ksHealthCheck []string
|
healthCheck []string
|
||||||
ksHealthTimeout time.Duration
|
healthTimeout time.Duration
|
||||||
ksSAName string
|
saName string
|
||||||
ksSANamespace string
|
decryptionProvider flags.DecryptionProvider
|
||||||
ksDecryptionProvider flags.DecryptionProvider
|
decryptionSecret string
|
||||||
ksDecryptionSecret string
|
targetNamespace string
|
||||||
)
|
wait bool
|
||||||
|
}
|
||||||
|
|
||||||
|
var kustomizationArgs = NewKustomizationFlags()
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
createKsCmd.Flags().Var(&ksSource, "source", ksSource.Description())
|
createKsCmd.Flags().Var(&kustomizationArgs.source, "source", kustomizationArgs.source.Description())
|
||||||
createKsCmd.Flags().StringVar(&ksPath, "path", "./", "path to the directory containing the Kustomization file")
|
createKsCmd.Flags().Var(&kustomizationArgs.path, "path", "path to the directory containing a kustomization.yaml file")
|
||||||
createKsCmd.Flags().BoolVar(&ksPrune, "prune", false, "enable garbage collection")
|
createKsCmd.Flags().BoolVar(&kustomizationArgs.prune, "prune", false, "enable garbage collection")
|
||||||
createKsCmd.Flags().StringArrayVar(&ksHealthCheck, "health-check", nil, "workload to be included in the health assessment, in the format '<kind>/<name>.<namespace>'")
|
createKsCmd.Flags().BoolVar(&kustomizationArgs.wait, "wait", false, "enable health checking of all the applied resources")
|
||||||
createKsCmd.Flags().DurationVar(&ksHealthTimeout, "health-check-timeout", 2*time.Minute, "timeout of health checking operations")
|
createKsCmd.Flags().StringSliceVar(&kustomizationArgs.healthCheck, "health-check", nil, "workload to be included in the health assessment, in the format '<kind>/<name>.<namespace>'")
|
||||||
createKsCmd.Flags().StringVar(&ksValidation, "validation", "", "validate the manifests before applying them on the cluster, can be 'client' or 'server'")
|
createKsCmd.Flags().DurationVar(&kustomizationArgs.healthTimeout, "health-check-timeout", 2*time.Minute, "timeout of health checking operations")
|
||||||
createKsCmd.Flags().StringArrayVar(&ksDependsOn, "depends-on", nil, "Kustomization that must be ready before this Kustomization can be applied, supported formats '<name>' and '<namespace>/<name>'")
|
createKsCmd.Flags().StringVar(&kustomizationArgs.validation, "validation", "", "validate the manifests before applying them on the cluster, can be 'client' or 'server'")
|
||||||
createKsCmd.Flags().StringVar(&ksSAName, "sa-name", "", "service account name")
|
createKsCmd.Flags().StringSliceVar(&kustomizationArgs.dependsOn, "depends-on", nil, "Kustomization that must be ready before this Kustomization can be applied, supported formats '<name>' and '<namespace>/<name>', also accepts comma-separated values")
|
||||||
createKsCmd.Flags().StringVar(&ksSANamespace, "sa-namespace", "", "service account namespace")
|
createKsCmd.Flags().StringVar(&kustomizationArgs.saName, "service-account", "", "the name of the service account to impersonate when reconciling this Kustomization")
|
||||||
createKsCmd.Flags().Var(&ksDecryptionProvider, "decryption-provider", ksDecryptionProvider.Description())
|
createKsCmd.Flags().Var(&kustomizationArgs.decryptionProvider, "decryption-provider", kustomizationArgs.decryptionProvider.Description())
|
||||||
createKsCmd.Flags().StringVar(&ksDecryptionSecret, "decryption-secret", "", "set the Kubernetes secret name that contains the OpenPGP private keys used for sops decryption")
|
createKsCmd.Flags().StringVar(&kustomizationArgs.decryptionSecret, "decryption-secret", "", "set the Kubernetes secret name that contains the OpenPGP private keys used for sops decryption")
|
||||||
|
createKsCmd.Flags().StringVar(&kustomizationArgs.targetNamespace, "target-namespace", "", "overrides the namespace of all Kustomization objects reconciled by this Kustomization")
|
||||||
|
createKsCmd.Flags().MarkDeprecated("validation", "this arg is no longer used, all resources are validated using server-side apply dry-run")
|
||||||
|
|
||||||
createCmd.AddCommand(createKsCmd)
|
createCmd.AddCommand(createKsCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewKustomizationFlags() kustomizationFlags {
|
||||||
|
return kustomizationFlags{
|
||||||
|
path: "./",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func createKsCmdRun(cmd *cobra.Command, args []string) error {
|
func createKsCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
if len(args) < 1 {
|
if len(args) < 1 {
|
||||||
return fmt.Errorf("Kustomization name is required")
|
return fmt.Errorf("Kustomization name is required")
|
||||||
}
|
}
|
||||||
name := args[0]
|
name := args[0]
|
||||||
|
|
||||||
if ksPath == "" {
|
if kustomizationArgs.path == "" {
|
||||||
return fmt.Errorf("path is required")
|
return fmt.Errorf("path is required")
|
||||||
}
|
}
|
||||||
if !strings.HasPrefix(ksPath, "./") {
|
if !strings.HasPrefix(kustomizationArgs.path.String(), "./") {
|
||||||
return fmt.Errorf("path must begin with ./")
|
return fmt.Errorf("path must begin with ./")
|
||||||
}
|
}
|
||||||
|
|
||||||
if !export {
|
if !createArgs.export {
|
||||||
logger.Generatef("generating Kustomization")
|
logger.Generatef("generating Kustomization")
|
||||||
}
|
}
|
||||||
|
|
||||||
ksLabels, err := parseLabels()
|
kslabels, err := parseLabels()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -125,28 +143,29 @@ func createKsCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
kustomization := kustomizev1.Kustomization{
|
kustomization := kustomizev1.Kustomization{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: name,
|
Name: name,
|
||||||
Namespace: namespace,
|
Namespace: rootArgs.namespace,
|
||||||
Labels: ksLabels,
|
Labels: kslabels,
|
||||||
},
|
},
|
||||||
Spec: kustomizev1.KustomizationSpec{
|
Spec: kustomizev1.KustomizationSpec{
|
||||||
DependsOn: utils.MakeDependsOn(ksDependsOn),
|
DependsOn: utils.MakeDependsOn(kustomizationArgs.dependsOn),
|
||||||
Interval: metav1.Duration{
|
Interval: metav1.Duration{
|
||||||
Duration: interval,
|
Duration: createArgs.interval,
|
||||||
},
|
},
|
||||||
Path: ksPath,
|
Path: kustomizationArgs.path.ToSlash(),
|
||||||
Prune: ksPrune,
|
Prune: kustomizationArgs.prune,
|
||||||
SourceRef: kustomizev1.CrossNamespaceSourceReference{
|
SourceRef: kustomizev1.CrossNamespaceSourceReference{
|
||||||
Kind: ksSource.Kind,
|
Kind: kustomizationArgs.source.Kind,
|
||||||
Name: ksSource.Name,
|
Name: kustomizationArgs.source.Name,
|
||||||
|
Namespace: kustomizationArgs.source.Namespace,
|
||||||
},
|
},
|
||||||
Suspend: false,
|
Suspend: false,
|
||||||
Validation: ksValidation,
|
TargetNamespace: kustomizationArgs.targetNamespace,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(ksHealthCheck) > 0 {
|
if len(kustomizationArgs.healthCheck) > 0 && !kustomizationArgs.wait {
|
||||||
healthChecks := make([]kustomizev1.CrossNamespaceObjectReference, 0)
|
healthChecks := make([]meta.NamespacedObjectKindReference, 0)
|
||||||
for _, w := range ksHealthCheck {
|
for _, w := range kustomizationArgs.healthCheck {
|
||||||
kindObj := strings.Split(w, "/")
|
kindObj := strings.Split(w, "/")
|
||||||
if len(kindObj) != 2 {
|
if len(kindObj) != 2 {
|
||||||
return fmt.Errorf("invalid health check '%s' must be in the format 'kind/name.namespace' %v", w, kindObj)
|
return fmt.Errorf("invalid health check '%s' must be in the format 'kind/name.namespace' %v", w, kindObj)
|
||||||
@@ -168,7 +187,7 @@ func createKsCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
return fmt.Errorf("invalid health check '%s' must be in the format 'kind/name.namespace'", w)
|
return fmt.Errorf("invalid health check '%s' must be in the format 'kind/name.namespace'", w)
|
||||||
}
|
}
|
||||||
|
|
||||||
check := kustomizev1.CrossNamespaceObjectReference{
|
check := meta.NamespacedObjectKindReference{
|
||||||
Kind: kind,
|
Kind: kind,
|
||||||
Name: nameNs[0],
|
Name: nameNs[0],
|
||||||
Namespace: nameNs[1],
|
Namespace: nameNs[1],
|
||||||
@@ -181,35 +200,39 @@ func createKsCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
kustomization.Spec.HealthChecks = healthChecks
|
kustomization.Spec.HealthChecks = healthChecks
|
||||||
kustomization.Spec.Timeout = &metav1.Duration{
|
kustomization.Spec.Timeout = &metav1.Duration{
|
||||||
Duration: ksHealthTimeout,
|
Duration: kustomizationArgs.healthTimeout,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ksSAName != "" && ksSANamespace != "" {
|
if kustomizationArgs.wait {
|
||||||
kustomization.Spec.ServiceAccount = &kustomizev1.ServiceAccount{
|
kustomization.Spec.Wait = true
|
||||||
Name: ksSAName,
|
kustomization.Spec.Timeout = &metav1.Duration{
|
||||||
Namespace: ksSANamespace,
|
Duration: kustomizationArgs.healthTimeout,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ksDecryptionProvider != "" {
|
if kustomizationArgs.saName != "" {
|
||||||
|
kustomization.Spec.ServiceAccountName = kustomizationArgs.saName
|
||||||
|
}
|
||||||
|
|
||||||
|
if kustomizationArgs.decryptionProvider != "" {
|
||||||
kustomization.Spec.Decryption = &kustomizev1.Decryption{
|
kustomization.Spec.Decryption = &kustomizev1.Decryption{
|
||||||
Provider: ksDecryptionProvider.String(),
|
Provider: kustomizationArgs.decryptionProvider.String(),
|
||||||
}
|
}
|
||||||
|
|
||||||
if ksDecryptionSecret != "" {
|
if kustomizationArgs.decryptionSecret != "" {
|
||||||
kustomization.Spec.Decryption.SecretRef = &corev1.LocalObjectReference{Name: ksDecryptionSecret}
|
kustomization.Spec.Decryption.SecretRef = &meta.LocalObjectReference{Name: kustomizationArgs.decryptionSecret}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if export {
|
if createArgs.export {
|
||||||
return exportKs(kustomization)
|
return printExport(exportKs(&kustomization))
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
kubeClient, err := utils.KubeClient(kubeconfig)
|
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -221,7 +244,7 @@ func createKsCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
logger.Waitingf("waiting for Kustomization reconciliation")
|
logger.Waitingf("waiting for Kustomization reconciliation")
|
||||||
if err := wait.PollImmediate(pollInterval, timeout,
|
if err := wait.PollImmediate(rootArgs.pollInterval, rootArgs.timeout,
|
||||||
isKustomizationReady(ctx, kubeClient, namespacedName, &kustomization)); err != nil {
|
isKustomizationReady(ctx, kubeClient, namespacedName, &kustomization)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -275,11 +298,11 @@ func isKustomizationReady(ctx context.Context, kubeClient client.Client,
|
|||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if c := meta.GetCondition(kustomization.Status.Conditions, meta.ReadyCondition); c != nil {
|
if c := apimeta.FindStatusCondition(kustomization.Status.Conditions, meta.ReadyCondition); c != nil {
|
||||||
switch c.Status {
|
switch c.Status {
|
||||||
case corev1.ConditionTrue:
|
case metav1.ConditionTrue:
|
||||||
return true, nil
|
return true, nil
|
||||||
case corev1.ConditionFalse:
|
case metav1.ConditionFalse:
|
||||||
return false, fmt.Errorf(c.Message)
|
return false, fmt.Errorf(c.Message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2020 The Flux CD contributors.
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -21,8 +21,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
corev1 "k8s.io/api/core/v1"
|
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
|
apimeta "k8s.io/apimachinery/pkg/api/meta"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
@@ -30,7 +30,8 @@ import (
|
|||||||
|
|
||||||
notificationv1 "github.com/fluxcd/notification-controller/api/v1beta1"
|
notificationv1 "github.com/fluxcd/notification-controller/api/v1beta1"
|
||||||
"github.com/fluxcd/pkg/apis/meta"
|
"github.com/fluxcd/pkg/apis/meta"
|
||||||
"github.com/fluxcd/toolkit/internal/utils"
|
|
||||||
|
"github.com/fluxcd/flux2/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
var createReceiverCmd = &cobra.Command{
|
var createReceiverCmd = &cobra.Command{
|
||||||
@@ -38,29 +39,30 @@ var createReceiverCmd = &cobra.Command{
|
|||||||
Short: "Create or update a Receiver resource",
|
Short: "Create or update a Receiver resource",
|
||||||
Long: "The create receiver command generates a Receiver resource.",
|
Long: "The create receiver command generates a Receiver resource.",
|
||||||
Example: ` # Create a Receiver
|
Example: ` # Create a Receiver
|
||||||
gotk create receiver github-receiver \
|
flux create receiver github-receiver \
|
||||||
--type github \
|
--type github \
|
||||||
--event ping \
|
--event ping \
|
||||||
--event push \
|
--event push \
|
||||||
--secret-ref webhook-token \
|
--secret-ref webhook-token \
|
||||||
--resource GitRepository/webapp \
|
--resource GitRepository/webapp \
|
||||||
--resource HelmRepository/webapp
|
--resource HelmRepository/webapp`,
|
||||||
`,
|
|
||||||
RunE: createReceiverCmdRun,
|
RunE: createReceiverCmdRun,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
type receiverFlags struct {
|
||||||
rcvType string
|
receiverType string
|
||||||
rcvSecretRef string
|
secretRef string
|
||||||
rcvEvents []string
|
events []string
|
||||||
rcvResources []string
|
resources []string
|
||||||
)
|
}
|
||||||
|
|
||||||
|
var receiverArgs receiverFlags
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
createReceiverCmd.Flags().StringVar(&rcvType, "type", "", "")
|
createReceiverCmd.Flags().StringVar(&receiverArgs.receiverType, "type", "", "")
|
||||||
createReceiverCmd.Flags().StringVar(&rcvSecretRef, "secret-ref", "", "")
|
createReceiverCmd.Flags().StringVar(&receiverArgs.secretRef, "secret-ref", "", "")
|
||||||
createReceiverCmd.Flags().StringArrayVar(&rcvEvents, "event", []string{}, "")
|
createReceiverCmd.Flags().StringSliceVar(&receiverArgs.events, "event", []string{}, "also accepts comma-separated values")
|
||||||
createReceiverCmd.Flags().StringArrayVar(&rcvResources, "resource", []string{}, "")
|
createReceiverCmd.Flags().StringSliceVar(&receiverArgs.resources, "resource", []string{}, "also accepts comma-separated values")
|
||||||
createCmd.AddCommand(createReceiverCmd)
|
createCmd.AddCommand(createReceiverCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,16 +72,16 @@ func createReceiverCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
name := args[0]
|
name := args[0]
|
||||||
|
|
||||||
if rcvType == "" {
|
if receiverArgs.receiverType == "" {
|
||||||
return fmt.Errorf("Receiver type is required")
|
return fmt.Errorf("Receiver type is required")
|
||||||
}
|
}
|
||||||
|
|
||||||
if rcvSecretRef == "" {
|
if receiverArgs.secretRef == "" {
|
||||||
return fmt.Errorf("secret ref is required")
|
return fmt.Errorf("secret ref is required")
|
||||||
}
|
}
|
||||||
|
|
||||||
resources := []notificationv1.CrossNamespaceObjectReference{}
|
resources := []notificationv1.CrossNamespaceObjectReference{}
|
||||||
for _, resource := range rcvResources {
|
for _, resource := range receiverArgs.resources {
|
||||||
kind, name := utils.ParseObjectKindName(resource)
|
kind, name := utils.ParseObjectKindName(resource)
|
||||||
if kind == "" {
|
if kind == "" {
|
||||||
return fmt.Errorf("invalid event source '%s', must be in format <kind>/<name>", resource)
|
return fmt.Errorf("invalid event source '%s', must be in format <kind>/<name>", resource)
|
||||||
@@ -100,35 +102,35 @@ func createReceiverCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !export {
|
if !createArgs.export {
|
||||||
logger.Generatef("generating Receiver")
|
logger.Generatef("generating Receiver")
|
||||||
}
|
}
|
||||||
|
|
||||||
receiver := notificationv1.Receiver{
|
receiver := notificationv1.Receiver{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: name,
|
Name: name,
|
||||||
Namespace: namespace,
|
Namespace: rootArgs.namespace,
|
||||||
Labels: sourceLabels,
|
Labels: sourceLabels,
|
||||||
},
|
},
|
||||||
Spec: notificationv1.ReceiverSpec{
|
Spec: notificationv1.ReceiverSpec{
|
||||||
Type: rcvType,
|
Type: receiverArgs.receiverType,
|
||||||
Events: rcvEvents,
|
Events: receiverArgs.events,
|
||||||
Resources: resources,
|
Resources: resources,
|
||||||
SecretRef: corev1.LocalObjectReference{
|
SecretRef: meta.LocalObjectReference{
|
||||||
Name: rcvSecretRef,
|
Name: receiverArgs.secretRef,
|
||||||
},
|
},
|
||||||
Suspend: false,
|
Suspend: false,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if export {
|
if createArgs.export {
|
||||||
return exportReceiver(receiver)
|
return printExport(exportReceiver(&receiver))
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
kubeClient, err := utils.KubeClient(kubeconfig)
|
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -140,7 +142,7 @@ func createReceiverCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
logger.Waitingf("waiting for Receiver reconciliation")
|
logger.Waitingf("waiting for Receiver reconciliation")
|
||||||
if err := wait.PollImmediate(pollInterval, timeout,
|
if err := wait.PollImmediate(rootArgs.pollInterval, rootArgs.timeout,
|
||||||
isReceiverReady(ctx, kubeClient, namespacedName, &receiver)); err != nil {
|
isReceiverReady(ctx, kubeClient, namespacedName, &receiver)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -189,11 +191,11 @@ func isReceiverReady(ctx context.Context, kubeClient client.Client,
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if c := meta.GetCondition(receiver.Status.Conditions, meta.ReadyCondition); c != nil {
|
if c := apimeta.FindStatusCondition(receiver.Status.Conditions, meta.ReadyCondition); c != nil {
|
||||||
switch c.Status {
|
switch c.Status {
|
||||||
case corev1.ConditionTrue:
|
case metav1.ConditionTrue:
|
||||||
return true, nil
|
return true, nil
|
||||||
case corev1.ConditionFalse:
|
case metav1.ConditionFalse:
|
||||||
return false, fmt.Errorf(c.Message)
|
return false, fmt.Errorf(c.Message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
63
cmd/flux/create_secret.go
Normal file
63
cmd/flux/create_secret.go
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
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"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
corev1 "k8s.io/api/core/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
|
"k8s.io/apimachinery/pkg/types"
|
||||||
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
|
)
|
||||||
|
|
||||||
|
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 upsertSecret(ctx context.Context, kubeClient client.Client, secret corev1.Secret) error {
|
||||||
|
namespacedName := types.NamespacedName{
|
||||||
|
Namespace: secret.GetNamespace(),
|
||||||
|
Name: secret.GetName(),
|
||||||
|
}
|
||||||
|
|
||||||
|
var existing corev1.Secret
|
||||||
|
err := kubeClient.Get(ctx, namespacedName, &existing)
|
||||||
|
if err != nil {
|
||||||
|
if errors.IsNotFound(err) {
|
||||||
|
if err := kubeClient.Create(ctx, &secret); err != nil {
|
||||||
|
return err
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
existing.StringData = secret.StringData
|
||||||
|
if err := kubeClient.Update(ctx, &existing); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
189
cmd/flux/create_secret_git.go
Normal file
189
cmd/flux/create_secret_git.go
Normal file
@@ -0,0 +1,189 @@
|
|||||||
|
/*
|
||||||
|
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"
|
||||||
|
"sigs.k8s.io/yaml"
|
||||||
|
|
||||||
|
"github.com/fluxcd/flux2/internal/flags"
|
||||||
|
"github.com/fluxcd/flux2/internal/utils"
|
||||||
|
"github.com/fluxcd/flux2/pkg/manifestgen/sourcesecret"
|
||||||
|
)
|
||||||
|
|
||||||
|
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 Git SSH authentication secret with a passwordless private key from file
|
||||||
|
# The public SSH host key will still be gathered from the host
|
||||||
|
flux create secret git podinfo-auth \
|
||||||
|
--url=ssh://git@github.com/stefanprodan/podinfo \
|
||||||
|
--private-key-file=./private.key
|
||||||
|
|
||||||
|
# Create a Git SSH authentication secret with a passworded private key from file
|
||||||
|
# The public SSH host key will still be gathered from the host
|
||||||
|
flux create secret git podinfo-auth \
|
||||||
|
--url=ssh://git@github.com/stefanprodan/podinfo \
|
||||||
|
--private-key-file=./private.key \
|
||||||
|
--password=<password>
|
||||||
|
|
||||||
|
# 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
|
||||||
|
flux create secret git podinfo-auth \
|
||||||
|
--url=ssh://git@github.com/stefanprodan/podinfo \
|
||||||
|
--export > podinfo-auth.yaml
|
||||||
|
|
||||||
|
# Print the deploy key
|
||||||
|
yq eval '.stringData."identity.pub"' podinfo-auth.yaml
|
||||||
|
|
||||||
|
# Encrypt the secret on disk with Mozilla SOPS
|
||||||
|
sops --encrypt --encrypted-regex '^(data|stringData)$' \
|
||||||
|
--in-place podinfo-auth.yaml`,
|
||||||
|
RunE: createSecretGitCmdRun,
|
||||||
|
}
|
||||||
|
|
||||||
|
type secretGitFlags struct {
|
||||||
|
url string
|
||||||
|
username string
|
||||||
|
password string
|
||||||
|
keyAlgorithm flags.PublicKeyAlgorithm
|
||||||
|
rsaBits flags.RSAKeyBits
|
||||||
|
ecdsaCurve flags.ECDSACurve
|
||||||
|
caFile string
|
||||||
|
privateKeyFile string
|
||||||
|
}
|
||||||
|
|
||||||
|
var secretGitArgs = NewSecretGitFlags()
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
createSecretGitCmd.Flags().StringVar(&secretGitArgs.url, "url", "", "git address, e.g. ssh://git@host/org/repository")
|
||||||
|
createSecretGitCmd.Flags().StringVarP(&secretGitArgs.username, "username", "u", "", "basic authentication username")
|
||||||
|
createSecretGitCmd.Flags().StringVarP(&secretGitArgs.password, "password", "p", "", "basic authentication password")
|
||||||
|
createSecretGitCmd.Flags().Var(&secretGitArgs.keyAlgorithm, "ssh-key-algorithm", secretGitArgs.keyAlgorithm.Description())
|
||||||
|
createSecretGitCmd.Flags().Var(&secretGitArgs.rsaBits, "ssh-rsa-bits", secretGitArgs.rsaBits.Description())
|
||||||
|
createSecretGitCmd.Flags().Var(&secretGitArgs.ecdsaCurve, "ssh-ecdsa-curve", secretGitArgs.ecdsaCurve.Description())
|
||||||
|
createSecretGitCmd.Flags().StringVar(&secretGitArgs.caFile, "ca-file", "", "path to TLS CA file used for validating self-signed certificates")
|
||||||
|
createSecretGitCmd.Flags().StringVar(&secretGitArgs.privateKeyFile, "private-key-file", "", "path to a passwordless private key file used for authenticating to the Git SSH server")
|
||||||
|
|
||||||
|
createSecretCmd.AddCommand(createSecretGitCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewSecretGitFlags() secretGitFlags {
|
||||||
|
return secretGitFlags{
|
||||||
|
keyAlgorithm: flags.PublicKeyAlgorithm(sourcesecret.ECDSAPrivateKeyAlgorithm),
|
||||||
|
rsaBits: 2048,
|
||||||
|
ecdsaCurve: flags.ECDSACurve{Curve: elliptic.P384()},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func createSecretGitCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
|
if len(args) < 1 {
|
||||||
|
return fmt.Errorf("secret name is required")
|
||||||
|
}
|
||||||
|
name := args[0]
|
||||||
|
if secretGitArgs.url == "" {
|
||||||
|
return fmt.Errorf("url is required")
|
||||||
|
}
|
||||||
|
|
||||||
|
u, err := url.Parse(secretGitArgs.url)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("git URL parse failed: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
labels, err := parseLabels()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
opts := sourcesecret.Options{
|
||||||
|
Name: name,
|
||||||
|
Namespace: rootArgs.namespace,
|
||||||
|
Labels: labels,
|
||||||
|
ManifestFile: sourcesecret.MakeDefaultOptions().ManifestFile,
|
||||||
|
}
|
||||||
|
switch u.Scheme {
|
||||||
|
case "ssh":
|
||||||
|
opts.SSHHostname = u.Host
|
||||||
|
opts.PrivateKeyPath = secretGitArgs.privateKeyFile
|
||||||
|
opts.PrivateKeyAlgorithm = sourcesecret.PrivateKeyAlgorithm(secretGitArgs.keyAlgorithm)
|
||||||
|
opts.RSAKeyBits = int(secretGitArgs.rsaBits)
|
||||||
|
opts.ECDSACurve = secretGitArgs.ecdsaCurve.Curve
|
||||||
|
opts.Password = secretGitArgs.password
|
||||||
|
case "http", "https":
|
||||||
|
if secretGitArgs.username == "" || secretGitArgs.password == "" {
|
||||||
|
return fmt.Errorf("for Git over HTTP/S the username and password are required")
|
||||||
|
}
|
||||||
|
opts.Username = secretGitArgs.username
|
||||||
|
opts.Password = secretGitArgs.password
|
||||||
|
opts.CAFilePath = secretGitArgs.caFile
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("git URL scheme '%s' not supported, can be: ssh, http and https", u.Scheme)
|
||||||
|
}
|
||||||
|
|
||||||
|
secret, err := sourcesecret.Generate(opts)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if createArgs.export {
|
||||||
|
rootCmd.Println(secret.Content)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var s corev1.Secret
|
||||||
|
if err := yaml.Unmarshal([]byte(secret.Content), &s); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if ppk, ok := s.StringData[sourcesecret.PublicKeySecretKey]; ok {
|
||||||
|
logger.Generatef("deploy key: %s", ppk)
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
|
||||||
|
defer cancel()
|
||||||
|
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := upsertSecret(ctx, kubeClient, s); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
logger.Actionf("git secret '%s' created in '%s' namespace", name, rootArgs.namespace)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
44
cmd/flux/create_secret_git_test.go
Normal file
44
cmd/flux/create_secret_git_test.go
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestCreateGitSecret(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
args string
|
||||||
|
assert assertFunc
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "no args",
|
||||||
|
args: "create secret git",
|
||||||
|
assert: assertError("secret name is required"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "basic secret",
|
||||||
|
args: "create secret git podinfo-auth --url=https://github.com/stefanprodan/podinfo --username=my-username --password=my-password --namespace=my-namespace --export",
|
||||||
|
assert: assertGoldenFile("./testdata/create_secret/git/secret-git-basic.yaml"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "ssh key",
|
||||||
|
args: "create secret git podinfo-auth --url=ssh://git@github.com/stefanprodan/podinfo --private-key-file=./testdata/create_secret/git/ecdsa.private --namespace=my-namespace --export",
|
||||||
|
assert: assertGoldenFile("testdata/create_secret/git/git-ssh-secret.yaml"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "ssh key with password",
|
||||||
|
args: "create secret git podinfo-auth --url=ssh://git@github.com/stefanprodan/podinfo --private-key-file=./testdata/create_secret/git/ecdsa-password.private --password=password --namespace=my-namespace --export",
|
||||||
|
assert: assertGoldenFile("testdata/create_secret/git/git-ssh-secret-password.yaml"),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
cmd := cmdTestCase{
|
||||||
|
args: tt.args,
|
||||||
|
assert: tt.assert,
|
||||||
|
}
|
||||||
|
cmd.runTestCmd(t)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
117
cmd/flux/create_secret_helm.go
Normal file
117
cmd/flux/create_secret_helm.go
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2021 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"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
corev1 "k8s.io/api/core/v1"
|
||||||
|
"sigs.k8s.io/yaml"
|
||||||
|
|
||||||
|
"github.com/fluxcd/flux2/internal/utils"
|
||||||
|
"github.com/fluxcd/flux2/pkg/manifestgen/sourcesecret"
|
||||||
|
)
|
||||||
|
|
||||||
|
var createSecretHelmCmd = &cobra.Command{
|
||||||
|
Use: "helm [name]",
|
||||||
|
Short: "Create or update a Kubernetes secret for Helm repository authentication",
|
||||||
|
Long: `The create secret helm command generates a Kubernetes secret with basic authentication credentials.`,
|
||||||
|
Example: ` # Create a Helm authentication secret on disk and encrypt it with Mozilla SOPS
|
||||||
|
flux create secret helm repo-auth \
|
||||||
|
--namespace=my-namespace \
|
||||||
|
--username=my-username \
|
||||||
|
--password=my-password \
|
||||||
|
--export > repo-auth.yaml
|
||||||
|
|
||||||
|
sops --encrypt --encrypted-regex '^(data|stringData)$' \
|
||||||
|
--in-place repo-auth.yaml
|
||||||
|
|
||||||
|
# Create a Helm authentication secret using a custom TLS cert
|
||||||
|
flux create secret helm repo-auth \
|
||||||
|
--username=username \
|
||||||
|
--password=password \
|
||||||
|
--cert-file=./cert.crt \
|
||||||
|
--key-file=./key.crt \
|
||||||
|
--ca-file=./ca.crt`,
|
||||||
|
RunE: createSecretHelmCmdRun,
|
||||||
|
}
|
||||||
|
|
||||||
|
type secretHelmFlags struct {
|
||||||
|
username string
|
||||||
|
password string
|
||||||
|
secretTLSFlags
|
||||||
|
}
|
||||||
|
|
||||||
|
var secretHelmArgs secretHelmFlags
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
createSecretHelmCmd.Flags().StringVarP(&secretHelmArgs.username, "username", "u", "", "basic authentication username")
|
||||||
|
createSecretHelmCmd.Flags().StringVarP(&secretHelmArgs.password, "password", "p", "", "basic authentication password")
|
||||||
|
initSecretTLSFlags(createSecretHelmCmd.Flags(), &secretHelmArgs.secretTLSFlags)
|
||||||
|
createSecretCmd.AddCommand(createSecretHelmCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func createSecretHelmCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
|
if len(args) < 1 {
|
||||||
|
return fmt.Errorf("secret name is required")
|
||||||
|
}
|
||||||
|
name := args[0]
|
||||||
|
|
||||||
|
labels, err := parseLabels()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
opts := sourcesecret.Options{
|
||||||
|
Name: name,
|
||||||
|
Namespace: rootArgs.namespace,
|
||||||
|
Labels: labels,
|
||||||
|
Username: secretHelmArgs.username,
|
||||||
|
Password: secretHelmArgs.password,
|
||||||
|
CAFilePath: secretHelmArgs.caFile,
|
||||||
|
CertFilePath: secretHelmArgs.certFile,
|
||||||
|
KeyFilePath: secretHelmArgs.keyFile,
|
||||||
|
}
|
||||||
|
secret, err := sourcesecret.Generate(opts)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if createArgs.export {
|
||||||
|
rootCmd.Println(secret.Content)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
|
||||||
|
defer cancel()
|
||||||
|
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
var s corev1.Secret
|
||||||
|
if err := yaml.Unmarshal([]byte(secret.Content), &s); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := upsertSecret(ctx, kubeClient, s); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Actionf("helm secret '%s' created in '%s' namespace", name, rootArgs.namespace)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
31
cmd/flux/create_secret_helm_test.go
Normal file
31
cmd/flux/create_secret_helm_test.go
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestCreateHelmSecret(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
args string
|
||||||
|
assert assertFunc
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
args: "create secret helm",
|
||||||
|
assert: assertError("secret name is required"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
args: "create secret helm helm-secret --username=my-username --password=my-password --namespace=my-namespace --export",
|
||||||
|
assert: assertGoldenFile("testdata/create_secret/helm/secret-helm.yaml"),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
cmd := cmdTestCase{
|
||||||
|
args: tt.args,
|
||||||
|
assert: tt.assert,
|
||||||
|
}
|
||||||
|
cmd.runTestCmd(t)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
114
cmd/flux/create_secret_tls.go
Normal file
114
cmd/flux/create_secret_tls.go
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020, 2021 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"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
"github.com/spf13/pflag"
|
||||||
|
corev1 "k8s.io/api/core/v1"
|
||||||
|
"sigs.k8s.io/yaml"
|
||||||
|
|
||||||
|
"github.com/fluxcd/flux2/internal/utils"
|
||||||
|
"github.com/fluxcd/flux2/pkg/manifestgen/sourcesecret"
|
||||||
|
)
|
||||||
|
|
||||||
|
var createSecretTLSCmd = &cobra.Command{
|
||||||
|
Use: "tls [name]",
|
||||||
|
Short: "Create or update a Kubernetes secret with TLS certificates",
|
||||||
|
Long: `The create secret tls command generates a Kubernetes secret with certificates for use with TLS.`,
|
||||||
|
Example: ` # Create a TLS secret on disk and encrypt it with Mozilla SOPS.
|
||||||
|
# Files are expected to be PEM-encoded.
|
||||||
|
flux create secret tls certs \
|
||||||
|
--namespace=my-namespace \
|
||||||
|
--cert-file=./client.crt \
|
||||||
|
--key-file=./client.key \
|
||||||
|
--export > certs.yaml
|
||||||
|
|
||||||
|
sops --encrypt --encrypted-regex '^(data|stringData)$' \
|
||||||
|
--in-place certs.yaml`,
|
||||||
|
RunE: createSecretTLSCmdRun,
|
||||||
|
}
|
||||||
|
|
||||||
|
type secretTLSFlags struct {
|
||||||
|
certFile string
|
||||||
|
keyFile string
|
||||||
|
caFile string
|
||||||
|
}
|
||||||
|
|
||||||
|
var secretTLSArgs secretTLSFlags
|
||||||
|
|
||||||
|
func initSecretTLSFlags(flags *pflag.FlagSet, args *secretTLSFlags) {
|
||||||
|
flags.StringVar(&args.certFile, "cert-file", "", "TLS authentication cert file path")
|
||||||
|
flags.StringVar(&args.keyFile, "key-file", "", "TLS authentication key file path")
|
||||||
|
flags.StringVar(&args.caFile, "ca-file", "", "TLS authentication CA file path")
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
flags := createSecretTLSCmd.Flags()
|
||||||
|
initSecretTLSFlags(flags, &secretTLSArgs)
|
||||||
|
createSecretCmd.AddCommand(createSecretTLSCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func createSecretTLSCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
|
if len(args) < 1 {
|
||||||
|
return fmt.Errorf("secret name is required")
|
||||||
|
}
|
||||||
|
name := args[0]
|
||||||
|
|
||||||
|
labels, err := parseLabels()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
opts := sourcesecret.Options{
|
||||||
|
Name: name,
|
||||||
|
Namespace: rootArgs.namespace,
|
||||||
|
Labels: labels,
|
||||||
|
CAFilePath: secretTLSArgs.caFile,
|
||||||
|
CertFilePath: secretTLSArgs.certFile,
|
||||||
|
KeyFilePath: secretTLSArgs.keyFile,
|
||||||
|
}
|
||||||
|
secret, err := sourcesecret.Generate(opts)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if createArgs.export {
|
||||||
|
rootCmd.Print(secret.Content)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
|
||||||
|
defer cancel()
|
||||||
|
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
var s corev1.Secret
|
||||||
|
if err := yaml.Unmarshal([]byte(secret.Content), &s); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := upsertSecret(ctx, kubeClient, s); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Actionf("tls secret '%s' created in '%s' namespace", name, rootArgs.namespace)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
31
cmd/flux/create_secret_tls_test.go
Normal file
31
cmd/flux/create_secret_tls_test.go
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestCreateTlsSecretNoArgs(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
args string
|
||||||
|
assert assertFunc
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
args: "create secret tls",
|
||||||
|
assert: assertError("secret name is required"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
args: "create secret tls certs --namespace=my-namespace --cert-file=./testdata/create_secret/tls/test-cert.pem --key-file=./testdata/create_secret/tls/test-key.pem --export",
|
||||||
|
assert: assertGoldenFile("testdata/create_secret/tls/secret-tls.yaml"),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
cmd := cmdTestCase{
|
||||||
|
args: tt.args,
|
||||||
|
assert: tt.assert,
|
||||||
|
}
|
||||||
|
cmd.runTestCmd(t)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2020 The Flux CD contributors.
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -17,29 +17,25 @@ limitations under the License.
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"time"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var exportCmd = &cobra.Command{
|
var createSourceCmd = &cobra.Command{
|
||||||
Use: "export",
|
Use: "source",
|
||||||
Short: "Export resources in YAML format",
|
Short: "Create or update sources",
|
||||||
Long: "The export sub-commands export resources in YAML format.",
|
Long: "The create source sub-commands generate sources.",
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
type createSourceFlags struct {
|
||||||
exportAll bool
|
fetchTimeout time.Duration
|
||||||
)
|
}
|
||||||
|
|
||||||
|
var createSourceArgs createSourceFlags
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
exportCmd.PersistentFlags().BoolVar(&exportAll, "all", false, "select all resources")
|
createSourceCmd.PersistentFlags().DurationVar(&createSourceArgs.fetchTimeout, "fetch-timeout", createSourceArgs.fetchTimeout,
|
||||||
|
"set a timeout for fetch operations performed by source-controller (e.g. 'git clone' or 'helm repo update')")
|
||||||
rootCmd.AddCommand(exportCmd)
|
createCmd.AddCommand(createSourceCmd)
|
||||||
}
|
|
||||||
|
|
||||||
func resourceToString(data []byte) string {
|
|
||||||
data = bytes.Replace(data, []byte(" creationTimestamp: null\n"), []byte(""), 1)
|
|
||||||
data = bytes.Replace(data, []byte("status: {}\n"), []byte(""), 1)
|
|
||||||
return string(data)
|
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2020 The Flux CD contributors.
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -19,7 +19,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@@ -30,19 +29,20 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
|
|
||||||
|
"github.com/fluxcd/pkg/apis/meta"
|
||||||
sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
|
sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
|
||||||
"github.com/fluxcd/toolkit/internal/flags"
|
|
||||||
"github.com/fluxcd/toolkit/internal/utils"
|
"github.com/fluxcd/flux2/internal/flags"
|
||||||
|
"github.com/fluxcd/flux2/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
var createSourceBucketCmd = &cobra.Command{
|
var createSourceBucketCmd = &cobra.Command{
|
||||||
Use: "bucket [name]",
|
Use: "bucket [name]",
|
||||||
Short: "Create or update a Bucket source",
|
Short: "Create or update a Bucket source",
|
||||||
Long: `
|
Long: `The create source bucket command generates a Bucket resource and waits for it to be downloaded.
|
||||||
The create source bucket command generates a Bucket resource and waits for it to be downloaded.
|
|
||||||
For Buckets with static authentication, the credentials are stored in a Kubernetes secret.`,
|
For Buckets with static authentication, the credentials are stored in a Kubernetes secret.`,
|
||||||
Example: ` # Create a source from a Buckets using static authentication
|
Example: ` # Create a source for a Bucket using static authentication
|
||||||
gotk create source bucket podinfo \
|
flux create source bucket podinfo \
|
||||||
--bucket-name=podinfo \
|
--bucket-name=podinfo \
|
||||||
--endpoint=minio.minio.svc.cluster.local:9000 \
|
--endpoint=minio.minio.svc.cluster.local:9000 \
|
||||||
--insecure=true \
|
--insecure=true \
|
||||||
@@ -50,52 +50,59 @@ For Buckets with static authentication, the credentials are stored in a Kubernet
|
|||||||
--secret-key=mysecretkey \
|
--secret-key=mysecretkey \
|
||||||
--interval=10m
|
--interval=10m
|
||||||
|
|
||||||
# Create a source from an Amazon S3 Bucket using IAM authentication
|
# Create a source for an Amazon S3 Bucket using IAM authentication
|
||||||
gotk create source bucket podinfo \
|
flux create source bucket podinfo \
|
||||||
--bucket-name=podinfo \
|
--bucket-name=podinfo \
|
||||||
--provider=aws \
|
--provider=aws \
|
||||||
--endpoint=s3.amazonaws.com \
|
--endpoint=s3.amazonaws.com \
|
||||||
--region=us-east-1 \
|
--region=us-east-1 \
|
||||||
--interval=10m
|
--interval=10m`,
|
||||||
`,
|
|
||||||
RunE: createSourceBucketCmdRun,
|
RunE: createSourceBucketCmdRun,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
type sourceBucketFlags struct {
|
||||||
sourceBucketName string
|
name string
|
||||||
sourceBucketProvider = flags.SourceBucketProvider(sourcev1.GenericBucketProvider)
|
provider flags.SourceBucketProvider
|
||||||
sourceBucketEndpoint string
|
endpoint string
|
||||||
sourceBucketAccessKey string
|
accessKey string
|
||||||
sourceBucketSecretKey string
|
secretKey string
|
||||||
sourceBucketRegion string
|
region string
|
||||||
sourceBucketInsecure bool
|
insecure bool
|
||||||
sourceBucketSecretRef string
|
secretRef string
|
||||||
)
|
}
|
||||||
|
|
||||||
|
var sourceBucketArgs = NewSourceBucketFlags()
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
createSourceBucketCmd.Flags().Var(&sourceBucketProvider, "provider", sourceBucketProvider.Description())
|
createSourceBucketCmd.Flags().Var(&sourceBucketArgs.provider, "provider", sourceBucketArgs.provider.Description())
|
||||||
createSourceBucketCmd.Flags().StringVar(&sourceBucketName, "bucket-name", "", "the bucket name")
|
createSourceBucketCmd.Flags().StringVar(&sourceBucketArgs.name, "bucket-name", "", "the bucket name")
|
||||||
createSourceBucketCmd.Flags().StringVar(&sourceBucketEndpoint, "endpoint", "", "the bucket endpoint address")
|
createSourceBucketCmd.Flags().StringVar(&sourceBucketArgs.endpoint, "endpoint", "", "the bucket endpoint address")
|
||||||
createSourceBucketCmd.Flags().StringVar(&sourceBucketAccessKey, "access-key", "", "the bucket access key")
|
createSourceBucketCmd.Flags().StringVar(&sourceBucketArgs.accessKey, "access-key", "", "the bucket access key")
|
||||||
createSourceBucketCmd.Flags().StringVar(&sourceBucketSecretKey, "secret-key", "", "the bucket secret key")
|
createSourceBucketCmd.Flags().StringVar(&sourceBucketArgs.secretKey, "secret-key", "", "the bucket secret key")
|
||||||
createSourceBucketCmd.Flags().StringVar(&sourceBucketRegion, "region", "", "the bucket region")
|
createSourceBucketCmd.Flags().StringVar(&sourceBucketArgs.region, "region", "", "the bucket region")
|
||||||
createSourceBucketCmd.Flags().BoolVar(&sourceBucketInsecure, "insecure", false, "for when connecting to a non-TLS S3 HTTP endpoint")
|
createSourceBucketCmd.Flags().BoolVar(&sourceBucketArgs.insecure, "insecure", false, "for when connecting to a non-TLS S3 HTTP endpoint")
|
||||||
createSourceBucketCmd.Flags().StringVar(&sourceBucketSecretRef, "secret-ref", "", "the name of an existing secret containing credentials")
|
createSourceBucketCmd.Flags().StringVar(&sourceBucketArgs.secretRef, "secret-ref", "", "the name of an existing secret containing credentials")
|
||||||
|
|
||||||
createSourceCmd.AddCommand(createSourceBucketCmd)
|
createSourceCmd.AddCommand(createSourceBucketCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewSourceBucketFlags() sourceBucketFlags {
|
||||||
|
return sourceBucketFlags{
|
||||||
|
provider: flags.SourceBucketProvider(sourcev1.GenericBucketProvider),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func createSourceBucketCmdRun(cmd *cobra.Command, args []string) error {
|
func createSourceBucketCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
if len(args) < 1 {
|
if len(args) < 1 {
|
||||||
return fmt.Errorf("Bucket source name is required")
|
return fmt.Errorf("Bucket source name is required")
|
||||||
}
|
}
|
||||||
name := args[0]
|
name := args[0]
|
||||||
|
|
||||||
if sourceBucketName == "" {
|
if sourceBucketArgs.name == "" {
|
||||||
return fmt.Errorf("bucket-name is required")
|
return fmt.Errorf("bucket-name is required")
|
||||||
}
|
}
|
||||||
|
|
||||||
if sourceBucketEndpoint == "" {
|
if sourceBucketArgs.endpoint == "" {
|
||||||
return fmt.Errorf("endpoint is required")
|
return fmt.Errorf("endpoint is required")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +111,7 @@ func createSourceBucketCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpDir, err := ioutil.TempDir("", name)
|
tmpDir, err := os.MkdirTemp("", name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -113,54 +120,60 @@ func createSourceBucketCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
bucket := &sourcev1.Bucket{
|
bucket := &sourcev1.Bucket{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: name,
|
Name: name,
|
||||||
Namespace: namespace,
|
Namespace: rootArgs.namespace,
|
||||||
Labels: sourceLabels,
|
Labels: sourceLabels,
|
||||||
},
|
},
|
||||||
Spec: sourcev1.BucketSpec{
|
Spec: sourcev1.BucketSpec{
|
||||||
BucketName: sourceBucketName,
|
BucketName: sourceBucketArgs.name,
|
||||||
Provider: sourceBucketProvider.String(),
|
Provider: sourceBucketArgs.provider.String(),
|
||||||
Insecure: sourceBucketInsecure,
|
Insecure: sourceBucketArgs.insecure,
|
||||||
Endpoint: sourceBucketEndpoint,
|
Endpoint: sourceBucketArgs.endpoint,
|
||||||
Region: sourceBucketRegion,
|
Region: sourceBucketArgs.region,
|
||||||
Interval: metav1.Duration{
|
Interval: metav1.Duration{
|
||||||
Duration: interval,
|
Duration: createArgs.interval,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if sourceHelmSecretRef != "" {
|
|
||||||
bucket.Spec.SecretRef = &corev1.LocalObjectReference{
|
if createSourceArgs.fetchTimeout > 0 {
|
||||||
Name: sourceBucketSecretRef,
|
bucket.Spec.Timeout = &metav1.Duration{Duration: createSourceArgs.fetchTimeout}
|
||||||
|
}
|
||||||
|
|
||||||
|
if sourceBucketArgs.secretRef != "" {
|
||||||
|
bucket.Spec.SecretRef = &meta.LocalObjectReference{
|
||||||
|
Name: sourceBucketArgs.secretRef,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if export {
|
if createArgs.export {
|
||||||
return exportBucket(*bucket)
|
return printExport(exportBucket(bucket))
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
kubeClient, err := utils.KubeClient(kubeconfig)
|
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Generatef("generating Bucket source")
|
logger.Generatef("generating Bucket source")
|
||||||
|
|
||||||
if sourceBucketSecretRef == "" {
|
if sourceBucketArgs.secretRef == "" {
|
||||||
secretName := fmt.Sprintf("bucket-%s", name)
|
secretName := fmt.Sprintf("bucket-%s", name)
|
||||||
|
|
||||||
secret := corev1.Secret{
|
secret := corev1.Secret{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: secretName,
|
Name: secretName,
|
||||||
Namespace: namespace,
|
Namespace: rootArgs.namespace,
|
||||||
|
Labels: sourceLabels,
|
||||||
},
|
},
|
||||||
StringData: map[string]string{},
|
StringData: map[string]string{},
|
||||||
}
|
}
|
||||||
|
|
||||||
if sourceBucketAccessKey != "" && sourceBucketSecretKey != "" {
|
if sourceBucketArgs.accessKey != "" && sourceBucketArgs.secretKey != "" {
|
||||||
secret.StringData["accesskey"] = sourceBucketAccessKey
|
secret.StringData["accesskey"] = sourceBucketArgs.accessKey
|
||||||
secret.StringData["secretkey"] = sourceBucketSecretKey
|
secret.StringData["secretkey"] = sourceBucketArgs.secretKey
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(secret.StringData) > 0 {
|
if len(secret.StringData) > 0 {
|
||||||
@@ -168,7 +181,7 @@ func createSourceBucketCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
if err := upsertSecret(ctx, kubeClient, secret); err != nil {
|
if err := upsertSecret(ctx, kubeClient, secret); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
bucket.Spec.SecretRef = &corev1.LocalObjectReference{
|
bucket.Spec.SecretRef = &meta.LocalObjectReference{
|
||||||
Name: secretName,
|
Name: secretName,
|
||||||
}
|
}
|
||||||
logger.Successf("authentication configured")
|
logger.Successf("authentication configured")
|
||||||
@@ -182,7 +195,7 @@ func createSourceBucketCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
logger.Waitingf("waiting for Bucket source reconciliation")
|
logger.Waitingf("waiting for Bucket source reconciliation")
|
||||||
if err := wait.PollImmediate(pollInterval, timeout,
|
if err := wait.PollImmediate(rootArgs.pollInterval, rootArgs.timeout,
|
||||||
isBucketReady(ctx, kubeClient, namespacedName, bucket)); err != nil {
|
isBucketReady(ctx, kubeClient, namespacedName, bucket)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
371
cmd/flux/create_source_git.go
Normal file
371
cmd/flux/create_source_git.go
Normal file
@@ -0,0 +1,371 @@
|
|||||||
|
/*
|
||||||
|
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"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/fluxcd/pkg/apis/meta"
|
||||||
|
sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
|
||||||
|
"github.com/manifoldco/promptui"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
corev1 "k8s.io/api/core/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
|
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"
|
||||||
|
"sigs.k8s.io/yaml"
|
||||||
|
|
||||||
|
"github.com/fluxcd/flux2/internal/flags"
|
||||||
|
"github.com/fluxcd/flux2/internal/utils"
|
||||||
|
"github.com/fluxcd/flux2/pkg/manifestgen/sourcesecret"
|
||||||
|
)
|
||||||
|
|
||||||
|
type sourceGitFlags struct {
|
||||||
|
url string
|
||||||
|
branch string
|
||||||
|
tag string
|
||||||
|
semver string
|
||||||
|
username string
|
||||||
|
password string
|
||||||
|
keyAlgorithm flags.PublicKeyAlgorithm
|
||||||
|
keyRSABits flags.RSAKeyBits
|
||||||
|
keyECDSACurve flags.ECDSACurve
|
||||||
|
secretRef string
|
||||||
|
gitImplementation flags.GitImplementation
|
||||||
|
caFile string
|
||||||
|
privateKeyFile string
|
||||||
|
recurseSubmodules bool
|
||||||
|
silent bool
|
||||||
|
}
|
||||||
|
|
||||||
|
var createSourceGitCmd = &cobra.Command{
|
||||||
|
Use: "git [name]",
|
||||||
|
Short: "Create or update a GitRepository source",
|
||||||
|
Long: `The create source git command generates a GitRepository resource and waits for it to sync.
|
||||||
|
For Git over SSH, host and SSH keys are automatically generated and stored in a Kubernetes secret.
|
||||||
|
For private Git repositories, the basic authentication credentials are stored in a Kubernetes secret.`,
|
||||||
|
Example: ` # Create a source from a public Git repository master branch
|
||||||
|
flux create source git podinfo \
|
||||||
|
--url=https://github.com/stefanprodan/podinfo \
|
||||||
|
--branch=master
|
||||||
|
|
||||||
|
# Create a source for a Git repository pinned to specific git tag
|
||||||
|
flux create source git podinfo \
|
||||||
|
--url=https://github.com/stefanprodan/podinfo \
|
||||||
|
--tag="3.2.3"
|
||||||
|
|
||||||
|
# Create a source from a public Git repository tag that matches a semver range
|
||||||
|
flux create source git podinfo \
|
||||||
|
--url=https://github.com/stefanprodan/podinfo \
|
||||||
|
--tag-semver=">=3.2.0 <3.3.0"
|
||||||
|
|
||||||
|
# Create a source for a Git repository using SSH authentication
|
||||||
|
flux create source git podinfo \
|
||||||
|
--url=ssh://git@github.com/stefanprodan/podinfo \
|
||||||
|
--branch=master
|
||||||
|
|
||||||
|
# Create a source for a Git repository using SSH authentication and an
|
||||||
|
# ECDSA P-521 curve public key
|
||||||
|
flux create source git podinfo \
|
||||||
|
--url=ssh://git@github.com/stefanprodan/podinfo \
|
||||||
|
--branch=master \
|
||||||
|
--ssh-key-algorithm=ecdsa \
|
||||||
|
--ssh-ecdsa-curve=p521
|
||||||
|
|
||||||
|
# Create a source for a Git repository using SSH authentication and a
|
||||||
|
# passwordless private key from file
|
||||||
|
# The public SSH host key will still be gathered from the host
|
||||||
|
flux create source git podinfo \
|
||||||
|
--url=ssh://git@github.com/stefanprodan/podinfo \
|
||||||
|
--branch=master \
|
||||||
|
--private-key-file=./private.key
|
||||||
|
|
||||||
|
# Create a source for a Git repository using SSH authentication and a
|
||||||
|
# private key with a password from file
|
||||||
|
# The public SSH host key will still be gathered from the host
|
||||||
|
flux create source git podinfo \
|
||||||
|
--url=ssh://git@github.com/stefanprodan/podinfo \
|
||||||
|
--branch=master \
|
||||||
|
--private-key-file=./private.key \
|
||||||
|
--password=<password>
|
||||||
|
|
||||||
|
# Create a source for a Git repository using basic authentication
|
||||||
|
flux create source git podinfo \
|
||||||
|
--url=https://github.com/stefanprodan/podinfo \
|
||||||
|
--username=username \
|
||||||
|
--password=password`,
|
||||||
|
RunE: createSourceGitCmdRun,
|
||||||
|
}
|
||||||
|
|
||||||
|
var sourceGitArgs = newSourceGitFlags()
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
createSourceGitCmd.Flags().StringVar(&sourceGitArgs.url, "url", "", "git address, e.g. ssh://git@host/org/repository")
|
||||||
|
createSourceGitCmd.Flags().StringVar(&sourceGitArgs.branch, "branch", "", "git branch")
|
||||||
|
createSourceGitCmd.Flags().StringVar(&sourceGitArgs.tag, "tag", "", "git tag")
|
||||||
|
createSourceGitCmd.Flags().StringVar(&sourceGitArgs.semver, "tag-semver", "", "git tag semver range")
|
||||||
|
createSourceGitCmd.Flags().StringVarP(&sourceGitArgs.username, "username", "u", "", "basic authentication username")
|
||||||
|
createSourceGitCmd.Flags().StringVarP(&sourceGitArgs.password, "password", "p", "", "basic authentication password")
|
||||||
|
createSourceGitCmd.Flags().Var(&sourceGitArgs.keyAlgorithm, "ssh-key-algorithm", sourceGitArgs.keyAlgorithm.Description())
|
||||||
|
createSourceGitCmd.Flags().Var(&sourceGitArgs.keyRSABits, "ssh-rsa-bits", sourceGitArgs.keyRSABits.Description())
|
||||||
|
createSourceGitCmd.Flags().Var(&sourceGitArgs.keyECDSACurve, "ssh-ecdsa-curve", sourceGitArgs.keyECDSACurve.Description())
|
||||||
|
createSourceGitCmd.Flags().StringVar(&sourceGitArgs.secretRef, "secret-ref", "", "the name of an existing secret containing SSH or basic credentials")
|
||||||
|
createSourceGitCmd.Flags().Var(&sourceGitArgs.gitImplementation, "git-implementation", sourceGitArgs.gitImplementation.Description())
|
||||||
|
createSourceGitCmd.Flags().StringVar(&sourceGitArgs.caFile, "ca-file", "", "path to TLS CA file used for validating self-signed certificates")
|
||||||
|
createSourceGitCmd.Flags().StringVar(&sourceGitArgs.privateKeyFile, "private-key-file", "", "path to a passwordless private key file used for authenticating to the Git SSH server")
|
||||||
|
createSourceGitCmd.Flags().BoolVar(&sourceGitArgs.recurseSubmodules, "recurse-submodules", false,
|
||||||
|
"when enabled, configures the GitRepository source to initialize and include Git submodules in the artifact it produces")
|
||||||
|
createSourceGitCmd.Flags().BoolVarP(&sourceGitArgs.silent, "silent", "s", false, "assumes the deploy key is already setup, skips confirmation")
|
||||||
|
|
||||||
|
createSourceCmd.AddCommand(createSourceGitCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newSourceGitFlags() sourceGitFlags {
|
||||||
|
return sourceGitFlags{
|
||||||
|
keyAlgorithm: flags.PublicKeyAlgorithm(sourcesecret.ECDSAPrivateKeyAlgorithm),
|
||||||
|
keyRSABits: 2048,
|
||||||
|
keyECDSACurve: flags.ECDSACurve{Curve: elliptic.P384()},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
|
if len(args) < 1 {
|
||||||
|
return fmt.Errorf("GitRepository source name is required")
|
||||||
|
}
|
||||||
|
name := args[0]
|
||||||
|
|
||||||
|
if sourceGitArgs.url == "" {
|
||||||
|
return fmt.Errorf("url is required")
|
||||||
|
}
|
||||||
|
|
||||||
|
u, err := url.Parse(sourceGitArgs.url)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("git URL parse failed: %w", err)
|
||||||
|
}
|
||||||
|
if u.Scheme != "ssh" && u.Scheme != "http" && u.Scheme != "https" {
|
||||||
|
return fmt.Errorf("git URL scheme '%s' not supported, can be: ssh, http and https", u.Scheme)
|
||||||
|
}
|
||||||
|
|
||||||
|
if sourceGitArgs.branch == "" && sourceGitArgs.tag == "" && sourceGitArgs.semver == "" {
|
||||||
|
return fmt.Errorf("a Git ref is required, use one of the following: --branch, --tag or --tag-semver")
|
||||||
|
}
|
||||||
|
|
||||||
|
if sourceGitArgs.caFile != "" && u.Scheme == "ssh" {
|
||||||
|
return fmt.Errorf("specifing a CA file is not supported for Git over SSH")
|
||||||
|
}
|
||||||
|
|
||||||
|
if sourceGitArgs.recurseSubmodules && sourceGitArgs.gitImplementation == sourcev1.LibGit2Implementation {
|
||||||
|
return fmt.Errorf("recurse submodules requires --git-implementation=%s", sourcev1.GoGitImplementation)
|
||||||
|
}
|
||||||
|
|
||||||
|
tmpDir, err := os.MkdirTemp("", name)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer os.RemoveAll(tmpDir)
|
||||||
|
|
||||||
|
sourceLabels, err := parseLabels()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
gitRepository := sourcev1.GitRepository{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: name,
|
||||||
|
Namespace: rootArgs.namespace,
|
||||||
|
Labels: sourceLabels,
|
||||||
|
},
|
||||||
|
Spec: sourcev1.GitRepositorySpec{
|
||||||
|
URL: sourceGitArgs.url,
|
||||||
|
Interval: metav1.Duration{
|
||||||
|
Duration: createArgs.interval,
|
||||||
|
},
|
||||||
|
RecurseSubmodules: sourceGitArgs.recurseSubmodules,
|
||||||
|
Reference: &sourcev1.GitRepositoryRef{},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
if createSourceArgs.fetchTimeout > 0 {
|
||||||
|
gitRepository.Spec.Timeout = &metav1.Duration{Duration: createSourceArgs.fetchTimeout}
|
||||||
|
}
|
||||||
|
|
||||||
|
if sourceGitArgs.gitImplementation != "" {
|
||||||
|
gitRepository.Spec.GitImplementation = sourceGitArgs.gitImplementation.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
if sourceGitArgs.semver != "" {
|
||||||
|
gitRepository.Spec.Reference.SemVer = sourceGitArgs.semver
|
||||||
|
} else if sourceGitArgs.tag != "" {
|
||||||
|
gitRepository.Spec.Reference.Tag = sourceGitArgs.tag
|
||||||
|
} else {
|
||||||
|
gitRepository.Spec.Reference.Branch = sourceGitArgs.branch
|
||||||
|
}
|
||||||
|
|
||||||
|
if sourceGitArgs.secretRef != "" {
|
||||||
|
gitRepository.Spec.SecretRef = &meta.LocalObjectReference{
|
||||||
|
Name: sourceGitArgs.secretRef,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if createArgs.export {
|
||||||
|
return printExport(exportGit(&gitRepository))
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Generatef("generating GitRepository source")
|
||||||
|
if sourceGitArgs.secretRef == "" {
|
||||||
|
secretOpts := sourcesecret.Options{
|
||||||
|
Name: name,
|
||||||
|
Namespace: rootArgs.namespace,
|
||||||
|
ManifestFile: sourcesecret.MakeDefaultOptions().ManifestFile,
|
||||||
|
}
|
||||||
|
switch u.Scheme {
|
||||||
|
case "ssh":
|
||||||
|
secretOpts.SSHHostname = u.Host
|
||||||
|
secretOpts.PrivateKeyPath = sourceGitArgs.privateKeyFile
|
||||||
|
secretOpts.PrivateKeyAlgorithm = sourcesecret.PrivateKeyAlgorithm(sourceGitArgs.keyAlgorithm)
|
||||||
|
secretOpts.RSAKeyBits = int(sourceGitArgs.keyRSABits)
|
||||||
|
secretOpts.ECDSACurve = sourceGitArgs.keyECDSACurve.Curve
|
||||||
|
secretOpts.Password = sourceGitArgs.password
|
||||||
|
case "https":
|
||||||
|
secretOpts.Username = sourceGitArgs.username
|
||||||
|
secretOpts.Password = sourceGitArgs.password
|
||||||
|
secretOpts.CAFilePath = sourceGitArgs.caFile
|
||||||
|
case "http":
|
||||||
|
logger.Warningf("insecure configuration: credentials configured for an HTTP URL")
|
||||||
|
secretOpts.Username = sourceGitArgs.username
|
||||||
|
secretOpts.Password = sourceGitArgs.password
|
||||||
|
}
|
||||||
|
secret, err := sourcesecret.Generate(secretOpts)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
var s corev1.Secret
|
||||||
|
if err = yaml.Unmarshal([]byte(secret.Content), &s); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if len(s.StringData) > 0 {
|
||||||
|
if hk, ok := s.StringData[sourcesecret.KnownHostsSecretKey]; ok {
|
||||||
|
logger.Successf("collected public key from SSH server:\n%s", hk)
|
||||||
|
}
|
||||||
|
if ppk, ok := s.StringData[sourcesecret.PublicKeySecretKey]; ok {
|
||||||
|
logger.Generatef("deploy key: %s", ppk)
|
||||||
|
if !sourceGitArgs.silent {
|
||||||
|
prompt := promptui.Prompt{
|
||||||
|
Label: "Have you added the deploy key to your repository",
|
||||||
|
IsConfirm: true,
|
||||||
|
}
|
||||||
|
if _, err := prompt.Run(); err != nil {
|
||||||
|
return fmt.Errorf("aborting")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logger.Actionf("applying secret with repository credentials")
|
||||||
|
if err := upsertSecret(ctx, kubeClient, s); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
gitRepository.Spec.SecretRef = &meta.LocalObjectReference{
|
||||||
|
Name: s.Name,
|
||||||
|
}
|
||||||
|
logger.Successf("authentication configured")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Actionf("applying GitRepository source")
|
||||||
|
namespacedName, err := upsertGitRepository(ctx, kubeClient, &gitRepository)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Waitingf("waiting for GitRepository source reconciliation")
|
||||||
|
if err := wait.PollImmediate(rootArgs.pollInterval, rootArgs.timeout,
|
||||||
|
isGitRepositoryReady(ctx, kubeClient, namespacedName, &gitRepository)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
logger.Successf("GitRepository source reconciliation completed")
|
||||||
|
|
||||||
|
if gitRepository.Status.Artifact == nil {
|
||||||
|
return fmt.Errorf("GitRepository source reconciliation completed but no artifact was found")
|
||||||
|
}
|
||||||
|
logger.Successf("fetched revision: %s", gitRepository.Status.Artifact.Revision)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func upsertGitRepository(ctx context.Context, kubeClient client.Client,
|
||||||
|
gitRepository *sourcev1.GitRepository) (types.NamespacedName, error) {
|
||||||
|
namespacedName := types.NamespacedName{
|
||||||
|
Namespace: gitRepository.GetNamespace(),
|
||||||
|
Name: gitRepository.GetName(),
|
||||||
|
}
|
||||||
|
|
||||||
|
var existing sourcev1.GitRepository
|
||||||
|
err := kubeClient.Get(ctx, namespacedName, &existing)
|
||||||
|
if err != nil {
|
||||||
|
if errors.IsNotFound(err) {
|
||||||
|
if err := kubeClient.Create(ctx, gitRepository); err != nil {
|
||||||
|
return namespacedName, err
|
||||||
|
} else {
|
||||||
|
logger.Successf("GitRepository source created")
|
||||||
|
return namespacedName, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return namespacedName, err
|
||||||
|
}
|
||||||
|
|
||||||
|
existing.Labels = gitRepository.Labels
|
||||||
|
existing.Spec = gitRepository.Spec
|
||||||
|
if err := kubeClient.Update(ctx, &existing); err != nil {
|
||||||
|
return namespacedName, err
|
||||||
|
}
|
||||||
|
gitRepository = &existing
|
||||||
|
logger.Successf("GitRepository source updated")
|
||||||
|
return namespacedName, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func isGitRepositoryReady(ctx context.Context, kubeClient client.Client,
|
||||||
|
namespacedName types.NamespacedName, gitRepository *sourcev1.GitRepository) wait.ConditionFunc {
|
||||||
|
return func() (bool, error) {
|
||||||
|
err := kubeClient.Get(ctx, namespacedName, gitRepository)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if c := apimeta.FindStatusCondition(gitRepository.Status.Conditions, 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
|
||||||
|
}
|
||||||
|
}
|
||||||
147
cmd/flux/create_source_git_test.go
Normal file
147
cmd/flux/create_source_git_test.go
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
// +build unit
|
||||||
|
|
||||||
|
/*
|
||||||
|
Copyright 2021 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"
|
||||||
|
"github.com/fluxcd/pkg/apis/meta"
|
||||||
|
sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
|
||||||
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
|
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"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
var pollInterval = 50 * time.Millisecond
|
||||||
|
var testTimeout = 10 * time.Second
|
||||||
|
|
||||||
|
// Update the GitRepository once created to exercise test specific behavior
|
||||||
|
type reconcileFunc func(repo *sourcev1.GitRepository)
|
||||||
|
|
||||||
|
// reconciler waits for an object to be created, then invokes a test supplied
|
||||||
|
// function to mutate that object, simulating a controller.
|
||||||
|
// Test should invoke run() to run the background reconciler task which
|
||||||
|
// polls to wait for the object to exist before applying the update function.
|
||||||
|
// Any errors from the reconciler are asserted on test completion.
|
||||||
|
type reconciler struct {
|
||||||
|
client client.Client
|
||||||
|
name types.NamespacedName
|
||||||
|
reconcile reconcileFunc
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start the background task that waits for the object to exist then applies
|
||||||
|
// the update function.
|
||||||
|
func (r *reconciler) run(t *testing.T) {
|
||||||
|
result := make(chan error)
|
||||||
|
go func() {
|
||||||
|
defer close(result)
|
||||||
|
err := wait.PollImmediate(
|
||||||
|
pollInterval,
|
||||||
|
testTimeout,
|
||||||
|
r.conditionFunc)
|
||||||
|
result <- err
|
||||||
|
}()
|
||||||
|
t.Cleanup(func() {
|
||||||
|
if err := <-result; err != nil {
|
||||||
|
t.Errorf("Failure from test reconciler: '%v':", err.Error())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// A ConditionFunction that waits for the named GitRepository to be created,
|
||||||
|
// then sets the ready condition to true.
|
||||||
|
func (r *reconciler) conditionFunc() (bool, error) {
|
||||||
|
var repo sourcev1.GitRepository
|
||||||
|
if err := r.client.Get(context.Background(), r.name, &repo); err != nil {
|
||||||
|
if errors.IsNotFound(err) {
|
||||||
|
return false, nil // Keep polling until object is created
|
||||||
|
}
|
||||||
|
return true, err
|
||||||
|
}
|
||||||
|
r.reconcile(&repo)
|
||||||
|
err := r.client.Status().Update(context.Background(), &repo)
|
||||||
|
return true, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCreateSourceGit(t *testing.T) {
|
||||||
|
// Default command used for multiple tests
|
||||||
|
var command = "create source git podinfo --url=https://github.com/stefanprodan/podinfo --branch=master --timeout=" + testTimeout.String()
|
||||||
|
|
||||||
|
cases := []struct {
|
||||||
|
name string
|
||||||
|
args string
|
||||||
|
assert assertFunc
|
||||||
|
reconcile reconcileFunc
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"NoArgs",
|
||||||
|
"create source git",
|
||||||
|
assertError("GitRepository source name is required"),
|
||||||
|
nil,
|
||||||
|
}, {
|
||||||
|
"Succeeded",
|
||||||
|
command,
|
||||||
|
assertGoldenFile("testdata/create_source_git/success.golden"),
|
||||||
|
func(repo *sourcev1.GitRepository) {
|
||||||
|
meta.SetResourceCondition(repo, meta.ReadyCondition, metav1.ConditionTrue, sourcev1.GitOperationSucceedReason, "succeeded message")
|
||||||
|
repo.Status.Artifact = &sourcev1.Artifact{
|
||||||
|
Path: "some-path",
|
||||||
|
Revision: "v1",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
"Failed",
|
||||||
|
command,
|
||||||
|
assertError("failed message"),
|
||||||
|
func(repo *sourcev1.GitRepository) {
|
||||||
|
meta.SetResourceCondition(repo, meta.ReadyCondition, metav1.ConditionFalse, sourcev1.URLInvalidReason, "failed message")
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
"NoArtifact",
|
||||||
|
command,
|
||||||
|
assertError("GitRepository source reconciliation completed but no artifact was found"),
|
||||||
|
func(repo *sourcev1.GitRepository) {
|
||||||
|
// Updated with no artifact
|
||||||
|
meta.SetResourceCondition(repo, meta.ReadyCondition, metav1.ConditionTrue, sourcev1.GitOperationSucceedReason, "succeeded message")
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tc := range cases {
|
||||||
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
|
ns := allocateNamespace("podinfo")
|
||||||
|
setupTestNamespace(ns, t)
|
||||||
|
if tc.reconcile != nil {
|
||||||
|
r := reconciler{
|
||||||
|
client: testEnv.client,
|
||||||
|
name: types.NamespacedName{Namespace: ns, Name: "podinfo"},
|
||||||
|
reconcile: tc.reconcile,
|
||||||
|
}
|
||||||
|
r.run(t)
|
||||||
|
}
|
||||||
|
cmd := cmdTestCase{
|
||||||
|
args: tc.args + " -n=" + ns,
|
||||||
|
assert: tc.assert,
|
||||||
|
}
|
||||||
|
cmd.runTestCmd(t)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
263
cmd/flux/create_source_helm.go
Normal file
263
cmd/flux/create_source_helm.go
Normal file
@@ -0,0 +1,263 @@
|
|||||||
|
/*
|
||||||
|
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"
|
||||||
|
"net/url"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/fluxcd/pkg/apis/meta"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
corev1 "k8s.io/api/core/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
|
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"
|
||||||
|
"sigs.k8s.io/yaml"
|
||||||
|
|
||||||
|
sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
|
||||||
|
|
||||||
|
"github.com/fluxcd/flux2/internal/utils"
|
||||||
|
"github.com/fluxcd/flux2/pkg/manifestgen/sourcesecret"
|
||||||
|
)
|
||||||
|
|
||||||
|
var createSourceHelmCmd = &cobra.Command{
|
||||||
|
Use: "helm [name]",
|
||||||
|
Short: "Create or update a HelmRepository source",
|
||||||
|
Long: `The create source helm command generates a HelmRepository resource and waits for it to fetch the index.
|
||||||
|
For private Helm repositories, the basic authentication credentials are stored in a Kubernetes secret.`,
|
||||||
|
Example: ` # Create a source for a public Helm repository
|
||||||
|
flux create source helm podinfo \
|
||||||
|
--url=https://stefanprodan.github.io/podinfo \
|
||||||
|
--interval=10m
|
||||||
|
|
||||||
|
# Create a source for a Helm repository using basic authentication
|
||||||
|
flux create source helm podinfo \
|
||||||
|
--url=https://stefanprodan.github.io/podinfo \
|
||||||
|
--username=username \
|
||||||
|
--password=password
|
||||||
|
|
||||||
|
# Create a source for a Helm repository using TLS authentication
|
||||||
|
flux create source helm podinfo \
|
||||||
|
--url=https://stefanprodan.github.io/podinfo \
|
||||||
|
--cert-file=./cert.crt \
|
||||||
|
--key-file=./key.crt \
|
||||||
|
--ca-file=./ca.crt`,
|
||||||
|
RunE: createSourceHelmCmdRun,
|
||||||
|
}
|
||||||
|
|
||||||
|
type sourceHelmFlags struct {
|
||||||
|
url string
|
||||||
|
username string
|
||||||
|
password string
|
||||||
|
certFile string
|
||||||
|
keyFile string
|
||||||
|
caFile string
|
||||||
|
secretRef string
|
||||||
|
passCredentials bool
|
||||||
|
}
|
||||||
|
|
||||||
|
var sourceHelmArgs sourceHelmFlags
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
createSourceHelmCmd.Flags().StringVar(&sourceHelmArgs.url, "url", "", "Helm repository address")
|
||||||
|
createSourceHelmCmd.Flags().StringVarP(&sourceHelmArgs.username, "username", "u", "", "basic authentication username")
|
||||||
|
createSourceHelmCmd.Flags().StringVarP(&sourceHelmArgs.password, "password", "p", "", "basic authentication password")
|
||||||
|
createSourceHelmCmd.Flags().StringVar(&sourceHelmArgs.certFile, "cert-file", "", "TLS authentication cert file path")
|
||||||
|
createSourceHelmCmd.Flags().StringVar(&sourceHelmArgs.keyFile, "key-file", "", "TLS authentication key file path")
|
||||||
|
createSourceHelmCmd.Flags().StringVar(&sourceHelmArgs.caFile, "ca-file", "", "TLS authentication CA file path")
|
||||||
|
createSourceHelmCmd.Flags().StringVarP(&sourceHelmArgs.secretRef, "secret-ref", "", "", "the name of an existing secret containing TLS or basic auth credentials")
|
||||||
|
createSourceHelmCmd.Flags().BoolVarP(&sourceHelmArgs.passCredentials, "pass-credentials", "", false, "pass credentials to all domains")
|
||||||
|
|
||||||
|
createSourceCmd.AddCommand(createSourceHelmCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func createSourceHelmCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
|
if len(args) < 1 {
|
||||||
|
return fmt.Errorf("HelmRepository source name is required")
|
||||||
|
}
|
||||||
|
name := args[0]
|
||||||
|
|
||||||
|
if sourceHelmArgs.url == "" {
|
||||||
|
return fmt.Errorf("url is required")
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceLabels, err := parseLabels()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
tmpDir, err := os.MkdirTemp("", name)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer os.RemoveAll(tmpDir)
|
||||||
|
|
||||||
|
if _, err := url.Parse(sourceHelmArgs.url); err != nil {
|
||||||
|
return fmt.Errorf("url parse failed: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
helmRepository := &sourcev1.HelmRepository{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: name,
|
||||||
|
Namespace: rootArgs.namespace,
|
||||||
|
Labels: sourceLabels,
|
||||||
|
},
|
||||||
|
Spec: sourcev1.HelmRepositorySpec{
|
||||||
|
URL: sourceHelmArgs.url,
|
||||||
|
Interval: metav1.Duration{
|
||||||
|
Duration: createArgs.interval,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
if createSourceArgs.fetchTimeout > 0 {
|
||||||
|
helmRepository.Spec.Timeout = &metav1.Duration{Duration: createSourceArgs.fetchTimeout}
|
||||||
|
}
|
||||||
|
|
||||||
|
if sourceHelmArgs.secretRef != "" {
|
||||||
|
helmRepository.Spec.SecretRef = &meta.LocalObjectReference{
|
||||||
|
Name: sourceHelmArgs.secretRef,
|
||||||
|
}
|
||||||
|
helmRepository.Spec.PassCredentials = sourceHelmArgs.passCredentials
|
||||||
|
}
|
||||||
|
|
||||||
|
if createArgs.export {
|
||||||
|
return printExport(exportHelmRepository(helmRepository))
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Generatef("generating HelmRepository source")
|
||||||
|
if sourceHelmArgs.secretRef == "" {
|
||||||
|
secretName := fmt.Sprintf("helm-%s", name)
|
||||||
|
secretOpts := sourcesecret.Options{
|
||||||
|
Name: secretName,
|
||||||
|
Namespace: rootArgs.namespace,
|
||||||
|
Username: sourceHelmArgs.username,
|
||||||
|
Password: sourceHelmArgs.password,
|
||||||
|
CertFilePath: sourceHelmArgs.certFile,
|
||||||
|
KeyFilePath: sourceHelmArgs.keyFile,
|
||||||
|
CAFilePath: sourceHelmArgs.caFile,
|
||||||
|
ManifestFile: sourcesecret.MakeDefaultOptions().ManifestFile,
|
||||||
|
}
|
||||||
|
secret, err := sourcesecret.Generate(secretOpts)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
var s corev1.Secret
|
||||||
|
if err = yaml.Unmarshal([]byte(secret.Content), &s); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if len(s.StringData) > 0 {
|
||||||
|
logger.Actionf("applying secret with repository credentials")
|
||||||
|
if err := upsertSecret(ctx, kubeClient, s); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
helmRepository.Spec.SecretRef = &meta.LocalObjectReference{
|
||||||
|
Name: secretName,
|
||||||
|
}
|
||||||
|
helmRepository.Spec.PassCredentials = sourceHelmArgs.passCredentials
|
||||||
|
logger.Successf("authentication configured")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Actionf("applying HelmRepository source")
|
||||||
|
namespacedName, err := upsertHelmRepository(ctx, kubeClient, helmRepository)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Waitingf("waiting for HelmRepository source reconciliation")
|
||||||
|
if err := wait.PollImmediate(rootArgs.pollInterval, rootArgs.timeout,
|
||||||
|
isHelmRepositoryReady(ctx, kubeClient, namespacedName, helmRepository)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
logger.Successf("HelmRepository source reconciliation completed")
|
||||||
|
|
||||||
|
if helmRepository.Status.Artifact == nil {
|
||||||
|
return fmt.Errorf("HelmRepository source reconciliation completed but no artifact was found")
|
||||||
|
}
|
||||||
|
logger.Successf("fetched revision: %s", helmRepository.Status.Artifact.Revision)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func upsertHelmRepository(ctx context.Context, kubeClient client.Client,
|
||||||
|
helmRepository *sourcev1.HelmRepository) (types.NamespacedName, error) {
|
||||||
|
namespacedName := types.NamespacedName{
|
||||||
|
Namespace: helmRepository.GetNamespace(),
|
||||||
|
Name: helmRepository.GetName(),
|
||||||
|
}
|
||||||
|
|
||||||
|
var existing sourcev1.HelmRepository
|
||||||
|
err := kubeClient.Get(ctx, namespacedName, &existing)
|
||||||
|
if err != nil {
|
||||||
|
if errors.IsNotFound(err) {
|
||||||
|
if err := kubeClient.Create(ctx, helmRepository); err != nil {
|
||||||
|
return namespacedName, err
|
||||||
|
} else {
|
||||||
|
logger.Successf("source created")
|
||||||
|
return namespacedName, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return namespacedName, err
|
||||||
|
}
|
||||||
|
|
||||||
|
existing.Labels = helmRepository.Labels
|
||||||
|
existing.Spec = helmRepository.Spec
|
||||||
|
if err := kubeClient.Update(ctx, &existing); err != nil {
|
||||||
|
return namespacedName, err
|
||||||
|
}
|
||||||
|
helmRepository = &existing
|
||||||
|
logger.Successf("source updated")
|
||||||
|
return namespacedName, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func isHelmRepositoryReady(ctx context.Context, kubeClient client.Client,
|
||||||
|
namespacedName types.NamespacedName, helmRepository *sourcev1.HelmRepository) wait.ConditionFunc {
|
||||||
|
return func() (bool, error) {
|
||||||
|
err := kubeClient.Get(ctx, namespacedName, helmRepository)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Confirm the state we are observing is for the current generation
|
||||||
|
if helmRepository.Generation != helmRepository.Status.ObservedGeneration {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if c := apimeta.FindStatusCondition(helmRepository.Status.Conditions, 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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2020 The Flux CD contributors.
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -21,7 +21,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/fluxcd/toolkit/internal/utils"
|
"github.com/fluxcd/flux2/internal/utils"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
rbacv1 "k8s.io/api/rbac/v1"
|
rbacv1 "k8s.io/api/rbac/v1"
|
||||||
@@ -37,37 +37,35 @@ import (
|
|||||||
var createTenantCmd = &cobra.Command{
|
var createTenantCmd = &cobra.Command{
|
||||||
Use: "tenant",
|
Use: "tenant",
|
||||||
Short: "Create or update a tenant",
|
Short: "Create or update a tenant",
|
||||||
Long: `
|
Long: `The create tenant command generates namespaces, service accounts and role bindings to limit the
|
||||||
The create tenant command generates namespaces and role bindings to limit the
|
|
||||||
reconcilers scope to the tenant namespaces.`,
|
reconcilers scope to the tenant namespaces.`,
|
||||||
Example: ` # Create a tenant with access to a namespace
|
Example: ` # Create a tenant with access to a namespace
|
||||||
gotk create tenant dev-team \
|
flux create tenant dev-team \
|
||||||
--with-namespace=frontend \
|
--with-namespace=frontend \
|
||||||
--label=environment=dev
|
--label=environment=dev
|
||||||
|
|
||||||
# Generate tenant namespaces and role bindings in YAML format
|
# Generate tenant namespaces and role bindings in YAML format
|
||||||
gotk create tenant dev-team \
|
flux create tenant dev-team \
|
||||||
--with-namespace=frontend \
|
--with-namespace=frontend \
|
||||||
--with-namespace=backend \
|
--with-namespace=backend \
|
||||||
--export > dev-team.yaml
|
--export > dev-team.yaml`,
|
||||||
`,
|
|
||||||
RunE: createTenantCmdRun,
|
RunE: createTenantCmdRun,
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
tenantLabel = "toolkit.fluxcd.io/tenant"
|
tenantLabel = "toolkit.fluxcd.io/tenant"
|
||||||
tenantRoleBinding = "gotk-reconciler"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
type tenantFlags struct {
|
||||||
tenantNamespaces []string
|
namespaces []string
|
||||||
tenantClusterRole string
|
clusterRole string
|
||||||
)
|
}
|
||||||
|
|
||||||
|
var tenantArgs tenantFlags
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
createTenantCmd.Hidden = true
|
createTenantCmd.Flags().StringSliceVar(&tenantArgs.namespaces, "with-namespace", nil, "namespace belonging to this tenant")
|
||||||
createTenantCmd.Flags().StringSliceVar(&tenantNamespaces, "with-namespace", nil, "namespace belonging to this tenant")
|
createTenantCmd.Flags().StringVar(&tenantArgs.clusterRole, "cluster-role", "cluster-admin", "cluster role of the tenant role binding")
|
||||||
createTenantCmd.Flags().StringVar(&tenantClusterRole, "cluster-role", "cluster-admin", "cluster role of the tenant role binding")
|
|
||||||
createCmd.AddCommand(createTenantCmd)
|
createCmd.AddCommand(createTenantCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,18 +78,19 @@ func createTenantCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
return fmt.Errorf("invalid tenant name '%s': %v", tenant, err)
|
return fmt.Errorf("invalid tenant name '%s': %v", tenant, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if tenantClusterRole == "" {
|
if tenantArgs.clusterRole == "" {
|
||||||
return fmt.Errorf("cluster-role is required")
|
return fmt.Errorf("cluster-role is required")
|
||||||
}
|
}
|
||||||
|
|
||||||
if tenantNamespaces == nil {
|
if tenantArgs.namespaces == nil {
|
||||||
return fmt.Errorf("with-namespace is required")
|
return fmt.Errorf("with-namespace is required")
|
||||||
}
|
}
|
||||||
|
|
||||||
var namespaces []corev1.Namespace
|
var namespaces []corev1.Namespace
|
||||||
|
var accounts []corev1.ServiceAccount
|
||||||
var roleBindings []rbacv1.RoleBinding
|
var roleBindings []rbacv1.RoleBinding
|
||||||
|
|
||||||
for _, ns := range tenantNamespaces {
|
for _, ns := range tenantArgs.namespaces {
|
||||||
if err := validation.IsQualifiedName(ns); len(err) > 0 {
|
if err := validation.IsQualifiedName(ns); len(err) > 0 {
|
||||||
return fmt.Errorf("invalid namespace '%s': %v", ns, err)
|
return fmt.Errorf("invalid namespace '%s': %v", ns, err)
|
||||||
}
|
}
|
||||||
@@ -111,9 +110,19 @@ func createTenantCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
namespaces = append(namespaces, namespace)
|
namespaces = append(namespaces, namespace)
|
||||||
|
|
||||||
|
account := corev1.ServiceAccount{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: tenant,
|
||||||
|
Namespace: ns,
|
||||||
|
Labels: objLabels,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
accounts = append(accounts, account)
|
||||||
|
|
||||||
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,
|
||||||
},
|
},
|
||||||
@@ -123,39 +132,49 @@ func createTenantCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
Kind: "User",
|
Kind: "User",
|
||||||
Name: fmt.Sprintf("gotk:%s:reconciler", ns),
|
Name: fmt.Sprintf("gotk:%s:reconciler", ns),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Kind: "ServiceAccount",
|
||||||
|
Name: tenant,
|
||||||
|
Namespace: ns,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
RoleRef: rbacv1.RoleRef{
|
RoleRef: rbacv1.RoleRef{
|
||||||
APIGroup: "rbac.authorization.k8s.io",
|
APIGroup: "rbac.authorization.k8s.io",
|
||||||
Kind: "ClusterRole",
|
Kind: "ClusterRole",
|
||||||
Name: tenantClusterRole,
|
Name: tenantArgs.clusterRole,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
roleBindings = append(roleBindings, roleBinding)
|
roleBindings = append(roleBindings, roleBinding)
|
||||||
}
|
}
|
||||||
|
|
||||||
if export {
|
if createArgs.export {
|
||||||
for i, _ := range tenantNamespaces {
|
for i := range tenantArgs.namespaces {
|
||||||
if err := exportTenant(namespaces[i], roleBindings[1]); err != nil {
|
if err := exportTenant(namespaces[i], accounts[i], roleBindings[i]); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
kubeClient, err := utils.KubeClient(kubeconfig)
|
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, _ := range tenantNamespaces {
|
for i := range tenantArgs.namespaces {
|
||||||
logger.Actionf("applying namespace %s", namespaces[i].Name)
|
logger.Actionf("applying namespace %s", namespaces[i].Name)
|
||||||
if err := upsertNamespace(ctx, kubeClient, namespaces[i]); err != nil {
|
if err := upsertNamespace(ctx, kubeClient, namespaces[i]); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.Actionf("applying service account %s", accounts[i].Name)
|
||||||
|
if err := upsertServiceAccount(ctx, kubeClient, accounts[i]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
logger.Actionf("applying role binding %s", roleBindings[i].Name)
|
logger.Actionf("applying role binding %s", roleBindings[i].Name)
|
||||||
if err := upsertRoleBinding(ctx, kubeClient, roleBindings[i]); err != nil {
|
if err := upsertRoleBinding(ctx, kubeClient, roleBindings[i]); err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -195,6 +214,35 @@ func upsertNamespace(ctx context.Context, kubeClient client.Client, namespace co
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func upsertServiceAccount(ctx context.Context, kubeClient client.Client, account corev1.ServiceAccount) error {
|
||||||
|
namespacedName := types.NamespacedName{
|
||||||
|
Namespace: account.GetNamespace(),
|
||||||
|
Name: account.GetName(),
|
||||||
|
}
|
||||||
|
|
||||||
|
var existing corev1.ServiceAccount
|
||||||
|
err := kubeClient.Get(ctx, namespacedName, &existing)
|
||||||
|
if err != nil {
|
||||||
|
if errors.IsNotFound(err) {
|
||||||
|
if err := kubeClient.Create(ctx, &account); err != nil {
|
||||||
|
return err
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if !equality.Semantic.DeepDerivative(account.Labels, existing.Labels) {
|
||||||
|
existing.Labels = account.Labels
|
||||||
|
if err := kubeClient.Update(ctx, &existing); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func upsertRoleBinding(ctx context.Context, kubeClient client.Client, roleBinding rbacv1.RoleBinding) error {
|
func upsertRoleBinding(ctx context.Context, kubeClient client.Client, roleBinding rbacv1.RoleBinding) error {
|
||||||
namespacedName := types.NamespacedName{
|
namespacedName := types.NamespacedName{
|
||||||
Namespace: roleBinding.GetNamespace(),
|
Namespace: roleBinding.GetNamespace(),
|
||||||
@@ -228,7 +276,7 @@ func upsertRoleBinding(ctx context.Context, kubeClient client.Client, roleBindin
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func exportTenant(namespace corev1.Namespace, roleBinding rbacv1.RoleBinding) error {
|
func exportTenant(namespace corev1.Namespace, account corev1.ServiceAccount, roleBinding rbacv1.RoleBinding) error {
|
||||||
namespace.TypeMeta = metav1.TypeMeta{
|
namespace.TypeMeta = metav1.TypeMeta{
|
||||||
APIVersion: "v1",
|
APIVersion: "v1",
|
||||||
Kind: "Namespace",
|
Kind: "Namespace",
|
||||||
@@ -242,6 +290,19 @@ func exportTenant(namespace corev1.Namespace, roleBinding rbacv1.RoleBinding) er
|
|||||||
data = bytes.Replace(data, []byte("spec: {}\n"), []byte(""), 1)
|
data = bytes.Replace(data, []byte("spec: {}\n"), []byte(""), 1)
|
||||||
fmt.Println(resourceToString(data))
|
fmt.Println(resourceToString(data))
|
||||||
|
|
||||||
|
account.TypeMeta = metav1.TypeMeta{
|
||||||
|
APIVersion: "v1",
|
||||||
|
Kind: "ServiceAccount",
|
||||||
|
}
|
||||||
|
data, err = yaml.Marshal(account)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("---")
|
||||||
|
data = bytes.Replace(data, []byte("spec: {}\n"), []byte(""), 1)
|
||||||
|
fmt.Println(resourceToString(data))
|
||||||
|
|
||||||
roleBinding.TypeMeta = metav1.TypeMeta{
|
roleBinding.TypeMeta = metav1.TypeMeta{
|
||||||
APIVersion: "rbac.authorization.k8s.io/v1",
|
APIVersion: "rbac.authorization.k8s.io/v1",
|
||||||
Kind: "RoleBinding",
|
Kind: "RoleBinding",
|
||||||
96
cmd/flux/delete.go
Normal file
96
cmd/flux/delete.go
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
/*
|
||||||
|
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"
|
||||||
|
|
||||||
|
"github.com/manifoldco/promptui"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
"k8s.io/apimachinery/pkg/types"
|
||||||
|
|
||||||
|
"github.com/fluxcd/flux2/internal/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
var deleteCmd = &cobra.Command{
|
||||||
|
Use: "delete",
|
||||||
|
Short: "Delete sources and resources",
|
||||||
|
Long: "The delete sub-commands delete sources and resources.",
|
||||||
|
}
|
||||||
|
|
||||||
|
type deleteFlags struct {
|
||||||
|
silent bool
|
||||||
|
}
|
||||||
|
|
||||||
|
var deleteArgs deleteFlags
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
deleteCmd.PersistentFlags().BoolVarP(&deleteArgs.silent, "silent", "s", false,
|
||||||
|
"delete resource without asking for confirmation")
|
||||||
|
|
||||||
|
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(), rootArgs.timeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
namespacedName := types.NamespacedName{
|
||||||
|
Namespace: rootArgs.namespace,
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
|
||||||
|
err = kubeClient.Get(ctx, namespacedName, del.object.asClientObject())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if !deleteArgs.silent {
|
||||||
|
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, rootArgs.namespace)
|
||||||
|
err = kubeClient.Delete(ctx, del.object.asClientObject())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
logger.Successf("%s deleted", del.humanKind)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
40
cmd/flux/delete_alert.go
Normal file
40
cmd/flux/delete_alert.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"
|
||||||
|
|
||||||
|
notificationv1 "github.com/fluxcd/notification-controller/api/v1beta1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var deleteAlertCmd = &cobra.Command{
|
||||||
|
Use: "alert [name]",
|
||||||
|
Short: "Delete a Alert resource",
|
||||||
|
Long: "The delete alert command removes the given Alert from the cluster.",
|
||||||
|
Example: ` # Delete an Alert and the Kubernetes resources created by it
|
||||||
|
flux delete alert main`,
|
||||||
|
ValidArgsFunction: resourceNamesCompletionFunc(notificationv1.GroupVersion.WithKind(notificationv1.AlertKind)),
|
||||||
|
RunE: deleteCommand{
|
||||||
|
apiType: alertType,
|
||||||
|
object: universalAdapter{¬ificationv1.Alert{}},
|
||||||
|
}.run,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
deleteCmd.AddCommand(deleteAlertCmd)
|
||||||
|
}
|
||||||
40
cmd/flux/delete_alertprovider.go
Normal file
40
cmd/flux/delete_alertprovider.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"
|
||||||
|
|
||||||
|
notificationv1 "github.com/fluxcd/notification-controller/api/v1beta1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var deleteAlertProviderCmd = &cobra.Command{
|
||||||
|
Use: "alert-provider [name]",
|
||||||
|
Short: "Delete a Provider resource",
|
||||||
|
Long: "The delete alert-provider command removes the given Provider from the cluster.",
|
||||||
|
Example: ` # Delete a Provider and the Kubernetes resources created by it
|
||||||
|
flux delete alert-provider slack`,
|
||||||
|
ValidArgsFunction: resourceNamesCompletionFunc(notificationv1.GroupVersion.WithKind(notificationv1.ProviderKind)),
|
||||||
|
RunE: deleteCommand{
|
||||||
|
apiType: alertProviderType,
|
||||||
|
object: universalAdapter{¬ificationv1.Provider{}},
|
||||||
|
}.run,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
deleteCmd.AddCommand(deleteAlertProviderCmd)
|
||||||
|
}
|
||||||
41
cmd/flux/delete_helmrelease.go
Normal file
41
cmd/flux/delete_helmrelease.go
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
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"
|
||||||
|
|
||||||
|
helmv2 "github.com/fluxcd/helm-controller/api/v2beta1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var deleteHelmReleaseCmd = &cobra.Command{
|
||||||
|
Use: "helmrelease [name]",
|
||||||
|
Aliases: []string{"hr"},
|
||||||
|
Short: "Delete a HelmRelease resource",
|
||||||
|
Long: "The delete helmrelease command removes the given HelmRelease from the cluster.",
|
||||||
|
Example: ` # Delete a Helm release and the Kubernetes resources created by it
|
||||||
|
flux delete hr podinfo`,
|
||||||
|
ValidArgsFunction: resourceNamesCompletionFunc(helmv2.GroupVersion.WithKind(helmv2.HelmReleaseKind)),
|
||||||
|
RunE: deleteCommand{
|
||||||
|
apiType: helmReleaseType,
|
||||||
|
object: universalAdapter{&helmv2.HelmRelease{}},
|
||||||
|
}.run,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
deleteCmd.AddCommand(deleteHelmReleaseCmd)
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2020 The Flux CD contributors.
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -20,12 +20,12 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var resumeCmd = &cobra.Command{
|
var deleteImageCmd = &cobra.Command{
|
||||||
Use: "resume",
|
Use: "image",
|
||||||
Short: "Resume suspended resources",
|
Short: "Delete image automation objects",
|
||||||
Long: "The resume sub-commands resume a suspended resource.",
|
Long: "The delete image sub-commands delete image automation objects.",
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(resumeCmd)
|
deleteCmd.AddCommand(deleteImageCmd)
|
||||||
}
|
}
|
||||||
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/v1beta1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var deleteImagePolicyCmd = &cobra.Command{
|
||||||
|
Use: "policy [name]",
|
||||||
|
Short: "Delete an ImagePolicy object",
|
||||||
|
Long: "The delete image policy command deletes the given ImagePolicy from the cluster.",
|
||||||
|
Example: ` # Delete an image policy
|
||||||
|
flux delete image policy alpine3.x`,
|
||||||
|
ValidArgsFunction: resourceNamesCompletionFunc(imagev1.GroupVersion.WithKind(imagev1.ImagePolicyKind)),
|
||||||
|
RunE: deleteCommand{
|
||||||
|
apiType: imagePolicyType,
|
||||||
|
object: universalAdapter{&imagev1.ImagePolicy{}},
|
||||||
|
}.run,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
deleteImageCmd.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/v1beta1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var deleteImageRepositoryCmd = &cobra.Command{
|
||||||
|
Use: "repository [name]",
|
||||||
|
Short: "Delete an ImageRepository object",
|
||||||
|
Long: "The delete image repository command deletes the given ImageRepository from the cluster.",
|
||||||
|
Example: ` # Delete an image repository
|
||||||
|
flux delete image repository alpine`,
|
||||||
|
ValidArgsFunction: resourceNamesCompletionFunc(imagev1.GroupVersion.WithKind(imagev1.ImageRepositoryKind)),
|
||||||
|
RunE: deleteCommand{
|
||||||
|
apiType: imageRepositoryType,
|
||||||
|
object: universalAdapter{&imagev1.ImageRepository{}},
|
||||||
|
}.run,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
deleteImageCmd.AddCommand(deleteImageRepositoryCmd)
|
||||||
|
}
|
||||||
40
cmd/flux/delete_image_update.go
Normal file
40
cmd/flux/delete_image_update.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/v1beta1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var deleteImageUpdateCmd = &cobra.Command{
|
||||||
|
Use: "update [name]",
|
||||||
|
Short: "Delete an ImageUpdateAutomation object",
|
||||||
|
Long: "The delete image update command deletes the given ImageUpdateAutomation from the cluster.",
|
||||||
|
Example: ` # Delete an image update automation
|
||||||
|
flux delete image update latest-images`,
|
||||||
|
ValidArgsFunction: resourceNamesCompletionFunc(autov1.GroupVersion.WithKind(autov1.ImageUpdateAutomationKind)),
|
||||||
|
RunE: deleteCommand{
|
||||||
|
apiType: imageUpdateAutomationType,
|
||||||
|
object: universalAdapter{&autov1.ImageUpdateAutomation{}},
|
||||||
|
}.run,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
deleteImageCmd.AddCommand(deleteImageUpdateCmd)
|
||||||
|
}
|
||||||
41
cmd/flux/delete_kustomization.go
Normal file
41
cmd/flux/delete_kustomization.go
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
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"
|
||||||
|
|
||||||
|
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1beta2"
|
||||||
|
)
|
||||||
|
|
||||||
|
var deleteKsCmd = &cobra.Command{
|
||||||
|
Use: "kustomization [name]",
|
||||||
|
Aliases: []string{"ks"},
|
||||||
|
Short: "Delete a Kustomization resource",
|
||||||
|
Long: "The delete kustomization command deletes the given Kustomization from the cluster.",
|
||||||
|
Example: ` # Delete a kustomization and the Kubernetes resources created by it
|
||||||
|
flux delete kustomization podinfo`,
|
||||||
|
ValidArgsFunction: resourceNamesCompletionFunc(kustomizev1.GroupVersion.WithKind(kustomizev1.KustomizationKind)),
|
||||||
|
RunE: deleteCommand{
|
||||||
|
apiType: kustomizationType,
|
||||||
|
object: universalAdapter{&kustomizev1.Kustomization{}},
|
||||||
|
}.run,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
deleteCmd.AddCommand(deleteKsCmd)
|
||||||
|
}
|
||||||
40
cmd/flux/delete_receiver.go
Normal file
40
cmd/flux/delete_receiver.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"
|
||||||
|
|
||||||
|
notificationv1 "github.com/fluxcd/notification-controller/api/v1beta1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var deleteReceiverCmd = &cobra.Command{
|
||||||
|
Use: "receiver [name]",
|
||||||
|
Short: "Delete a Receiver resource",
|
||||||
|
Long: "The delete receiver command removes the given Receiver from the cluster.",
|
||||||
|
Example: ` # Delete an Receiver and the Kubernetes resources created by it
|
||||||
|
flux delete receiver main`,
|
||||||
|
ValidArgsFunction: resourceNamesCompletionFunc(notificationv1.GroupVersion.WithKind(notificationv1.ReceiverKind)),
|
||||||
|
RunE: deleteCommand{
|
||||||
|
apiType: receiverType,
|
||||||
|
object: universalAdapter{¬ificationv1.Receiver{}},
|
||||||
|
}.run,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
deleteCmd.AddCommand(deleteReceiverCmd)
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2020 The Flux CD contributors.
|
Copyright 2020 The Flux authors
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
40
cmd/flux/delete_source_bucket.go
Normal file
40
cmd/flux/delete_source_bucket.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"
|
||||||
|
|
||||||
|
sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var deleteSourceBucketCmd = &cobra.Command{
|
||||||
|
Use: "bucket [name]",
|
||||||
|
Short: "Delete a Bucket source",
|
||||||
|
Long: "The delete source bucket command deletes the given Bucket from the cluster.",
|
||||||
|
Example: ` # Delete a Bucket source
|
||||||
|
flux delete source bucket podinfo`,
|
||||||
|
ValidArgsFunction: resourceNamesCompletionFunc(sourcev1.GroupVersion.WithKind(sourcev1.BucketKind)),
|
||||||
|
RunE: deleteCommand{
|
||||||
|
apiType: bucketType,
|
||||||
|
object: universalAdapter{&sourcev1.Bucket{}},
|
||||||
|
}.run,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
deleteSourceCmd.AddCommand(deleteSourceBucketCmd)
|
||||||
|
}
|
||||||
40
cmd/flux/delete_source_git.go
Normal file
40
cmd/flux/delete_source_git.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"
|
||||||
|
|
||||||
|
sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var deleteSourceGitCmd = &cobra.Command{
|
||||||
|
Use: "git [name]",
|
||||||
|
Short: "Delete a GitRepository source",
|
||||||
|
Long: "The delete source git command deletes the given GitRepository from the cluster.",
|
||||||
|
Example: ` # Delete a Git repository
|
||||||
|
flux delete source git podinfo`,
|
||||||
|
ValidArgsFunction: resourceNamesCompletionFunc(sourcev1.GroupVersion.WithKind(sourcev1.GitRepositoryKind)),
|
||||||
|
RunE: deleteCommand{
|
||||||
|
apiType: gitRepositoryType,
|
||||||
|
object: universalAdapter{&sourcev1.GitRepository{}},
|
||||||
|
}.run,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
deleteSourceCmd.AddCommand(deleteSourceGitCmd)
|
||||||
|
}
|
||||||
40
cmd/flux/delete_source_helm.go
Normal file
40
cmd/flux/delete_source_helm.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"
|
||||||
|
|
||||||
|
sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var deleteSourceHelmCmd = &cobra.Command{
|
||||||
|
Use: "helm [name]",
|
||||||
|
Short: "Delete a HelmRepository source",
|
||||||
|
Long: "The delete source helm command deletes the given HelmRepository from the cluster.",
|
||||||
|
Example: ` # Delete a Helm repository
|
||||||
|
flux delete source helm podinfo`,
|
||||||
|
ValidArgsFunction: resourceNamesCompletionFunc(sourcev1.GroupVersion.WithKind(sourcev1.HelmRepositoryKind)),
|
||||||
|
RunE: deleteCommand{
|
||||||
|
apiType: helmRepositoryType,
|
||||||
|
object: universalAdapter{&sourcev1.HelmRepository{}},
|
||||||
|
}.run,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
deleteSourceCmd.AddCommand(deleteSourceHelmCmd)
|
||||||
|
}
|
||||||
69
cmd/flux/docgen.go
Normal file
69
cmd/flux/docgen.go
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2021 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"
|
||||||
|
"path"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
"github.com/spf13/cobra/doc"
|
||||||
|
)
|
||||||
|
|
||||||
|
const fmTemplate = `---
|
||||||
|
title: "%s"
|
||||||
|
---
|
||||||
|
`
|
||||||
|
|
||||||
|
var (
|
||||||
|
cmdDocPath string
|
||||||
|
)
|
||||||
|
|
||||||
|
var docgenCmd = &cobra.Command{
|
||||||
|
Use: "docgen",
|
||||||
|
Short: "Generate the documentation for the CLI commands.",
|
||||||
|
Hidden: true,
|
||||||
|
RunE: docgenCmdRun,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
docgenCmd.Flags().StringVar(&cmdDocPath, "path", "./docs/cmd", "path to write the generated documentation to")
|
||||||
|
|
||||||
|
rootCmd.AddCommand(docgenCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func docgenCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
|
err := doc.GenMarkdownTreeCustom(rootCmd, cmdDocPath, frontmatterPrepender, linkHandler)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func frontmatterPrepender(filename string) string {
|
||||||
|
name := filepath.Base(filename)
|
||||||
|
base := strings.TrimSuffix(name, path.Ext(name))
|
||||||
|
title := strings.Replace(base, "_", " ", -1)
|
||||||
|
return fmt.Sprintf(fmTemplate, title)
|
||||||
|
}
|
||||||
|
|
||||||
|
func linkHandler(name string) string {
|
||||||
|
base := strings.TrimSuffix(name, path.Ext(name))
|
||||||
|
return "../" + strings.ToLower(base) + "/"
|
||||||
|
}
|
||||||
125
cmd/flux/export.go
Normal file
125
cmd/flux/export.go
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
/*
|
||||||
|
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 (
|
||||||
|
"bytes"
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"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{
|
||||||
|
Use: "export",
|
||||||
|
Short: "Export resources in YAML format",
|
||||||
|
Long: "The export sub-commands export resources in YAML format.",
|
||||||
|
}
|
||||||
|
|
||||||
|
type exportFlags struct {
|
||||||
|
all bool
|
||||||
|
}
|
||||||
|
|
||||||
|
var exportArgs exportFlags
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
exportCmd.PersistentFlags().BoolVar(&exportArgs.all, "all", false, "select all resources")
|
||||||
|
|
||||||
|
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 {
|
||||||
|
listAdapter
|
||||||
|
exportItem(i int) interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
type exportCommand struct {
|
||||||
|
object exportable
|
||||||
|
list exportableList
|
||||||
|
}
|
||||||
|
|
||||||
|
func (export exportCommand) run(cmd *cobra.Command, args []string) error {
|
||||||
|
if !exportArgs.all && len(args) < 1 {
|
||||||
|
return fmt.Errorf("name is required")
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if exportArgs.all {
|
||||||
|
err = kubeClient.List(ctx, export.list.asClientList(), client.InNamespace(rootArgs.namespace))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if export.list.len() == 0 {
|
||||||
|
return fmt.Errorf("no objects found in %s namespace", rootArgs.namespace)
|
||||||
|
}
|
||||||
|
|
||||||
|
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: rootArgs.namespace,
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
err = kubeClient.Get(ctx, namespacedName, export.object.asClientObject())
|
||||||
|
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
|
||||||
|
}
|
||||||
|
rootCmd.Println("---")
|
||||||
|
rootCmd.Println(resourceToString(data))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func resourceToString(data []byte) string {
|
||||||
|
data = bytes.Replace(data, []byte(" creationTimestamp: null\n"), []byte(""), 1)
|
||||||
|
data = bytes.Replace(data, []byte("status: {}\n"), []byte(""), 1)
|
||||||
|
return string(data)
|
||||||
|
}
|
||||||
71
cmd/flux/export_alert.go
Normal file
71
cmd/flux/export_alert.go
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
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"
|
||||||
|
|
||||||
|
notificationv1 "github.com/fluxcd/notification-controller/api/v1beta1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var exportAlertCmd = &cobra.Command{
|
||||||
|
Use: "alert [name]",
|
||||||
|
Short: "Export Alert resources in YAML format",
|
||||||
|
Long: "The export alert command exports one or all Alert resources in YAML format.",
|
||||||
|
Example: ` # Export all Alert resources
|
||||||
|
flux export alert --all > alerts.yaml
|
||||||
|
|
||||||
|
# Export a Alert
|
||||||
|
flux export alert main > main.yaml`,
|
||||||
|
ValidArgsFunction: resourceNamesCompletionFunc(notificationv1.GroupVersion.WithKind(notificationv1.AlertKind)),
|
||||||
|
RunE: exportCommand{
|
||||||
|
object: alertAdapter{¬ificationv1.Alert{}},
|
||||||
|
list: alertListAdapter{¬ificationv1.AlertList{}},
|
||||||
|
}.run,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
exportCmd.AddCommand(exportAlertCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func exportAlert(alert *notificationv1.Alert) interface{} {
|
||||||
|
gvk := notificationv1.GroupVersion.WithKind("Alert")
|
||||||
|
export := notificationv1.Alert{
|
||||||
|
TypeMeta: metav1.TypeMeta{
|
||||||
|
Kind: gvk.Kind,
|
||||||
|
APIVersion: gvk.GroupVersion().String(),
|
||||||
|
},
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: alert.Name,
|
||||||
|
Namespace: alert.Namespace,
|
||||||
|
Labels: alert.Labels,
|
||||||
|
Annotations: alert.Annotations,
|
||||||
|
},
|
||||||
|
Spec: alert.Spec,
|
||||||
|
}
|
||||||
|
|
||||||
|
return export
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ex alertAdapter) export() interface{} {
|
||||||
|
return exportAlert(ex.Alert)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ex alertListAdapter) exportItem(i int) interface{} {
|
||||||
|
return exportAlert(&ex.AlertList.Items[i])
|
||||||
|
}
|
||||||
70
cmd/flux/export_alertprovider.go
Normal file
70
cmd/flux/export_alertprovider.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"
|
||||||
|
|
||||||
|
notificationv1 "github.com/fluxcd/notification-controller/api/v1beta1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var exportAlertProviderCmd = &cobra.Command{
|
||||||
|
Use: "alert-provider [name]",
|
||||||
|
Short: "Export Provider resources in YAML format",
|
||||||
|
Long: "The export alert-provider command exports one or all Provider resources in YAML format.",
|
||||||
|
Example: ` # Export all Provider resources
|
||||||
|
flux export alert-provider --all > alert-providers.yaml
|
||||||
|
|
||||||
|
# Export a Provider
|
||||||
|
flux export alert-provider slack > slack.yaml`,
|
||||||
|
ValidArgsFunction: resourceNamesCompletionFunc(notificationv1.GroupVersion.WithKind(notificationv1.ProviderKind)),
|
||||||
|
RunE: exportCommand{
|
||||||
|
object: alertProviderAdapter{¬ificationv1.Provider{}},
|
||||||
|
list: alertProviderListAdapter{¬ificationv1.ProviderList{}},
|
||||||
|
}.run,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
exportCmd.AddCommand(exportAlertProviderCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func exportAlertProvider(alertProvider *notificationv1.Provider) interface{} {
|
||||||
|
gvk := notificationv1.GroupVersion.WithKind("Provider")
|
||||||
|
export := notificationv1.Provider{
|
||||||
|
TypeMeta: metav1.TypeMeta{
|
||||||
|
Kind: gvk.Kind,
|
||||||
|
APIVersion: gvk.GroupVersion().String(),
|
||||||
|
},
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: alertProvider.Name,
|
||||||
|
Namespace: alertProvider.Namespace,
|
||||||
|
Labels: alertProvider.Labels,
|
||||||
|
Annotations: alertProvider.Annotations,
|
||||||
|
},
|
||||||
|
Spec: alertProvider.Spec,
|
||||||
|
}
|
||||||
|
return export
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ex alertProviderAdapter) export() interface{} {
|
||||||
|
return exportAlertProvider(ex.Provider)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ex alertProviderListAdapter) exportItem(i int) interface{} {
|
||||||
|
return exportAlertProvider(&ex.ProviderList.Items[i])
|
||||||
|
}
|
||||||
71
cmd/flux/export_helmrelease.go
Normal file
71
cmd/flux/export_helmrelease.go
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
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"
|
||||||
|
|
||||||
|
helmv2 "github.com/fluxcd/helm-controller/api/v2beta1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var exportHelmReleaseCmd = &cobra.Command{
|
||||||
|
Use: "helmrelease [name]",
|
||||||
|
Aliases: []string{"hr"},
|
||||||
|
Short: "Export HelmRelease resources in YAML format",
|
||||||
|
Long: "The export helmrelease command exports one or all HelmRelease resources in YAML format.",
|
||||||
|
Example: ` # Export all HelmRelease resources
|
||||||
|
flux export helmrelease --all > kustomizations.yaml
|
||||||
|
|
||||||
|
# Export a HelmRelease
|
||||||
|
flux export hr my-app > app-release.yaml`,
|
||||||
|
ValidArgsFunction: resourceNamesCompletionFunc(helmv2.GroupVersion.WithKind(helmv2.HelmReleaseKind)),
|
||||||
|
RunE: exportCommand{
|
||||||
|
object: helmReleaseAdapter{&helmv2.HelmRelease{}},
|
||||||
|
list: helmReleaseListAdapter{&helmv2.HelmReleaseList{}},
|
||||||
|
}.run,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
exportCmd.AddCommand(exportHelmReleaseCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func exportHelmRelease(helmRelease *helmv2.HelmRelease) interface{} {
|
||||||
|
gvk := helmv2.GroupVersion.WithKind(helmv2.HelmReleaseKind)
|
||||||
|
export := helmv2.HelmRelease{
|
||||||
|
TypeMeta: metav1.TypeMeta{
|
||||||
|
Kind: gvk.Kind,
|
||||||
|
APIVersion: gvk.GroupVersion().String(),
|
||||||
|
},
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: helmRelease.Name,
|
||||||
|
Namespace: helmRelease.Namespace,
|
||||||
|
Labels: helmRelease.Labels,
|
||||||
|
Annotations: helmRelease.Annotations,
|
||||||
|
},
|
||||||
|
Spec: helmRelease.Spec,
|
||||||
|
}
|
||||||
|
return export
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ex helmReleaseAdapter) export() interface{} {
|
||||||
|
return exportHelmRelease(ex.HelmRelease)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ex helmReleaseListAdapter) exportItem(i int) interface{} {
|
||||||
|
return exportHelmRelease(&ex.HelmReleaseList.Items[i])
|
||||||
|
}
|
||||||
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/v1beta1"
|
||||||
|
)
|
||||||
|
|
||||||
|
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`,
|
||||||
|
ValidArgsFunction: resourceNamesCompletionFunc(imagev1.GroupVersion.WithKind(imagev1.ImagePolicyKind)),
|
||||||
|
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/v1beta1"
|
||||||
|
)
|
||||||
|
|
||||||
|
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`,
|
||||||
|
ValidArgsFunction: resourceNamesCompletionFunc(imagev1.GroupVersion.WithKind(imagev1.ImageRepositoryKind)),
|
||||||
|
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_update.go
Normal file
72
cmd/flux/export_image_update.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/v1beta1"
|
||||||
|
)
|
||||||
|
|
||||||
|
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`,
|
||||||
|
ValidArgsFunction: resourceNamesCompletionFunc(autov1.GroupVersion.WithKind(autov1.ImageUpdateAutomationKind)),
|
||||||
|
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])
|
||||||
|
}
|
||||||
72
cmd/flux/export_kustomization.go
Normal file
72
cmd/flux/export_kustomization.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"
|
||||||
|
|
||||||
|
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1beta2"
|
||||||
|
)
|
||||||
|
|
||||||
|
var exportKsCmd = &cobra.Command{
|
||||||
|
Use: "kustomization [name]",
|
||||||
|
Aliases: []string{"ks"},
|
||||||
|
Short: "Export Kustomization resources in YAML format",
|
||||||
|
Long: "The export kustomization command exports one or all Kustomization resources in YAML format.",
|
||||||
|
Example: ` # Export all Kustomization resources
|
||||||
|
flux export kustomization --all > kustomizations.yaml
|
||||||
|
|
||||||
|
# Export a Kustomization
|
||||||
|
flux export kustomization my-app > kustomization.yaml`,
|
||||||
|
ValidArgsFunction: resourceNamesCompletionFunc(kustomizev1.GroupVersion.WithKind(kustomizev1.KustomizationKind)),
|
||||||
|
RunE: exportCommand{
|
||||||
|
object: kustomizationAdapter{&kustomizev1.Kustomization{}},
|
||||||
|
list: kustomizationListAdapter{&kustomizev1.KustomizationList{}},
|
||||||
|
}.run,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
exportCmd.AddCommand(exportKsCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func exportKs(kustomization *kustomizev1.Kustomization) interface{} {
|
||||||
|
gvk := kustomizev1.GroupVersion.WithKind("Kustomization")
|
||||||
|
export := kustomizev1.Kustomization{
|
||||||
|
TypeMeta: metav1.TypeMeta{
|
||||||
|
Kind: gvk.Kind,
|
||||||
|
APIVersion: gvk.GroupVersion().String(),
|
||||||
|
},
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: kustomization.Name,
|
||||||
|
Namespace: kustomization.Namespace,
|
||||||
|
Labels: kustomization.Labels,
|
||||||
|
Annotations: kustomization.Annotations,
|
||||||
|
},
|
||||||
|
Spec: kustomization.Spec,
|
||||||
|
}
|
||||||
|
|
||||||
|
return export
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ex kustomizationAdapter) export() interface{} {
|
||||||
|
return exportKs(ex.Kustomization)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ex kustomizationListAdapter) exportItem(i int) interface{} {
|
||||||
|
return exportKs(&ex.KustomizationList.Items[i])
|
||||||
|
}
|
||||||
71
cmd/flux/export_receiver.go
Normal file
71
cmd/flux/export_receiver.go
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
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"
|
||||||
|
|
||||||
|
notificationv1 "github.com/fluxcd/notification-controller/api/v1beta1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var exportReceiverCmd = &cobra.Command{
|
||||||
|
Use: "receiver [name]",
|
||||||
|
Short: "Export Receiver resources in YAML format",
|
||||||
|
Long: "The export receiver command exports one or all Receiver resources in YAML format.",
|
||||||
|
Example: ` # Export all Receiver resources
|
||||||
|
flux export receiver --all > receivers.yaml
|
||||||
|
|
||||||
|
# Export a Receiver
|
||||||
|
flux export receiver main > main.yaml`,
|
||||||
|
ValidArgsFunction: resourceNamesCompletionFunc(notificationv1.GroupVersion.WithKind(notificationv1.ReceiverKind)),
|
||||||
|
RunE: exportCommand{
|
||||||
|
list: receiverListAdapter{¬ificationv1.ReceiverList{}},
|
||||||
|
object: receiverAdapter{¬ificationv1.Receiver{}},
|
||||||
|
}.run,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
exportCmd.AddCommand(exportReceiverCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func exportReceiver(receiver *notificationv1.Receiver) interface{} {
|
||||||
|
gvk := notificationv1.GroupVersion.WithKind("Receiver")
|
||||||
|
export := notificationv1.Receiver{
|
||||||
|
TypeMeta: metav1.TypeMeta{
|
||||||
|
Kind: gvk.Kind,
|
||||||
|
APIVersion: gvk.GroupVersion().String(),
|
||||||
|
},
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: receiver.Name,
|
||||||
|
Namespace: receiver.Namespace,
|
||||||
|
Labels: receiver.Labels,
|
||||||
|
Annotations: receiver.Annotations,
|
||||||
|
},
|
||||||
|
Spec: receiver.Spec,
|
||||||
|
}
|
||||||
|
|
||||||
|
return export
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ex receiverAdapter) export() interface{} {
|
||||||
|
return exportReceiver(ex.Receiver)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ex receiverListAdapter) exportItem(i int) interface{} {
|
||||||
|
return exportReceiver(&ex.ReceiverList.Items[i])
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user