Issue #57: Switch dependency from community.kubernetes to kubernetes.core. (#58)

* Issue #57: Switch dependency from community.kubernetes to kubernetes.core.

* Issue #57: Rely on kubernetes.core install directly.

* Issue #57: Don't install kubernetes.core from source anymore.
This commit is contained in:
Jeff Geerling
2020-11-16 13:35:18 -06:00
committed by GitHub
parent 32a6a1fda3
commit 87cd174b96
12 changed files with 34 additions and 52 deletions

View File

@@ -93,7 +93,7 @@ jobs:
# # OPTIONAL If your integration test requires Python libraries or modules from other collections # # OPTIONAL If your integration test requires Python libraries or modules from other collections
# # Install them like this # # Install them like this
# - name: Install collection dependencies # - name: Install collection dependencies
# run: ansible-galaxy collection install community.kubernetes -p . # run: ansible-galaxy collection install kubernetes.core -p .
# # Run the integration tests # # Run the integration tests
# - name: Run integration test # - name: Run integration test
@@ -111,7 +111,7 @@ jobs:
# fail_ci_if_error: false # fail_ci_if_error: false
# #
downstream-sanity-29: downstream-sanity-29:
name: Sanity (Ⓐ${{ matrix.ansible }}+py${{ matrix.python }}) name: Downstream Sanity (Ⓐ${{ matrix.ansible }}+py${{ matrix.python }})
strategy: strategy:
matrix: matrix:
ansible: ansible:

View File

