changed the way kube manifest are applyied
This commit is contained in:
parent
063d57d9e7
commit
ba940bfc80
@ -307,7 +307,7 @@ func (k *KubernetesService) CreateAdmiraltyTarget(context context.Context, execu
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := dynamicClientApply(executionId, "target", gvrTargets, context, target)
|
res, err := dynamicClientApply(executionId, "target-" + peerId + "-" +executionId, gvrTargets, context, target)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.New("Error when trying to apply Target definition :" + err.Error())
|
return nil, errors.New("Error when trying to apply Target definition :" + err.Error())
|
||||||
}
|
}
|
||||||
@ -339,7 +339,7 @@ func (k *KubernetesService) CreateAdmiraltySource(context context.Context,execut
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
res, err := dynamicClientApply(executionId, "source",gvrSources, context, source)
|
res, err := dynamicClientApply(executionId, "source-" + executionId,gvrSources, context, source)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.New("Error when trying to apply Source definition :" + err.Error())
|
return nil, errors.New("Error when trying to apply Source definition :" + err.Error())
|
||||||
}
|
}
|
||||||
@ -449,7 +449,7 @@ func getCDRapiKube(client kubernetes.Clientset, ctx context.Context, path string
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func dynamicClientApply(executionId string, typeResource string, resourceDefinition schema.GroupVersionResource, ctx context.Context, object map[string]interface{}) ([]byte, error) {
|
func dynamicClientApply(executionId string, resourceName string, resourceDefinition schema.GroupVersionResource, ctx context.Context, object map[string]interface{}) ([]byte, error) {
|
||||||
cli, err := NewDynamicClient()
|
cli, err := NewDynamicClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.New("Could not retrieve dynamic client when creating Admiralty Source : " + err.Error())
|
return nil, errors.New("Could not retrieve dynamic client when creating Admiralty Source : " + err.Error())
|
||||||
@ -458,14 +458,15 @@ func dynamicClientApply(executionId string, typeResource string, resourceDefinit
|
|||||||
res, err := cli.Resource(resourceDefinition).
|
res, err := cli.Resource(resourceDefinition).
|
||||||
Namespace(executionId).
|
Namespace(executionId).
|
||||||
Apply(ctx,
|
Apply(ctx,
|
||||||
typeResource + "-" + executionId,
|
resourceName,
|
||||||
&unstructured.Unstructured{Object: object},
|
&unstructured.Unstructured{Object: object},
|
||||||
metav1.ApplyOptions{
|
metav1.ApplyOptions{
|
||||||
FieldManager: "kubectl-client-side-apply",
|
FieldManager: "kubectl-client-side-apply",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error from k8s API when applying " + fmt.Sprint(object) + " to " + gvrSources.String() + " : " , err)
|
o, err := json.Marshal(object)
|
||||||
|
fmt.Println("Error from k8s API when applying " + fmt.Sprint(string(o)) + " to " + gvrSources.String() + " : " , err)
|
||||||
return nil,err
|
return nil,err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user