Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(render): add integration tests to check rendering output #118

Merged
merged 12 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 26 additions & 20 deletions cmd/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,34 @@ func init() {
ANNOTATION_SMART_MODE: ANNOTATION_TRUE,
},
Run: func(cmd *cobra.Command, args []string) {
g := myks.New(".")

if err := g.ValidateRootDir(); err != nil {
log.Fatal().Err(err).Msg("Root directory is not suitable for myks")
}

if err := g.Init(asyncLevel, envAppMap); err != nil {
log.Fatal().Err(err).Msg("Unable to initialize myks's globe")
}

if err := g.SyncAndRender(asyncLevel); err != nil {
log.Fatal().Err(err).Msg("Unable to sync vendir configs")
}

// Cleaning up only if all environments and applications were processed
if envAppMap == nil {
if err := g.Cleanup(); err != nil {
log.Fatal().Err(err).Msg("Unable to cleanup")
}
}
RunAllCmd()
},
}

rootCmd.AddCommand(cmd)
}

func RunAllCmd() {
g := myks.New(".")

if err := g.ValidateRootDir(); err != nil {
log.Fatal().Err(err).Msg("Root directory is not suitable for myks")
}

log.Info().Msg("Init################")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it leftovers after debugging?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll remove it and merge.

Zebradil marked this conversation as resolved.
Show resolved Hide resolved
if err := g.Init(asyncLevel, envAppMap); err != nil {
log.Fatal().Err(err).Msg("Unable to initialize myks's globe")
}
log.Info().Msg("Sync and render#########")
Zebradil marked this conversation as resolved.
Show resolved Hide resolved

if err := g.SyncAndRender(asyncLevel); err != nil {
log.Fatal().Err(err).Msg("Unable to sync vendir configs")
}

// Cleaning up only if all environments and applications were processed
if envAppMap == nil {
if err := g.Cleanup(); err != nil {
log.Fatal().Err(err).Msg("Unable to cleanup")
}
}
}
1 change: 1 addition & 0 deletions examples/default/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/.myks/tmp/
7 changes: 7 additions & 0 deletions examples/default/.myks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
# Sets the number of applications to be processed in parallel.
# The default (0) is no limit.
async: 0
# One of the zerolog log levels.
# See: https://github.com/rs/zerolog#leveled-logging
log-level: info
1 change: 1 addition & 0 deletions examples/default/envs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/.myks/tmp/
12 changes: 12 additions & 0 deletions examples/default/envs/_env/argocd/annotations.overlay.ytt.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#@ load("@ytt:overlay", "overlay")
#@ load("@ytt:data", "data")

#! Match all ArgoCD resources: Application, AppProject, Secret.
#@overlay/match by=overlay.all, expects="1+"
---
#@overlay/match missing_ok=True
#@overlay/match-child-defaults missing_ok=True
metadata:
annotations:
myks.dev/environment: #@ data.values.environment.id
app.kubernetes.io/source: #@ data.values.myks.gitRepoUrl
15 changes: 15 additions & 0 deletions examples/default/envs/_env/argocd/secret.overlay.ytt.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#@ load("@ytt:overlay", "overlay")
---
#@ def secret_fragment():
kind: Secret
metadata:
labels:
argocd.argoproj.io/secret-type: cluster
#@ end

#@overlay/match by=overlay.subset(secret_fragment()), expects="0+"
---
#! See https://argo-cd.readthedocs.io/en/release-2.8/operator-manual/declarative-setup/#clusters
stringData:
config: ARGOCD_CLUSTER_CONNECT_CONFIG
server: ARGOCD_CLUSTER_SERVER_URL
17 changes: 17 additions & 0 deletions examples/default/envs/_env/ytt/common.ytt.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#! This file contains YTT overlays for common modifications to Kubernetes resources.

#@ load("@ytt:data", "data")
#@ load("@ytt:overlay", "overlay")

#! Add common labels and annotations to all resources.
#! ------------------------------------------------------------
#@overlay/match by=lambda i, l, r: "metadata" in l, when="1+"
---
#@overlay/match-child-defaults missing_ok=True
metadata:
#! See https://ambassadorlabs.github.io/k8s-for-humans/
annotations:
a8r.io/repository: #@ data.values.myks.gitRepoUrl
#! More examples:
#! a8r.io/owner: https://github.com/mykso
#! a8r.io/chat: #@ data.values.application.chat
28 changes: 28 additions & 0 deletions examples/default/envs/env-data.ytt.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#! This is an example of a data values file for the root environment.
#! All nested environments inherit these values. The values can be overridden in nested environments.
#! This file is a good place to define default values for all environments.
#!
#! To change the schema of the data values, use `data/values-schema` annotation instead of `data/values`.
#! Refer to the documentation of ytt overlays and data values for more information.

#@data/values
---
argocd:
namespace: system-argocd
app:
prefix: app-
#! Disable finalizers to preserve resources after deleting the ArgoCD application.
finalizers: []
source:
plugin:
name: argocd-vault-plugin-v1.0.0
#! Fixed config to run tests successfull in pipeline
targetRevision: main
repoURL: [email protected]:mykso/myks.git
project:
prefix: env-

#! Fixed git config to run tests successfull in pipeline.
myks:
gitRepoBranch: "main"
gitRepoUrl: "[email protected]:mykso/myks.git"
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: vendir.k14s.io/v1alpha1
directories:
- contents:
- git:
commitTitle: Bump version to 2.7.3 (#13719)...
sha: e7891b899a35dca06ae94965ea5ae2a86b344848
tags:
- v2.7.3
path: .
path: ytt/argocd
kind: LockConfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ytt/argocd: c9846652945082356eb1bde564cd69e4c2162b49b698ffc04a5225d93d532f69
12 changes: 12 additions & 0 deletions examples/default/envs/mykso/dev/_apps/argocd/.myks/vendir.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: vendir.k14s.io/v1alpha1
kind: Config
directories:
- path: ytt/argocd
contents:
- path: .
git:
url: https://github.com/argoproj/argo-cd
ref: v2.7.3
includePaths:
- manifests/ha/install.yaml
newRootPath: manifests/ha
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#@data/values-schema
---
#@overlay/match-child-defaults missing_ok=True
application:
gcpServiceAccountEmail: [email protected]
Loading
Loading