1
0
mirror of https://github.com/rancher/types.git synced 2025-04-27 18:25:05 +00:00

fix namespace_reference mapper on update handler

This commit is contained in:
gitlawr 2018-09-11 18:51:44 +08:00 committed by Alena Prokharchyk
parent 30c4b554a2
commit 6a993793e3
2 changed files with 2 additions and 5 deletions

View File

@ -149,7 +149,7 @@ type PipelineSpec struct {
TriggerWebhookTag bool `json:"triggerWebhookTag,omitempty" yaml:"triggerWebhookTag,omitempty"`
RepositoryURL string `json:"repositoryUrl,omitempty" yaml:"repositoryUrl,omitempty"`
SourceCodeCredentialName string `json:"sourceCodeCredentialName,omitempty" yaml:"sourceCodeCredentialName,omitempty" norman:"type=reference[sourceCodeCredential]"`
SourceCodeCredentialName string `json:"sourceCodeCredentialName,omitempty" yaml:"sourceCodeCredentialName,omitempty" norman:"type=reference[sourceCodeCredential],noupdate"`
}
type PipelineConfig struct {

View File

@ -32,13 +32,10 @@ func (n *NamespaceReference) FromInternal(data map[string]interface{}) {
func (n *NamespaceReference) ToInternal(data map[string]interface{}) error {
namespaceID, ok := data["namespaceId"]
if !ok {
return nil
}
for _, path := range n.fields {
convert.Transform(data, path, func(input interface{}) interface{} {
parts := strings.SplitN(convert.ToString(input), ":", 2)
if len(parts) == 2 && (parts[0] == namespaceID) {
if len(parts) == 2 && (!ok || parts[0] == namespaceID) {
return parts[1]
}
return input