Empty slice literal of type "[]creds.SecretLookupPath" used to define "lookupPaths"
35
36// NewSecretLookupPaths defines how variables will be searched in the underlying secret manager
37func (v Vault) NewSecretLookupPaths(teamName string, pipelineName string, allowRootPath bool) []creds.SecretLookupPath {
38 lookupPaths := []creds.SecretLookupPath{} 39 for _, tmpl := range v.LookupTemplates {
40 if lPath := creds.NewSecretLookupWithTemplate(tmpl, teamName, pipelineName); lPath != nil {
41 lookupPaths = append(lookupPaths, lPath)
Empty slice literal of type "[]*creds.SecretTemplate" used to define "templates"
190func (manager *VaultManager) NewSecretsFactory(logger lager.Logger) (creds.SecretsFactory, error) {
191 if manager.SecretFactory == nil {
192
193 templates := []*creds.SecretTemplate{}194 for _, prefix := range getPrefixes(manager.PathPrefixes, manager.PathPrefix) {
195 for i, tmpl := range manager.LookupTemplates {
196 name := fmt.Sprintf("lookup-template-%d", i)
Empty slice literal of type "[]string" used to define "caCerts"
60 options = append(options, credhub.SkipTLSValidation(true))
61 }
62
63 caCerts := []string{} 64 for _, cert := range manager.TLS.CACerts {
65 contents, err := ioutil.ReadFile(cert)
66 if err != nil {
Empty slice literal of type "[]creds.SecretLookupPath" used to define "lookupPaths"
19
20// NewSecretLookupPaths defines how variables will be searched in the underlying secret manager
21func (c CredHubAtc) NewSecretLookupPaths(teamName string, pipelineName string, allowRootPath bool) []creds.SecretLookupPath {
22 lookupPaths := []creds.SecretLookupPath{}23 prefixes := getPrefixes(c.prefixes, c.prefix)
24 if len(pipelineName) > 0 {
25 for _, prefix := range prefixes {
Description
An empty slice can be represented by nil
or an empty slice literal. They are
functionally equivalent — their len
and cap
are both zero — but the nil
slice is the preferred style. For more information about empty slices,
see Declaring Empty Slices.
Bad practice
package main
func foo() {
a := []int{}
}
Recommended
package main
func foo() {
var a []int
}