@@ -12,11 +12,8 @@ build: clean
ansible-galaxy collection build ansible-galaxy collection build
install-kubernetes-src: install-kubernetes-src:
mkdir -p ansible_collections/community/kubernetes ansible-galaxy collection install -p ansible_collections kubernetes.core
rm -rf ansible_collections/community/kubernetes/*
curl -L https://github.com/ansible-collections/community.kubernetes/archive/main.tar.gz | tar -xz -C ansible_collections/community/kubernetes --strip-components 1
# TODO: Once we no longer rely on features in main we should drop the install-kubernetes-src dependency
install: build install-kubernetes-src install: build install-kubernetes-src
ansible-galaxy collection install -p ansible_collections community-okd-$(VERSION).tar.gz ansible-galaxy collection install -p ansible_collections community-okd-$(VERSION).tar.gz

View File

@@ -43,8 +43,7 @@ f_text_sub()
sed -i.bak "s/Kubernetes/OpenShift/g" "${_build_dir}/galaxy.yml" sed -i.bak "s/Kubernetes/OpenShift/g" "${_build_dir}/galaxy.yml"
sed -i.bak "s/^version\:.*$/version: ${DOWNSTREAM_VERSION}/" "${_build_dir}/galaxy.yml" sed -i.bak "s/^version\:.*$/version: ${DOWNSTREAM_VERSION}/" "${_build_dir}/galaxy.yml"
sed -i.bak "/STARTREMOVE/,/ENDREMOVE/d" "${_build_dir}/README.md" sed -i.bak "/STARTREMOVE/,/ENDREMOVE/d" "${_build_dir}/README.md"
find ${_build_dir} -type f -exec sed -i.bak "s/community\.kubernetes/kubernetes\.core/g" {} \;
find ${_build_dir} -type f -exec sed -i.bak "s/community\.okd/redhat\.openshift/g" {} \; find ${_build_dir} -type f -exec sed -i.bak "s/community\.okd/redhat\.openshift/g" {} \;
find "${_build_dir}" -type f -name "*.bak" -delete find "${_build_dir}" -type f -name "*.bak" -delete
} }
@@ -128,25 +127,11 @@ f_create_collection_dir_structure()
fi fi
} }
f_install_kubernetes_core_from_src() f_install_kubernetes_core()
{ {
local community_k8s_tmpdir="${_tmp_dir}/community.kubernetes"
local install_collections_dir="${_tmp_dir}/ansible_collections" local install_collections_dir="${_tmp_dir}/ansible_collections"
mkdir -p "${community_k8s_tmpdir}"
pushd "${_tmp_dir}" pushd "${_tmp_dir}"
# curl -L \ ansible-galaxy collection install -p "${install_collections_dir}" kubernetes.core
# https://github.com/ansible-collections/community.kubernetes/archive/main.tar.gz \
# | tar -xz -C "${community_k8s_tmpdir}" --strip-components 1
# pushd "${community_k8s_tmpdir}"
# make downstream-build
# ansible-galaxy collection install -p "${install_collections_dir}" "${community_k8s_tmpdir}"/kubernetes-core-*.tar.gz
# popd
#popd
git clone https://github.com/ansible-collections/community.kubernetes "${community_k8s_tmpdir}"
pushd "${community_k8s_tmpdir}"
make downstream-build
ansible-galaxy collection install -p "${install_collections_dir}" "${community_k8s_tmpdir}"/kubernetes-core-*.tar.gz
popd
popd popd
} }
@@ -171,11 +156,11 @@ f_test_sanity_option()
{ {
f_log_info "${FUNCNAME[0]}" f_log_info "${FUNCNAME[0]}"
f_common_steps f_common_steps
f_install_kubernetes_core_from_src f_install_kubernetes_core
pushd "${_build_dir}" || return pushd "${_build_dir}" || return
ansible-galaxy collection build ansible-galaxy collection build
f_log_info "SANITY TEST PWD: ${PWD}" f_log_info "SANITY TEST PWD: ${PWD}"
## Can't do this because the upstream community.kubernetes dependency logic ## Can't do this because the upstream kubernetes.core dependency logic
## is bound as a Makefile dep to the test-sanity target ## is bound as a Makefile dep to the test-sanity target
#SANITY_TEST_ARGS="--docker --color --python 3.6" make test-sanity #SANITY_TEST_ARGS="--docker --color --python 3.6" make test-sanity
# Run tests in docker if available, venv otherwise # Run tests in docker if available, venv otherwise
@@ -194,7 +179,7 @@ f_test_integration_option()
{ {
f_log_info "${FUNCNAME[0]}" f_log_info "${FUNCNAME[0]}"
f_common_steps f_common_steps
f_install_kubernetes_core_from_src f_install_kubernetes_core
pushd "${_build_dir}" || return pushd "${_build_dir}" || return
f_log_info "INTEGRATION TEST WD: ${PWD}" f_log_info "INTEGRATION TEST WD: ${PWD}"
OVERRIDE_COLLECTION_PATH="${_tmp_dir}" molecule test OVERRIDE_COLLECTION_PATH="${_tmp_dir}" molecule test
@@ -211,7 +196,7 @@ f_build_option()
f_log_info "BUILD WD: ${PWD}" f_log_info "BUILD WD: ${PWD}"
# FIXME # FIXME
# This doesn't work because we end up either recursively curl'ing # This doesn't work because we end up either recursively curl'ing
# community.kubernetes and redoing the text replacement over and over # kubernetes.core and redoing the text replacement over and over
# #
# make build # make build
ansible-galaxy collection build ansible-galaxy collection build

View File

@@ -5,7 +5,7 @@ authors:
- willthames (https://github.com/willthames) - willthames (https://github.com/willthames)
- Akasurde (https://github.com/akasurde) - Akasurde (https://github.com/akasurde)
dependencies: dependencies:
community.kubernetes: '>=1.0.0' kubernetes.core: '>=1.1.1'
description: OKD Collection for Ansible. description: OKD Collection for Ansible.
documentation: '' documentation: ''
homepage: '' homepage: ''

View File

@@ -12,7 +12,7 @@
register: openshift_auth_results register: openshift_auth_results
- name: Get the test User - name: Get the test User
community.kubernetes.k8s_info: kubernetes.core.k8s_info:
api_key: "{{ openshift_auth_results.openshift_auth.api_key }}" api_key: "{{ openshift_auth_results.openshift_auth.api_key }}"
host: '{{ openshift_host }}' host: '{{ openshift_host }}'
verify_ssl: false verify_ssl: false
@@ -35,7 +35,7 @@
verify_ssl: false verify_ssl: false
- name: Get the test user - name: Get the test user
community.kubernetes.k8s_info: kubernetes.core.k8s_info:
api_key: "{{ openshift_auth_results.openshift_auth.api_key }}" api_key: "{{ openshift_auth_results.openshift_auth.api_key }}"
host: '{{ openshift_host }}' host: '{{ openshift_host }}'
verify_ssl: false verify_ssl: false

View File

@@ -133,7 +133,7 @@
that: result is not changed that: result is not changed
- name: Get the created configmap - name: Get the created configmap
community.kubernetes.k8s_info: kubernetes.core.k8s_info:
api_version: v1 api_version: v1
kind: ConfigMap kind: ConfigMap
name: example name: example

View File

@@ -147,7 +147,7 @@ DOCUMENTATION = '''
aliases: [ oc_verify_ssl ] aliases: [ oc_verify_ssl ]
''' '''
from ansible_collections.community.kubernetes.plugins.connection.kubectl import Connection as KubectlConnection from ansible_collections.kubernetes.core.plugins.connection.kubectl import Connection as KubectlConnection
CONNECTION_TRANSPORT = 'oc' CONNECTION_TRANSPORT = 'oc'

View File

@@ -113,7 +113,7 @@ connections:
context: 'awx/192-168-64-4:8443/developer' context: 'awx/192-168-64-4:8443/developer'
''' '''
from ansible_collections.community.kubernetes.plugins.inventory.k8s import K8sInventoryException, InventoryModule as K8sInventoryModule, format_dynamic_api_exc from ansible_collections.kubernetes.core.plugins.inventory.k8s import K8sInventoryException, InventoryModule as K8sInventoryModule, format_dynamic_api_exc
try: try:
from openshift.dynamic.exceptions import DynamicApiError from openshift.dynamic.exceptions import DynamicApiError

View File

@@ -36,10 +36,10 @@ description:
- Optimized for OKD/OpenShift Kubernetes flavors - Optimized for OKD/OpenShift Kubernetes flavors
extends_documentation_fragment: extends_documentation_fragment:
- community.kubernetes.k8s_state_options - kubernetes.core.k8s_state_options
- community.kubernetes.k8s_name_options - kubernetes.core.k8s_name_options
- community.kubernetes.k8s_resource_options - kubernetes.core.k8s_resource_options
- community.kubernetes.k8s_auth_options - kubernetes.core.k8s_auth_options
notes: notes:
- If your OpenShift Python library is not 0.9.0 or newer and you are trying to - If your OpenShift Python library is not 0.9.0 or newer and you are trying to
@@ -273,7 +273,7 @@ from functools import reduce
from ansible.module_utils._text import to_native from ansible.module_utils._text import to_native
try: try:
from ansible_collections.community.kubernetes.plugins.module_utils.raw import KubernetesRawModule from ansible_collections.kubernetes.core.plugins.module_utils.raw import KubernetesRawModule
HAS_KUBERNETES_COLLECTION = True HAS_KUBERNETES_COLLECTION = True
except ImportError as e: except ImportError as e:
HAS_KUBERNETES_COLLECTION = False HAS_KUBERNETES_COLLECTION = False
@@ -297,7 +297,7 @@ class OKDRawModule(KubernetesRawModule):
def __init__(self): def __init__(self):
if not HAS_KUBERNETES_COLLECTION: if not HAS_KUBERNETES_COLLECTION:
self.fail_json( self.fail_json(
msg="The community.kubernetes collection must be installed", msg="The kubernetes.core collection must be installed",
exception=K8S_COLLECTION_ERROR, exception=K8S_COLLECTION_ERROR,
error=to_native(k8s_collection_import_exception) error=to_native(k8s_collection_import_exception)
) )

View File

@@ -99,7 +99,7 @@ EXAMPLES = r'''
# Previous task provides the token/api_key, while all other parameters # Previous task provides the token/api_key, while all other parameters
# are taken from module_defaults # are taken from module_defaults
- name: Get a list of all pods from any namespace - name: Get a list of all pods from any namespace
community.kubernetes.k8s_info: kubernetes.core.k8s_info:
api_key: "{{ openshift_auth_results.openshift_auth.api_key }}" api_key: "{{ openshift_auth_results.openshift_auth.api_key }}"
kind: Pod kind: Pod
register: pod_list register: pod_list

View File

@@ -25,9 +25,9 @@ description:
- For CRUD operations on Template resources themselves, see the community.okd.k8s module. - For CRUD operations on Template resources themselves, see the community.okd.k8s module.
extends_documentation_fragment: extends_documentation_fragment:
- community.kubernetes.k8s_auth_options - kubernetes.core.k8s_auth_options
- community.kubernetes.k8s_wait_options - kubernetes.core.k8s_wait_options
- community.kubernetes.k8s_resource_options - kubernetes.core.k8s_resource_options
requirements: requirements:
- "python >= 2.7" - "python >= 2.7"
@@ -212,7 +212,7 @@ from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils._text import to_native from ansible.module_utils._text import to_native
try: try:
from ansible_collections.community.kubernetes.plugins.module_utils.common import ( from ansible_collections.kubernetes.core.plugins.module_utils.common import (
K8sAnsibleMixin, AUTH_ARG_SPEC, RESOURCE_ARG_SPEC, WAIT_ARG_SPEC K8sAnsibleMixin, AUTH_ARG_SPEC, RESOURCE_ARG_SPEC, WAIT_ARG_SPEC
) )
HAS_KUBERNETES_COLLECTION = True HAS_KUBERNETES_COLLECTION = True
@@ -243,7 +243,7 @@ class OpenShiftProcess(K8sAnsibleMixin):
if not HAS_KUBERNETES_COLLECTION: if not HAS_KUBERNETES_COLLECTION:
self.module.fail_json( self.module.fail_json(
msg="The community.kubernetes collection must be installed", msg="The kubernetes.core collection must be installed",
exception=K8S_COLLECTION_ERROR, exception=K8S_COLLECTION_ERROR,
error=to_native(k8s_collection_import_exception) error=to_native(k8s_collection_import_exception)
) )

View File

@@ -21,12 +21,12 @@ author: "Fabian von Feilitzsch (@fabianvf)"
description: description:
- Looks up a Service and creates a new Route based on it. - Looks up a Service and creates a new Route based on it.
- Analogous to `oc expose` and `oc create route` for creating Routes, but does not support creating Services. - Analogous to `oc expose` and `oc create route` for creating Routes, but does not support creating Services.
- For creating Services from other resources, see community.kubernetes.k8s_expose - For creating Services from other resources, see kubernetes.core.k8s_expose
extends_documentation_fragment: extends_documentation_fragment:
- community.kubernetes.k8s_auth_options - kubernetes.core.k8s_auth_options
- community.kubernetes.k8s_wait_options - kubernetes.core.k8s_wait_options
- community.kubernetes.k8s_state_options - kubernetes.core.k8s_state_options
requirements: requirements:
- "python >= 2.7" - "python >= 2.7"
@@ -304,7 +304,7 @@ from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils._text import to_native from ansible.module_utils._text import to_native
try: try:
from ansible_collections.community.kubernetes.plugins.module_utils.common import ( from ansible_collections.kubernetes.core.plugins.module_utils.common import (
K8sAnsibleMixin, AUTH_ARG_SPEC, WAIT_ARG_SPEC, COMMON_ARG_SPEC K8sAnsibleMixin, AUTH_ARG_SPEC, WAIT_ARG_SPEC, COMMON_ARG_SPEC
) )
HAS_KUBERNETES_COLLECTION = True HAS_KUBERNETES_COLLECTION = True
@@ -332,7 +332,7 @@ class OpenShiftRoute(K8sAnsibleMixin):
if not HAS_KUBERNETES_COLLECTION: if not HAS_KUBERNETES_COLLECTION:
self.module.fail_json( self.module.fail_json(
msg="The community.kubernetes collection must be installed", msg="The kubernetes.core collection must be installed",
exception=K8S_COLLECTION_ERROR, exception=K8S_COLLECTION_ERROR,
error=to_native(k8s_collection_import_exception) error=to_native(k8s_collection_import_exception)
) )