-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add stash-crd-installer image to install CRDs on helm pre-install hook (
#145) Signed-off-by: Emruz Hossain <[email protected]>
- Loading branch information
Emruz Hossain
authored
Feb 7, 2022
1 parent
9c52874
commit 0906fab
Showing
9 changed files
with
241 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- "*.*" | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v1 | ||
|
||
- name: Set up Go 1.17 | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.17 | ||
id: go | ||
|
||
- name: Print version info | ||
id: semver | ||
run: | | ||
make version | ||
- name: Set up QEMU | ||
id: qemu | ||
uses: docker/setup-qemu-action@v1 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Publish to GitHub Container Registry | ||
env: | ||
REGISTRY: ghcr.io/stashed | ||
DOCKER_TOKEN: ${{ secrets.LGTM_GITHUB_TOKEN }} | ||
USERNAME: 1gtm | ||
APPSCODE_ENV: prod | ||
run: | | ||
docker login ghcr.io --username ${USERNAME} --password ${DOCKER_TOKEN} | ||
make release | ||
- name: Publish to Docker Registry | ||
env: | ||
DOCKER_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} | ||
USERNAME: 1gtm | ||
APPSCODE_ENV: prod | ||
run: | | ||
docker login --username ${USERNAME} --password ${DOCKER_TOKEN} | ||
make release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
/* | ||
Copyright AppsCode Inc. and Contributors | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package main | ||
|
||
import ( | ||
"flag" | ||
"os" | ||
|
||
stashv1alpha1 "stash.appscode.dev/apimachinery/apis/stash/v1alpha1" | ||
stashv1beta1 "stash.appscode.dev/apimachinery/apis/stash/v1beta1" | ||
|
||
crd_cs "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" | ||
"k8s.io/client-go/tools/clientcmd" | ||
"k8s.io/klog/v2" | ||
"kmodules.xyz/client-go/apiextensions" | ||
appcatalog "kmodules.xyz/custom-resources/apis/appcatalog/v1alpha1" | ||
metrics "kmodules.xyz/custom-resources/apis/metrics/v1alpha1" | ||
) | ||
|
||
var ( | ||
masterURL string | ||
kubeConfig string | ||
enableEnterpriseFeatures bool | ||
) | ||
|
||
func init() { | ||
flag.StringVar(&kubeConfig, "kubeconfig", kubeConfig, "Path to a kube config file. Only required if out-of-cluster.") | ||
flag.StringVar(&masterURL, "master", masterURL, "The address of the Kubernetes API server. Overrides any value in kube config file. Only required if out-of-cluster.") | ||
flag.BoolVar(&enableEnterpriseFeatures, "enterprise", false, "Specify whether enterprise features enabled or not.") | ||
} | ||
|
||
func main() { | ||
flag.Parse() | ||
|
||
cfg, err := clientcmd.BuildConfigFromFlags(masterURL, kubeConfig) | ||
if err != nil { | ||
klog.Errorf("Error building kubeconfig: %s", err.Error()) | ||
os.Exit(1) | ||
} | ||
|
||
crdClient, err := crd_cs.NewForConfig(cfg) | ||
if err != nil { | ||
klog.Errorf("Error building CRD client: %s", err.Error()) | ||
os.Exit(1) | ||
} | ||
|
||
if err := registerCRDs(crdClient); err != nil { | ||
klog.Errorf("Error building CRD client: %s", err.Error()) | ||
os.Exit(1) | ||
} | ||
klog.Infoln("Successfully installed all CRDs.") | ||
} | ||
|
||
func registerCRDs(crdClient crd_cs.Interface) error { | ||
var resources []*apiextensions.CustomResourceDefinition | ||
|
||
resources = append(resources, getStashCRDs()...) | ||
resources = append(resources, getAppCatalogCRDs()...) | ||
|
||
if enableEnterpriseFeatures { | ||
resources = append(resources, getMetricCRDs()...) | ||
} | ||
return apiextensions.RegisterCRDs(crdClient, resources) | ||
} | ||
|
||
func getStashCRDs() []*apiextensions.CustomResourceDefinition { | ||
// community features CRDs | ||
var stashCRDs []*apiextensions.CustomResourceDefinition | ||
|
||
stashCRDs = append(stashCRDs, | ||
// v1alpha1 resources | ||
stashv1alpha1.Repository{}.CustomResourceDefinition(), | ||
|
||
// v1beta1 resources | ||
stashv1beta1.BackupConfiguration{}.CustomResourceDefinition(), | ||
stashv1beta1.BackupSession{}.CustomResourceDefinition(), | ||
stashv1beta1.RestoreSession{}.CustomResourceDefinition(), | ||
stashv1beta1.Function{}.CustomResourceDefinition(), | ||
stashv1beta1.Task{}.CustomResourceDefinition(), | ||
) | ||
|
||
// enterprise features CRDs | ||
if enableEnterpriseFeatures { | ||
stashCRDs = append(stashCRDs, | ||
// v1beta1 resources | ||
stashv1beta1.BackupBatch{}.CustomResourceDefinition(), | ||
stashv1beta1.BackupBlueprint{}.CustomResourceDefinition(), | ||
stashv1beta1.RestoreBatch{}.CustomResourceDefinition(), | ||
) | ||
} | ||
return stashCRDs | ||
} | ||
|
||
func getAppCatalogCRDs() []*apiextensions.CustomResourceDefinition { | ||
return []*apiextensions.CustomResourceDefinition{ | ||
// v1alpha1 resources | ||
appcatalog.AppBinding{}.CustomResourceDefinition(), | ||
} | ||
} | ||
|
||
func getMetricCRDs() []*apiextensions.CustomResourceDefinition { | ||
return []*apiextensions.CustomResourceDefinition{ | ||
// v1alpha1 resources | ||
metrics.MetricsConfiguration{}.CustomResourceDefinition(), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.