github.com/oam-dev/kubevela@v1.9.11/references/cli/test-data/config-templates/image-registry.cue (about)

     1  import (
     2  	"encoding/base64"
     3  	"encoding/json"
     4  	"strconv"
     5  )
     6  
     7  metadata: {
     8  	name:        "image-registry"
     9  	alias:       "Image Registry"
    10  	scope:       "project"
    11  	description: "Config information to authenticate image registry"
    12  	sensitive:   false
    13  }
    14  
    15  template: {
    16  	output: {
    17  		apiVersion: "v1"
    18  		kind:       "Secret"
    19  		metadata: {
    20  			name:      context.name
    21  			namespace: context.namespace
    22  			labels: {
    23  				"config.oam.dev/catalog": "velacore-config"
    24  				"config.oam.dev/type":    "image-registry"
    25  			}
    26  		}
    27  		if parameter.auth != _|_ {
    28  			type: "kubernetes.io/dockerconfigjson"
    29  		}
    30  		if parameter.auth == _|_ {
    31  			type: "Opaque"
    32  		}
    33  		stringData: {
    34  			if parameter.auth != _|_ && parameter.auth.username != _|_ {
    35  				".dockerconfigjson": json.Marshal({
    36  					"auths": "\(parameter.registry)": {
    37  						"username": parameter.auth.username
    38  						"password": parameter.auth.password
    39  						if parameter.auth.email != _|_ {
    40  							"email": parameter.auth.email
    41  						}
    42  						"auth": base64.Encode(null, (parameter.auth.username + ":" + parameter.auth.password))
    43  					}
    44  				})
    45  			}
    46  			if parameter.insecure != _|_ {
    47  				"insecure-skip-verify": strconv.FormatBool(parameter.insecure)
    48  			}
    49  			if parameter.useHTTP != _|_ {
    50  				"protocol-use-http": strconv.FormatBool(parameter.useHTTP)
    51  			}
    52  		}
    53  	}
    54  
    55  	parameter: {
    56  		// +usage=Image registry FQDN, such as: index.docker.io
    57  		registry: string
    58  		// +usage=Authenticate the image registry
    59  		auth?: {
    60  			// +usage=Private Image registry username
    61  			username: string
    62  			// +usage=Private Image registry password
    63  			password: string
    64  			// +usage=Private Image registry email
    65  			email?: string
    66  		}
    67  		// +usage=For the registry server that uses the self-signed certificate
    68  		insecure?: bool
    69  		// +usage=For the registry server that uses the HTTP protocol
    70  		useHTTP?: bool
    71  	}
    72  }