
{{! ========================================================== }}
{{! ========================================================== }}
{{! ==================Objectstore channel ==================== }}
{{! ========================================================== }}
{{! ========================================================== }}

{{#unless channelNamespace}}
{{#unless channelNamespaceExists}}
---
apiVersion: v1                      
kind: Namespace
metadata:
  name: {{{channelName}}}-ns
{{/unless}}
---
apiVersion: apps.open-cluster-management.io/v1
kind: Channel
metadata:
  name: {{{channelName}}}
  namespace: {{{channelName}}}-ns
  {{#if selfLinks}}
  selfLink: {{{selfLinks.Channel}}}
  {{/if}}
spec:
  type: ObjectBucket
{{#if objectstoreURL}}
  pathname: '{{{objectstoreURL}}}'
{{/if}}
{{#if accessKey}}
  secretRef:
    name: {{{channelName}}}-auth
---
apiVersion: v1
kind: Secret
metadata:
  name: {{{channelName}}}-auth
  namespace: {{{channelName}}}-ns
data:
  AccessKeyID: {{{accessKey}}}
  SecretAccessKey: {{{secretKey}}}
{{/if}} 
{{/unless}}      
---
apiVersion: apps.open-cluster-management.io/v1
kind: Subscription
metadata:
  labels:
    app: {{{@root.name}}}
  name: {{{@root.name}}}-subscription-{{uniqueGroupID}}
  namespace: {{{@root.namespace}}}
  {{#if selfLinks}}
  selfLink: {{{selfLinks.Subscription}}}
  {{/if}}
spec:
{{#if ansibleSecretName}} 
  hooksecretref: 
    name: {{{ansibleSecretName}}}
{{/if}}
{{#if channelNamespace}}
  channel: {{{channelNamespace}}}/{{{channelName}}}
{{else}}
  channel: {{{channelName}}}-ns/{{{channelName}}}
{{/if}}
