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

fix: issues after changing version #13

Merged
merged 2 commits into from
Apr 27, 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
52 changes: 32 additions & 20 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ on:
- main
- '[0-9]+.[0-9]+.x'
workflow_dispatch:

env:
# Default minimum version of Go to support.
DEFAULT_GO_VERSION: 1.19
REGISTRY: ghcr.io
defaults:
run:
shell: bash
Expand All @@ -32,34 +35,43 @@ jobs:
token: ${{secrets.GITHUB_TOKEN}}
default-branch: main

goreleaser:
if: needs.release-please.outputs.releases_created == 'true'
release-charts:
needs: release-please
permissions:
contents: write
needs:
- release-please
runs-on: ubuntu-latest
if: ${{ needs.release-please.outputs.release_created }}
steps:
- name: Checkout
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4
with:
go-version: '1.20'
- name: Download Syft
uses: anchore/sbom-action/download-syft@422cb34a0f8b599678c41b21163ea6088edb2624 # v0.14.1
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@f82d6c1c344bcacabba2c841718984797f664a6b # v4

- name: Setup go
uses: actions/setup-go@v4
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.K8SGPT_BOT_SECRET }}
go-version: ${{ env.DEFAULT_GO_VERSION }}

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"

- name: Generate helm charts
run: IMG=ghcr.io/k8sgpt-ai/k8sgpt-operator:${{ needs.release-please.outputs.release_tag_name }} make helm-package

- name: Commit files
run: |
git add charts/
git add index.yaml
git commit -s -m "chore: released charts ${{ needs.release-please.outputs.release_tag_name }}"

- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ env.GITHUB_PAGES_BRANCH }}

build-container:
if: needs.release-please.outputs.releases_created == 'true'
needs:
Expand Down
15 changes: 8 additions & 7 deletions api/v1alpha1/k8sgpt_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ type SecretRef struct {

// K8sGPTSpec defines the desired state of K8sGPT
type K8sGPTSpec struct {
Backend string `json:"backend,omitempty"`
Model string `json:"model,omitempty"`
Secret SecretRef `json:"secret,omitempty"`
Namespace string `json:"namespace,omitempty"`
Version string `json:"version,omitempty"`
EnableAI bool `json:"enableAI,omitempty"`
NoCache bool `json:"noCache,omitempty"`
Backend string `json:"backend,omitempty"`
BaseUrl string `json:"baseUrl,omitempty"`
Model string `json:"model,omitempty"`
Secret *SecretRef `json:"secret,omitempty"`
Namespace string `json:"namespace,omitempty"`
Version string `json:"version,omitempty"`
EnableAI bool `json:"enableAI,omitempty"`
NoCache bool `json:"noCache,omitempty"`
}

// K8sGPTStatus defines the observed state of K8sGPT
Expand Down
8 changes: 6 additions & 2 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions config/crd/bases/core.k8sgpt.ai_k8sgpts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ spec:
properties:
backend:
type: string
baseUrl:
type: string
enableAI:
type: boolean
model:
Expand Down
36 changes: 25 additions & 11 deletions pkg/resources/k8sgpt.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,17 +177,6 @@ func GetDeployment(config v1alpha1.K8sGPT) (*appsv1.Deployment, error) {
"serve",
},
Env: []v1.EnvVar{
{
Name: "K8SGPT_PASSWORD",
ValueFrom: &v1.EnvVarSource{
SecretKeyRef: &v1.SecretKeySelector{
LocalObjectReference: v1.LocalObjectReference{
Name: config.Spec.Secret.Name,
},
Key: config.Spec.Secret.Key,
},
},
},
{
Name: "K8SGPT_MODEL",
Value: config.Spec.Model,
Expand Down Expand Up @@ -218,6 +207,31 @@ func GetDeployment(config v1alpha1.K8sGPT) (*appsv1.Deployment, error) {
},
},
}
if config.Spec.Secret != nil {
password := v1.EnvVar{
Name: "K8SGPT_PASSWORD",
ValueFrom: &v1.EnvVarSource{
SecretKeyRef: &v1.SecretKeySelector{
LocalObjectReference: v1.LocalObjectReference{
Name: config.Spec.Secret.Name,
},
Key: config.Spec.Secret.Key,
},
},
}
deployment.Spec.Template.Spec.Containers[0].Env = append(
deployment.Spec.Template.Spec.Containers[0].Env, password,
)
}
if config.Spec.BaseUrl != "" {
baseUrl := v1.EnvVar{
Name: "K8SGPT_BASEURL",
Value: config.Spec.BaseUrl,
}
deployment.Spec.Template.Spec.Containers[0].Env = append(
deployment.Spec.Template.Spec.Containers[0].Env, baseUrl,
)
}
return &deployment, nil
}

Expand Down