Skip to content

Commit

Permalink
Issue openshift#57: Switch dependency from community.kubernetes to ku…
Browse files Browse the repository at this point in the history
…bernetes.core.
  • Loading branch information
geerlingguy committed Nov 13, 2020
1 parent 32a6a1f commit 36a27e8
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ansible-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ jobs:
# # OPTIONAL If your integration test requires Python libraries or modules from other collections
# # Install them like this
# - name: Install collection dependencies
# run: ansible-galaxy collection install community.kubernetes -p .
# run: ansible-galaxy collection install kubernetes.core -p .

# # Run the integration tests
# - name: Run integration test
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ build: clean
ansible-galaxy collection build

install-kubernetes-src:
mkdir -p ansible_collections/community/kubernetes
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
mkdir -p ansible_collections/kubernetes/core
rm -rf ansible_collections/kubernetes/core/*
curl -L https://github.com/ansible-collections/kubernetes.core/archive/main.tar.gz | tar -xz -C ansible_collections/kubernetes/core --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
Expand Down
13 changes: 6 additions & 7 deletions ci/downstream.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ f_text_sub()
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 "/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 -name "*.bak" -delete
}
Expand Down Expand Up @@ -130,19 +129,19 @@ f_create_collection_dir_structure()

f_install_kubernetes_core_from_src()
{
local community_k8s_tmpdir="${_tmp_dir}/community.kubernetes"
local community_k8s_tmpdir="${_tmp_dir}/kubernetes.core"
local install_collections_dir="${_tmp_dir}/ansible_collections"
mkdir -p "${community_k8s_tmpdir}"
pushd "${_tmp_dir}"
# curl -L \
# https://github.com/ansible-collections/community.kubernetes/archive/main.tar.gz \
# https://github.com/ansible-collections/kubernetes.core/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}"
git clone https://github.com/ansible-collections/kubernetes.core "${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
Expand Down Expand Up @@ -175,7 +174,7 @@ f_test_sanity_option()
pushd "${_build_dir}" || return
ansible-galaxy collection build
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
#SANITY_TEST_ARGS="--docker --color --python 3.6" make test-sanity
# Run tests in docker if available, venv otherwise
Expand Down Expand Up @@ -211,7 +210,7 @@ f_build_option()
f_log_info "BUILD WD: ${PWD}"
# FIXME
# 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
ansible-galaxy collection build
Expand Down
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors:
- willthames (https://github.com/willthames)
- Akasurde (https://github.com/akasurde)
dependencies:
community.kubernetes: '>=1.0.0'
kubernetes.core: '>=1.1.1'
description: OKD Collection for Ansible.
documentation: ''
homepage: ''
Expand Down
4 changes: 2 additions & 2 deletions molecule/default/tasks/openshift_auth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
register: openshift_auth_results

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

- name: Get the test user
community.kubernetes.k8s_info:
kubernetes.core.k8s_info:
api_key: "{{ openshift_auth_results.openshift_auth.api_key }}"
host: '{{ openshift_host }}'
verify_ssl: false
Expand Down
2 changes: 1 addition & 1 deletion molecule/default/tasks/openshift_process.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
that: result is not changed

- name: Get the created configmap
community.kubernetes.k8s_info:
kubernetes.core.k8s_info:
api_version: v1
kind: ConfigMap
name: example
Expand Down
2 changes: 1 addition & 1 deletion plugins/connection/oc.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
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'
Expand Down
2 changes: 1 addition & 1 deletion plugins/inventory/openshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
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:
from openshift.dynamic.exceptions import DynamicApiError
Expand Down
12 changes: 6 additions & 6 deletions plugins/modules/k8s.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
- Optimized for OKD/OpenShift Kubernetes flavors
extends_documentation_fragment:
- community.kubernetes.k8s_state_options
- community.kubernetes.k8s_name_options
- community.kubernetes.k8s_resource_options
- community.kubernetes.k8s_auth_options
- kubernetes.core.k8s_state_options
- kubernetes.core.k8s_name_options
- kubernetes.core.k8s_resource_options
- kubernetes.core.k8s_auth_options
notes:
- If your OpenShift Python library is not 0.9.0 or newer and you are trying to
Expand Down Expand Up @@ -273,7 +273,7 @@
from ansible.module_utils._text import to_native

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
except ImportError as e:
HAS_KUBERNETES_COLLECTION = False
Expand All @@ -297,7 +297,7 @@ class OKDRawModule(KubernetesRawModule):
def __init__(self):
if not HAS_KUBERNETES_COLLECTION:
self.fail_json(
msg="The community.kubernetes collection must be installed",
msg="The kubernetes.core collection must be installed",
exception=K8S_COLLECTION_ERROR,
error=to_native(k8s_collection_import_exception)
)
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/openshift_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
# Previous task provides the token/api_key, while all other parameters
# are taken from module_defaults
- 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 }}"
kind: Pod
register: pod_list
Expand Down
10 changes: 5 additions & 5 deletions plugins/modules/openshift_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
- For CRUD operations on Template resources themselves, see the community.okd.k8s module.
extends_documentation_fragment:
- community.kubernetes.k8s_auth_options
- community.kubernetes.k8s_wait_options
- community.kubernetes.k8s_resource_options
- kubernetes.core.k8s_auth_options
- kubernetes.core.k8s_wait_options
- kubernetes.core.k8s_resource_options
requirements:
- "python >= 2.7"
Expand Down Expand Up @@ -212,7 +212,7 @@
from ansible.module_utils._text import to_native

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
)
HAS_KUBERNETES_COLLECTION = True
Expand Down Expand Up @@ -243,7 +243,7 @@ def __init__(self):

if not HAS_KUBERNETES_COLLECTION:
self.module.fail_json(
msg="The community.kubernetes collection must be installed",
msg="The kubernetes.core collection must be installed",
exception=K8S_COLLECTION_ERROR,
error=to_native(k8s_collection_import_exception)
)
Expand Down
12 changes: 6 additions & 6 deletions plugins/modules/openshift_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
description:
- 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.
- 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:
- community.kubernetes.k8s_auth_options
- community.kubernetes.k8s_wait_options
- community.kubernetes.k8s_state_options
- kubernetes.core.k8s_auth_options
- kubernetes.core.k8s_wait_options
- kubernetes.core.k8s_state_options
requirements:
- "python >= 2.7"
Expand Down Expand Up @@ -304,7 +304,7 @@
from ansible.module_utils._text import to_native

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
)
HAS_KUBERNETES_COLLECTION = True
Expand Down Expand Up @@ -332,7 +332,7 @@ def __init__(self):

if not HAS_KUBERNETES_COLLECTION:
self.module.fail_json(
msg="The community.kubernetes collection must be installed",
msg="The kubernetes.core collection must be installed",
exception=K8S_COLLECTION_ERROR,
error=to_native(k8s_collection_import_exception)
)
Expand Down

0 comments on commit 36a27e8

Please sign in to comment.