Skip to content

Commit

Permalink
Merge pull request #569 from apigee/issue568
Browse files Browse the repository at this point in the history
feat: adds support to include tls ver in ts #568
  • Loading branch information
ssvaidyanathan authored Nov 5, 2024
2 parents bf2226b + f1aece1 commit 5626403
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
3 changes: 1 addition & 2 deletions internal/client/observe/observe.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ package observe

import (
"encoding/json"
"internal/apiclient"
"net/url"
"path"
"strconv"
"strings"

"internal/apiclient"
)

type Action uint8
Expand Down
25 changes: 20 additions & 5 deletions internal/client/targetservers/targetservers.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ type commonName struct {
}

// Create
func Create(name string, description string, host string, port int, enable bool, protocol string, keyStore string, keyAlias string, trustStore string, tlsenabled string, tlsenforce string, clientAuthEnabled string, ignoreValidationErrors string) (respBody []byte, err error) {
func Create(name string, description string, host string, port int, enable bool, protocol string,
keyStore string, keyAlias string, trustStore string, tlsenabled string, tlsenforce string,
clientAuthEnabled string, tlsVersions []string, ignoreValidationErrors string,
) (respBody []byte, err error) {
e := new(bool)
*e = enable

Expand All @@ -69,11 +72,15 @@ func Create(name string, description string, host string, port int, enable bool,
IsEnabled: e,
}

return createOrUpdate("create", targetsvr, name, description, host, port, protocol, keyStore, keyAlias, trustStore, tlsenabled, tlsenforce, clientAuthEnabled, ignoreValidationErrors)
return createOrUpdate("create", targetsvr, name, description, host, port, protocol,
keyStore, keyAlias, trustStore, tlsenabled, tlsenforce, clientAuthEnabled, tlsVersions, ignoreValidationErrors)
}

// Update
func Update(name string, description string, host string, port int, enable bool, protocol string, keyStore string, keyAlias string, trustStore string, tlsenabled string, tlsenforce string, clientAuthEnabled string, ignoreValidationErrors string) (respBody []byte, err error) {
func Update(name string, description string, host string, port int, enable bool, protocol string,
keyStore string, keyAlias string, trustStore string, tlsenabled string, tlsenforce string,
clientAuthEnabled string, tlsVersions []string, ignoreValidationErrors string,
) (respBody []byte, err error) {
apiclient.ClientPrintHttpResponse.Set(false)
targetRespBody, err := Get(name)
if err != nil {
Expand All @@ -88,10 +95,15 @@ func Update(name string, description string, host string, port int, enable bool,

targetsvr.IsEnabled = &enable

return createOrUpdate("update", targetsvr, name, description, host, port, protocol, keyStore, keyAlias, trustStore, tlsenabled, tlsenforce, clientAuthEnabled, ignoreValidationErrors)
return createOrUpdate("update", targetsvr, name, description, host, port, protocol, keyStore,
keyAlias, trustStore, tlsenabled, tlsenforce, clientAuthEnabled, tlsVersions, ignoreValidationErrors)
}

func createOrUpdate(action string, targetsvr targetserver, name string, description string, host string, port int, protocol string, keyStore string, keyAlias string, trustStore string, tlsenabled string, tlsenforce string, clientAuthEnabled string, ignoreValidationErrors string) (respBody []byte, err error) {
func createOrUpdate(action string, targetsvr targetserver, name string, description string,
host string, port int, protocol string, keyStore string, keyAlias string, trustStore string,
tlsenabled string, tlsenforce string, clientAuthEnabled string, tlsVersions []string,
ignoreValidationErrors string,
) (respBody []byte, err error) {
if description != "" {
targetsvr.Description = description
}
Expand Down Expand Up @@ -126,6 +138,9 @@ func createOrUpdate(action string, targetsvr targetserver, name string, descript
if ignoreValidationErrors != "" {
targetsvr.SslInfo.IgnoreValidationErrors = getBool(ignoreValidationErrors)
}
if len(tlsVersions) != 0 {
targetsvr.SslInfo.Protocols = tlsVersions
}
}

reqBody, err := json.Marshal(targetsvr)
Expand Down
5 changes: 5 additions & 0 deletions internal/cmd/targetservers/crtts.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ var CreateCmd = &cobra.Command{
protocol,
keyStore, keyAlias, trustStore,
tlsenabled, tlsenforce, clientAuthEnabled,
tlsVersions,
ignoreValidationErrors)
return err
},
Expand All @@ -72,6 +73,7 @@ var CreateCmd = &cobra.Command{
var (
tlsenabled, tlsenforce, clientAuthEnabled, description, host, keyStore, keyAlias string
trustStore, protocol, ignoreValidationErrors string
tlsVersions []string
enable bool
port int
)
Expand Down Expand Up @@ -107,6 +109,9 @@ func init() {
CreateCmd.Flags().StringVarP(&protocol, "protocol", "",
"HTTP", "Protocol for a TargetServer; default is HTTP")

CreateCmd.Flags().StringArrayVarP(&tlsVersions, "tls-versions", "",
nil, "TLS versions for the target server")

_ = CreateCmd.MarkFlagRequired("name")
_ = CreateCmd.MarkFlagRequired("host")
}
4 changes: 4 additions & 0 deletions internal/cmd/targetservers/updatets.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ var UpdateCmd = &cobra.Command{
protocol,
keyStore, keyAlias, trustStore,
tlsenabled, tlsenforce, clientAuthEnabled,
tlsVersions,
ignoreValidationErrors)
return err
},
Expand Down Expand Up @@ -100,5 +101,8 @@ func init() {
UpdateCmd.Flags().StringVarP(&protocol, "protocol", "",
"", "Protocol for a TargetServer")

UpdateCmd.Flags().StringArrayVarP(&tlsVersions, "tls-versions", "",
nil, "TLS versions for the target server")

_ = UpdateCmd.MarkFlagRequired("name")
}

0 comments on commit 5626403

Please sign in to comment.