10 Commits

Author SHA1 Message Date
7df8d80508 add omitempty to Secret in k8s VolumeSource
Secret was populating a generated kube as `null`. Add omitempty
so that when the volume source is not a secret, we do not print unnecessary info

resolves #15156

Signed-off-by: Charlie Doern <cdoern@redhat.com>
2022-08-03 16:42:28 -04:00
438fef1caa kube secret handling for podman play kube
add support for both creating a secret using yaml and mounting a secret as a volume given a yaml file.
Kubernetes secrets have a different structure than podman and therefore have to be handeled differently.
In this PR, I have introduced the basic usecases of kube secrets with more implementations like env secrets
to come!

resolves #12396

Signed-off-by: Charlie Doern <cdoern@redhat.com>
2022-07-20 12:55:33 -04:00
51fbf3da9e enable gocritic linter
The linter ensures a common code style.
- use switch/case instead of else if
- use if instead of switch/case for single case statement
- add space between comment and text
- detect the use of defer with os.Exit()
- use short form var += "..." instead of var = var + "..."
- detect problems with append()
```
newSlice := append(orgSlice, val)
```
  This could lead to nasty bugs because the orgSlice will be changed in
  place if it has enough capacity too hold the new elements. Thus we
  newSlice might not be a copy.

Of course most of the changes are just cosmetic and do not cause any
logic errors but I think it is a good idea to enforce a common style.
This should help maintainability.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-26 18:12:22 +02:00
5b4af0584d replace golint with revive linter
golint, scopelint and interfacer are deprecated. golint is replaced by
revive. This linter is better because it will also check for our error
style: `error strings should not be capitalized or end with punctuation or a newline`

scopelint is replaced by exportloopref (already endabled)
interfacer has no replacement but I do not think this linter is
important.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-22 15:12:33 +02:00
ffbab30d7b Run codespell to cleanup typos
[NO NEW TESTS NEEDED]

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-03-25 15:34:41 -04:00
dd9e4dc72b pkg/k8s.io/api/core/v1: remove unneeded types
Remove types that are not applicable for podman. This are types I do not
think we need, there is definitely more that could be removed but this
should be handled by someone who knows the k8s code better than me.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-03-15 14:48:11 +01:00
0612f859b8 pkg/k8s.io/...: remove protobuf field tags
Since we do not use protobuf we can remove these field tags. This will
save some KB in the final binary size.

This change was automated with the following commands:
find pkg/k8s.io/ -type f -name "*.go" -exec sed -i -e 's/\sprotobuf\:\".*\"//g' {} +
find pkg/k8s.io/ -type f -name "*.go" -exec sed -i -e 's/\s`protobuf\:\".*\"`//g' {} +

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-03-15 14:48:11 +01:00
f8577766d0 pkg/k8s.io/...: fix lint errors
Fix linting errors. We use different/stricter linters, instead of
skipping these packages we should fix it.

Most errors are about naming conventions, since I do not want to change
the names I added the nolint comment there. I also removed some unused
fields where the linter complained.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-03-15 14:48:10 +01:00
a0ad1f2ad4 remove unneeded k8s code
There is a lot of unneeded code, k8s is the by far the biggest
dependency in podman. We should remove as much as possible so that we
only have the stuff left that we use.

This is just a quick skim over the code which removes a lot of the
generated code and many packages that are now unused.
I know that this will be impossible to properly review. I will try to
make smaller changes in follow up work.

Right now this reduces about 8 MB in binary size!!!

[NO NEW TESTS NEEDED] Hopefully existing tests will catch any problems.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-03-15 14:48:08 +01:00
918fc88a98 move k8s deps into podman
We only need a small part of the k8s dependencies but they are the
biggest dependencies in podman by far. Moving them into podman allows us
to remove the unnecessary parts.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-03-15 14:46:29 +01:00