add deprecation warning per secret key field and constant
Signed-off-by: Sanskar Jaiswal <jaiswalsanskar078@gmail.com>
This commit is contained in:
@@ -110,10 +110,10 @@ func createSecretTLSCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if secretTLSArgs.tlsCrtFile != "" && secretTLSArgs.tlsKeyFile != "" {
|
if secretTLSArgs.tlsCrtFile != "" && secretTLSArgs.tlsKeyFile != "" {
|
||||||
if opts.TlsCrt, err = os.ReadFile(secretTLSArgs.tlsCrtFile); err != nil {
|
if opts.TLSCrt, err = os.ReadFile(secretTLSArgs.tlsCrtFile); err != nil {
|
||||||
return fmt.Errorf("failed to read cert file: %w", err)
|
return fmt.Errorf("failed to read cert file: %w", err)
|
||||||
}
|
}
|
||||||
if opts.TlsKey, err = os.ReadFile(secretTLSArgs.tlsKeyFile); err != nil {
|
if opts.TLSKey, err = os.ReadFile(secretTLSArgs.tlsKeyFile); err != nil {
|
||||||
return fmt.Errorf("failed to read key file: %w", err)
|
return fmt.Errorf("failed to read key file: %w", err)
|
||||||
}
|
}
|
||||||
} else if secretTLSArgs.certFile != "" && secretTLSArgs.keyFile != "" {
|
} else if secretTLSArgs.certFile != "" && secretTLSArgs.keyFile != "" {
|
||||||
|
|||||||
@@ -34,18 +34,22 @@ const (
|
|||||||
UsernameSecretKey = "username"
|
UsernameSecretKey = "username"
|
||||||
PasswordSecretKey = "password"
|
PasswordSecretKey = "password"
|
||||||
CACrtSecretKey = "ca.crt"
|
CACrtSecretKey = "ca.crt"
|
||||||
TlsCrtSecretKey = "tls.crt"
|
TLSCrtSecretKey = "tls.crt"
|
||||||
TlsKeySecretKey = "tls.key"
|
TLSKeySecretKey = "tls.key"
|
||||||
PrivateKeySecretKey = "identity"
|
PrivateKeySecretKey = "identity"
|
||||||
PublicKeySecretKey = "identity.pub"
|
PublicKeySecretKey = "identity.pub"
|
||||||
KnownHostsSecretKey = "known_hosts"
|
KnownHostsSecretKey = "known_hosts"
|
||||||
BearerTokenKey = "bearerToken"
|
BearerTokenKey = "bearerToken"
|
||||||
|
|
||||||
// Depreacted: These keys are used in the generated secrets if the
|
// Deprecated: Replaced by CACrtSecretKey, but kept for backwards
|
||||||
// command was invoked with the deprecated TLS flags.
|
// compatibility with deprecated TLS flags.
|
||||||
CAFileSecretKey = "caFile"
|
CAFileSecretKey = "caFile"
|
||||||
|
// Deprecated: Replaced by TLSCrtSecretKey, but kept for backwards
|
||||||
|
// compatibility with deprecated TLS flags.
|
||||||
CertFileSecretKey = "certFile"
|
CertFileSecretKey = "certFile"
|
||||||
KeyFileSecretKey = "keyFile"
|
// Deprecated: Replaced by TLSKeySecretKey, but kept for backwards
|
||||||
|
// compatibility with deprecated TLS flags.
|
||||||
|
KeyFileSecretKey = "keyFile"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Options struct {
|
type Options struct {
|
||||||
@@ -61,17 +65,21 @@ type Options struct {
|
|||||||
Username string
|
Username string
|
||||||
Password string
|
Password string
|
||||||
CACrt []byte
|
CACrt []byte
|
||||||
TlsCrt []byte
|
TLSCrt []byte
|
||||||
TlsKey []byte
|
TLSKey []byte
|
||||||
TargetPath string
|
TargetPath string
|
||||||
ManifestFile string
|
ManifestFile string
|
||||||
BearerToken string
|
BearerToken string
|
||||||
|
|
||||||
// Depreacted: These fields are used to store TLS data that
|
// Deprecated: Replaced by CACrt, but kept for backwards compatibility
|
||||||
// specified by the deprecated TLS flags.
|
// with deprecated TLS flags.
|
||||||
CAFile []byte
|
CAFile []byte
|
||||||
|
// Deprecated: Replaced by TLSCrt, but kept for backwards compatibility
|
||||||
|
// with deprecated TLS flags.
|
||||||
CertFile []byte
|
CertFile []byte
|
||||||
KeyFile []byte
|
// Deprecated: Replaced by TLSKey, but kept for backwards compatibility
|
||||||
|
// with deprecated TLS flags.
|
||||||
|
KeyFile []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func MakeDefaultOptions() Options {
|
func MakeDefaultOptions() Options {
|
||||||
|
|||||||
@@ -162,9 +162,9 @@ func buildSecret(keypair *ssh.KeyPair, hostKey, dockerCfg []byte, options Option
|
|||||||
secret.StringData[CAFileSecretKey] = string(options.CAFile)
|
secret.StringData[CAFileSecretKey] = string(options.CAFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(options.TlsCrt) != 0 && len(options.TlsKey) != 0 {
|
if len(options.TLSCrt) != 0 && len(options.TLSKey) != 0 {
|
||||||
secret.StringData[TlsCrtSecretKey] = string(options.TlsCrt)
|
secret.StringData[TLSCrtSecretKey] = string(options.TLSCrt)
|
||||||
secret.StringData[TlsKeySecretKey] = string(options.TlsKey)
|
secret.StringData[TLSKeySecretKey] = string(options.TLSKey)
|
||||||
} else if len(options.CertFile) != 0 && len(options.KeyFile) != 0 {
|
} else if len(options.CertFile) != 0 && len(options.KeyFile) != 0 {
|
||||||
secret.StringData[CertFileSecretKey] = string(options.CertFile)
|
secret.StringData[CertFileSecretKey] = string(options.CertFile)
|
||||||
secret.StringData[KeyFileSecretKey] = string(options.KeyFile)
|
secret.StringData[KeyFileSecretKey] = string(options.KeyFile)
|
||||||
|
|||||||
Reference in New Issue
Block a user