Skip to content

Commit

Permalink
apply owned-by=fetchit label to raw pods (#279)
Browse files Browse the repository at this point in the history
Signed-off-by: Oleg <97077423+RobotSail@users.noreply.github.com>

Signed-off-by: Oleg <97077423+RobotSail@users.noreply.github.com>
  • Loading branch information
RobotSail committed Dec 5, 2022
1 parent 82644f9 commit f85359c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
18 changes: 18 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,24 @@ jobs:

- name: Check that no capabilities exist for cap2
run: if [[ $(sudo podman container inspect cap2 --format {{.EffectiveCaps}} | jq length) = "0" ]] ; then echo "Container successfully launched"; else exit 1; fi

- name: 'Check that the "owned-by:fetchit" label is applied'
run: |
declare -i numContainers=$(sudo podman ps --filter label=owned-by=fetchit | wc -l)
if (( numContainers > 1 )); then
echo 'Successfully applied labels'
else
exit 1
fi
# check against a garbage label
declare -i checkAgainst=$(sudo podman ps --filter label=owned-by=abcdefghijklmnopqrstuvwxyz | wc -l)
if (( checkAgainst == numContainers )); then
echo 'container amount with label cannot equal container amount with nonexistent label'
exit 1
else
echo 'Label was applied correctly'
fi
config-env-raw-validate:
runs-on: ubuntu-latest
Expand Down
9 changes: 8 additions & 1 deletion pkg/engine/raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import (
"gopkg.in/yaml.v3"
)

const rawMethod = "raw"
const (
rawMethod = "raw"
FetchItLabel = "fetchit"
)

// Raw to deploy pods from json or yaml files
type Raw struct {
Expand Down Expand Up @@ -241,6 +244,10 @@ func createSpecGen(raw RawPod) *specgen.SpecGenerator {
s.CapAdd = []string(raw.CapAdd)
s.CapDrop = []string(raw.CapDrop)
s.RestartPolicy = "always"
// add a label to signify ownership of fetchit <--> this container
s.Labels = map[string]string{
"owned-by": FetchItLabel,
}
return s
}

Expand Down

0 comments on commit f85359c

Please sign in to comment.