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

[pull] main from labring:main #643

Merged
merged 13 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ jobs:
matrix:
module:
[
providers/cronjob,
providers/template,
providers/adminer,
providers/applaunchpad,
Expand Down
200 changes: 100 additions & 100 deletions .github/workflows/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
module: [ auth, hub ]
module: [ hub ]
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -159,102 +159,102 @@ jobs:

save-sealos:
uses: ./.github/workflows/import-save-sealos.yml
build-cluster-image:
if: ${{ (github.event_name == 'push') ||(github.event_name == 'create') || (inputs.push_image == true) }}
needs:
- image-build
- save-sealos
runs-on: ubuntu-latest
strategy:
matrix:
module: [ auth ]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Expose git commit data
uses: rlespinasse/git-commit-data-action@v1
- name: Check if tag
id: check_tag
run: |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
echo "isTag=true" >> "$GITHUB_OUTPUT"
else
echo "isTag=false" >> "$GITHUB_OUTPUT"
fi
- name: Prepare
id: prepare
run: |
bash ./scripts/resolve-tag-image.sh "${{ inputs.push_image }}" "${{ steps.check_tag.outputs.isTag }}" "${{ inputs.push_image_tag }}"
echo old_docker_repo=ghcr.io/labring/sealos-${{ matrix.module }}-service >> $GITHUB_OUTPUT
echo new_docker_repo=ghcr.io/${{ github.repository_owner }}/sealos-${{ matrix.module }}-service >> $GITHUB_OUTPUT
echo cluster_repo=ghcr.io/${{ github.repository_owner }}/sealos-cloud-${{ matrix.module }}-service >> $GITHUB_OUTPUT

- name: Download sealos
uses: actions/download-artifact@v3
with:
name: sealos
path: /tmp/
- name: Verify sealos
run: |
sudo chmod a+x /tmp/sealos
sudo mv /tmp/sealos /usr/bin/sealos
sudo sealos version

- name: Sealos login to ghcr.io
# if push to master, then login to ghcr.io
run: |
sudo sealos login -u ${{ github.repository_owner }} -p ${{ secrets.GH_PAT }} --debug ghcr.io

- name: Mutate image tag in deploy files
working-directory: service/${{ matrix.module }}/deploy
run: |
OLD_DOCKER_IMAGE_NAME=${{ steps.prepare.outputs.old_docker_repo }}:latest
NEW_DOCKER_IMAGE_NAME=${{ steps.prepare.outputs.new_docker_repo }}:${{ steps.prepare.outputs.tag_name }}
sed -i "s;${OLD_DOCKER_IMAGE_NAME};${NEW_DOCKER_IMAGE_NAME};" manifests/*

- name: Build ${{ matrix.module }}-service cluster image
working-directory: service/${{ matrix.module }}/deploy
run: |
CLUSTER_IMAGE_NAME=${{ steps.prepare.outputs.cluster_repo }}:${{ steps.prepare.outputs.tag_name }}
sudo sealos build -t ${CLUSTER_IMAGE_NAME}-amd64 --platform linux/amd64 -f Kubefile
sudo sealos build -t ${CLUSTER_IMAGE_NAME}-arm64 --platform linux/arm64 -f Kubefile
sudo sealos images
- name: Build ${{ matrix.module }}-service cluster image for latest
run: |
CLUSTER_IMAGE_NAME=${{ steps.prepare.outputs.cluster_repo }}:${{ steps.prepare.outputs.tag_name }}
CLUSTER_IMAGE_NAME_LATEST=${{ steps.prepare.outputs.cluster_repo }}:latest
sudo sealos tag ${CLUSTER_IMAGE_NAME}-amd64 ${CLUSTER_IMAGE_NAME_LATEST}-amd64
sudo sealos tag ${CLUSTER_IMAGE_NAME}-amd64 ${CLUSTER_IMAGE_NAME_LATEST}-amd64
sudo sealos images
bash docker/patch/manifest-cluster-images.sh $CLUSTER_IMAGE_NAME_LATEST
- name: Renew issue and Sync Images
uses: labring/[email protected]
if: ${{ github.repository_owner == env.DEFAULT_OWNER }}
with:
version: v0.0.8-rc1
env:
GH_TOKEN: "${{ secrets.GH_PAT }}"
SEALOS_TYPE: "issue_renew"
SEALOS_ISSUE_TITLE: "[DaylyReport] Auto build for sealos"
SEALOS_ISSUE_BODYFILE: "scripts/ISSUE_RENEW.md"
SEALOS_ISSUE_LABEL: "dayly-report"
SEALOS_ISSUE_TYPE: "day"
SEALOS_ISSUE_REPO: "labring-actions/cluster-image"
SEALOS_COMMENT_BODY: "/imagesync ghcr.io/${{ github.repository_owner }}/sealos-cloud-${{ matrix.module }}-service:${{ steps.prepare.outputs.tag_name }}"
- name: Renew issue and Sync Images for latest
uses: labring/[email protected]
if: ${{ github.repository_owner == env.DEFAULT_OWNER }}
with:
version: v0.0.8-rc1
env:
GH_TOKEN: "${{ secrets.GH_PAT }}"
SEALOS_TYPE: "issue_renew"
SEALOS_ISSUE_TITLE: "[DaylyReport] Auto build for sealos"
SEALOS_ISSUE_BODYFILE: "scripts/ISSUE_RENEW.md"
SEALOS_ISSUE_LABEL: "dayly-report"
SEALOS_ISSUE_TYPE: "day"
SEALOS_ISSUE_REPO: "labring-actions/cluster-image"
SEALOS_COMMENT_BODY: "/imagesync ghcr.io/${{ github.repository_owner }}/sealos-cloud-${{ matrix.module }}-service:latest"
# build-cluster-image:
# if: ${{ (github.event_name == 'push') ||(github.event_name == 'create') || (inputs.push_image == true) }}
# needs:
# - image-build
# - save-sealos
# runs-on: ubuntu-latest
# strategy:
# matrix:
# module: [ ]
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# with:
# fetch-depth: 0
#
# - name: Expose git commit data
# uses: rlespinasse/git-commit-data-action@v1
# - name: Check if tag
# id: check_tag
# run: |
# if [[ "${{ github.ref }}" == refs/tags/* ]]; then
# echo "isTag=true" >> "$GITHUB_OUTPUT"
# else
# echo "isTag=false" >> "$GITHUB_OUTPUT"
# fi
# - name: Prepare
# id: prepare
# run: |
# bash ./scripts/resolve-tag-image.sh "${{ inputs.push_image }}" "${{ steps.check_tag.outputs.isTag }}" "${{ inputs.push_image_tag }}"
# echo old_docker_repo=ghcr.io/labring/sealos-${{ matrix.module }}-service >> $GITHUB_OUTPUT
# echo new_docker_repo=ghcr.io/${{ github.repository_owner }}/sealos-${{ matrix.module }}-service >> $GITHUB_OUTPUT
# echo cluster_repo=ghcr.io/${{ github.repository_owner }}/sealos-cloud-${{ matrix.module }}-service >> $GITHUB_OUTPUT
#
# - name: Download sealos
# uses: actions/download-artifact@v3
# with:
# name: sealos
# path: /tmp/
# - name: Verify sealos
# run: |
# sudo chmod a+x /tmp/sealos
# sudo mv /tmp/sealos /usr/bin/sealos
# sudo sealos version
#
# - name: Sealos login to ghcr.io
# # if push to master, then login to ghcr.io
# run: |
# sudo sealos login -u ${{ github.repository_owner }} -p ${{ secrets.GH_PAT }} --debug ghcr.io
#
# - name: Mutate image tag in deploy files
# working-directory: service/${{ matrix.module }}/deploy
# run: |
# OLD_DOCKER_IMAGE_NAME=${{ steps.prepare.outputs.old_docker_repo }}:latest
# NEW_DOCKER_IMAGE_NAME=${{ steps.prepare.outputs.new_docker_repo }}:${{ steps.prepare.outputs.tag_name }}
# sed -i "s;${OLD_DOCKER_IMAGE_NAME};${NEW_DOCKER_IMAGE_NAME};" manifests/*
#
# - name: Build ${{ matrix.module }}-service cluster image
# working-directory: service/${{ matrix.module }}/deploy
# run: |
# CLUSTER_IMAGE_NAME=${{ steps.prepare.outputs.cluster_repo }}:${{ steps.prepare.outputs.tag_name }}
# sudo sealos build -t ${CLUSTER_IMAGE_NAME}-amd64 --platform linux/amd64 -f Kubefile
# sudo sealos build -t ${CLUSTER_IMAGE_NAME}-arm64 --platform linux/arm64 -f Kubefile
# sudo sealos images
# - name: Build ${{ matrix.module }}-service cluster image for latest
# run: |
# CLUSTER_IMAGE_NAME=${{ steps.prepare.outputs.cluster_repo }}:${{ steps.prepare.outputs.tag_name }}
# CLUSTER_IMAGE_NAME_LATEST=${{ steps.prepare.outputs.cluster_repo }}:latest
# sudo sealos tag ${CLUSTER_IMAGE_NAME}-amd64 ${CLUSTER_IMAGE_NAME_LATEST}-amd64
# sudo sealos tag ${CLUSTER_IMAGE_NAME}-amd64 ${CLUSTER_IMAGE_NAME_LATEST}-amd64
# sudo sealos images
# bash docker/patch/manifest-cluster-images.sh $CLUSTER_IMAGE_NAME_LATEST
# - name: Renew issue and Sync Images
# uses: labring/[email protected]
# if: ${{ github.repository_owner == env.DEFAULT_OWNER }}
# with:
# version: v0.0.8-rc1
# env:
# GH_TOKEN: "${{ secrets.GH_PAT }}"
# SEALOS_TYPE: "issue_renew"
# SEALOS_ISSUE_TITLE: "[DaylyReport] Auto build for sealos"
# SEALOS_ISSUE_BODYFILE: "scripts/ISSUE_RENEW.md"
# SEALOS_ISSUE_LABEL: "dayly-report"
# SEALOS_ISSUE_TYPE: "day"
# SEALOS_ISSUE_REPO: "labring-actions/cluster-image"
# SEALOS_COMMENT_BODY: "/imagesync ghcr.io/${{ github.repository_owner }}/sealos-cloud-${{ matrix.module }}-service:${{ steps.prepare.outputs.tag_name }}"
# - name: Renew issue and Sync Images for latest
# uses: labring/[email protected]
# if: ${{ github.repository_owner == env.DEFAULT_OWNER }}
# with:
# version: v0.0.8-rc1
# env:
# GH_TOKEN: "${{ secrets.GH_PAT }}"
# SEALOS_TYPE: "issue_renew"
# SEALOS_ISSUE_TITLE: "[DaylyReport] Auto build for sealos"
# SEALOS_ISSUE_BODYFILE: "scripts/ISSUE_RENEW.md"
# SEALOS_ISSUE_LABEL: "dayly-report"
# SEALOS_ISSUE_TYPE: "day"
# SEALOS_ISSUE_REPO: "labring-actions/cluster-image"
# SEALOS_COMMENT_BODY: "/imagesync ghcr.io/${{ github.repository_owner }}/sealos-cloud-${{ matrix.module }}-service:latest"
30 changes: 21 additions & 9 deletions cmd/sealctl/cmd/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"strings"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
"helm.sh/helm/v3/pkg/cli/values"
"helm.sh/helm/v3/pkg/getter"

Expand All @@ -28,21 +29,29 @@ import (
"github.com/labring/sealos/pkg/utils/maps"
)

type renderOptions struct {
values []string
sets []string
clear bool
}

func (o *renderOptions) RegisterFlags(fs *pflag.FlagSet) {
fs.StringSliceVarP(&o.values, "values", "f", []string{}, "values files for context")
fs.StringSliceVar(&o.sets, "set", []string{}, "k/v sets for context")
fs.BoolVarP(&o.clear, "clear", "c", false, "clean up template files after rendering")
}

func newRenderCommand() *cobra.Command {
var (
valueFiles []string
sets []string
)
opts := &renderOptions{}
cmd := &cobra.Command{
Use: "render",
Short: "render template files with values and envs",
Args: cobra.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
return runRender(valueFiles, sets, args)
return runRender(opts, args)
},
}
cmd.Flags().StringSliceVarP(&valueFiles, "values", "f", []string{}, "values files for context")
cmd.Flags().StringSliceVar(&sets, "set", []string{}, "k/v sets for context")
opts.RegisterFlags(cmd.Flags())
return cmd
}

Expand All @@ -69,8 +78,8 @@ func findTemplateFiles(paths ...string) ([]string, error) {
return ret, nil
}

func runRender(valueFiles, sets []string, args []string) error {
mergedValues, err := loadValues(valueFiles, sets)
func runRender(opts *renderOptions, args []string) error {
mergedValues, err := loadValues(opts.values, opts.sets)
if err != nil {
return err
}
Expand Down Expand Up @@ -112,6 +121,9 @@ func runRender(valueFiles, sets []string, args []string) error {
return err
}
logger.Info("render %s from %s completed", trimed, fp)
if opts.clear {
return os.Remove(fp)
}
return nil
}(filepaths[i]); err != nil {
return err
Expand Down
9 changes: 9 additions & 0 deletions controllers/account/PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,13 @@ resources:
kind: Transfer
path: github.com/labring/sealos/controllers/account/api/v1
version: v1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: sealos.io
group: account
kind: NamespaceBillingHistory
path: github.com/labring/sealos/controllers/account/api/v1
version: v1
version: "3"
65 changes: 65 additions & 0 deletions controllers/account/api/v1/namespacebillinghistory_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
Copyright 2023.

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 v1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// NamespaceBillingHistorySpec defines the desired state of NamespaceBillingHistory
type NamespaceBillingHistorySpec struct {
StartTime metav1.Time `json:"startTime,omitempty"`
EndTime metav1.Time `json:"endTime,omitempty"`
Type Type `json:"type"`
}

// NamespaceBillingHistoryStatus defines the observed state of NamespaceBillingHistory
type NamespaceBillingHistoryStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
NamespaceList []string `json:"namespaceList,omitempty"`
Status Status `json:"status,omitempty"`
Detail string `json:"detail,omitempty"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// NamespaceBillingHistory is the Schema for the namespacebillinghistories API
type NamespaceBillingHistory struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec NamespaceBillingHistorySpec `json:"spec,omitempty"`
Status NamespaceBillingHistoryStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// NamespaceBillingHistoryList contains a list of NamespaceBillingHistory
type NamespaceBillingHistoryList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []NamespaceBillingHistory `json:"items"`
}

func init() {
SchemeBuilder.Register(&NamespaceBillingHistory{}, &NamespaceBillingHistoryList{})
}
Loading
Loading