-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #138 from harness/PL-25840
[PL-25840]: Model and enum changes for sshkey type secret
- Loading branch information
Showing
17 changed files
with
412 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package nextgen | ||
|
||
type SSHAuthenticationType string | ||
|
||
var SSHAuthenticationTypes = struct { | ||
Kerberos SSHAuthenticationType | ||
SSH SSHAuthenticationType | ||
}{ | ||
Kerberos: "Kerberos", | ||
SSH: "SSH", | ||
} | ||
|
||
var SSHAuthenticationTypeValues = []string{ | ||
SSHAuthenticationTypes.Kerberos.String(), | ||
SSHAuthenticationTypes.SSH.String(), | ||
} | ||
|
||
func (e SSHAuthenticationType) String() string { | ||
return string(e) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package nextgen | ||
|
||
type SSHConfigType string | ||
|
||
var SSHConfigTypes = struct { | ||
Password SSHConfigType | ||
KeyPath SSHConfigType | ||
KeyReference SSHConfigType | ||
}{ | ||
Password: "Password", | ||
KeyPath: "KeyPath", | ||
KeyReference: "KeyReference", | ||
} | ||
|
||
var SSHConfigTypeValues = []string{ | ||
SSHConfigTypes.Password.String(), | ||
SSHConfigTypes.KeyPath.String(), | ||
SSHConfigTypes.KeyReference.String(), | ||
} | ||
|
||
func (e SSHConfigType) String() string { | ||
return string(e) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package nextgen | ||
|
||
type SSHSpecificationType string | ||
|
||
var SSHSpecificationTypes = struct { | ||
KerberosConfigDTO SSHSpecificationType | ||
SSHConfig SSHSpecificationType | ||
}{ | ||
KerberosConfigDTO: "KerberosConfigDTO", | ||
SSHConfig: "SSHConfig", | ||
} | ||
|
||
var SSHSpecificationTypeValues = []string{ | ||
SSHSpecificationTypes.KerberosConfigDTO.String(), | ||
SSHSpecificationTypes.SSHConfig.String(), | ||
} | ||
|
||
func (e SSHSpecificationType) String() string { | ||
return string(e) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package nextgen | ||
|
||
type TgtGenerationMethodType string | ||
|
||
var TgtGenerationMethodTypes = struct { | ||
TGTKeyTabFilePathSpecDTO TgtGenerationMethodType | ||
TGTPasswordSpecDTO TgtGenerationMethodType | ||
}{ | ||
TGTKeyTabFilePathSpecDTO: "KeyTabFilePath", | ||
TGTPasswordSpecDTO: "Password", | ||
} | ||
|
||
var TgtGenerationMethodTypeValues = []string{ | ||
TgtGenerationMethodTypes.TGTKeyTabFilePathSpecDTO.String(), | ||
TgtGenerationMethodTypes.TGTPasswordSpecDTO.String(), | ||
} | ||
|
||
func (e TgtGenerationMethodType) String() string { | ||
return string(e) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
harness/nextgen/model_kerberos_config_spec_serialization.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package nextgen | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
) | ||
|
||
func (a *KerberosConfig) UnmarshalJSON(data []byte) error { | ||
|
||
type Alias KerberosConfig | ||
|
||
aux := &struct { | ||
*Alias | ||
}{ | ||
Alias: (*Alias)(a), | ||
} | ||
|
||
err := json.Unmarshal(data, &aux) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
switch a.TgtGenerationMethod { | ||
case TgtGenerationMethodTypes.TGTKeyTabFilePathSpecDTO: | ||
err = json.Unmarshal(aux.Spec, &a.KeyTabFilePathSpec) | ||
case TgtGenerationMethodTypes.TGTPasswordSpecDTO: | ||
err = json.Unmarshal(aux.Spec, &a.PasswordSpec) | ||
default: | ||
panic(fmt.Sprintf("unknown Tgt generation method type %s", a.TgtGenerationMethod)) | ||
} | ||
|
||
return err | ||
} | ||
|
||
func (a *KerberosConfig) MarshalJSON() ([]byte, error) { | ||
type Alias KerberosConfig | ||
|
||
var spec []byte | ||
var err error | ||
|
||
switch a.TgtGenerationMethod { | ||
case TgtGenerationMethodTypes.TGTKeyTabFilePathSpecDTO: | ||
spec, err = json.Marshal(a.KeyTabFilePathSpec) | ||
case TgtGenerationMethodTypes.TGTPasswordSpecDTO: | ||
spec, err = json.Marshal(a.PasswordSpec) | ||
default: | ||
panic(fmt.Sprintf("unknown Tgt generation method type %s", a.TgtGenerationMethod)) | ||
} | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
a.Spec = json.RawMessage(spec) | ||
|
||
return json.Marshal((*Alias)(a)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package nextgen | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
) | ||
|
||
func (a *SshAuth) UnmarshalJSON(data []byte) error { | ||
|
||
type Alias SshAuth | ||
|
||
aux := &struct { | ||
*Alias | ||
}{ | ||
Alias: (*Alias)(a), | ||
} | ||
|
||
err := json.Unmarshal(data, &aux) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
switch a.Type_ { | ||
case SSHAuthenticationTypes.Kerberos: | ||
err = json.Unmarshal(aux.Spec, &a.KerberosConfig) | ||
case SSHAuthenticationTypes.SSH: | ||
err = json.Unmarshal(aux.Spec, &a.SSHConfig) | ||
default: | ||
panic(fmt.Sprintf("unknown SSH authentication type %s", a.Type_)) | ||
} | ||
|
||
return err | ||
} | ||
|
||
func (a *SshAuth) MarshalJSON() ([]byte, error) { | ||
type Alias SshAuth | ||
|
||
var spec []byte | ||
var err error | ||
|
||
switch a.Type_ { | ||
case SSHAuthenticationTypes.Kerberos: | ||
spec, err = json.Marshal(a.KerberosConfig) | ||
case SSHAuthenticationTypes.SSH: | ||
spec, err = json.Marshal(a.SSHConfig) | ||
default: | ||
panic(fmt.Sprintf("unknown SSH authentication type %s", a.Type_)) | ||
} | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
a.Spec = json.RawMessage(spec) | ||
|
||
return json.Marshal((*Alias)(a)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package nextgen | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
) | ||
|
||
func (a *SshConfig) UnmarshalJSON(data []byte) error { | ||
|
||
type Alias SshConfig | ||
|
||
aux := &struct { | ||
*Alias | ||
}{ | ||
Alias: (*Alias)(a), | ||
} | ||
|
||
err := json.Unmarshal(data, &aux) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
switch a.CredentialType { | ||
case SSHConfigTypes.KeyPath: | ||
err = json.Unmarshal(aux.Spec, &a.KeyPathCredential) | ||
case SSHConfigTypes.KeyReference: | ||
err = json.Unmarshal(aux.Spec, &a.KeyReferenceCredential) | ||
case SSHConfigTypes.Password: | ||
err = json.Unmarshal(aux.Spec, &a.PasswordCredential) | ||
default: | ||
panic(fmt.Sprintf("unknown SSH config type %s", a.Type_)) | ||
} | ||
|
||
return err | ||
} | ||
|
||
func (a *SshConfig) MarshalJSON() ([]byte, error) { | ||
type Alias SshConfig | ||
|
||
var spec []byte | ||
var err error | ||
|
||
switch a.CredentialType { | ||
case SSHConfigTypes.KeyPath: | ||
spec, err = json.Marshal(a.KeyPathCredential) | ||
case SSHConfigTypes.KeyReference: | ||
spec, err = json.Marshal(a.KeyReferenceCredential) | ||
case SSHConfigTypes.Password: | ||
spec, err = json.Marshal(a.PasswordCredential) | ||
default: | ||
panic(fmt.Sprintf("unknown SSH config type %s", a.Type_)) | ||
} | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
a.Spec = json.RawMessage(spec) | ||
|
||
return json.Marshal((*Alias)(a)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.