Skip to content

Go client and CRD definition of SQLUser are inconsistent #598

@radoslav-tomov

Description

@radoslav-tomov

Bug Description

SQLUser CRD definiton states:

password:
description: |-
  The password for the user. Can be updated. For Postgres instances this is a Required field, unless type is set to
                  either CLOUD_IAM_USER or CLOUD_IAM_SERVICE_ACCOUNT.
oneOf:
- not:
    required:
    - valueFrom
  required:
  - value
- not:
    required:
    - value
  required:
  - valueFrom
properties:
  value:
    description: Value of the field. Cannot be used if 'valueFrom'
      is specified.
    type: string
  valueFrom:
    description: Source for the field's value. Cannot be used if 'value'
      is specified.
    properties:
      secretKeyRef:
        description: Reference to a value with the given key in the
          given Secret in the resource's namespace.
        properties:
          key:
            description: Key that identifies the value to be extracted.
            type: string
          name:
            description: Name of the Secret to extract a value from.
            type: string
        required:
        - name
        - key
        type: object

Notice, that the secretKeyRef actually is a object with key and name.
The Go struct generated for the SQLUser boils down to

type UserValueFrom struct {
	/* Reference to a value with the given key in the given Secret in the resource's namespace. */
	// +optional
	SecretKeyRef *v1alpha1.ResourceRef `json:"secretKeyRef,omitempty"`
}

and the ResourceRef

type ResourceRef struct {
	/* The external name of the referenced resource */
	External string `json:"external,omitempty"`
	/* Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names */
	Name string `json:"name,omitempty"`
	/* Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/ */
	Namespace string `json:"namespace,omitempty"`
}

So when I try to create a SQLUser resource and attempt to reference the password from Secret I get an error.

Additional Diagnostic Information

Kubernetes Cluster Version

❯ kubectl version --short
Client Version: v1.21.2
Server Version: v1.22.4

Config Connector Version

k8s-config-connector v1.71.0

Config Connector Mode

cluster

Log Output

SQLUser.sql.cnrm.cloud.google.com \"alpha\" is invalid: spec.password.valueFrom.secretKeyRef.key: Required value", "errorVerbose": "SQLUser.sql.cnrm.cloud.google.com \"XXXX\" is invalid: spec.password.valueFrom.secretKeyRef.key: Required value

Steps to Reproduce

Steps to reproduce the issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions