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

1.8.0 broke environment resolving #497

Closed
rbtcollins opened this issue Feb 13, 2025 · 2 comments
Closed

1.8.0 broke environment resolving #497

rbtcollins opened this issue Feb 13, 2025 · 2 comments

Comments

@rbtcollins
Copy link

I haven't yet dug into why, but it is an API break, so if kong is following semver, please consider pulling 1.8, and re-tagging as 2.0. That would avoid renovate/dependabot autoupdating this everywhere.

Thanks!

@alecthomas
Copy link
Owner

There was a change to envar resolution, but tests pass. Can you provide a reproduction?

@rbtcollins
Copy link
Author

rbtcollins commented Feb 13, 2025

It is internal code, sorry.

But I can sketch perhaps that is enough.

We have a main() in our components using Kong like so:

func main() {
	var cli CLI
	kctx := kong.Parse(&cli)
	ctx, cancel := context.WithCancel(context.Background())
	ch := make(chan os.Signal, 5)
	signal.Notify(ch, os.Interrupt, syscall.SIGTERM)
	go func() {
		<-ch
		// Cancel running code
		fmt.Println("Exiting...")
		cancel()
	}()
	c, err := db.NewConnection(context.Background(), os.Getenv("DATABASE_URL"))
	if err != nil {
		kctx.FatalIfErrorf(err)
	}
	err = kctx.Run(&ctx, &c)
	// Cancel any web servers and the like that might be running.
	cancel()
	if err != nil {
		if err.Error() != "context canceled" {
			kctx.FatalIfErrorf(err)
		} else {
			fmt.Fprintf(os.Stderr, "Exiting: %v\n", err)
		}
	}
}

And a CLI definition like so:

type CLI struct {
	Debug             bool   `help:"Enable debug mode."`
	CertFile          string `env:"CERT_FILE" help:"TLS CRT path." optional:""`
	KeyFile           string `env:"KEY_FILE" arg:"" help:"TLS KEY path." optional:""`
	Insecure          bool   `help:"Disable TLS."`
	MetricsPort       int    `env:"METRICS_PORT" help:"Port to listen for metrics requests." default:"8080"`
	GrpcPort          int    `env:"GRPC_PORT" help:"gRPC port."`
	ClusterOidcIssuer string `env:"CLUSTER_OIDC_ISSUER" help:"OIDC issuer for the cluster."`
	ReadOnlyIssuers   string `env:"RO_ISSUERS" help:"Additional OIDC issuers that only grant read access."`
	ApiAudience       string `env:"API_AUDIENCE" help:"API audience."`
}

Then code consuming this would fail:

	creds, err := credentials.NewServerTLSFromFile(cli.CertFile, cli.KeyFile)
	if err != nil {
	    log.Fatalf("Failed to generate credentials: %v", err)
	}

with

2025/02/13 06:39:22 Failed to generate credentials: open : no such file or directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants