-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates tektonPipeline to make it independent of tektonConfig
- With the addition of operator version config map getting created in tektonConfig, the targetNamespace was getting created in tektonConfig reconciler, but if tektonConfig is not installed and tektonPipeline is supposed to installed alone then it won't be installed as it would miss the targetNamespace. So this patch checks for the targetNamespace in tektonPipeline reconciler, if it is not present then it creates the targetNamespace and also the operator version config map i.e. makes tektonPipeline independent of tektonConfig Signed-off-by: Puneet Punamiya <[email protected]>
- Loading branch information
1 parent
24070f0
commit 38bd9a2
Showing
3 changed files
with
68 additions
and
27 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,54 @@ | ||
package common | ||
|
||
import ( | ||
"context" | ||
mf "github.com/manifestival/manifestival" | ||
"github.com/tektoncd/operator/pkg/apis/operator/v1alpha1" | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/client-go/kubernetes" | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
func CreateTargetNamespace(labels map[string]string, obj v1alpha1.TektonComponent, kubeClientSet kubernetes.Interface) error { | ||
namespace := &corev1.Namespace{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: obj.GetSpec().GetTargetNamespace(), | ||
Labels: map[string]string{ | ||
"operator.tekton.dev/targetNamespace": "true", | ||
}, | ||
}, | ||
} | ||
for key, value := range labels { | ||
namespace.Labels[key] = value | ||
} | ||
|
||
if _, err := kubeClientSet.CoreV1().Namespaces().Create(context.TODO(), namespace, metav1.CreateOptions{}); err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
func CreateOperatorVersionConfigMap(manifest mf.Manifest, obj v1alpha1.TektonComponent) error { | ||
koDataDir := os.Getenv(KoEnvKey) | ||
operatorDir := filepath.Join(koDataDir, "info") | ||
|
||
if err := AppendManifest(&manifest, operatorDir); err != nil { | ||
return err | ||
} | ||
|
||
manifest, err := manifest.Transform( | ||
mf.InjectNamespace(obj.GetSpec().GetTargetNamespace()), | ||
mf.InjectOwner(obj), | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if err = manifest.Apply(); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
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