Skip to content

Commit

Permalink
Merge pull request #45 from krateoplatformops/41-docs-update
Browse files Browse the repository at this point in the history
41 docs update
  • Loading branch information
matteogastaldello authored Sep 12, 2024
2 parents 02f6ff0 + 6792e13 commit 6ef8722
Show file tree
Hide file tree
Showing 20 changed files with 857 additions and 399 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/release-tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,9 @@ jobs:
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ github.repository }}:${{ steps.meta.outputs.version }}
update-crd-doc:
runs-on: ubuntu-latest
steps:
- name: Update CRD doc
run: |
curl -s https://doc.crds.dev/github.com/${{ github.repository_owner }}/{{ github.repository }}@${{ github.ref_name }}
20 changes: 20 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Test and coverage

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 'stable'
- name: Gather dependencies
run: go mod download
- name: Run coverage
run: go test -race -coverprofile=coverage.txt -covermode=atomic ./...
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
65 changes: 0 additions & 65 deletions Makefile

This file was deleted.

90 changes: 57 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,73 @@
# Git Provider

This is a [Krateo](https://krateoplatformops.github.io/) Provider that clones git repositories (eventually applying templates).
This is a [Krateo](https://krateo.io) Provider that clones git repositories (eventually applying templates).

## Getting Started
## Summary

You’ll need a Kubernetes cluster to run against.
- [Summary](#summary)
- [Overview](#overview)
- [Examples](#examples)
- [Configuration](#configuration)


> You can use [KIND](https://sigs.k8s.io/kind) to get a local cluster for testing, or run against a remote cluster.
## Overview

Git Provider clones git repositories and may apply [Mustache templates](https://mustache.github.io). It then pushes the cloned and modified repository to a different location. The templating values are retrieved in a configmap referenced in the custom resource.
It provides automatic reconciliation when changes are retrieved from the original repository.

### Running on the cluster
Git Provider leverages Krateo [provider-runtime](https://docs.krateo.io/key-concepts/kco/#provider-runtime) a production-grade version of the controller-runtime.

1. Install the provider:
## Examples

```sh
### Provider Installation

```bash
$ helm repo add krateo https://charts.krateo.io
$ helm repo update krateo
$ helm install git-provider krateo/git-provider
```

2. Install Instances of Custom Resources:

```sh
$ kubectl apply -f samples/
```

### Test It Out

1. Start a local cluster using [KIND](https://sigs.k8s.io/kind):

```sh
$ make kind-up
```

2. Run your provider (this will run in the foreground, so switch to a new terminal if you want to leave it running):

```sh
$ make dev
```

### Modifying the API definitions
If you are editing the API definitions, generate the CRDs using:

```sh
$ make generate
### Manifest application

```yaml
apiVersion: git.krateo.io/v1alpha1
kind: Repo
metadata:
name: git-azuredevops-branch-5
spec:
enableUpdate: false
configMapKeyRef:
key: values
name: filename-replace-values
namespace: default
deletionPolicy: Delete
fromRepo:
authMethod: generic
branch: main
path: skeleton/
usernameRef:
key: username
name: github-user
namespace: default
secretRef:
key: token
name: github-token
namespace: default
url: https://github.com/matteogastaldello/fromRepo
toRepo:
authMethod: generic
branch: test-5
usernameRef:
key: username
name: azure-user
namespace: default
secretRef:
key: token
name: azure-token
namespace: default
url: https://matteogastaldello-org@dev.azure.com/matteogastaldello-org/teamproject/_git/repo-generated
unsupportedCapabilities: true
```
**NOTE:** Run `make help` for more information on all potential `make` targets
## Configuration
To view the CR configuration visit [this link](https://doc.crds.dev/github.com/krateoplatformops/git-provider).
27 changes: 14 additions & 13 deletions apis/repo/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,30 @@ import (
)

type RepoOpts struct {
// Url: the repository URL.
// Url: url of the remote repository
// +immutable
Url string `json:"url"`

// Path: name of the folder in the git repository
// to copy from (or to).
// Path: if in spec.fromRepo, Represents the folder to clone from. If not set the entire repository is cloned. If in spec.toRepo, represents the folder to use as destination.
// +kubebuilder:default:="/"
// +optional
Path *string `json:"path,omitempty"`

// Branch: in the git repository to copy from (or to).
// Branch: if in spec.fromRepo, the branch to copy from. If in spec.toRepo, represents the branch to populate; If the branch does not exist on remote is created by the provider.
// +required
Branch *string `json:"branch"`

// SecretRef: holds token required to git server authentication or cookie file in case of 'cookiefile' authMethod.
// SecretRef: reference to a secret that contains token required to git server authentication or cookie file in case of 'cookiefile' authMethod.
SecretRef *commonv1.SecretKeySelector `json:"secretRef"`

// UsernameRef: holds username required to git server authentication. - If 'authMethod' is 'bearer' the field is ignored. If the field is not set, username is setted as 'krateoctl'
// UsernameRef: holds username required to git server authentication. - If 'authMethod' is 'bearer' or 'cookiefile' the field is ignored. If the field is not set, username is setted as 'krateoctl'
// +optional
UsernameRef *commonv1.SecretKeySelector `json:"usernameRef"`

// AuthMethod defines the authentication mode. One of 'basic' or 'bearer' or 'cookiefile'.
// AuthMethod: Possible values are: `generic`, `bearer`, `gitcookies`. `generic` requires `secretRef` and `usernameRef`; `generic` requires only `secretRef`; `cookiefile` requires only `secretRef`
// In case of 'cookiefile' the secretRef must contain a file with the cookie.
// +kubebuilder:validation:Enum=generic;bearer;cookiefile
// +kubebuilder:default:=generic
// +optional
AuthMethod *string `json:"authMethod,omitempty"`

Expand All @@ -56,18 +58,17 @@ type RepoSpec struct {
// +optional
ConfigMapKeyRef *commonv1.ConfigMapKeySelector `json:"configMapKeyRef,omitempty"`

// Insecure is useful with hand made SSL certs (default: false)
// Insecure: Insecure is useful with hand made SSL certs (default: false)
// +optional
Insecure *bool `json:"insecure,omitempty"`

// UnsupportedCapabilities enable Go-Git transport.UnsupportedCapabilities (default: false)
// Azure DevOps requires capabilities multi_ack / multi_ack_detailed,
// which are not fully implemented in go-git library and by default
// are included in transport.UnsupportedCapabilities.
// UnsupportedCapabilities: If `true` [capabilities not supported by any client implementation](https://github.com/go-git/go-git/blob/4fd9979d5c2940e72bdd6946fec21e02d959f0f6/plumbing/transport/common.go#L310) will not be used by the provider
// +optional
// +kubebuilder:default:=false
UnsupportedCapabilities *bool `json:"unsupportedCapabilities,omitempty"`

// Enable sync with origin repo. Target repo will be reconciled the changes on origin - experimental (default: false)
// EnableUpdate: If `true`, the provider performs updates on the repository specified in `toRepo` when newer commits are retrieved from `fromRepo`
// +kubebuilder:default:=false
// +optional
EnableUpdate *bool `json:"enableUpdate,omitempty"`
}
Expand Down
7 changes: 7 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# sample regex patterns
ignore:
- "internal/controllers/repo/repo.go"
- "internal/controllers/repo/setup.go"
- "internal/controllers/git.go"
- "apis"
- "cmd/*.go"
Loading

0 comments on commit 6ef8722

Please sign in to comment.