-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create update-status function from operator
- Loading branch information
hossainemruz
committed
Jul 1, 2019
1 parent
955b1ad
commit cefa7fb
Showing
2 changed files
with
49 additions
and
0 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,40 @@ | ||
package util | ||
|
||
import ( | ||
kerr "k8s.io/apimachinery/pkg/api/errors" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
api_v1beta1 "stash.appscode.dev/stash/apis/stash/v1beta1" | ||
cs "stash.appscode.dev/stash/client/clientset/versioned" | ||
"stash.appscode.dev/stash/pkg/docker" | ||
) | ||
|
||
func EnsureUpdateStatusFunction(stashClient cs.Interface, registry, imageTag string) error { | ||
image := docker.Docker{ | ||
Registry: registry, | ||
Image: docker.ImageStash, | ||
Tag: imageTag, | ||
} | ||
|
||
updateStatusFunc := &api_v1beta1.Function{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "update-status", | ||
}, | ||
Spec: api_v1beta1.FunctionSpec{ | ||
Image: image.ToContainerImage(), | ||
Args: []string{ | ||
"update-status", | ||
"--namespace=${NAMESPACE:=default}", | ||
"--repository=${REPOSITORY_NAME:=}", | ||
"--restore-session=${RESTORE_SESSION:=}", | ||
"--output-dir=${outputDir:=}", | ||
"--enable-status-subresource=${ENABLE_STATUS_SUBRESOURCE:=false}", | ||
}, | ||
}, | ||
} | ||
|
||
_, err := stashClient.StashV1beta1().Functions().Create(updateStatusFunc) | ||
if err != nil && !kerr.IsAlreadyExists(err) { | ||
return err | ||
} | ||
return nil | ||
} |