106
vendor/helm.sh/helm/v3/pkg/release/hook.go
vendored
Normal file
106
vendor/helm.sh/helm/v3/pkg/release/hook.go
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
Copyright The Helm Authors.
|
||||
|
||||
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 release
|
||||
|
||||
import (
|
||||
"helm.sh/helm/v3/pkg/time"
|
||||
)
|
||||
|
||||
// HookEvent specifies the hook event
|
||||
type HookEvent string
|
||||
|
||||
// Hook event types
|
||||
const (
|
||||
HookPreInstall HookEvent = "pre-install"
|
||||
HookPostInstall HookEvent = "post-install"
|
||||
HookPreDelete HookEvent = "pre-delete"
|
||||
HookPostDelete HookEvent = "post-delete"
|
||||
HookPreUpgrade HookEvent = "pre-upgrade"
|
||||
HookPostUpgrade HookEvent = "post-upgrade"
|
||||
HookPreRollback HookEvent = "pre-rollback"
|
||||
HookPostRollback HookEvent = "post-rollback"
|
||||
HookTest HookEvent = "test"
|
||||
)
|
||||
|
||||
func (x HookEvent) String() string { return string(x) }
|
||||
|
||||
// HookDeletePolicy specifies the hook delete policy
|
||||
type HookDeletePolicy string
|
||||
|
||||
// Hook delete policy types
|
||||
const (
|
||||
HookSucceeded HookDeletePolicy = "hook-succeeded"
|
||||
HookFailed HookDeletePolicy = "hook-failed"
|
||||
HookBeforeHookCreation HookDeletePolicy = "before-hook-creation"
|
||||
)
|
||||
|
||||
func (x HookDeletePolicy) String() string { return string(x) }
|
||||
|
||||
// HookAnnotation is the label name for a hook
|
||||
const HookAnnotation = "helm.sh/hook"
|
||||
|
||||
// HookWeightAnnotation is the label name for a hook weight
|
||||
const HookWeightAnnotation = "helm.sh/hook-weight"
|
||||
|
||||
// HookDeleteAnnotation is the label name for the delete policy for a hook
|
||||
const HookDeleteAnnotation = "helm.sh/hook-delete-policy"
|
||||
|
||||
// Hook defines a hook object.
|
||||
type Hook struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
// Kind is the Kubernetes kind.
|
||||
Kind string `json:"kind,omitempty"`
|
||||
// Path is the chart-relative path to the template.
|
||||
Path string `json:"path,omitempty"`
|
||||
// Manifest is the manifest contents.
|
||||
Manifest string `json:"manifest,omitempty"`
|
||||
// Events are the events that this hook fires on.
|
||||
Events []HookEvent `json:"events,omitempty"`
|
||||
// LastRun indicates the date/time this was last run.
|
||||
LastRun HookExecution `json:"last_run,omitempty"`
|
||||
// Weight indicates the sort order for execution among similar Hook type
|
||||
Weight int `json:"weight,omitempty"`
|
||||
// DeletePolicies are the policies that indicate when to delete the hook
|
||||
DeletePolicies []HookDeletePolicy `json:"delete_policies,omitempty"`
|
||||
}
|
||||
|
||||
// A HookExecution records the result for the last execution of a hook for a given release.
|
||||
type HookExecution struct {
|
||||
// StartedAt indicates the date/time this hook was started
|
||||
StartedAt time.Time `json:"started_at,omitempty"`
|
||||
// CompletedAt indicates the date/time this hook was completed.
|
||||
CompletedAt time.Time `json:"completed_at,omitempty"`
|
||||
// Phase indicates whether the hook completed successfully
|
||||
Phase HookPhase `json:"phase"`
|
||||
}
|
||||
|
||||
// A HookPhase indicates the state of a hook execution
|
||||
type HookPhase string
|
||||
|
||||
const (
|
||||
// HookPhaseUnknown indicates that a hook is in an unknown state
|
||||
HookPhaseUnknown HookPhase = "Unknown"
|
||||
// HookPhaseRunning indicates that a hook is currently executing
|
||||
HookPhaseRunning HookPhase = "Running"
|
||||
// HookPhaseSucceeded indicates that hook execution succeeded
|
||||
HookPhaseSucceeded HookPhase = "Succeeded"
|
||||
// HookPhaseFailed indicates that hook execution failed
|
||||
HookPhaseFailed HookPhase = "Failed"
|
||||
)
|
||||
|
||||
// Strng converts a hook phase to a printable string
|
||||
func (x HookPhase) String() string { return string(x) }
|
||||
36
vendor/helm.sh/helm/v3/pkg/release/info.go
vendored
Normal file
36
vendor/helm.sh/helm/v3/pkg/release/info.go
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
Copyright The Helm Authors.
|
||||
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 release
|
||||
|
||||
import (
|
||||
"helm.sh/helm/v3/pkg/time"
|
||||
)
|
||||
|
||||
// Info describes release information.
|
||||
type Info struct {
|
||||
// FirstDeployed is when the release was first deployed.
|
||||
FirstDeployed time.Time `json:"first_deployed,omitempty"`
|
||||
// LastDeployed is when the release was last deployed.
|
||||
LastDeployed time.Time `json:"last_deployed,omitempty"`
|
||||
// Deleted tracks when this object was deleted.
|
||||
Deleted time.Time `json:"deleted"`
|
||||
// Description is human-friendly "log entry" about this release.
|
||||
Description string `json:"description,omitempty"`
|
||||
// Status is the current state of the release
|
||||
Status Status `json:"status,omitempty"`
|
||||
// Contains the rendered templates/NOTES.txt if available
|
||||
Notes string `json:"notes,omitempty"`
|
||||
}
|
||||
115
vendor/helm.sh/helm/v3/pkg/release/mock.go
vendored
Normal file
115
vendor/helm.sh/helm/v3/pkg/release/mock.go
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
Copyright The Helm Authors.
|
||||
|
||||
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 release
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
|
||||
"helm.sh/helm/v3/pkg/chart"
|
||||
"helm.sh/helm/v3/pkg/time"
|
||||
)
|
||||
|
||||
// MockHookTemplate is the hook template used for all mock release objects.
|
||||
var MockHookTemplate = `apiVersion: v1
|
||||
kind: Job
|
||||
metadata:
|
||||
annotations:
|
||||
"helm.sh/hook": pre-install
|
||||
`
|
||||
|
||||
// MockManifest is the manifest used for all mock release objects.
|
||||
var MockManifest = `apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: fixture
|
||||
`
|
||||
|
||||
// MockReleaseOptions allows for user-configurable options on mock release objects.
|
||||
type MockReleaseOptions struct {
|
||||
Name string
|
||||
Version int
|
||||
Chart *chart.Chart
|
||||
Status Status
|
||||
Namespace string
|
||||
}
|
||||
|
||||
// Mock creates a mock release object based on options set by MockReleaseOptions. This function should typically not be used outside of testing.
|
||||
func Mock(opts *MockReleaseOptions) *Release {
|
||||
date := time.Unix(242085845, 0).UTC()
|
||||
|
||||
name := opts.Name
|
||||
if name == "" {
|
||||
name = "testrelease-" + string(rand.Intn(100))
|
||||
}
|
||||
|
||||
version := 1
|
||||
if opts.Version != 0 {
|
||||
version = opts.Version
|
||||
}
|
||||
|
||||
namespace := opts.Namespace
|
||||
if namespace == "" {
|
||||
namespace = "default"
|
||||
}
|
||||
|
||||
ch := opts.Chart
|
||||
if opts.Chart == nil {
|
||||
ch = &chart.Chart{
|
||||
Metadata: &chart.Metadata{
|
||||
Name: "foo",
|
||||
Version: "0.1.0-beta.1",
|
||||
AppVersion: "1.0",
|
||||
},
|
||||
Templates: []*chart.File{
|
||||
{Name: "templates/foo.tpl", Data: []byte(MockManifest)},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
scode := StatusDeployed
|
||||
if len(opts.Status) > 0 {
|
||||
scode = opts.Status
|
||||
}
|
||||
|
||||
info := &Info{
|
||||
FirstDeployed: date,
|
||||
LastDeployed: date,
|
||||
Status: scode,
|
||||
Description: "Release mock",
|
||||
Notes: "Some mock release notes!",
|
||||
}
|
||||
|
||||
return &Release{
|
||||
Name: name,
|
||||
Info: info,
|
||||
Chart: ch,
|
||||
Config: map[string]interface{}{"name": "value"},
|
||||
Version: version,
|
||||
Namespace: namespace,
|
||||
Hooks: []*Hook{
|
||||
{
|
||||
Name: "pre-install-hook",
|
||||
Kind: "Job",
|
||||
Path: "pre-install-hook.yaml",
|
||||
Manifest: MockHookTemplate,
|
||||
LastRun: HookExecution{},
|
||||
Events: []HookEvent{HookPreInstall},
|
||||
},
|
||||
},
|
||||
Manifest: MockManifest,
|
||||
}
|
||||
}
|
||||
46
vendor/helm.sh/helm/v3/pkg/release/release.go
vendored
Normal file
46
vendor/helm.sh/helm/v3/pkg/release/release.go
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
Copyright The Helm Authors.
|
||||
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 release
|
||||
|
||||
import "helm.sh/helm/v3/pkg/chart"
|
||||
|
||||
// Release describes a deployment of a chart, together with the chart
|
||||
// and the variables used to deploy that chart.
|
||||
type Release struct {
|
||||
// Name is the name of the release
|
||||
Name string `json:"name,omitempty"`
|
||||
// Info provides information about a release
|
||||
Info *Info `json:"info,omitempty"`
|
||||
// Chart is the chart that was released.
|
||||
Chart *chart.Chart `json:"chart,omitempty"`
|
||||
// Config is the set of extra Values added to the chart.
|
||||
// These values override the default values inside of the chart.
|
||||
Config map[string]interface{} `json:"config,omitempty"`
|
||||
// Manifest is the string representation of the rendered template.
|
||||
Manifest string `json:"manifest,omitempty"`
|
||||
// Hooks are all of the hooks declared for this release.
|
||||
Hooks []*Hook `json:"hooks,omitempty"`
|
||||
// Version is an int which represents the revision of the release.
|
||||
Version int `json:"version,omitempty"`
|
||||
// Namespace is the kubernetes namespace of the release.
|
||||
Namespace string `json:"namespace,omitempty"`
|
||||
}
|
||||
|
||||
// SetStatus is a helper for setting the status on a release.
|
||||
func (r *Release) SetStatus(status Status, msg string) {
|
||||
r.Info.Status = status
|
||||
r.Info.Description = msg
|
||||
}
|
||||
24
vendor/helm.sh/helm/v3/pkg/release/responses.go
vendored
Normal file
24
vendor/helm.sh/helm/v3/pkg/release/responses.go
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
Copyright The Helm Authors.
|
||||
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 release
|
||||
|
||||
// UninstallReleaseResponse represents a successful response to an uninstall request.
|
||||
type UninstallReleaseResponse struct {
|
||||
// Release is the release that was marked deleted.
|
||||
Release *Release `json:"release,omitempty"`
|
||||
// Info is an uninstall message
|
||||
Info string `json:"info,omitempty"`
|
||||
}
|
||||
44
vendor/helm.sh/helm/v3/pkg/release/status.go
vendored
Normal file
44
vendor/helm.sh/helm/v3/pkg/release/status.go
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
Copyright The Helm Authors.
|
||||
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 release
|
||||
|
||||
// Status is the status of a release
|
||||
type Status string
|
||||
|
||||
// Describe the status of a release
|
||||
// NOTE: Make sure to update cmd/helm/status.go when adding or modifying any of these statuses.
|
||||
const (
|
||||
// StatusUnknown indicates that a release is in an uncertain state.
|
||||
StatusUnknown Status = "unknown"
|
||||
// StatusDeployed indicates that the release has been pushed to Kubernetes.
|
||||
StatusDeployed Status = "deployed"
|
||||
// StatusUninstalled indicates that a release has been uninstalled from Kubernetes.
|
||||
StatusUninstalled Status = "uninstalled"
|
||||
// StatusSuperseded indicates that this release object is outdated and a newer one exists.
|
||||
StatusSuperseded Status = "superseded"
|
||||
// StatusFailed indicates that the release was not successfully deployed.
|
||||
StatusFailed Status = "failed"
|
||||
// StatusUninstalling indicates that a uninstall operation is underway.
|
||||
StatusUninstalling Status = "uninstalling"
|
||||
// StatusPendingInstall indicates that an install operation is underway.
|
||||
StatusPendingInstall Status = "pending-install"
|
||||
// StatusPendingUpgrade indicates that an upgrade operation is underway.
|
||||
StatusPendingUpgrade Status = "pending-upgrade"
|
||||
// StatusPendingRollback indicates that an rollback operation is underway.
|
||||
StatusPendingRollback Status = "pending-rollback"
|
||||
)
|
||||
|
||||
func (x Status) String() string { return string(x) }
|
||||
Reference in New Issue
Block a user