1
0
mirror of synced 2026-02-07 03:05:56 +00:00
Commit Graph

549 Commits

Author SHA1 Message Date
Kazuki Suda
dd81ed896b Fix "get" subcommands to use stdout instead of stderr
Signed-off-by: Kazuki Suda <kazuki.suda@gmail.com>
2021-10-06 10:46:37 +09:00
Somtochi Onyekwere
3ee8747fdc Add flux version command
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-10-05 10:29:00 +01:00
Somtochi Onyekwere
50a1e32da3 Sort pods from each deployment to get first and ready pod
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-10-03 14:30:31 +01:00
Somtochi Onyekwere
d06a2936cc Better checks for reconciliation in reconcile run command
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-10-01 08:24:13 +01:00
Somtochi Onyekwere
a096bd2d71 Allow users to define team roles
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-09-27 21:16:12 +01:00
Somtochi Onyekwere
1849e1768a Set username when it isn't default
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-09-22 09:46:04 +01:00
Somtochi Onyekwere
68a89d3cd4 Check for nil pointer before setting createNamespace in helmrelease
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-09-21 14:37:20 +01:00
Somtochi Onyekwere
64f39e160b Check if helmRelease.Spec.Install is nil
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-09-21 11:04:21 +01:00
Max Jonas Werner
546be76f55 fix: don't set 'Install' field by default in 'create hr'
This fixes the case where you create a HelmRelease with `--export` and
the `install: {}` field being there, adding no value to the manifest.

Signed-off-by: Max Jonas Werner <mail@makk.es>
2021-09-20 14:42:29 +02:00
Kazuki Suda
254cc131ae Add dynamic completion suppport
This commit adds dynamic completion support for the following commands
and flags:

- `flux delete ...` command
- `flux export ...` command
- `flux get ...` command
- `flux reconcile ...` command
- `flux resume ...` command
- `flux suspend ...` command
- `--namespace` flag
- `--context` flag

Signed-off-by: Kazuki Suda <kazuki.suda@gmail.com>
2021-09-18 17:27:47 +09:00
Kazuki Suda
4cc2326c7f Fix flux completion zsh to work with source only
Signed-off-by: Kazuki Suda <kazuki.suda@gmail.com>
2021-09-17 17:49:47 +09:00
Fynn Späker
18acae57bd Fix SecretRef
Signed-off-by: Fynn Späker <spaeker@23technologies.cloud>
2021-09-07 12:15:35 +02:00
Max Jonas Werner
2e6ca16a4a chore: use os.ReadFile instead of deprecated ioutil.ReadFile
Signed-off-by: Max Jonas Werner <mail@makk.es>
2021-09-03 12:20:57 +02:00
Max Jonas Werner
e98f1142a6 feat: enable bootstrap with custom CA locally
When a user provided the `--ca-file` flag to the `bootstrap` command,
the given CA file wasn't taken into account for cloning the repository
locally. It was just passed along to the CR that is created so Flux
can make use of it when cloning the repository in-cluster.

However, users may not want to add a custom CA to their local host's
trust chain and may expect the `--ca-file` flag to be respected also
for cloning the repository locally. This is what this commit
accomplishes.

closes #1775

Signed-off-by: Max Jonas Werner <mail@makk.es>
2021-09-01 15:38:53 +02:00
Allen Porter
8cbd4e8172 Add test for "flux create source git"
The create source tests are more interesting than the existing tests as they
create objects then wit for the flux source reconciler to complete. The tests
simulate this with a background goroutine that waits for an object to be
created then uses a test specific function to update it.

The tests set a timeout so that if there is a failure they timeout somewhat
quickly rather than hanging for a longer period of time.

Signed-off-by: Allen Porter <allen@thebends.org>
2021-08-30 07:44:03 -07:00
Daniel Petró
c6f4d71187 Be able to create a git source without human interaction.
Signed-off-by: Daniel Petró <daniel.petro@icloud.com>
2021-08-27 13:01:35 +02:00
Tomas Tulka
54758b1692 add --since and --since-time
Signed-off-by: Tomas Tulka <tomas.tulka@gmail.com>
2021-08-25 22:10:47 +02:00
Allen Porter
e2454d91f1 Remove use of deprecated io/ioutil
Signed-off-by: Allen Porter <allen@thebends.org>
2021-08-24 13:06:17 -07:00
Allen Porter
d45501a129 Use shared envTest for unit tests
Speed up unit tests by using a shared envTest. This requires each
test to use its own namespace to avoid clobbering objects for
other tests. Tests previously took around 8 seconds each, and now
the initial test takes 2 seconds with follow up tests taking less
than a second each.

Also update existing tests that use a fixed namespace to use a
generated namespace.

Share gold file template function with yaml files.

Remove the testClusterMode, and instead rely on MainTest to do
the appropriate test setup and rootArgs flag setup. Move the
rootArg flag setup out of NewTestEnvKubeManager to avoid
side effects.

A follow up change can be to push the individual setups
from NewTestEnvKubeManager() into their respective TestMain since
the harness share little code.

Signed-off-by: Allen Porter <allen@thebends.org>
2021-08-24 01:01:14 -07:00
Allen Porter
11708d4189 Rename trace test golden files
Rename trace test golden files to match the convention used by other tests

Signed-off-by: Allen Porter <allen@thebends.org>
2021-08-23 09:29:27 -07:00
Allen Porter
3a3bdc62c8 Make test harness more flexible with functions
Replace the 4 arguments to cmdTestCase with a function that
can let tests run arbitrary logic if it is more complex than
what is provided by the test harness. Move the existing logic
into functions that the test can use for common assertions on
golden files and golden values.

These changes were pulled out of PR #1696 to make a smaller review.

Signed-off-by: Allen Porter <allen@thebends.org>
2021-08-23 08:57:43 -07:00
Allen Porter
e8d6d5fe5c Remove fakeclient and use testenv for flux cmd tests
Remove use of the fake client, and replace with a real client connected to the
testEnv.

This required fixes to the yaml files as the testEnv has stricter verifcation
of objects. This also meant it was not possible to test a GitRepository with
a missing artifact since that is not a valid state.

The tests are slower than before, taking around 7-10 seconds each because the
 testEnv is setup and destroyed for every test. These will be sped up in a
 follow up PR.

Signed-off-by: Allen Porter <allen@thebends.org>
2021-08-18 18:53:53 -07:00
Chanwit Kaewkasi
cc32c1be07 add e2e test for check --pre with templating support
Signed-off-by: Chanwit Kaewkasi <chanwit@gmail.com>
2021-08-18 18:28:37 +07:00
Stefan Prodan
375edffd15 Add image scanning e2e tests
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-08-17 15:15:42 +03:00
Stefan Prodan
d1982e64b2 Refactor e2e tests
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-08-17 13:55:14 +03:00
Chanwit Kaewkasi
8f78263455 implement testEnv for e2e tests
Signed-off-by: Chanwit Kaewkasi <chanwit@gmail.com>
2021-08-17 00:07:09 +07:00
Soule BA
c18d0b9217 Adds a watch flag to the get command
The new flag fetch and display the request ressource and then continue
watching the ressource until timeout or cancellation.

A single ressource/ressource type is supported.

Signed-off-by: Soule BA <soule@weave.works>
2021-08-06 13:44:06 +02:00
Allen Porter
4146df1f02 Replace init() with TestMain()
Signed-off-by: Allen Porter <allen@thebends.org>
2021-08-04 08:14:22 -07:00
Allen Porter
8b68d7d7e2 Remove deprecated io/ioutil usage
Issue #1658

Signed-off-by: Allen Porter <allen@thebends.org>
2021-08-04 07:46:25 -07:00
Charles Cai
70f2b5028f feat: display success message while create secrets via flux cli.
Signed-off-by: Charles Cai <charles.cai@sap.com>
2021-08-04 21:31:57 +08:00
Hidde Beydals
9607b07e65 Request reconcile using patch instead of update
This should prevent the generation of the object getting bumped, as
observed on a GKE K8s 1.18 cluster using the  logic before this commit.

We only want to generation to increase when there are actual changes to
the `spec` of a resource, as some controllers use the `generation`
value to make assumptions about what they should do during a
reconciliation.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-08-04 13:08:36 +02:00
Stefan Prodan
dd0f17d7a5 Refactor test helpers
- move test helpers to main
- add support for inline golden values
- add test for `flux --version`

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-08-04 10:47:33 +03:00
Allen Porter
351d287d88 Add tests for flux trace command
Add tests for flux trace command that fake out the kubernetes client,
load objects from a yaml file and create them in the client, and
assert on the output of the trace command to an expected golden file.

