Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix getSubnets for podman #2199

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/cluster/internal/providers/podman/provision.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ func getProxyEnv(cfg *config.Cluster) (map[string]string, error) {
}

func getSubnets(networkName string) ([]string, error) {
format := `{{range (index (index . "IPAM") "Config")}}{{index . "Subnet"}} {{end}}`
format := `{{ range (index (index (index (index . "plugins") 0 ) "ipam" ) "ranges")}}{{ index ( index . 0 ) "subnet" }} {{end}}`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This format is getting too complicated now. might be worth just unmarshalling the JSON ourselves.
but fine as a follow up.

Also, is this after podman 3.0 ?
do we want to warn/error if podman version is less than that.

@aojea how is our Github Actions working, is this path not exercised?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This format is getting too complicated now. might be worth just unmarshalling the JSON ourselves.
but fine as a follow up.

amen, it took me a big chunk of time to come up with the template

Also, is this after podman 3.0 ?
do we want to warn/error if podman version is less than that.

I can't know if this worked before because this is only used to populate the proxy environment variables ... let's keep it this way, I can't imagine we have such power users of podman until now

@aojea how is our Github Actions working, is this path not exercised?

nope

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to json in a follow up

cmd := exec.Command("podman", "network", "inspect", "-f", format, networkName)
lines, err := exec.OutputLines(cmd)
if err != nil {
Expand Down