...

Source file src/github.com/emissary-ingress/emissary/v3/pkg/api/getambassador.io/v2/handwritten.enum.go

Documentation: github.com/emissary-ingress/emissary/v3/pkg/api/getambassador.io/v2

     1  // Copyright 2020 Datawire.  All rights reserved
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  ///////////////////////////////////////////////////////////////////////////
    16  // Important: Run "make update-yaml" to regenerate code after modifying
    17  // this file.
    18  ///////////////////////////////////////////////////////////////////////////
    19  
    20  package v2
    21  
    22  // This file is support code for enum types.  I'm disappointed that
    23  // controller-gen doesn't generate this.
    24  //
    25  // FIXME(lukeshu): Either patch (and PR) controller-gen to generate
    26  // this, or create a separate code-gen tool to generate it.
    27  //
    28  //  - Constants for the values of the enum
    29  //
    30  //  - For enums that have an 'int' type in Go:
    31  //     - A MarshalJSON() method
    32  //     - An UnmarshalJSON() method
    33  //     - A String() method
    34  
    35  import (
    36  	"encoding/json"
    37  )
    38  
    39  const (
    40  	HostState_Initial = HostState(iota)
    41  	HostState_Pending
    42  	HostState_Ready
    43  	HostState_Error
    44  )
    45  
    46  var (
    47  	hostState_name = map[HostState]string{
    48  		0: "Initial",
    49  		1: "Pending",
    50  		2: "Ready",
    51  		3: "Error",
    52  	}
    53  
    54  	hostState_value = map[string]HostState{
    55  		"Initial": 0,
    56  		"Pending": 1,
    57  		"Ready":   2,
    58  		"Error":   3,
    59  	}
    60  )
    61  
    62  func (o HostState) MarshalJSON() ([]byte, error) {
    63  	return json.Marshal(o.String())
    64  }
    65  
    66  func (o HostState) String() string {
    67  	return hostState_name[o]
    68  }
    69  
    70  func (o *HostState) UnmarshalJSON(data []byte) error {
    71  	if string(data) == "null" {
    72  		*o = 0
    73  		return nil
    74  	}
    75  
    76  	var str string
    77  	if err := json.Unmarshal(data, &str); err != nil {
    78  		return err
    79  	}
    80  
    81  	*o = hostState_value[str]
    82  	return nil
    83  }
    84  
    85  const (
    86  	HostPhase_NA = HostPhase(iota)
    87  	HostPhase_DefaultsFilled
    88  	HostPhase_ACMEUserPrivateKeyCreated
    89  	HostPhase_ACMEUserRegistered
    90  	HostPhase_ACMECertificateChallenge
    91  )
    92  
    93  var (
    94  	hostPhase_name = map[HostPhase]string{
    95  		HostPhase_NA:                        "NA",
    96  		HostPhase_DefaultsFilled:            "DefaultsFilled",
    97  		HostPhase_ACMEUserPrivateKeyCreated: "ACMEUserPrivateKeyCreated",
    98  		HostPhase_ACMEUserRegistered:        "ACMEUserRegistered",
    99  		HostPhase_ACMECertificateChallenge:  "ACMECertificateChallenge",
   100  	}
   101  
   102  	hostPhase_value = map[string]HostPhase{
   103  		"NA":                        HostPhase_NA,
   104  		"DefaultsFilled":            HostPhase_DefaultsFilled,
   105  		"ACMEUserPrivateKeyCreated": HostPhase_ACMEUserPrivateKeyCreated,
   106  		"ACMEUserRegistered":        HostPhase_ACMEUserRegistered,
   107  		"ACMECertificateChallenge":  HostPhase_ACMECertificateChallenge,
   108  	}
   109  )
   110  
   111  func (o HostPhase) MarshalJSON() ([]byte, error) {
   112  	return json.Marshal(o.String())
   113  }
   114  
   115  func (o HostPhase) String() string {
   116  	return hostPhase_name[o]
   117  }
   118  
   119  func (o *HostPhase) UnmarshalJSON(data []byte) error {
   120  	if string(data) == "null" {
   121  		*o = 0
   122  		return nil
   123  	}
   124  
   125  	var str string
   126  	if err := json.Unmarshal(data, &str); err != nil {
   127  		return err
   128  	}
   129  
   130  	*o = hostPhase_value[str]
   131  	return nil
   132  }
   133  
   134  const (
   135  	PreviewURLType_Path = "Path"
   136  )
   137  
   138  const (
   139  	HostTLSCertificateSource_Unknown = "Unknown"
   140  	HostTLSCertificateSource_None    = "None"
   141  	HostTLSCertificateSource_Other   = "Other"
   142  	HostTLSCertificateSource_ACME    = "ACME"
   143  )
   144  

View as plain text