kops icon indicating copy to clipboard operation
kops copied to clipboard

`kops env` should show up current configuration and environment settings

Open remyleone opened this issue 1 year ago • 2 comments

/kind feature

1. Describe IN DETAIL the feature/behavior/change you would like to see.

I would like to have a command such as kops env or kops config that would show up all the configuration environment variables used by kops.

2. Feel free to provide a design supporting your feature request.

I was thinking about leveraging viper to be sure to catch all configurations options.

package main

import (
	"context"
	"fmt"
	"github.com/spf13/cobra"
	"github.com/spf13/viper"
	"io"
	"k8s.io/kops/cmd/kops/util"
	"k8s.io/kops/pkg/commands/commandutils"
	"k8s.io/kubectl/pkg/util/i18n"
)

func NewCmdEnv(f *util.Factory, out io.Writer) *cobra.Command {
	cmd := &cobra.Command{
		Use:   "env",
		Short: i18n.T(`Get all environment variables.`),
		RunE: func(cmd *cobra.Command, args []string) error {
			return RunEnv(cmd.Context(), f, out)
		},
	}

	return cmd
}

func RunEnv(ctx context.Context, f commandutils.Factory, out io.Writer) error {
	viper.AllSettings()
	for k, v := range viper.AllSettings() {
		fmt.Fprintf(out, "%s: %s\n", k, v)
	}
	return nil
}

What do you think of it? Is there a different configuration/settings store that I could use and iterate over?

Related to https://github.com/kubernetes/kops/issues/1764

remyleone avatar Apr 17 '24 14:04 remyleone

In complement to this function I would like to have an env package that would bind all the environment variables used across kops. This binding function should be called as early as possible to ensure that we are able to access the string using viper.GetString.

remyleone avatar Apr 17 '24 15:04 remyleone

/kind office-hours

hakman avatar May 10 '24 04:05 hakman

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Aug 08 '24 04:08 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle rotten
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

k8s-triage-robot avatar Sep 07 '24 05:09 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

k8s-triage-robot avatar Oct 07 '24 05:10 k8s-triage-robot

@k8s-triage-robot: Closing this issue, marking it as "Not Planned".

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

k8s-ci-robot avatar Oct 07 '24 05:10 k8s-ci-robot