WithoutSecrets returns a copy of the config without secret values.
()
| 4936 | |
| 4937 | // WithoutSecrets returns a copy of the config without secret values. |
| 4938 | func (c *DeploymentValues) WithoutSecrets() (*DeploymentValues, error) { |
| 4939 | var ff DeploymentValues |
| 4940 | |
| 4941 | // Create copy via JSON. |
| 4942 | byt, err := json.Marshal(c) |
| 4943 | if err != nil { |
| 4944 | return nil, err |
| 4945 | } |
| 4946 | err = json.Unmarshal(byt, &ff) |
| 4947 | if err != nil { |
| 4948 | return nil, err |
| 4949 | } |
| 4950 | |
| 4951 | for _, opt := range ff.Options() { |
| 4952 | if !IsSecretDeploymentOption(opt) { |
| 4953 | continue |
| 4954 | } |
| 4955 | |
| 4956 | // This only works with string values for now. |
| 4957 | switch v := opt.Value.(type) { |
| 4958 | case *serpent.String, *serpent.StringArray: |
| 4959 | err := v.Set("") |
| 4960 | if err != nil { |
| 4961 | panic(err) |
| 4962 | } |
| 4963 | default: |
| 4964 | return nil, xerrors.Errorf("unsupported type %T", v) |
| 4965 | } |
| 4966 | } |
| 4967 | |
| 4968 | return &ff, nil |
| 4969 | } |
| 4970 | |
| 4971 | // DeploymentConfig returns the deployment config for the coder server. |
| 4972 | func (c *Client) DeploymentConfig(ctx context.Context) (*DeploymentConfig, error) { |