github.com/theishshah/operator-sdk@v0.6.0/pkg/scaffold/ansible/molecule_test_local_molecule.go (about)

     1  // Copyright 2018 The Operator-SDK Authors
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package ansible
    16  
    17  import (
    18  	"path/filepath"
    19  
    20  	"github.com/operator-framework/operator-sdk/pkg/scaffold/input"
    21  )
    22  
    23  const MoleculeTestLocalMoleculeFile = "molecule.yml"
    24  
    25  type MoleculeTestLocalMolecule struct {
    26  	input.Input
    27  }
    28  
    29  // GetInput - gets the input
    30  func (m *MoleculeTestLocalMolecule) GetInput() (input.Input, error) {
    31  	if m.Path == "" {
    32  		m.Path = filepath.Join(MoleculeTestLocalDir, MoleculeTestLocalMoleculeFile)
    33  	}
    34  	m.TemplateBody = moleculeTestLocalMoleculeAnsibleTmpl
    35  
    36  	return m.Input, nil
    37  }
    38  
    39  const moleculeTestLocalMoleculeAnsibleTmpl = `---
    40  dependency:
    41    name: galaxy
    42  driver:
    43    name: docker
    44  lint:
    45    name: yamllint
    46    enabled: False
    47  platforms:
    48  - name: kind-test-local
    49    groups:
    50    - k8s
    51    image: bsycorp/kind:latest-1.12
    52    privileged: True
    53    override_command: no
    54    exposed_ports:
    55      - 8443/tcp
    56      - 10080/tcp
    57    published_ports:
    58      - 0.0.0.0:${TEST_CLUSTER_PORT:-10443}:8443/tcp
    59    pre_build_image: yes
    60    volumes:
    61      - ${MOLECULE_PROJECT_DIRECTORY}:/build:Z
    62  provisioner:
    63    name: ansible
    64    log: True
    65    lint:
    66      name: ansible-lint
    67      enabled: False
    68    inventory:
    69      group_vars:
    70        all:
    71          namespace: ${TEST_NAMESPACE:-osdk-test}
    72    env:
    73      K8S_AUTH_KUBECONFIG: /tmp/molecule/kind-test-local/kubeconfig
    74      KUBECONFIG: /tmp/molecule/kind-test-local/kubeconfig
    75      ANSIBLE_ROLES_PATH: ${MOLECULE_PROJECT_DIRECTORY}/roles
    76      KIND_PORT: '${TEST_CLUSTER_PORT:-10443}'
    77  scenario:
    78    name: test-local
    79    test_sequence:
    80      - lint
    81      - destroy
    82      - dependency
    83      - syntax
    84      - create
    85      - prepare
    86      - converge
    87      - side_effect
    88      - verify
    89      - destroy
    90  verifier:
    91    name: testinfra
    92    lint:
    93      name: flake8
    94  `