Skip to content

Commit

Permalink
Migrated to the new .NET based Git Credential Manager (#48)
Browse files Browse the repository at this point in the history
This supersedes the old Java based Git Credential Manager for Mac and Linux.
  • Loading branch information
freemanjp authored Jan 3, 2022
1 parent 28fd238 commit 9f95cb3
Show file tree
Hide file tree
Showing 24 changed files with 58 additions and 427 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,9 @@ jobs:
ansible-version:
- '2.9.1'
molecule-scenario:
- centos
- debian_max
- debian_min
- ubuntu_max
- opensuse
- fedora
include:
- ansible-version: '2.8.16'
molecule-scenario: ubuntu_min
Expand Down
48 changes: 13 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Ansible Role: Git Credential Manager
[![Ansible Galaxy](https://img.shields.io/badge/ansible--galaxy-gantsign.git__credential__manager-blue.svg)](https://galaxy.ansible.com/gantsign/git_credential_manager)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/gantsign/ansible_role_git_credential_manager/master/LICENSE)

Role to install Microsoft's [Git Credential Manager for Mac and Linux](https://github.com/Microsoft/Git-Credential-Manager-for-Mac-and-Linux).
Role to install the [Git Credential Manager](https://github.com/GitCredentialManager/git-credential-manager).

**Important:** while Microsoft's Git Credential Manager works on macOS this
Ansible role is presently for Linux only.
**Important:** while the Git Credential Manager works on macOS and Windows this
Ansible role only works on Debian and Ubuntu.

Requirements
------------
Expand All @@ -21,29 +21,13 @@ Requirements

* Debian

* Jessie (8)
* Stretch (9)
* Buster (10)
* Bullseye (11)

* Ubuntu

* Xenial (16.04)
* Bionic (18.04)

* RedHat Family

* CentOS

* 7

* Fedora

* 31

* SUSE Family

* openSUSE

* 15.1
* Focal (20.04)

* Note: other versions are likely to work but have not been tested.

Expand All @@ -54,22 +38,16 @@ The following variables will change the behavior of this role:

```yaml
# Git Credential Manager version number
git_credential_manager_version: '2.0.4'

# The SHA256 of the Git Credential Manager JAR
git_credential_manager_jar_sha256sum: 'fb8536aac9b00cdf6bdeb0dd152bb1306d88cd3fdb7a958ac9a144bf4017cad7'

# The major version of the JRE
git_credential_manager_jre_major_version: '8'
git_credential_manager_version: '2.0.632'

# The full version of the JRE (from AdoptOpenJDK)
git_credential_manager_jre_version: 'jdk8u282-b08_openj9-0.24.0'
# Git Credential Manager build number
git_credential_manager_build: '34631'

# The SHA256 of the JRE
git_credential_manager_jre_sha256sum: '4fad259c32eb23ec98925c8b2cf28aaacbdb55e034db74c31a7636e75b6af08d'
# The SHA256 of the Git Credential Manager JAR
git_credential_manager_redis_sha256sum: '41d116b3e4b62099a41d7de21f815724cefa8d386af767695da8ef0ac8b4aa33'

# Base installation directory the Git Credential Manager
git_credential_manager_install_dir: '/opt/git-credential-manager/{{ git_credential_manager_version }}'
# The credential store to use
git_credential_manager_credential_store: 'secretservice'

# Directory to store files downloaded for the Git Credential Manager
git_credential_manager_download_dir: "{{ x_ansible_download_dir | default(ansible_env.HOME + '/.ansible/tmp/downloads') }}"
Expand Down
20 changes: 7 additions & 13 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
---
# Git Credential Manager version number
git_credential_manager_version: '2.0.4'
git_credential_manager_version: '2.0.632'

# The SHA256 of the Git Credential Manager JAR
git_credential_manager_jar_sha256sum: 'fb8536aac9b00cdf6bdeb0dd152bb1306d88cd3fdb7a958ac9a144bf4017cad7'

# The major version of the JRE
git_credential_manager_jre_major_version: '8'
# Git Credential Manager build number
git_credential_manager_build: '34631'

# The full version of the JRE (from AdoptOpenJDK)
git_credential_manager_jre_version: 'jdk8u282-b08_openj9-0.24.0'

# The SHA256 of the JRE
git_credential_manager_jre_sha256sum: '4fad259c32eb23ec98925c8b2cf28aaacbdb55e034db74c31a7636e75b6af08d'
# The SHA256 of the Git Credential Manager JAR
git_credential_manager_redis_sha256sum: '41d116b3e4b62099a41d7de21f815724cefa8d386af767695da8ef0ac8b4aa33'

# Base installation directory the Git Credential Manager
git_credential_manager_install_dir: '/opt/git-credential-manager/{{ git_credential_manager_version }}'
# The credential store to use
git_credential_manager_credential_store: 'secretservice'

# Directory to store files downloaded for the Git Credential Manager
git_credential_manager_download_dir: "{{ x_ansible_download_dir | default(ansible_env.HOME + '/.ansible/tmp/downloads') }}"
13 changes: 2 additions & 11 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,14 @@ galaxy_info:
license: MIT
min_ansible_version: 2.8
platforms:
- name: EL
versions:
- 7
- name: Fedora
versions:
- 31
- name: Ubuntu
versions:
- xenial
- bionic
- name: Debian
versions:
- jessie
- stretch
- name: opensuse
versions:
- 15.1
- buster
- bullseye
galaxy_tags:
- git
- development
Expand Down
22 changes: 0 additions & 22 deletions molecule/centos/INSTALL.rst

This file was deleted.

26 changes: 0 additions & 26 deletions molecule/centos/molecule.yml

This file was deleted.

2 changes: 1 addition & 1 deletion molecule/debian_max/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ lint: |
platforms:
- name: ansible_role_git_credential_manager_debian_max
image: debian:9
image: debian:11
dockerfile: ../default/Dockerfile.j2

provisioner:
Expand Down
2 changes: 1 addition & 1 deletion molecule/debian_min/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ lint: |
platforms:
- name: ansible_role_git_credential_manager_debian_min
image: debian:8
image: debian:10
dockerfile: ../default/Dockerfile.j2

provisioner:
Expand Down
6 changes: 0 additions & 6 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@
apt:
update_cache: yes
changed_when: no
when: ansible_pkg_mgr == 'apt'

- name: install find (dnf)
dnf:
name: findutils
when: ansible_pkg_mgr == 'dnf'

roles:
- role: ansible_role_git_credential_manager
2 changes: 1 addition & 1 deletion molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ lint: |
platforms:
- name: ansible_role_git_credential_manager_default
image: ubuntu:18.04
image: ubuntu:20.04

provisioner:
name: ansible
Expand Down
83 changes: 7 additions & 76 deletions molecule/default/tests/test_role.py
Original file line number Diff line number Diff line change
@@ -1,84 +1,15 @@
import pytest
import re


@pytest.mark.parametrize('dir_name', [
'bin',
'libexec',
'jre',
])
def test_directories(host, dir_name):
install_dir_pattern = '/opt/git-credential-manager/[0-9\\.]+$'
install_dir = host.check_output('find %s | grep --color=never -E %s',
'/opt/git-credential-manager',
install_dir_pattern)
dir = host.file(install_dir)
assert dir.exists
assert dir.is_directory
assert dir.user == 'root'
assert dir.group == 'root'

dir = host.file(install_dir + '/' + dir_name)
assert dir.exists
assert dir.is_directory
assert dir.user == 'root'
assert dir.group == 'root'


@pytest.mark.parametrize('file_path', [
'bin/git-credential-manager',
'jre/bin/java',
])
def test_files(host, file_path):
install_dir_pattern = '/opt/git-credential-manager/[0-9\\.]+$'
install_dir = host.check_output('find %s | grep --color=never -E %s',
'/opt/git-credential-manager',
install_dir_pattern)
dir = host.file(install_dir)
assert dir.exists
assert dir.is_directory
assert dir.user == 'root'
assert dir.group == 'root'

installed_file = host.file(install_dir + '/' + file_path)
assert installed_file.exists
assert installed_file.is_file
assert installed_file.user == 'root'
assert installed_file.group == 'root'


def test_libexec(host):
file_pattern = ('/opt/git-credential-manager/[0-9\\.]+/libexec/'
'git-credential-manager-[0-9\\.]+\\.jar$')
file_path = host.check_output('find %s | grep --color=never -E %s',
'/opt/git-credential-manager',
file_pattern)
installed_file = host.file(file_path)
assert installed_file.exists
assert installed_file.is_file
assert installed_file.user == 'root'
assert installed_file.group == 'root'


def test_link(host):
installed_file = host.file('/usr/local/bin/git-credential-manager')
assert installed_file.exists
assert installed_file.is_symlink
assert installed_file.user == 'root'
assert installed_file.group in ['root', 'staff']


def test_version(host):
version = host.check_output('git-credential-manager version')
pattern = 'Git Credential Manager for Mac and Linux version [0-9\\.]'
assert re.match(pattern, version)
version = host.check_output('git-credential-manager-core --version')
pattern = r'[0-9\.]+(\.[0-9\.]+){2}'
assert re.search(pattern, version)


def test_git_config(host):
config = host.check_output('git config --system credential.helper')
pattern = ("!'?/opt/git-credential-manager/[0-9\\.]+/jre/bin/java'?"
" -Ddebug=false -Djava.net.useSystemProxies=true"
" -Xshareclasses:name=git-credential-manager -Xquickstart"
" -jar '?/opt/git-credential-manager/[0-9\\.]+/libexec/"
"git-credential-manager-[0-9\\.]+.jar'?")
assert re.match(pattern, config)
assert config == '/usr/local/share/gcm-core/git-credential-manager-core'
config = host.check_output(
'git config --system credential.credentialStore')
assert config == 'secretservice'
22 changes: 0 additions & 22 deletions molecule/fedora/INSTALL.rst

This file was deleted.

26 changes: 0 additions & 26 deletions molecule/fedora/molecule.yml

This file was deleted.

22 changes: 0 additions & 22 deletions molecule/opensuse/INSTALL.rst

This file was deleted.

Loading

0 comments on commit 9f95cb3

Please sign in to comment.