This is a follow up from the suggestions in PR https://github.com/fluxcd/flux2/pull/1626 which suggested that additional
testing would be helpful. This test approach is modeled after the helm command tests.

This required some changes to the kubernetes client setup to make it
possible to use a fake. If we agree this pattern makes sense, it can be
applied to other commands.

Signed-off-by: Allen Porter <allen@thebends.org>
2021-08-03 06:35:13 -07:00
Dmitry Rybin
7f425efa6b chore: remove deprecated io/ioutil
Signed-off-by: Dmitry Rybin <ayrowa@yandex.ru>
2021-07-30 20:51:46 +02:00
Allen Porter
bd250c9871 Fix template optional field check in trace
Signed-off-by: Allen Porter <allen@thebends.org>
2021-07-22 20:20:21 -07:00
Allen Porter
91b3788362 Fix trace for optional GitRepository.Spec.Reference
Check for existence of GitRepository.Spec.Reference when displaying a trace to
avoid error:

✗ template: tmpl:28:21: executing "tmpl" at <.GitRepository.Spec.Reference.Tag>: nil pointer evaluating *v1beta1.GitRepositoryRef.Tag

Fixes issue #1621
Manually tested using the use cases highlighted in the issue.

Signed-off-by: Allen Porter <allen@thebends.org>
2021-07-22 20:20:21 -07:00
Chanwit Kaewkasi
d8911e0c77 add an example to the status-selector flag's description
Co-authored-by: Stefan Prodan <stefan.prodan@gmail.com>
Signed-off-by: Chanwit Kaewkasi <chanwit@gmail.com>
2021-07-07 14:21:26 +07:00
Chanwit Kaewkasi
1be006a45f implement status selector
Signed-off-by: Chanwit Kaewkasi <chanwit@gmail.com>
2021-07-06 22:59:03 +07:00
Alex Petrov
b1a9583262 Add no-header flag for get commands to omit printing the header
Signed-off-by: Alex Petrov <alex.petrov.vt@gmail.com>
2021-07-05 20:04:37 -04:00
Stefan Prodan
3f613341cb Extend tracing to owner references
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-06-29 11:01:01 +03:00
Stefan Prodan
4305b8a77d Implement flux trace command
The trace command allows Flux users to point the CLI to a Kubernetes object in-cluster and get a detailed report about the GitOps pipeline that manages that particular object.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-06-29 11:01:00 +03:00
Michael Bridgen
34484734d8 Use image API v1beta1
Signed-off-by: Michael Bridgen <michael@weave.works>
2021-06-28 16:20:05 +01:00
Stefan Prodan
179062876e Add create target namespace arg to helmrelease cmd
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-06-18 17:39:31 +03:00
Hidde Beydals
4f7b040405 Update source-controller to v0.15.1
This includes an introduction of a `--pass-credentials` flag for the
`flux create source helm` command to allow configuring the new
option introduced.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-06-18 15:04:48 +02:00
Stefan Prodan
6b179aa7d9 Allow disabling the deploy key prompt for bootstrap git
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-06-17 15:20:49 +03:00
Stefan Prodan
db28907543 Fix yq example for create secret git
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-06-11 12:58:46 +03:00
Hidde Beydals
465ea5ccfd Update go-git to v5.4.1
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-05-26 15:56:50 +02:00
Hidde Beydals
fbe7050cb8 Switch to crypto/ssh for parsing of private keys
This changes the logic for the parsing of private keys, as already
done for the source-controller, so that it is able to recognize and
work with a wider range of key formats instead of returning a vague
error:

```console
$ flux bootstrap git [..]
✗ ssh: this private key is passphrase protected
```

A patch for this was already submitted and merged in `go-git/go-git`,
but is not made available in a release yet:
https://github.com/go-git/go-git/pull/298

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-05-10 15:30:25 +02:00
Tobias Jakobsson
ea62cb5fc9 Use proper Host configuration for SSH
This removes the usage of Hostname() which does not honor configured SSH
port to be used.

Resolves: #1377
See also: #1101, #1102

Signed-off-by: Tobias Jakobsson <jakobsson.tobias@gmail.com>
2021-05-10 15:04:09 +02:00
Stefan Prodan
2597ad0f73 Make the Git ref required
Remove the default branch value from `flux create source git` and validate that one of the ref options are specified.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-05-06 15:28:55 +03:00